Download Source Code

CAviEncode Class Reference

Encapsulates Windows AVI functionality. More...

#include <AviEncode.h>

Inheritance diagram for CAviEncode:

Inheritance graph
[legend]
Collaboration diagram for CAviEncode:

Collaboration graph
[legend]
List of all members.

Public Member Functions

BOOL StartRecording (LPCTSTR pFile, LPRECT pRect, DWORD dwFrames, DWORD dwSeconds, DWORD dwFourCC)
 Opens the avi and prepares for writing frames.
BOOL StopRecording (LPCTSTR pRename=NULL)
 Closes the avi and releases all resources.
BOOL AddFrame (CWinDc *pDc)
 Adds a frame of video to the avi.
void ReleaseBuffers ()
 Releases async buffers.
BOOL AllocateBuffers ()
 Allocates async buffers.
void Destroy ()
 Closes the AVI file and releases all resources.
BOOL Init (DWORD dwBufferSize)
 Initializes the class by allocating async buffers.
virtual BOOL EndThread (LPVOID pData)
 Thread clean-up function.
virtual BOOL DoThread (LPVOID pData)
 Main thread body.
virtual BOOL InitThread (LPVOID pData)
 Thread initialization function.
 CAviEncode ()
 Constructor.
virtual ~CAviEncode ()
 Destructor.
BOOL IsRecording ()
 Returns non-zero if an AVI is currently available open for writing.
LPCTSTR GetFileName ()
 Returns a pointer to the open filename.
CWinAviGetAvi ()
 Returns a pointer to the encapsulated AVI class.
LPRECT GetRect ()
 Retuns the size of a single frame of video.

Detailed Description

Encapsulates Windows AVI functionality.

This class contains its own thread to handle AVI encoding. When AddFrame() is called, the image data is queued in an asynchronous buffer until the thread can write it into the AVI file. This takes away blocking effect from the calling thread.


Member Function Documentation

BOOL CAviEncode::AddFrame CWinDc *  pDc  ) 
 

Adds a frame of video to the avi.

Parameters:
[in] pDc - CWinDc object holding single video frame to add to the AVI file.
Returns:
Returns non-zero if success.

BOOL CAviEncode::AllocateBuffers  ) 
 

Allocates async buffers.

Returns:
Returns non-zero if success.

void CAviEncode::Destroy  ) 
 

Closes the AVI file and releases all resources.

It is ok to call this function instead of StopRecording(), however, this function also releases all async buffers.

BOOL CAviEncode::DoThread LPVOID  pData  )  [virtual]
 

Main thread body.

See also:
CThread::DoThread()
Returns:
Return zero to end thread

Reimplemented from CThread.

BOOL CAviEncode::EndThread LPVOID  pData  )  [virtual]
 

Thread clean-up function.

See also:
CThread::EndThread()
Returns:
Return zero to end thread

Reimplemented from CThread.

BOOL CAviEncode::Init DWORD  dwBufferSize  ) 
 

Initializes the class by allocating async buffers.

Parameters:
[in] dwBufferSize - Number of async buffers to allocate.
Returns:
Returns non-zero if success.

BOOL CAviEncode::InitThread LPVOID  pData  )  [virtual]
 

Thread initialization function.

See also:
CThread::InitThread()
Returns:
Return code ignored

Reimplemented from CThread.

BOOL CAviEncode::StartRecording LPCTSTR  pFile,
LPRECT  pRect,
DWORD  dwFrames,
DWORD  dwSeconds,
DWORD  dwFourCC
 

Opens the avi and prepares for writing frames.

Parameters:
[in] pFile - The filename for the AVI.
[in] pRect - The size of a single video frame.
[in] dwFrames - The number of frames in dwSeconds of video.
[in] dwSeconds - The number of seconds of dwFrames of video.
[in] dwFourCC - The four character code of the compressor to use.
Examples for how to set dwFrames and dwSeconds: 30 fps - dwFrames = 30, dwSeconds = 1 5 fps - dwFrames = 5, dwSeconds = 1 2 fpm - dwFrames = 2, dwSeconds = 60 or dwFrames = 1, dwSeconds = 30

Returns:
Returns non-zero if success.

BOOL CAviEncode::StopRecording LPCTSTR  pRename = NULL  ) 
 

Closes the avi and releases all resources.

Parameters:
[in] pRename - Optional filename. If not NULL, the file will be renamed.
Returns:
Returns non-zero if success.


The documentation for this class was generated from the following files:
  • inc/AviEncode.h
  • AviEncode.cpp
Copyright Robert Umbehant
This documentation is covered by the LGPL