dmo.h
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:10k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * dmo.h : DirectMedia Object codec module for vlc
  3.  *****************************************************************************
  4.  * Copyright (C) 2002, 2003 the VideoLAN team
  5.  * $Id: edb5fe5419da000a578e9ab35e9bde8d260a63bb $
  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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  22.  *****************************************************************************/
  23. const GUID IID_IUnknown;
  24. const GUID IID_IClassFactory;
  25. const GUID IID_IWMCodecPrivateData;
  26. const GUID IID_IMediaObject;
  27. const GUID IID_IMediaBuffer;
  28. const GUID MEDIATYPE_Video;
  29. const GUID MEDIATYPE_Audio;
  30. const GUID MEDIASUBTYPE_PCM;
  31. const GUID FORMAT_VideoInfo;
  32. const GUID FORMAT_WaveFormatEx;
  33. const GUID GUID_NULL;
  34. const GUID MEDIASUBTYPE_I420;
  35. const GUID MEDIASUBTYPE_YV12;
  36. const GUID MEDIASUBTYPE_RGB24;
  37. const GUID MEDIASUBTYPE_RGB565;
  38. #ifndef WIN32
  39. void* CoTaskMemAlloc(unsigned long cb);
  40. void CoTaskMemFree(void* cb);
  41. #endif
  42. #define IUnknown IUnknownHack
  43. #define IClassFactory IClassFactoryHack
  44. typedef struct _IUnknown IUnknown;
  45. typedef struct _IClassFactory IClassFactory;
  46. typedef struct _IWMCodecPrivateData IWMCodecPrivateData;
  47. typedef struct _IEnumDMO IEnumDMO;
  48. typedef struct _IMediaBuffer IMediaBuffer;
  49. typedef struct _IMediaObject IMediaObject;
  50. #ifndef STDCALL
  51. #define STDCALL __stdcall
  52. #endif
  53. #define DMO_INPUT_DATA_BUFFERF_SYNCPOINT 1
  54. #define DMO_INPUT_DATA_BUFFERF_TIME 2
  55. #define DMO_INPUT_DATA_BUFFERF_TIMELENGTH 4
  56. #define DMO_OUTPUT_DATA_BUFFERF_SYNCPOINT 1
  57. #define DMO_OUTPUT_DATA_BUFFERF_TIME 2
  58. #define DMO_OUTPUT_DATA_BUFFERF_TIMELENGTH 4
  59. #define DMO_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER 1
  60. #define DMO_E_NOTACCEPTING 0x80040204
  61. /*
  62.  * DMO types definition
  63.  */
  64. typedef struct
  65. #ifdef HAVE_ATTRIBUTE_PACKED
  66.     __attribute__((__packed__))
  67. #endif
  68.  _DMO_PARTIAL_MEDIATYPE
  69. {
  70.     GUID type;
  71.     GUID subtype;
  72. } DMO_PARTIAL_MEDIATYPE;
  73. typedef struct
  74. #ifdef HAVE_ATTRIBUTE_PACKED
  75.     __attribute__((__packed__))
  76. #endif
  77.  _DMO_OUTPUT_DATA_BUFFER
  78. {
  79.     IMediaBuffer *pBuffer;
  80.     uint32_t dwStatus;
  81.     REFERENCE_TIME rtTimestamp;
  82.     REFERENCE_TIME rtTimelength;
  83. } DMO_OUTPUT_DATA_BUFFER;
  84. typedef struct
  85. #ifdef HAVE_ATTRIBUTE_PACKED
  86.     __attribute__((__packed__))
  87. #endif
  88.  _DMOMediaType
  89. {
  90.     GUID     majortype;
  91.     GUID     subtype;
  92.     int      bFixedSizeSamples;
  93.     int      bTemporalCompression;
  94.     uint32_t lSampleSize;
  95.     GUID     formattype;
  96.     IUnknown *pUnk;
  97.     uint32_t cbFormat;
  98.     char     *pbFormat;
  99. } DMO_MEDIA_TYPE;
  100. /*
  101.  * IUnknown interface
  102.  */
  103. typedef struct IUnknown_vt
  104. {
  105.     /* IUnknown methods */
  106.     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
  107.                                    void **ppvObject);
  108.     long (STDCALL *AddRef)(IUnknown *This);
  109.     long (STDCALL *Release)(IUnknown *This);
  110. } IUnknown_vt;
  111. struct _IUnknown { IUnknown_vt* vt; };
  112. /*
  113.  * IClassFactory interface
  114.  */
  115. typedef struct IClassFactory_vt
  116. {
  117.     long (STDCALL *QueryInterface)(IUnknown *This, const GUID* riid,
  118.                                    void **ppvObject);
  119.     long (STDCALL *AddRef)(IUnknown *This) ;
  120.     long (STDCALL *Release)(IUnknown *This) ;
  121.     long (STDCALL *CreateInstance)(IClassFactory *This, IUnknown *pUnkOuter,
  122.                                    const GUID* riid, void** ppvObject);
  123. } IClassFactory_vt;
  124. struct _IClassFactory { IClassFactory_vt* vt; };
  125. /*
  126.  * IWMCodecPrivateData interface
  127.  */
  128. typedef struct IWMCodecPrivateData_vt
  129. {
  130.     long (STDCALL *QueryInterface)(IUnknown *This, const GUID* riid,
  131.                                    void **ppvObject);
  132.     long (STDCALL *AddRef)(IUnknown *This) ;
  133.     long (STDCALL *Release)(IUnknown *This) ;
  134.  
  135.     long (STDCALL *SetPartialOutputType)(IWMCodecPrivateData * This,
  136.                                          DMO_MEDIA_TYPE *pmt);
  137.     long (STDCALL *GetPrivateData )(IWMCodecPrivateData * This,
  138.                                     uint8_t *pbData, uint32_t *pcbData);
  139. } IWMCodecPrivateData_vt;
  140. struct _IWMCodecPrivateData { IWMCodecPrivateData_vt* vt; };
  141. /*
  142.  * IEnumDMO interface
  143.  */
  144. typedef struct IEnumDMO_vt
  145. {
  146.     /* IUnknown methods */
  147.     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
  148.                                    void **ppvObject);
  149.     long (STDCALL *AddRef)(IUnknown *This);
  150.     long (STDCALL *Release)(IUnknown *This);
  151.     /* IEnumDMO methods */
  152.     long (STDCALL *Next)(IEnumDMO *This, uint32_t cItemsToFetch,
  153.                          const GUID *pCLSID, WCHAR **Names,
  154.                          uint32_t *pcItemsFetched);
  155.     long (STDCALL *Skip)(IEnumDMO *This, uint32_t cItemsToSkip);
  156.     long (STDCALL *Reset)(IEnumDMO *This);
  157.     long (STDCALL *Clone)(IEnumDMO *This, IEnumDMO **ppEnum);
  158. } IEnumDMO_vt;
  159. struct _IEnumDMO { IEnumDMO_vt* vt; };
  160. /*
  161.  * IMediaBuffer interface
  162.  */
  163. typedef struct IMediaBuffer_vt
  164. {
  165.     /* IUnknown methods */
  166.     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
  167.                                    void **ppvObject);
  168.     long (STDCALL *AddRef)(IUnknown *This);
  169.     long (STDCALL *Release)(IUnknown *This);
  170.     long (STDCALL *SetLength)(IMediaBuffer* This, uint32_t cbLength);
  171.     long (STDCALL *GetMaxLength)(IMediaBuffer* This, uint32_t *pcbMaxLength);
  172.     long (STDCALL *GetBufferAndLength)(IMediaBuffer* This,
  173.                                        char **ppBuffer, uint32_t *pcbLength);
  174. } IMediaBuffer_vt;
  175. struct _IMediaBuffer { IMediaBuffer_vt* vt; };
  176. /*
  177.  * IMediaObject interface
  178.  */
  179. typedef struct IMediaObject_vt
  180. {
  181.     /* IUnknown methods */
  182.     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
  183.                                    void **ppvObject);
  184.     long (STDCALL *AddRef)(IUnknown *This);
  185.     long (STDCALL *Release)(IUnknown *This);
  186.     /* IEnumDMO methods */
  187.     long (STDCALL *GetStreamCount)(IMediaObject *This,
  188.                                    uint32_t *pcInputStreams,
  189.                                    uint32_t *pcOutputStreams);
  190.     long (STDCALL *GetInputStreamInfo)(IMediaObject *This,
  191.                                        uint32_t dwInputStreamIndex,
  192.                                        uint32_t *pdwFlags);
  193.     long (STDCALL *GetOutputStreamInfo)(IMediaObject *This,
  194.                                         uint32_t dwOutputStreamIndex,
  195.                                         uint32_t *pdwFlags);
  196.     long (STDCALL *GetInputType)(IMediaObject *This,
  197.                                  uint32_t dwInputStreamIndex,
  198.                                  uint32_t dwTypeIndex,
  199.                                  DMO_MEDIA_TYPE *pmt);
  200.     long (STDCALL *GetOutputType)(IMediaObject *This,
  201.                                   uint32_t dwOutputStreamIndex,
  202.                                   uint32_t dwTypeIndex,
  203.                                   DMO_MEDIA_TYPE *pmt);
  204.     long (STDCALL *SetInputType)(IMediaObject *This,
  205.                                  uint32_t dwInputStreamIndex,
  206.                                  const DMO_MEDIA_TYPE *pmt,
  207.                                  uint32_t dwFlags);
  208.     long (STDCALL *SetOutputType)(IMediaObject *This,
  209.                                   uint32_t dwOutputStreamIndex,
  210.                                   const DMO_MEDIA_TYPE *pmt,
  211.                                   uint32_t dwFlags);
  212.     long (STDCALL *GetInputCurrentType)(IMediaObject *This,
  213.                                         uint32_t dwInputStreamIndex,
  214.                                         DMO_MEDIA_TYPE *pmt);
  215.     long (STDCALL *GetOutputCurrentType)(IMediaObject *This,
  216.                                          uint32_t dwOutputStreamIndex,
  217.                                          DMO_MEDIA_TYPE *pmt);
  218.     long (STDCALL *GetInputSizeInfo)(IMediaObject *This,
  219.                                      uint32_t dwInputStreamIndex,
  220.                                      uint32_t *pcbSize,
  221.                                      uint32_t *pcbMaxLookahead,
  222.                                      uint32_t *pcbAlignment);
  223.     long (STDCALL *GetOutputSizeInfo)(IMediaObject *This,
  224.                                       uint32_t dwOutputStreamIndex,
  225.                                       uint32_t *pcbSize,
  226.                                       uint32_t *pcbAlignment);
  227.     long (STDCALL *GetInputMaxLatency)(IMediaObject *This,
  228.                                        uint32_t dwInputStreamIndex,
  229.                                        REFERENCE_TIME *prtMaxLatency);
  230.     long (STDCALL *SetInputMaxLatency)(IMediaObject *This,
  231.                                        uint32_t dwInputStreamIndex,
  232.                                        REFERENCE_TIME rtMaxLatency);
  233.     long (STDCALL *Flush)(IMediaObject * This);
  234.     long (STDCALL *Discontinuity)(IMediaObject *This,
  235.                                   uint32_t dwInputStreamIndex);
  236.     long (STDCALL *AllocateStreamingResources)(IMediaObject * This);
  237.     long (STDCALL *FreeStreamingResources)(IMediaObject * This);
  238.     long (STDCALL *GetInputStatus)(IMediaObject *This,
  239.                                    uint32_t dwInputStreamIndex,
  240.                                    uint32_t *dwFlags);
  241.     long (STDCALL *ProcessInput)(IMediaObject *This,
  242.                                  uint32_t dwInputStreamIndex,
  243.                                  IMediaBuffer *pBuffer,
  244.                                  uint32_t dwFlags,
  245.                                  REFERENCE_TIME rtTimestamp,
  246.                                  REFERENCE_TIME rtTimelength);
  247.     long (STDCALL *ProcessOutput)(IMediaObject *This,
  248.                                   uint32_t dwFlags,
  249.                                   uint32_t cOutputBufferCount,
  250.                                   DMO_OUTPUT_DATA_BUFFER *pOutputBuffers,
  251.                                   uint32_t *pdwStatus);
  252.     long (STDCALL *Lock)(IMediaObject *This, long bLock);
  253. } IMediaObject_vt;
  254. struct _IMediaObject { IMediaObject_vt* vt; };
  255. /* Implementation of IMediaBuffer */
  256. typedef struct _CMediaBuffer
  257. {
  258.     IMediaBuffer_vt *vt;
  259.     int i_ref;
  260.     block_t *p_block;
  261.     int i_max_size;
  262.     bool b_own;
  263. } CMediaBuffer;
  264. CMediaBuffer *CMediaBufferCreate( block_t *, int, bool );