BaseMuxer.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:3k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /* 
  2.  * Copyright (C) 2003-2005 Gabest
  3.  * http://www.gabest.org
  4.  *
  5.  *  This Program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2, or (at your option)
  8.  *  any later version.
  9.  *   
  10.  *  This Program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13.  *  GNU General Public License for more details.
  14.  *   
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with GNU Make; see the file COPYING.  If not, write to
  17.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  18.  *  http://www.gnu.org/copyleft/gpl.html
  19.  *
  20.  */
  21. #pragma once
  22. #include "BaseMuxerInputPin.h"
  23. #include "BaseMuxerOutputPin.h"
  24. #include "BitStream.h"
  25. class CBaseMuxerFilter
  26. : public CBaseFilter
  27. , public CCritSec
  28. , public CAMThread
  29. , public IMediaSeeking
  30. , public IDSMPropertyBagImpl
  31. , public IDSMResourceBagImpl
  32. , public IDSMChapterBagImpl
  33. {
  34. private:
  35. CAutoPtrList<CBaseMuxerInputPin> m_pInputs;
  36. CAutoPtr<CBaseMuxerOutputPin> m_pOutput;
  37. enum {CMD_EXIT, CMD_RUN};
  38. DWORD ThreadProc();
  39. REFERENCE_TIME m_rtCurrent;
  40. CList<CBaseMuxerInputPin*> m_pActivePins;
  41. CAutoPtr<MuxerPacket> GetPacket();
  42. protected:
  43. CList<CBaseMuxerInputPin*> m_pPins;
  44. virtual void MuxInit() = 0;
  45. // only called when the output pin is connected
  46. virtual void MuxHeader(IBitStream* pBS) {}
  47. virtual void MuxPacket(IBitStream* pBS, const MuxerPacket* pPacket) {}
  48. virtual void MuxFooter(IBitStream* pBS) {}
  49. // always called (useful if the derived class wants to write somewhere else than downstream)
  50. virtual void MuxHeader() {}
  51. virtual void MuxPacket(const MuxerPacket* pPacket) {}
  52. virtual void MuxFooter() {}
  53. virtual HRESULT CreateInput(CStringW name, CBaseMuxerInputPin** ppPin);
  54. public:
  55. CBaseMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid);
  56. virtual ~CBaseMuxerFilter();
  57. DECLARE_IUNKNOWN;
  58.     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
  59. void AddInput();
  60. //void Receive(CAutoPtr<Packet> pPacket);
  61. int GetPinCount();
  62. CBasePin* GetPin(int n);
  63. STDMETHODIMP Stop();
  64. STDMETHODIMP Pause();
  65. STDMETHODIMP Run(REFERENCE_TIME tStart);
  66. // IMediaSeeking
  67. STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
  68. STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
  69. STDMETHODIMP IsFormatSupported(const GUID* pFormat);
  70. STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
  71. STDMETHODIMP GetTimeFormat(GUID* pFormat);
  72. STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
  73. STDMETHODIMP SetTimeFormat(const GUID* pFormat);
  74. STDMETHODIMP GetDuration(LONGLONG* pDuration);
  75. STDMETHODIMP GetStopPosition(LONGLONG* pStop);
  76. STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
  77. STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
  78. STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
  79. STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
  80. STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
  81. STDMETHODIMP SetRate(double dRate);
  82. STDMETHODIMP GetRate(double* pdRate);
  83. STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
  84. };