dmo.h
上传用户:riyaled888
上传日期:2009-03-27
资源大小:7338k
文件大小:12k
源码类别:

多媒体

开发平台:

MultiPlatform

  1. /*****************************************************************************
  2.  * dmo.h : DirectMedia Object codec module for vlc
  3.  *****************************************************************************
  4.  * Copyright (C) 2002, 2003 VideoLAN
  5.  * $Id: dmo.h 8462 2004-08-19 15:02:51Z gbazin $
  6.  *
  7.  * Author: Gildas Bazin <gbazin@videolan.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  22.  *****************************************************************************/
  23. static const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46}};
  24. static const GUID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
  25. static const GUID IID_IWMCodecPrivateData = {0x73f0be8e, 0x57f7, 0x4f01, {0xaa, 0x66, 0x9f, 0x57, 0x34, 0xc, 0xfe, 0xe}};
  26. static const GUID IID_IMediaObject = {0xd8ad0f58, 0x5494, 0x4102, {0x97, 0xc5, 0xec, 0x79, 0x8e, 0x59, 0xbc, 0xf4}};
  27. static const GUID IID_IMediaBuffer = {0x59eff8b9, 0x938c, 0x4a26, {0x82, 0xf2, 0x95, 0xcb, 0x84, 0xcd, 0xc8, 0x37}};
  28. static const GUID MEDIATYPE_Video = {0x73646976, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
  29. static const GUID MEDIATYPE_Audio = {0x73647561, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
  30. static const GUID MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
  31. static const GUID FORMAT_VideoInfo = {0x05589f80, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
  32. static const GUID FORMAT_WaveFormatEx = {0x05589f81, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
  33. static const GUID GUID_NULL = {0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
  34. static const GUID MEDIASUBTYPE_I420 = {0x30323449, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
  35. static const GUID MEDIASUBTYPE_YV12 = {0x32315659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
  36. static const GUID MEDIASUBTYPE_RGB24 = {0xe436eb7d, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
  37. static const GUID MEDIASUBTYPE_RGB565 = {0xe436eb7b, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
  38. #define IUnknown IUnknownHack
  39. #define IClassFactory IClassFactoryHack
  40. typedef struct _IUnknown IUnknown;
  41. typedef struct _IClassFactory IClassFactory;
  42. typedef struct _IWMCodecPrivateData IWMCodecPrivateData;
  43. typedef struct _IEnumDMO IEnumDMO;
  44. typedef struct _IMediaBuffer IMediaBuffer;
  45. typedef struct _IMediaObject IMediaObject;
  46. #ifndef STDCALL
  47. #define STDCALL __stdcall
  48. #endif
  49. #define DMO_INPUT_DATA_BUFFERF_SYNCPOINT 1
  50. #define DMO_INPUT_DATA_BUFFERF_TIME 2
  51. #define DMO_INPUT_DATA_BUFFERF_TIMELENGTH 4
  52. #define DMO_OUTPUT_DATA_BUFFERF_SYNCPOINT 1
  53. #define DMO_OUTPUT_DATA_BUFFERF_TIME 2
  54. #define DMO_OUTPUT_DATA_BUFFERF_TIMELENGTH 4
  55. #define DMO_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER 1
  56. #define DMO_E_NOTACCEPTING 0x80040204
  57. /*
  58.  * DMO types definition
  59.  */
  60. typedef struct
  61. #ifdef HAVE_ATTRIBUTE_PACKED
  62.     __attribute__((__packed__))
  63. #endif
  64.  _DMO_PARTIAL_MEDIATYPE
  65. {
  66.     GUID type;
  67.     GUID subtype;
  68. } DMO_PARTIAL_MEDIATYPE;
  69. typedef struct
  70. #ifdef HAVE_ATTRIBUTE_PACKED
  71.     __attribute__((__packed__))
  72. #endif
  73.  _DMO_OUTPUT_DATA_BUFFER
  74. {
  75.     IMediaBuffer *pBuffer;
  76.     uint32_t dwStatus;
  77.     REFERENCE_TIME rtTimestamp;
  78.     REFERENCE_TIME rtTimelength;
  79. } DMO_OUTPUT_DATA_BUFFER;
  80. typedef struct
  81. #ifdef HAVE_ATTRIBUTE_PACKED
  82.     __attribute__((__packed__))
  83. #endif
  84.  _DMOMediaType
  85. {
  86.     GUID     majortype;
  87.     GUID     subtype;
  88.     int      bFixedSizeSamples;
  89.     int      bTemporalCompression;
  90.     uint32_t lSampleSize;
  91.     GUID     formattype;
  92.     IUnknown *pUnk;
  93.     uint32_t cbFormat;
  94.     char     *pbFormat;
  95. } DMO_MEDIA_TYPE;
  96. /*
  97.  * IUnknown interface
  98.  */
  99. typedef struct IUnknown_vt
  100. {
  101.     /* IUnknown methods */
  102.     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
  103.                                    void **ppvObject);
  104.     long (STDCALL *AddRef)(IUnknown *This);
  105.     long (STDCALL *Release)(IUnknown *This);
  106. } IUnknown_vt;
  107. struct _IUnknown { IUnknown_vt* vt; };
  108. /*
  109.  * IClassFactory interface
  110.  */
  111. typedef struct IClassFactory_vt
  112. {
  113.     long (STDCALL *QueryInterface)(IUnknown *This, const GUID* riid,
  114.                                    void **ppvObject);
  115.     long (STDCALL *AddRef)(IUnknown *This) ;
  116.     long (STDCALL *Release)(IUnknown *This) ;
  117.     long (STDCALL *CreateInstance)(IClassFactory *This, IUnknown *pUnkOuter,
  118.                                    const GUID* riid, void** ppvObject);
  119. } IClassFactory_vt;
  120. struct _IClassFactory { IClassFactory_vt* vt; };
  121. /*
  122.  * IWMCodecPrivateData interface
  123.  */
  124. typedef struct IWMCodecPrivateData_vt
  125. {
  126.     long (STDCALL *QueryInterface)(IUnknown *This, const GUID* riid,
  127.                                    void **ppvObject);
  128.     long (STDCALL *AddRef)(IUnknown *This) ;
  129.     long (STDCALL *Release)(IUnknown *This) ;
  130.         
  131.     long (STDCALL *SetPartialOutputType)(IWMCodecPrivateData * This,
  132.                                          DMO_MEDIA_TYPE *pmt);
  133.     long (STDCALL *GetPrivateData )(IWMCodecPrivateData * This,
  134.                                     uint8_t *pbData, uint32_t *pcbData);
  135. } IWMCodecPrivateData_vt;
  136. struct _IWMCodecPrivateData { IWMCodecPrivateData_vt* vt; };
  137. /*
  138.  * IEnumDMO interface
  139.  */
  140. typedef struct IEnumDMO_vt
  141. {
  142.     /* IUnknown methods */
  143.     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
  144.                                    void **ppvObject);
  145.     long (STDCALL *AddRef)(IUnknown *This);
  146.     long (STDCALL *Release)(IUnknown *This);
  147.     /* IEnumDMO methods */
  148.     long (STDCALL *Next)(IEnumDMO *This, uint32_t cItemsToFetch,
  149.                          const GUID *pCLSID, WCHAR **Names,
  150.                          uint32_t *pcItemsFetched);
  151.     long (STDCALL *Skip)(IEnumDMO *This, uint32_t cItemsToSkip);
  152.     long (STDCALL *Reset)(IEnumDMO *This);
  153.     long (STDCALL *Clone)(IEnumDMO *This, IEnumDMO **ppEnum);
  154. } IEnumDMO_vt;
  155. struct _IEnumDMO { IEnumDMO_vt* vt; };
  156. /*
  157.  * IMediaBuffer interface
  158.  */
  159. typedef struct IMediaBuffer_vt
  160. {
  161.     /* IUnknown methods */
  162.     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
  163.                                    void **ppvObject);
  164.     long (STDCALL *AddRef)(IUnknown *This);
  165.     long (STDCALL *Release)(IUnknown *This);
  166.     long (STDCALL *SetLength)(IMediaBuffer* This, uint32_t cbLength);
  167.     long (STDCALL *GetMaxLength)(IMediaBuffer* This, uint32_t *pcbMaxLength);
  168.     long (STDCALL *GetBufferAndLength)(IMediaBuffer* This,
  169.                                        char **ppBuffer, uint32_t *pcbLength);
  170. } IMediaBuffer_vt;
  171. struct _IMediaBuffer { IMediaBuffer_vt* vt; };
  172. /*
  173.  * IMediaObject interface
  174.  */
  175. typedef struct IMediaObject_vt
  176. {
  177.     /* IUnknown methods */
  178.     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
  179.                                    void **ppvObject);
  180.     long (STDCALL *AddRef)(IUnknown *This);
  181.     long (STDCALL *Release)(IUnknown *This);
  182.     /* IEnumDMO methods */
  183.     long (STDCALL *GetStreamCount)(IMediaObject *This,
  184.                                    uint32_t *pcInputStreams,
  185.                                    uint32_t *pcOutputStreams);
  186.     long (STDCALL *GetInputStreamInfo)(IMediaObject *This,
  187.                                        uint32_t dwInputStreamIndex,
  188.                                        uint32_t *pdwFlags);
  189.     long (STDCALL *GetOutputStreamInfo)(IMediaObject *This,
  190.                                         uint32_t dwOutputStreamIndex,
  191.                                         uint32_t *pdwFlags);
  192.     long (STDCALL *GetInputType)(IMediaObject *This,
  193.                                  uint32_t dwInputStreamIndex,
  194.                                  uint32_t dwTypeIndex,
  195.                                  DMO_MEDIA_TYPE *pmt);
  196.     long (STDCALL *GetOutputType)(IMediaObject *This,
  197.                                   uint32_t dwOutputStreamIndex,
  198.                                   uint32_t dwTypeIndex,
  199.                                   DMO_MEDIA_TYPE *pmt);
  200.     long (STDCALL *SetInputType)(IMediaObject *This,
  201.                                  uint32_t dwInputStreamIndex,
  202.                                  const DMO_MEDIA_TYPE *pmt,
  203.                                  uint32_t dwFlags);
  204.     long (STDCALL *SetOutputType)(IMediaObject *This,
  205.                                   uint32_t dwOutputStreamIndex,
  206.                                   const DMO_MEDIA_TYPE *pmt,
  207.                                   uint32_t dwFlags);
  208.     long (STDCALL *GetInputCurrentType)(IMediaObject *This,
  209.                                         uint32_t dwInputStreamIndex,
  210.                                         DMO_MEDIA_TYPE *pmt);
  211.     long (STDCALL *GetOutputCurrentType)(IMediaObject *This,
  212.                                          uint32_t dwOutputStreamIndex,
  213.                                          DMO_MEDIA_TYPE *pmt);
  214.     long (STDCALL *GetInputSizeInfo)(IMediaObject *This,
  215.                                      uint32_t dwInputStreamIndex,
  216.                                      uint32_t *pcbSize,
  217.                                      uint32_t *pcbMaxLookahead,
  218.                                      uint32_t *pcbAlignment);
  219.     long (STDCALL *GetOutputSizeInfo)(IMediaObject *This,
  220.                                       uint32_t dwOutputStreamIndex,
  221.                                       uint32_t *pcbSize,
  222.                                       uint32_t *pcbAlignment);
  223.     long (STDCALL *GetInputMaxLatency)(IMediaObject *This,
  224.                                        uint32_t dwInputStreamIndex,
  225.                                        REFERENCE_TIME *prtMaxLatency);
  226.     long (STDCALL *SetInputMaxLatency)(IMediaObject *This,
  227.                                        uint32_t dwInputStreamIndex,
  228.                                        REFERENCE_TIME rtMaxLatency);
  229.     long (STDCALL *Flush)(IMediaObject * This);
  230.     long (STDCALL *Discontinuity)(IMediaObject *This,
  231.                                   uint32_t dwInputStreamIndex);
  232.     long (STDCALL *AllocateStreamingResources)(IMediaObject * This);
  233.     long (STDCALL *FreeStreamingResources)(IMediaObject * This);
  234.     long (STDCALL *GetInputStatus)(IMediaObject *This,
  235.                                    uint32_t dwInputStreamIndex,
  236.                                    uint32_t *dwFlags);
  237.     long (STDCALL *ProcessInput)(IMediaObject *This,
  238.                                  uint32_t dwInputStreamIndex,
  239.                                  IMediaBuffer *pBuffer,
  240.                                  uint32_t dwFlags,
  241.                                  REFERENCE_TIME rtTimestamp,
  242.                                  REFERENCE_TIME rtTimelength);
  243.     long (STDCALL *ProcessOutput)(IMediaObject *This,
  244.                                   uint32_t dwFlags,
  245.                                   uint32_t cOutputBufferCount,
  246.                                   DMO_OUTPUT_DATA_BUFFER *pOutputBuffers,
  247.                                   uint32_t *pdwStatus);
  248.     long (STDCALL *Lock)(IMediaObject *This, long bLock);
  249. } IMediaObject_vt;
  250. struct _IMediaObject { IMediaObject_vt* vt; };
  251. /* Implementation of IMediaBuffer */
  252. typedef struct _CMediaBuffer
  253. {
  254.     IMediaBuffer_vt *vt;
  255.     int i_ref;
  256.     block_t *p_block;
  257.     int i_max_size;
  258.     vlc_bool_t b_own;
  259. } CMediaBuffer;
  260. CMediaBuffer *CMediaBufferCreate( block_t *, int, vlc_bool_t );