2
* Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
4
* gstdshowfakesink.cpp:
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public
17
* License along with this library; if not, write to the
18
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
* Boston, MA 02111-1307, USA.
22
#include "gstdshowfakesink.h"
25
CDshowFakeSink::CDshowFakeSink()
26
: m_hres(S_OK), CBaseRenderer(CLSID_DshowFakeSink, "DshowFakeSink", NULL, &m_hres)
31
CDshowFakeSink::~CDshowFakeSink()
37
CUnknown* WINAPI CDshowFakeSink::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr)
39
CDshowFakeSink *pNewObject = new CDshowFakeSink();
40
if (pNewObject == NULL) {
46
STDMETHODIMP CDshowFakeSink::QueryInterface(REFIID riid, void **ppvObject)
48
if (riid == IID_IGstDshowInterface) {
49
*ppvObject = (IGstDshowInterface*) this;
54
return CBaseRenderer::QueryInterface (riid, ppvObject);
57
ULONG STDMETHODCALLTYPE CDshowFakeSink::AddRef()
59
return CBaseRenderer::AddRef();
62
ULONG STDMETHODCALLTYPE CDshowFakeSink::Release()
64
return CBaseRenderer::Release();
68
STDMETHODIMP CDshowFakeSink::gst_set_media_type (AM_MEDIA_TYPE *pmt)
70
m_MediaType.Set (*pmt);
74
STDMETHODIMP CDshowFakeSink::gst_set_buffer_callback (push_buffer_func push, byte *data)
81
STDMETHODIMP CDshowFakeSink::gst_push_buffer (byte *buffer, __int64 start, __int64 stop, unsigned int size, bool discount)
86
STDMETHODIMP CDshowFakeSink::gst_flush ()
91
STDMETHODIMP CDshowFakeSink::gst_set_sample_size(unsigned int size)
96
HRESULT CDshowFakeSink::CheckMediaType(const CMediaType *pmt)
102
p1 = (VIDEOINFOHEADER *)pmt->Format();
103
p2 = (VIDEOINFOHEADER *)m_MediaType.Format();
104
if (*pmt == m_MediaType)
111
HRESULT CDshowFakeSink::DoRenderSample(IMediaSample *pMediaSample)
113
if(pMediaSample && m_callback)
115
BYTE *pBuffer = NULL;
116
LONGLONG lStart = 0, lStop = 0;
117
pMediaSample->GetPointer(&pBuffer);
118
long size = pMediaSample->GetActualDataLength();
119
pMediaSample->GetTime(&lStart, &lStop);
122
m_callback(pBuffer, size, m_data, lStart, lStop);