CFugue
AviFile.h
1 #pragma once
2 
3 #ifndef __AVIFILE_H
4 #define __AVIFILE_H
5 
6 #include <vfw.h>
7 #include <TChar.h>
8 
9 class CAviFile
10 {
11  HDC m_hAviDC;
12  HANDLE m_hHeap;
13  LPVOID m_lpBits; // Useful for holding the bitmap content, if any
14  LONG m_lSample; // Keeps track of the current Frame Index
15  PAVIFILE m_pAviFile;
16  PAVISTREAM m_pAviStream;
17  PAVISTREAM m_pAviCompressedStream;
18  AVISTREAMINFO m_AviStreamInfo;
19  AVICOMPRESSOPTIONS m_AviCompressOptions;
20  DWORD m_dwFrameRate; // Frames Per Second Rate (FPS)
21  DWORD m_dwFCCHandler; // Video Codec FourCC
22  TCHAR m_szFileName[MAX_PATH]; // Holds the Output Movie File Name
23  TCHAR m_szErrMsg[MAX_PATH]; // Holds the Last Error Message, if any
24 
25  int m_nAppendFuncSelector; //0=Dummy 1=FirstTime 2=Usual
26 
27  HRESULT AppendFrameFirstTime(HBITMAP );
28  HRESULT AppendFrameUsual(HBITMAP);
29  HRESULT AppendDummy(HBITMAP);
30  HRESULT (CAviFile::*pAppendFrame[3])(HBITMAP hBitmap);
31 
32  HRESULT AppendFrameFirstTime(int, int, LPVOID,int );
33  HRESULT AppendFrameUsual(int, int, LPVOID,int );
34  HRESULT AppendDummy(int, int, LPVOID,int );
35  HRESULT (CAviFile::*pAppendFrameBits[3])(int, int, LPVOID, int);
36 
37  /// Takes care of creating the memory, streams, compression options etc. required for the movie
38  HRESULT InitMovieCreation(int nFrameWidth, int nFrameHeight, int nBitsPerPixel);
39 
40  /// Takes care of releasing the memory and movie related handles
41  void ReleaseMemory();
42 
43  /// Sets the Error Message
44  void SetErrorMessage(LPCTSTR lpszErrMsg);
45 
46 public:
47  /// <Summary>
48  /// Constructor accepts the filename, video code and frame rate settings
49  /// as parameters.
50  /// lpszFileName: Name of the output movie file to create
51  /// dwCodec: FourCC of the Video Codec to be used for compression
52  /// dwFrameRate: The Frames Per Second (FPS) setting to be used for the movie
53  /// </Summary>
54  /// <Remarks>
55  /// The default Codec used here is MPG4. To use a different codec, pass its Fourcc
56  /// value as the input parameter for dwCodec.
57  /// For example,
58  /// pass mmioFOURCC('D','I','V','X') to use DIVX codec, or
59  /// pass mmioFOURCC('I','V','5','0') to use IV50 codec etc...
60  ///
61  /// Also, you can pass just 0 to avoid the codecs altogether. In that case, Frames
62  /// would be saved as they are without any compression; However, the output movie file
63  /// size would be very huge in that case.
64  ///
65  /// Finally, make sure you have the codec installed on the machine before
66  /// passing its Fourcc here.
67  /// </Remarks>
68  CAviFile(LPCTSTR lpszFileName=_T("Output.avi"),
69  DWORD dwCodec = mmioFOURCC('M','P','G','4'),
70  DWORD dwFrameRate = 1);
71 
72  /// <Summary>
73  /// Destructor closes the movie file and flushes all the frames
74  /// </Summary>
75  ~CAviFile(void);
76 
77  /// </Summary>
78  /// Inserts the given HBitmap into the movie as a new Frame at the end.
79  /// </Summary>
80  HRESULT AppendNewFrame(HBITMAP hBitmap);
81 
82  /// </Summary>
83  /// Inserts the given bitmap bits into the movie as a new Frame at the end.
84  /// The width, height and nBitsPerPixel are the width, height and bits per pixel
85  /// of the bitmap pointed to by the input pBits.
86  /// </Summary>
87  HRESULT AppendNewFrame(int nWidth, int nHeight, LPVOID pBits,int nBitsPerPixel);
88 
89  /// <Summary>
90  /// Returns the last error message, if any.
91  /// </Summary>
92  LPCTSTR GetLastErrorMessage() const { return m_szErrMsg; }
93 };
94 
95 #endif
HRESULT AppendNewFrame(HBITMAP hBitmap)
Definition: AviFile.cpp:234
CAviFile(LPCTSTR lpszFileName=_T("Output.avi"), DWORD dwCodec=mmioFOURCC('M','P','G','4'), DWORD dwFrameRate=1)
Definition: AviFile.cpp:10
LPCTSTR GetLastErrorMessage() const
Definition: AviFile.h:92
~CAviFile(void)
Definition: AviFile.cpp:43

CFugue, the C++ Music Programming Library © Copyright 2009 Cenacle Research India Private Limited Gopalakrishna Palem