sys/dshowdecwrapper/: Major rewrite of dshowdecwrapper. Converts code to

Original commit message from CVS:
* sys/dshowdecwrapper/Makefile.am:
* sys/dshowdecwrapper/gstdshowaudiodec.c:
* sys/dshowdecwrapper/gstdshowaudiodec.cpp:
* sys/dshowdecwrapper/gstdshowaudiodec.h:
* sys/dshowdecwrapper/gstdshowdecwrapper.c:
* sys/dshowdecwrapper/gstdshowdecwrapper.cpp:
* sys/dshowdecwrapper/gstdshowdecwrapper.h:
* sys/dshowdecwrapper/gstdshowfakesrc.cpp:
* sys/dshowdecwrapper/gstdshowfakesrc.h:
* sys/dshowdecwrapper/gstdshowutil.cpp:
* sys/dshowdecwrapper/gstdshowutil.h:
* sys/dshowdecwrapper/gstdshowvideodec.c:
* sys/dshowdecwrapper/gstdshowvideodec.cpp:
* sys/dshowdecwrapper/gstdshowvideodec.h:
Major rewrite of dshowdecwrapper. Converts code to
C++, moves to direct use of DirectShow base classes,
make a lot of code clearer, simplify, etc.
Fix decode of MP3 on Vista by working around an apparent
bug in the decoder.
This commit is contained in:
Michael Smith 2008-09-10 23:15:11 +00:00
parent 61dee51291
commit 007478f09c
11 changed files with 2862 additions and 16 deletions

View file

@ -1,3 +1,25 @@
2008-09-10 Michael Smith <msmith@songbirdnest.com>
* sys/dshowdecwrapper/Makefile.am:
* sys/dshowdecwrapper/gstdshowaudiodec.c:
* sys/dshowdecwrapper/gstdshowaudiodec.cpp:
* sys/dshowdecwrapper/gstdshowaudiodec.h:
* sys/dshowdecwrapper/gstdshowdecwrapper.c:
* sys/dshowdecwrapper/gstdshowdecwrapper.cpp:
* sys/dshowdecwrapper/gstdshowdecwrapper.h:
* sys/dshowdecwrapper/gstdshowfakesrc.cpp:
* sys/dshowdecwrapper/gstdshowfakesrc.h:
* sys/dshowdecwrapper/gstdshowutil.cpp:
* sys/dshowdecwrapper/gstdshowutil.h:
* sys/dshowdecwrapper/gstdshowvideodec.c:
* sys/dshowdecwrapper/gstdshowvideodec.cpp:
* sys/dshowdecwrapper/gstdshowvideodec.h:
Major rewrite of dshowdecwrapper. Converts code to
C++, moves to direct use of DirectShow base classes,
make a lot of code clearer, simplify, etc.
Fix decode of MP3 on Vista by working around an apparent
bug in the decoder.
2008-09-10 Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
* sys/winks/gstksclock.c (gst_ks_clock_worker_thread_func,

View file

@ -1,9 +1,14 @@
plugin_LTLIBRARIES = libgstdshowdecwrapper.la
libgstdshowdecwrapper_la_SOURCES = gstdshowaudiodec.c gstdshowdecwrapper.c gstdshowvideodec.c
libgstdshowdecwrapper_la_SOURCES = gstdshowaudiodec.cpp gstdshowdecwrapper.cpp \
gstdshowvideodec.cpp gstdshowutil.cpp \
gstdshowfakesrc.cpp
libgstdshowdecwrapper_la_CFLAGS = $(GST_CFLAGS) -I$(top_srcdir)/gst-libs/gst -DLIBGSTDSHOWDECWRAPPER_EXPORTS
libgstdshowdecwrapper_la_LIBADD = $(GST_LIBS) $(top_builddir)/gst-libs/gst/dshow/libgstdshow-@GST_MAJORMINOR@.la
libgstdshowdecwrapper_la_LIBADD = $(top_builddir)/gst-libs/gst/dshow/libgstdshow-@GST_MAJORMINOR@.la \
$(GST_BASE_LIBS) $(GST_LIBS)
libgstdshowdecwrapper_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS = gstdshowaudiodec.h gstdshowdecwrapper.h gstdshowvideodec.h
noinst_HEADERS = gstdshowaudiodec.h gstdshowvideodec.h gstdshowfakesrc.h \
gstdshowutil.h

File diff suppressed because it is too large Load diff

View file

@ -47,11 +47,21 @@
#ifndef __GST_DSHOWAUDIODEC_H__
#define __GST_DSHOWAUDIODEC_H__
#include <atlbase.h>
#include <gst/gst.h>
#include "gstdshowdecwrapper.h"
#include "gstdshowutil.h"
#include "gstdshowfakesrc.h"
G_BEGIN_DECLS
typedef struct {
gchar *element_name; /* The gst element factory name */
gchar *element_longname; /* Description string for element */
gint32 format; /* WAVEFORMATEX format */
gchar *sinkcaps; /* GStreamer caps of input format */
} AudioCodecEntry;
#define GST_TYPE_DSHOWAUDIODEC (gst_dshowaudiodec_get_type())
#define GST_DSHOWAUDIODEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DSHOWAUDIODEC,GstDshowAudioDec))
#define GST_DSHOWAUDIODEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DSHOWAUDIODEC,GstDshowAudioDecClass))
@ -61,6 +71,8 @@ G_BEGIN_DECLS
typedef struct _GstDshowAudioDec GstDshowAudioDec;
typedef struct _GstDshowAudioDecClass GstDshowAudioDecClass;
class AudioFakeSink;
struct _GstDshowAudioDec
{
GstElement element;
@ -72,14 +84,14 @@ struct _GstDshowAudioDec
GstFlowReturn last_ret;
/* filters interfaces*/
IBaseFilter *srcfilter;
IGstDshowInterface *gstdshowsrcfilter;
IBaseFilter *decfilter;
IBaseFilter *sinkfilter;
FakeSrc *fakesrc;
AudioFakeSink *fakesink;
CComPtr<IBaseFilter> decfilter;
/* graph manager interfaces */
IMediaFilter *mediafilter;
IFilterGraph *filtergraph;
CComPtr<IMediaFilter> mediafilter;
CComPtr<IFilterGraph> filtergraph;
/* true when dshow graph is setup */
gboolean setup;
@ -105,11 +117,39 @@ struct _GstDshowAudioDec
struct _GstDshowAudioDecClass
{
GstElementClass parent_class;
const CodecEntry *entry;
const AudioCodecEntry *entry;
};
gboolean dshow_adec_register (GstPlugin * plugin);
const GUID CLSID_AudioFakeSink =
{ 0x3867f537, 0x3e3d, 0x44da,
{ 0xbb, 0xf2, 0x02, 0x48, 0x7b, 0xb0, 0xbc, 0xc4} };
class AudioFakeSink : public CBaseRenderer
{
public:
AudioFakeSink(GstDshowAudioDec *dec) :
m_hres(S_OK),
CBaseRenderer(CLSID_AudioFakeSink, L"AudioFakeSink", NULL, &m_hres),
mDec(dec)
{};
virtual ~AudioFakeSink() {};
HRESULT DoRenderSample(IMediaSample *pMediaSample);
HRESULT CheckMediaType(const CMediaType *pmt);
HRESULT SetMediaType (AM_MEDIA_TYPE *pmt)
{
m_MediaType.Set (*pmt);
return S_OK;
}
protected:
HRESULT m_hres;
CMediaType m_MediaType;
GstDshowAudioDec *mDec;
};
G_END_DECLS
#endif /* __GST_DSHOWAUDIODEC_H__ */

View file

@ -0,0 +1,73 @@
/*
* GStreamer DirectShow codecs wrapper
* Copyright <2006, 2007, 2008> Fluendo <gstreamer@fluendo.com>
* Copyright <2006, 2007, 2008> Pioneers of the Inevitable <songbird@songbirdnest.com>
* Copyright <2007,2008> Sebastien Moutte <sebastien@moutte.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Alternatively, the contents of this file may be used under the
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
* which case the following provisions apply instead of the ones
* mentioned above:
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstdshowaudiodec.h"
#include "gstdshowvideodec.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!dshow_adec_register (plugin))
return FALSE;
if (!dshow_vdec_register (plugin))
return FALSE;
return TRUE;
}
extern "C" {
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"dshowdecwrapper",
"DirectShow decoder wrapper plugin",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
}

View file

@ -0,0 +1,153 @@
/* GStreamer
* Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
*
* gstdshowfakesrc.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 "gstdshowfakesrc.h"
const GUID CLSID_DecodeFakeSrc =
{ 0x039527db, 0x6b48, 0x45a7, { 0xab, 0xcf, 0x21, 0xab, 0xc5, 0x44, 0xbb, 0xb6} };
static CCritSec g_pCriticSec;
/* output pin*/
FakeOutputPin::FakeOutputPin (CBaseFilter *pFilter, CCritSec *sec):
CBaseOutputPin("FakeOutputPin", pFilter, sec, &m_hres, L"output")
{
}
FakeOutputPin::~FakeOutputPin()
{
}
HRESULT FakeOutputPin::GetMediaType(int iPosition,
CMediaType *pMediaType)
{
if(iPosition == 0) {
*pMediaType = m_MediaType;
return S_OK;
}
return VFW_S_NO_MORE_ITEMS;
}
HRESULT FakeOutputPin::CheckMediaType(const CMediaType *pmt)
{
if (m_MediaType == *pmt) {
return S_OK;
}
return S_FALSE;
}
HRESULT FakeOutputPin::DecideBufferSize (IMemAllocator *pAlloc,
ALLOCATOR_PROPERTIES *ppropInputRequest)
{
ALLOCATOR_PROPERTIES properties;
ppropInputRequest->cbBuffer = m_SampleSize;
ppropInputRequest->cBuffers = 1;
HRESULT hres = pAlloc->SetProperties(ppropInputRequest, &properties);
pAlloc->Commit();
return S_OK;
}
STDMETHODIMP FakeOutputPin::SetMediaType (AM_MEDIA_TYPE *pmt)
{
m_MediaType.Set (*pmt);
m_SampleSize = m_MediaType.GetSampleSize();
return S_OK;
}
STDMETHODIMP FakeOutputPin::PushBuffer(byte *buffer,
__int64 start, __int64 stop,
unsigned int size, bool discont)
{
IMediaSample *pSample = NULL;
if (start != -1) {
start /= 100;
stop /= 100;
}
HRESULT hres = GetDeliveryBuffer(&pSample, NULL, NULL, 0);
if (hres == S_OK && pSample)
{
BYTE *sample_buffer;
pSample->GetPointer(&sample_buffer);
if(sample_buffer)
{
memcpy (sample_buffer, buffer, size);
pSample->SetActualDataLength(size);
}
pSample->SetDiscontinuity(discont);
pSample->SetSyncPoint(TRUE);
pSample->SetPreroll(FALSE);
if (start != -1)
pSample->SetTime(&start, &stop);
hres = Deliver(pSample);
pSample->Release();
}
return S_OK;
}
STDMETHODIMP FakeOutputPin::Flush ()
{
DeliverBeginFlush();
DeliverEndFlush();
return S_OK;
}
STDMETHODIMP FakeOutputPin::SetSampleSize (unsigned int size)
{
m_SampleSize = size;
return S_OK;
}
/* filter */
FakeSrc::FakeSrc() :
CBaseFilter("DshowFakeSink", NULL, &g_pCriticSec, CLSID_DecodeFakeSrc)
{
m_pOutputPin = new FakeOutputPin((CSource *)this, m_pLock);
}
FakeSrc::~FakeSrc()
{
if (m_pOutputPin)
delete m_pOutputPin;
}
int FakeSrc::GetPinCount()
{
return 1;
}
CBasePin *FakeSrc::GetPin(int n)
{
return (CBasePin *)m_pOutputPin;
}
FakeOutputPin *FakeSrc::GetOutputPin()
{
return m_pOutputPin;
}

View file

@ -0,0 +1,65 @@
/* GStreamer
* Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
*
* gstdshowfakesrc.h:
*
* 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.
*/
#ifndef _DSHOWDECWRAPPER_FAKESRC_H_
#define _DSHOWDECWRAPPER_FAKESRC_H_
#include <gst/gst.h>
#include "gstdshowutil.h"
class FakeOutputPin : public CBaseOutputPin
{
protected:
/* members */
HRESULT m_hres;
CMediaType m_MediaType;
unsigned int m_SampleSize;
public:
/* methods */
FakeOutputPin (CBaseFilter *pFilter, CCritSec *sec);
~FakeOutputPin ();
virtual HRESULT CheckMediaType(const CMediaType *pmt);
HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
virtual HRESULT DecideBufferSize (IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);
STDMETHOD (SetMediaType) (AM_MEDIA_TYPE *pmt);
STDMETHOD (PushBuffer) (byte *buffer, __int64 start, __int64 stop, unsigned int size, bool discont);
STDMETHOD (Flush) ();
STDMETHOD (SetSampleSize) (unsigned int size);
};
class FakeSrc : public CBaseFilter
{
public:
/* members */
FakeOutputPin *m_pOutputPin;
/* methods */
FakeSrc ();
virtual ~FakeSrc ();
virtual int GetPinCount();
virtual CBasePin *GetPin(int n);
FakeOutputPin *GetOutputPin();
};
#endif // _DSHOWDECWRAPPER_FAKESRC_H_

View file

@ -0,0 +1,156 @@
/* GStreamer
* Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
*
* gstdshow.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 <atlbase.h>
#include "gstdshowutil.h"
#include "gstdshowfakesrc.h"
IPin *
gst_dshow_get_pin_from_filter (IBaseFilter *filter, PIN_DIRECTION pindir)
{
CComPtr<IEnumPins> enumpins;
CComPtr<IPin> pin;
HRESULT hres;
hres = filter->EnumPins (&enumpins);
if (FAILED(hres)) {
return NULL;
}
while (enumpins->Next (1, &pin, NULL) == S_OK)
{
PIN_DIRECTION pindirtmp;
hres = pin->QueryDirection (&pindirtmp);
if (hres == S_OK && pindir == pindirtmp) {
return pin;
}
pin.Release();
}
return NULL;
}
gboolean gst_dshow_find_filter(CLSID input_majortype, CLSID input_subtype,
CLSID output_majortype, CLSID output_subtype,
gchar * prefered_filter_name, IBaseFilter **filter)
{
gboolean ret = FALSE;
HRESULT hres;
GUID arrayInTypes[2];
GUID arrayOutTypes[2];
IFilterMapper2 *mapper = NULL;
IEnumMoniker *enum_moniker = NULL;
IMoniker *moniker = NULL;
ULONG fetched;
gchar *prefered_filter_upper = NULL;
gboolean exit = FALSE;
/* initialize output parameter */
if (filter)
*filter = NULL;
/* create a private copy of prefered filter substring in upper case */
if (prefered_filter_name) {
prefered_filter_upper = g_strdup (prefered_filter_name);
strupr (prefered_filter_upper);
}
hres = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC,
IID_IFilterMapper2, (void **) &mapper);
if (FAILED(hres))
goto clean;
memcpy(&arrayInTypes[0], &input_majortype, sizeof (CLSID));
memcpy(&arrayInTypes[1], &input_subtype, sizeof (CLSID));
memcpy(&arrayOutTypes[0], &output_majortype, sizeof (CLSID));
memcpy(&arrayOutTypes[1], &output_subtype, sizeof (CLSID));
hres = mapper->EnumMatchingFilters (&enum_moniker, 0, FALSE, MERIT_DO_NOT_USE+1,
TRUE, 1, arrayInTypes, NULL, NULL, FALSE,
TRUE, 1, arrayOutTypes, NULL, NULL);
if (FAILED(hres))
goto clean;
enum_moniker->Reset ();
while(hres = enum_moniker->Next (1, &moniker, &fetched),hres == S_OK
&& !exit) {
IBaseFilter *filter_temp = NULL;
IPropertyBag *property_bag = NULL;
gchar * friendly_name = NULL;
hres = moniker->BindToStorage (NULL, NULL, IID_IPropertyBag, (void **)&property_bag);
if(SUCCEEDED(hres) && property_bag) {
VARIANT varFriendlyName;
VariantInit (&varFriendlyName);
hres = property_bag->Read (L"FriendlyName", &varFriendlyName, NULL);
if(hres == S_OK && varFriendlyName.bstrVal) {
friendly_name = g_utf16_to_utf8((const gunichar2*)varFriendlyName.bstrVal,
wcslen(varFriendlyName.bstrVal), NULL, NULL, NULL);
if (friendly_name)
strupr (friendly_name);
SysFreeString (varFriendlyName.bstrVal);
}
property_bag->Release ();
}
hres = moniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&filter_temp);
if(SUCCEEDED(hres) && filter_temp) {
ret = TRUE;
if (filter) {
if (*filter)
(*filter)->Release ();
*filter = filter_temp;
(*filter)->AddRef ();
if (prefered_filter_upper && friendly_name &&
strstr(friendly_name, prefered_filter_upper))
exit = TRUE;
}
/* if we just want to know if the formats are supported OR
if we don't care about what will be the filter used
=> we can stop enumeration */
if (!filter || !prefered_filter_upper)
exit = TRUE;
filter_temp->Release ();
}
if (friendly_name)
g_free (friendly_name);
moniker->Release ();
}
clean:
if (prefered_filter_upper)
g_free (prefered_filter_upper);
if (enum_moniker)
enum_moniker->Release ();
if (mapper)
mapper->Release ();
return ret;
}

View file

@ -0,0 +1,42 @@
/* GStreamer
* Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
*
* gstdshow.h:
*
* 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.
*/
#ifndef _GST_DSHOW_UTIL_H_
#define _GST_DSHOW_UTIL_H_
#include <windows.h>
#include <objbase.h>
#include <dshow.h>
#include <Rpc.h>
#include <streams.h>
#include <strmif.h>
#include <glib.h>
/* get a pin from directshow filter */
IPin *gst_dshow_get_pin_from_filter (IBaseFilter *filter, PIN_DIRECTION pindir);
/* find and return a filter according to the input and output types */
gboolean gst_dshow_find_filter(CLSID input_majortype, CLSID input_subtype,
CLSID output_majortype, CLSID output_subtype,
gchar * prefered_filter_name, IBaseFilter **filter);
#endif /* _GST_DSHOW_UTIL_H_ */

File diff suppressed because it is too large Load diff

View file

@ -47,10 +47,24 @@
#define __GST_DSHOWVIDEODEC_H__
#include <gst/gst.h>
#include "gstdshowdecwrapper.h"
#include "gstdshowutil.h"
#include "gstdshowfakesrc.h"
G_BEGIN_DECLS
typedef struct {
gchar *element_name; /* The gst element factory name */
gchar *element_longname; /* Description string for element */
gchar *preferred_filter_substring; /* TODO: Remove this? */
gint32 format; /* ??? */
GUID input_majortype;
GUID input_subtype;
gchar *sinkcaps; /* GStreamer caps of input format */
GUID output_majortype;
GUID output_subtype;
gchar *srccaps;
} VideoCodecEntry;
#define GST_TYPE_DSHOWVIDEODEC (gst_dshowvideodec_get_type())
#define GST_DSHOWVIDEODEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DSHOWVIDEODEC,GstDshowVideoDec))
#define GST_DSHOWVIDEODEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DSHOWVIDEODEC,GstDshowVideoDecClass))
@ -60,6 +74,8 @@ G_BEGIN_DECLS
typedef struct _GstDshowVideoDec GstDshowVideoDec;
typedef struct _GstDshowVideoDecClass GstDshowVideoDecClass;
class VideoFakeSink;
struct _GstDshowVideoDec
{
GstElement element;
@ -77,10 +93,10 @@ struct _GstDshowVideoDec
GList *mediatypes;
/* filters interfaces */
IBaseFilter *srcfilter;
IGstDshowInterface *gstdshowsrcfilter;
FakeSrc *fakesrc;
VideoFakeSink *fakesink;
IBaseFilter *decfilter;
IBaseFilter *sinkfilter;
/* graph manager interfaces */
IMediaFilter *mediafilter;
@ -93,17 +109,47 @@ struct _GstDshowVideoDec
/* current segment */
GstSegment *segment;
gboolean setup;
gboolean comInitialized;
};
struct _GstDshowVideoDecClass
{
GstElementClass parent_class;
const CodecEntry *entry;
const VideoCodecEntry *entry;
};
gboolean dshow_vdec_register (GstPlugin * plugin);
const GUID CLSID_VideoFakeSink =
{ 0xff8f0c8e, 0x64f9, 0x4471,
{ 0x96, 0x0e, 0xd2, 0xd3, 0x18, 0x87, 0x78, 0x9a} };
class VideoFakeSink : public CBaseRenderer
{
public:
VideoFakeSink(GstDshowVideoDec *dec) :
m_hres(S_OK),
CBaseRenderer(CLSID_VideoFakeSink, L"VideoFakeSink", NULL, &m_hres),
mDec(dec)
{};
virtual ~VideoFakeSink() {};
HRESULT DoRenderSample(IMediaSample *pMediaSample);
HRESULT CheckMediaType(const CMediaType *pmt);
HRESULT SetMediaType (AM_MEDIA_TYPE *pmt)
{
m_MediaType.Set (*pmt);
return S_OK;
}
protected:
HRESULT m_hres;
CMediaType m_MediaType;
GstDshowVideoDec *mDec;
};
G_END_DECLS
#endif /* __GST_DSHOWVIDEODEC_H__ */