00001
00035 #pragma once
00036
00037
00038 #pragma warning(push) // disable for this header only
00039 #pragma warning(disable:4312)
00040
00041 #include <Streams.h>
00042 #pragma warning(pop) // restore original warning level
00043
00044
00045 #include <string>
00046 #include <vector>
00047
00048
00049 #include "RtpPacketManager.h"
00050 #include <DirectShow/CStatusInterface.h>
00051 #include <DirectShow/CSettingsInterface.h>
00052
00053
00054 class RtspSourceOutputPin;
00055 class RtspDataSession;
00056 class MediaSubsession;
00057
00058
00059 #define g_wszFilterName L"Meraka RTVC RTSP Source Filter(Audio)"
00060
00061 #define STREAM_USING_TCP "streamusingtcp"
00062
00063
00064 static const GUID CLSID_RTVC_RtspAudioSourceFilter =
00065 { 0xcf5878ac, 0x78f0, 0x4544, { 0x83, 0xb9, 0xa9, 0x40, 0xe2, 0xd, 0x96, 0x90 } };
00066
00067
00068 static const GUID CLSID_RtspProperties =
00069 { 0x3955be86, 0xa1e9, 0x4fa3, { 0x86, 0x54, 0x62, 0x3d, 0x73, 0xdd, 0x2f, 0x29 } };
00070
00075 class RtspSourceFilter : public CSource,
00076 public CSettingsInterface,
00077 public CStatusInterface,
00078 public IFileSourceFilter,
00079 public IAMFilterMiscFlags,
00080 public ISpecifyPropertyPages
00081 {
00083 DECLARE_IUNKNOWN;
00084
00086 friend class RtspSourceOutputPin;
00087
00088 public:
00090 static CUnknown *WINAPI CreateInstance(IUnknown* pUnk, HRESULT* phr);
00091
00093 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
00094
00096 virtual void initParameters()
00097 {
00098 addParameter(STREAM_USING_TCP, &m_bStreamUsingTCP, true);
00099 }
00100
00102 STDMETHODIMP Load(LPCOLESTR lpwszFileName, const AM_MEDIA_TYPE *pmt);
00104 STDMETHODIMP GetCurFile(LPOLESTR * ppszFileName, AM_MEDIA_TYPE *pmt);
00105
00107 virtual ULONG STDMETHODCALLTYPE GetMiscFlags()
00108 {
00109 return AM_FILTER_MISC_FLAGS_IS_SOURCE;
00110 }
00111
00113 virtual int GetPinCount();
00115 virtual CBasePin * GetPin(int n);
00117 virtual STDMETHODIMP FindPin(LPCWSTR Id, IPin **ppPin);
00118
00120 STDMETHODIMP Stop();
00122 STDMETHODIMP Pause();
00123
00125 STDMETHODIMP GetState( DWORD dwMilliSecsTimeout, FILTER_STATE *State );
00126
00128 void StartRtspServerThreadIfNotStarted();
00130 void StartRtspSession();
00131
00136 void createOutputPin(MediaSubsession *pSubsession, HRESULT* phr);
00137
00138 STDMETHODIMP GetPages(CAUUID *pPages)
00139 {
00140 if (pPages == NULL) return E_POINTER;
00141 pPages->cElems = 1;
00142 pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID));
00143 if (pPages->pElems == NULL)
00144 {
00145 return E_OUTOFMEMORY;
00146 }
00147 pPages->pElems[0] = CLSID_RtspProperties;
00148 return S_OK;
00149 }
00150 private:
00151
00153 RtspSourceFilter(IUnknown* pUnk, HRESULT* phr);
00154 virtual ~RtspSourceFilter(void);
00155
00158 void notifyFilterAboutOffset(double dOffset);
00159
00161 std::vector<RtspSourceOutputPin*> m_vOutputPins;
00162
00164 std::string m_sUrl;
00165
00166 CCritSec m_stateLock;
00167
00169 bool m_bStreamUsingTCP;
00170
00172 bool m_bStreaming;
00173
00176 HANDLE m_hLiveMediaStopEvent;
00177
00179 REFERENCE_TIME m_tStreamTimeOffset;
00180 double m_dStreamTimeOffset;
00181
00182
00183 RtpPacketManager m_rtpPacketManager;
00184
00186 RtspDataSession* m_pRtspDataSession;
00187 };