2007-05-23 22:44:12 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
|
|
|
|
*
|
|
|
|
* gstdshowfakesink.cpp:
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gstdshowfakesink.h"
|
|
|
|
|
2009-09-07 08:59:53 +00:00
|
|
|
CDshowFakeSink::CDshowFakeSink ():
|
|
|
|
m_hres (S_OK),
|
|
|
|
m_callback (NULL),
|
|
|
|
m_data (NULL),
|
2009-09-07 14:44:52 +00:00
|
|
|
CBaseRenderer (CLSID_DshowFakeSink, _T("DshowFakeSink"), NULL, &m_hres)
|
2007-05-23 22:44:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-09-07 08:59:53 +00:00
|
|
|
STDMETHODIMP CDshowFakeSink::gst_set_media_type (AM_MEDIA_TYPE * pmt)
|
2007-05-23 22:44:12 +00:00
|
|
|
{
|
|
|
|
m_MediaType.Set (*pmt);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-07 08:59:53 +00:00
|
|
|
STDMETHODIMP
|
|
|
|
CDshowFakeSink::gst_set_buffer_callback (push_buffer_func push,
|
|
|
|
gpointer data)
|
2007-05-23 22:44:12 +00:00
|
|
|
{
|
|
|
|
m_callback = push;
|
|
|
|
m_data = data;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-07 08:59:53 +00:00
|
|
|
HRESULT CDshowFakeSink::CheckMediaType (const CMediaType * pmt)
|
2007-05-23 22:44:12 +00:00
|
|
|
{
|
2009-07-27 12:52:57 +00:00
|
|
|
if (pmt != NULL) {
|
2007-05-23 22:44:12 +00:00
|
|
|
if (*pmt == m_MediaType)
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-07 08:59:53 +00:00
|
|
|
HRESULT CDshowFakeSink::DoRenderSample (IMediaSample * pMediaSample)
|
2007-05-23 22:44:12 +00:00
|
|
|
{
|
2009-09-07 08:59:53 +00:00
|
|
|
if (pMediaSample && m_callback) {
|
|
|
|
BYTE *
|
|
|
|
pBuffer = NULL;
|
|
|
|
LONGLONG
|
|
|
|
lStart = 0, lStop = 0;
|
|
|
|
pMediaSample->GetPointer (&pBuffer);
|
|
|
|
long
|
|
|
|
size = pMediaSample->GetActualDataLength ();
|
|
|
|
pMediaSample->GetTime (&lStart, &lStop);
|
|
|
|
lStart *= 100;
|
|
|
|
lStop *= 100;
|
|
|
|
m_callback (pBuffer, size, m_data, lStart, lStop);
|
2007-05-23 22:44:12 +00:00
|
|
|
}
|
2009-09-07 08:59:53 +00:00
|
|
|
|
2007-05-23 22:44:12 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|