DecapsAVI.h
上传用户:tuheem
上传日期:2007-05-01
资源大小:21889k
文件大小:4k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /**************************************************************************************
  2.  *                                                                                    *
  3.  *                                                                                    *
  4.  **************************************************************************************/
  5. #ifndef DECAPS_AVI_H
  6. #define DECAPS_AVI_H
  7. #include "MediaClasses.h"
  8. #include "mmreg.h"
  9. #include <stdio.h>
  10. #define AVI_MAX_LEN 2000000000
  11. #define HEADERBYTES 2048
  12. #define PAD_EVEN(x) ( ((x)+1) & ~1 )
  13. #define AVIIF_KEYFRAME 0x00000010L
  14. typedef struct
  15. {
  16.   long pos;
  17.   long len;
  18.   long flags;
  19. } video_index_entry;
  20. typedef struct
  21. {
  22.    long pos;
  23.    long len;
  24.    long tot;
  25. } audio_index_entry;
  26. class MediaDecapsAVI : public MediaItemDecaps {
  27. public:
  28. BITMAPINFOHEADER   bitmapinfoheader;
  29. MPEGLAYER3WAVEFORMAT waveformatex;
  30.     long               width;             
  31.     long               height;            
  32.     double             fps;               
  33.     char               compressor[8];     
  34.     long               video_strn;        
  35.     long               video_frames;      
  36.     char               video_tag[4];      
  37.     long               video_pos;         
  38.     long               a_fmt;             
  39.     long               a_chans;           
  40.     long               a_rate;            
  41.     long               a_bits;            
  42.     long               audio_strn;        
  43.     long               audio_bytes;       
  44.     long               audio_chunks;      
  45.     char               audio_tag[4];      
  46.     long               audio_posc;        
  47.     long               audio_posb;        
  48.     long               pos;               
  49.     long               n_idx;             
  50.     long               max_idx;           
  51.     char               (*idx)[16]; 
  52.     video_index_entry *video_index;
  53.     audio_index_entry *audio_index;
  54.     long               last_pos;          
  55.     long               last_len;          
  56.     int                must_use_index;    
  57.     long               movi_start;
  58. HANDLE             hIOMutex;
  59. MediaItemInput    *input;
  60. int  IsAVI();
  61. int  FillHeader(int getIndex);
  62. int  ReFillIndex();
  63. int  AddIndexEntry(char *tag, 
  64.              long flags, 
  65.              long pos, 
  66.              long len);
  67. BOOL isKeyframe(long frame);
  68. int  SampleSize();
  69. public:
  70. MediaDecapsAVI();
  71. ~MediaDecapsAVI();
  72. media_type_t  GetType();
  73. char         *GetName();
  74. MP_RESULT     Connect(MediaItem *item);
  75. MP_RESULT     ReleaseConnections();
  76. DWORD         GetCaps();
  77. MP_RESULT     Configure(HINSTANCE hInstance, HWND hwnd);
  78. unsigned int  GetNumberOfVideoStreams();
  79. unsigned int  GetNumberOfAudioStreams();
  80. unsigned int  GetVideoWidth(unsigned int StreamId);
  81. unsigned int  GetVideoHeight(unsigned int StreamId);
  82. double        GetVideoFrameRate(unsigned int StreamId);
  83. char  *GetVideoCompression(unsigned int StreamId);
  84. BITMAPINFOHEADER *GetVideoHeader(unsigned int StreamId);
  85. unsigned long GetCurrentVideoFrame(unsigned int StreamId);
  86. unsigned long GetTotalVideoFrames(unsigned int StreamId);
  87. unsigned long GetTotalVideoTime(unsigned int StreamId);
  88. unsigned int  GetAudioBits(unsigned int StreamId);
  89. unsigned int  GetAudioChannels(unsigned int StreamId);
  90. unsigned int  GetAudioFrequency(unsigned int StreamId);
  91. WAVEFORMATEX *GetAudioFormat(unsigned int StreamId);
  92. unsigned int  GetNextVideoFrameSize(unsigned int StreamId);
  93. unsigned int  ReadVideoFrame(unsigned int StreamId, MediaBuffer *mb);
  94. unsigned int  ReadAudioData(unsigned int StreamId, char *buffer, unsigned int bytes);
  95. MP_RESULT     UpdateForSize();
  96. MP_RESULT     SeekAudio(unsigned int StreamId, long bytes);
  97. MP_RESULT     SeekVideo(unsigned int StreamId, long frame);
  98. MP_RESULT     ReSeekAudio(unsigned int StreamId);
  99. MP_RESULT     Seek(unsigned int videoStreamId, unsigned int audioStreamId, int percent);
  100. MP_RESULT     Rewind(unsigned int videoStreamId, unsigned int audioStreamId);
  101. MP_RESULT     SeekNextKeyFrame(unsigned int StreamId);
  102. MP_RESULT     SeekPreviousKeyFrame(unsigned int StreamId);
  103. };
  104. #endif