mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
dshowsrcwrapper: indent
This commit is contained in:
parent
9844d73b37
commit
0518509f0a
8 changed files with 367 additions and 296 deletions
|
@ -62,7 +62,8 @@ gst_dshow_new_pin_mediatype (IPin *pin, gint id, IAMStreamConfig * streamcaps)
|
|||
{
|
||||
GstCapturePinMediaType *pin_mediatype = g_new0 (GstCapturePinMediaType, 1);
|
||||
|
||||
HRESULT hres = streamcaps->GetStreamCaps(id, &pin_mediatype->mediatype, (BYTE *) & pin_mediatype->vscc);
|
||||
HRESULT hres = streamcaps->GetStreamCaps (id, &pin_mediatype->mediatype,
|
||||
(BYTE *) & pin_mediatype->vscc);
|
||||
if (FAILED (hres) || !pin_mediatype->mediatype) {
|
||||
gst_dshow_free_pin_mediatype (pin_mediatype);
|
||||
return NULL;
|
||||
|
@ -102,7 +103,8 @@ gst_dshow_check_mediatype (AM_MEDIA_TYPE *media_type, const GUID sub_type,
|
|||
}
|
||||
|
||||
gboolean
|
||||
gst_dshow_get_pin_from_filter (IBaseFilter *filter, PIN_DIRECTION pindir, IPin **pin)
|
||||
gst_dshow_get_pin_from_filter (IBaseFilter * filter, PIN_DIRECTION pindir,
|
||||
IPin ** pin)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
IEnumPins *enumpins = NULL;
|
||||
|
@ -115,8 +117,7 @@ gst_dshow_get_pin_from_filter (IBaseFilter *filter, PIN_DIRECTION pindir, IPin *
|
|||
return ret;
|
||||
}
|
||||
|
||||
while (enumpins->Next (1, &pintmp, NULL) == S_OK)
|
||||
{
|
||||
while (enumpins->Next (1, &pintmp, NULL) == S_OK) {
|
||||
PIN_DIRECTION pindirtmp;
|
||||
hres = pintmp->QueryDirection (&pindirtmp);
|
||||
if (hres == S_OK && pindir == pindirtmp) {
|
||||
|
@ -131,7 +132,8 @@ gst_dshow_get_pin_from_filter (IBaseFilter *filter, PIN_DIRECTION pindir, IPin *
|
|||
return ret;
|
||||
}
|
||||
|
||||
gboolean gst_dshow_find_filter(CLSID input_majortype, CLSID input_subtype,
|
||||
gboolean
|
||||
gst_dshow_find_filter (CLSID input_majortype, CLSID input_subtype,
|
||||
CLSID output_majortype, CLSID output_subtype,
|
||||
gchar * prefered_filter_name, IBaseFilter ** filter)
|
||||
{
|
||||
|
@ -166,9 +168,10 @@ gboolean gst_dshow_find_filter(CLSID input_majortype, CLSID input_subtype,
|
|||
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);
|
||||
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;
|
||||
|
||||
|
@ -180,14 +183,17 @@ gboolean gst_dshow_find_filter(CLSID input_majortype, CLSID input_subtype,
|
|||
IPropertyBag *property_bag = NULL;
|
||||
gchar *friendly_name = NULL;
|
||||
|
||||
hres = moniker->BindToStorage (NULL, NULL, IID_IPropertyBag, (void **)&property_bag);
|
||||
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,
|
||||
friendly_name =
|
||||
g_utf16_to_utf8 ((const gunichar2 *) varFriendlyName.bstrVal,
|
||||
wcslen (varFriendlyName.bstrVal), NULL, NULL, NULL);
|
||||
if (friendly_name)
|
||||
_strupr (friendly_name);
|
||||
|
@ -196,7 +202,9 @@ gboolean gst_dshow_find_filter(CLSID input_majortype, CLSID input_subtype,
|
|||
property_bag->Release ();
|
||||
}
|
||||
|
||||
hres = moniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&filter_temp);
|
||||
hres =
|
||||
moniker->BindToObject (NULL, NULL, IID_IBaseFilter,
|
||||
(void **) &filter_temp);
|
||||
if (SUCCEEDED (hres) && filter_temp) {
|
||||
ret = TRUE;
|
||||
if (filter) {
|
||||
|
@ -238,7 +246,8 @@ clean:
|
|||
|
||||
|
||||
gchar *
|
||||
gst_dshow_getdevice_from_devicename (const GUID *device_category, gchar **device_name)
|
||||
gst_dshow_getdevice_from_devicename (const GUID * device_category,
|
||||
gchar ** device_name)
|
||||
{
|
||||
gchar *ret = NULL;
|
||||
ICreateDevEnum *devices_enum = NULL;
|
||||
|
@ -267,14 +276,17 @@ gst_dshow_getdevice_from_devicename (const GUID *device_category, gchar **devic
|
|||
while (hres = enum_moniker->Next (1, &moniker, &fetched), hres == S_OK
|
||||
&& !bfound) {
|
||||
IPropertyBag *property_bag = NULL;
|
||||
hres = moniker->BindToStorage(NULL, NULL, IID_IPropertyBag, (void **)&property_bag);
|
||||
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) {
|
||||
gchar * friendly_name = g_utf16_to_utf8((const gunichar2*)varFriendlyName.bstrVal,
|
||||
gchar *friendly_name =
|
||||
g_utf16_to_utf8 ((const gunichar2 *) varFriendlyName.bstrVal,
|
||||
wcslen (varFriendlyName.bstrVal), NULL, NULL, NULL);
|
||||
|
||||
if (!*device_name) {
|
||||
|
@ -315,9 +327,9 @@ gst_dshow_show_propertypage (IBaseFilter *base_filter)
|
|||
{
|
||||
gboolean ret = FALSE;
|
||||
ISpecifyPropertyPages *pProp = NULL;
|
||||
HRESULT hres = base_filter->QueryInterface (IID_ISpecifyPropertyPages, (void **)&pProp);
|
||||
if (SUCCEEDED(hres))
|
||||
{
|
||||
HRESULT hres =
|
||||
base_filter->QueryInterface (IID_ISpecifyPropertyPages, (void **) &pProp);
|
||||
if (SUCCEEDED (hres)) {
|
||||
/* Get the filter's name and IUnknown pointer. */
|
||||
FILTER_INFO FilterInfo;
|
||||
CAUUID caGUID;
|
||||
|
@ -338,12 +350,14 @@ gst_dshow_show_propertypage (IBaseFilter *base_filter)
|
|||
return ret;
|
||||
}
|
||||
|
||||
GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar* name,
|
||||
GstCaps *
|
||||
gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar * name,
|
||||
GstCapturePinMediaType * pin_mediatype)
|
||||
{
|
||||
GstCaps *video_caps = NULL;
|
||||
GstStructure *video_structure = NULL;
|
||||
VIDEOINFOHEADER *video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat;
|
||||
VIDEOINFOHEADER *video_info =
|
||||
(VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat;
|
||||
|
||||
pin_mediatype->defaultWidth = video_info->bmiHeader.biWidth;
|
||||
pin_mediatype->defaultHeight = video_info->bmiHeader.biHeight;
|
||||
|
@ -392,12 +406,13 @@ GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar* nam
|
|||
/* value that the filter supports" as it said in the VIDEO_STREAM_CONFIG_CAPS dshwo doc */
|
||||
|
||||
gst_structure_set (video_structure,
|
||||
"width", GST_TYPE_INT_RANGE, pin_mediatype->vscc.MinOutputSize.cx, pin_mediatype->vscc.MaxOutputSize.cx,
|
||||
"height", GST_TYPE_INT_RANGE, pin_mediatype->vscc.MinOutputSize.cy, pin_mediatype->vscc.MaxOutputSize.cy,
|
||||
"framerate", GST_TYPE_FRACTION_RANGE,
|
||||
"width", GST_TYPE_INT_RANGE, pin_mediatype->vscc.MinOutputSize.cx,
|
||||
pin_mediatype->vscc.MaxOutputSize.cx, "height", GST_TYPE_INT_RANGE,
|
||||
pin_mediatype->vscc.MinOutputSize.cy,
|
||||
pin_mediatype->vscc.MaxOutputSize.cy, "framerate",
|
||||
GST_TYPE_FRACTION_RANGE,
|
||||
(gint) (10000000 / pin_mediatype->vscc.MaxFrameInterval), 1,
|
||||
(gint) (10000000 / pin_mediatype->vscc.MinFrameInterval), 1,
|
||||
NULL);
|
||||
(gint) (10000000 / pin_mediatype->vscc.MinFrameInterval), 1, NULL);
|
||||
|
||||
return video_caps;
|
||||
}
|
||||
|
|
|
@ -54,16 +54,19 @@ void gst_dshow_free_pin_mediatype (gpointer pt);
|
|||
void gst_dshow_free_mediatype (AM_MEDIA_TYPE * pmt);
|
||||
|
||||
/* create a new capture media type that handles dshow video caps of a capture pin */
|
||||
GstCapturePinMediaType *gst_dshow_new_pin_mediatype (IPin *pin, gint id, IAMStreamConfig * streamcaps);
|
||||
GstCapturePinMediaType *gst_dshow_new_pin_mediatype (IPin * pin, gint id,
|
||||
IAMStreamConfig * streamcaps);
|
||||
|
||||
/* free the memory of all mediatypes of the input list if pin mediatype */
|
||||
void gst_dshow_free_pins_mediatypes (GList * mediatypes);
|
||||
|
||||
/* allow to know what kind of media type we have */
|
||||
gboolean gst_dshow_check_mediatype (AM_MEDIA_TYPE *media_type, const GUID sub_type, const GUID format_type);
|
||||
gboolean gst_dshow_check_mediatype (AM_MEDIA_TYPE * media_type,
|
||||
const GUID sub_type, const GUID format_type);
|
||||
|
||||
/* get a pin from directshow filter */
|
||||
gboolean gst_dshow_get_pin_from_filter (IBaseFilter *filter, PIN_DIRECTION pindir, IPin **pin);
|
||||
gboolean gst_dshow_get_pin_from_filter (IBaseFilter * filter,
|
||||
PIN_DIRECTION pindir, IPin ** pin);
|
||||
|
||||
/* find and return a filter according to the input and output types */
|
||||
gboolean gst_dshow_find_filter (CLSID input_majortype, CLSID input_subtype,
|
||||
|
@ -72,13 +75,14 @@ gboolean gst_dshow_find_filter(CLSID input_majortype, CLSID input_subtype,
|
|||
|
||||
/* get the dshow device path from device friendly name.
|
||||
If friendly name is not set, it will return the first available device */
|
||||
gchar *gst_dshow_getdevice_from_devicename (const GUID *device_category, gchar **device_name);
|
||||
gchar *gst_dshow_getdevice_from_devicename (const GUID * device_category,
|
||||
gchar ** device_name);
|
||||
|
||||
/* show the capture filter property page (generally used to setup the device). the page is modal*/
|
||||
gboolean gst_dshow_show_propertypage (IBaseFilter * base_filter);
|
||||
|
||||
/* transform a dshow video caps to a gstreamer video caps */
|
||||
GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar* name,
|
||||
GstCapturePinMediaType *pin_mediatype);
|
||||
GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format,
|
||||
const gchar * name, GstCapturePinMediaType * pin_mediatype);
|
||||
|
||||
#endif /* _GSTDSHOW_ */
|
|
@ -273,7 +273,9 @@ gst_dshowaudiosrc_get_device_name_values (GstDshowAudioSrc * src)
|
|||
hres = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
|
||||
IID_ICreateDevEnum, (LPVOID *) & devices_enum);
|
||||
if (hres != S_OK) {
|
||||
GST_ERROR ("Can't create an instance of the system device enumerator (error=0x%x)", hres);
|
||||
GST_ERROR
|
||||
("Can't create an instance of the system device enumerator (error=0x%x)",
|
||||
hres);
|
||||
array = NULL;
|
||||
goto clean;
|
||||
}
|
||||
|
@ -288,8 +290,7 @@ gst_dshowaudiosrc_get_device_name_values (GstDshowAudioSrc * src)
|
|||
|
||||
moniker_enum->Reset ();
|
||||
|
||||
while (hres = moniker_enum->Next(1, &moniker, &fetched),
|
||||
hres == S_OK) {
|
||||
while (hres = moniker_enum->Next (1, &moniker, &fetched), hres == S_OK) {
|
||||
IPropertyBag *property_bag = NULL;
|
||||
|
||||
hres = moniker->BindToStorage (NULL, NULL, IID_IPropertyBag,
|
||||
|
@ -416,7 +417,8 @@ gst_dshowaudiosrc_get_caps (GstBaseSrc * basesrc)
|
|||
if (!src->audio_cap_filter) {
|
||||
hres = CreateBindCtx (0, &lpbc);
|
||||
if (SUCCEEDED (hres)) {
|
||||
hres = MkParseDisplayName (lpbc, (LPCOLESTR) unidevice, &dwEaten, &audiom);
|
||||
hres =
|
||||
MkParseDisplayName (lpbc, (LPCOLESTR) unidevice, &dwEaten, &audiom);
|
||||
if (SUCCEEDED (hres)) {
|
||||
hres = audiom->BindToObject (lpbc, NULL, IID_IBaseFilter,
|
||||
(LPVOID *) & src->audio_cap_filter);
|
||||
|
@ -437,7 +439,8 @@ gst_dshowaudiosrc_get_caps (GstBaseSrc * basesrc)
|
|||
while (enumpins->Next (1, &capture_pin, NULL) == S_OK) {
|
||||
IKsPropertySet *pKs = NULL;
|
||||
|
||||
hres = capture_pin->QueryInterface(IID_IKsPropertySet, (LPVOID *) &pKs);
|
||||
hres =
|
||||
capture_pin->QueryInterface (IID_IKsPropertySet, (LPVOID *) & pKs);
|
||||
if (SUCCEEDED (hres) && pKs) {
|
||||
DWORD cbReturned;
|
||||
GUID pin_category;
|
||||
|
@ -453,7 +456,8 @@ gst_dshowaudiosrc_get_caps (GstBaseSrc * basesrc)
|
|||
&rpcstatus) == 0) {
|
||||
IAMStreamConfig *streamcaps = NULL;
|
||||
|
||||
if (SUCCEEDED (capture_pin->QueryInterface(IID_IAMStreamConfig, (LPVOID *) &streamcaps))) {
|
||||
if (SUCCEEDED (capture_pin->QueryInterface (IID_IAMStreamConfig,
|
||||
(LPVOID *) & streamcaps))) {
|
||||
src->caps =
|
||||
gst_dshowaudiosrc_getcaps_from_streamcaps (src, capture_pin,
|
||||
streamcaps);
|
||||
|
@ -505,7 +509,8 @@ gst_dshowaudiosrc_change_state (GstElement * element, GstStateChange transition)
|
|||
if (src->media_filter)
|
||||
hres = src->media_filter->Stop ();
|
||||
if (hres != S_OK) {
|
||||
GST_ERROR ("Can't STOP the directshow capture graph (error=0x%x)", hres);
|
||||
GST_ERROR ("Can't STOP the directshow capture graph (error=0x%x)",
|
||||
hres);
|
||||
return GST_STATE_CHANGE_FAILURE;
|
||||
}
|
||||
src->is_running = FALSE;
|
||||
|
@ -531,13 +536,19 @@ gst_dshowaudiosrc_open (GstAudioSrc * asrc)
|
|||
hres = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC,
|
||||
IID_IFilterGraph, (LPVOID *) & src->filter_graph);
|
||||
if (hres != S_OK || !src->filter_graph) {
|
||||
GST_ERROR ("Can't create an instance of the directshow graph manager (error=0x%x)", hres);
|
||||
GST_ERROR
|
||||
("Can't create an instance of the directshow graph manager (error=0x%x)",
|
||||
hres);
|
||||
goto error;
|
||||
}
|
||||
|
||||
hres = src->filter_graph->QueryInterface(IID_IMediaFilter, (LPVOID *) &src->media_filter);
|
||||
hres =
|
||||
src->filter_graph->QueryInterface (IID_IMediaFilter,
|
||||
(LPVOID *) & src->media_filter);
|
||||
if (hres != S_OK || !src->media_filter) {
|
||||
GST_ERROR ("Can't get IMediacontrol interface from the graph manager (error=0x%x)", hres);
|
||||
GST_ERROR
|
||||
("Can't get IMediacontrol interface from the graph manager (error=0x%x)",
|
||||
hres);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -546,7 +557,9 @@ gst_dshowaudiosrc_open (GstAudioSrc * asrc)
|
|||
|
||||
hres = src->filter_graph->AddFilter (src->audio_cap_filter, L"capture");
|
||||
if (hres != S_OK) {
|
||||
GST_ERROR ("Can't add the directshow capture filter to the graph (error=0x%x)", hres);
|
||||
GST_ERROR
|
||||
("Can't add the directshow capture filter to the graph (error=0x%x)",
|
||||
hres);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -621,7 +634,9 @@ gst_dshowaudiosrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
|
|||
input_pin->Release ();
|
||||
|
||||
if (hres != S_OK) {
|
||||
GST_ERROR ("Can't connect capture filter with fakesink filter (error=0x%x)", hres);
|
||||
GST_ERROR
|
||||
("Can't connect capture filter with fakesink filter (error=0x%x)",
|
||||
hres);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -779,7 +794,8 @@ gst_dshowaudiosrc_getcaps_from_streamcaps (GstDshowAudioSrc * src, IPin * pin,
|
|||
if (!caps)
|
||||
caps = gst_caps_new_empty ();
|
||||
|
||||
if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_PCM, FORMAT_WaveFormatEx)) {
|
||||
if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_PCM,
|
||||
FORMAT_WaveFormatEx)) {
|
||||
WAVEFORMATEX *wavformat =
|
||||
(WAVEFORMATEX *) pin_mediatype->mediatype->pbFormat;
|
||||
mediacaps =
|
||||
|
|
|
@ -35,7 +35,9 @@ STDMETHODIMP CDshowFakeSink::gst_set_media_type (AM_MEDIA_TYPE *pmt)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CDshowFakeSink::gst_set_buffer_callback (push_buffer_func push, gpointer data)
|
||||
STDMETHODIMP
|
||||
CDshowFakeSink::gst_set_buffer_callback (push_buffer_func push,
|
||||
gpointer data)
|
||||
{
|
||||
m_callback = push;
|
||||
m_data = data;
|
||||
|
@ -54,12 +56,14 @@ HRESULT CDshowFakeSink::CheckMediaType(const CMediaType *pmt)
|
|||
|
||||
HRESULT CDshowFakeSink::DoRenderSample (IMediaSample * pMediaSample)
|
||||
{
|
||||
if(pMediaSample && m_callback)
|
||||
{
|
||||
BYTE *pBuffer = NULL;
|
||||
LONGLONG lStart = 0, lStop = 0;
|
||||
if (pMediaSample && m_callback) {
|
||||
BYTE *
|
||||
pBuffer = NULL;
|
||||
LONGLONG
|
||||
lStart = 0, lStop = 0;
|
||||
pMediaSample->GetPointer (&pBuffer);
|
||||
long size = pMediaSample->GetActualDataLength();
|
||||
long
|
||||
size = pMediaSample->GetActualDataLength ();
|
||||
pMediaSample->GetTime (&lStart, &lStop);
|
||||
lStart *= 100;
|
||||
lStop *= 100;
|
||||
|
|
|
@ -26,15 +26,20 @@
|
|||
|
||||
//{6A780808-9725-4d0b-8695-A4DD8D210773}
|
||||
static const GUID CLSID_DshowFakeSink =
|
||||
{ 0x6a780808, 0x9725, 0x4d0b, { 0x86, 0x95, 0xa4, 0xdd, 0x8d, 0x21, 0x7, 0x73 } };
|
||||
{ 0x6a780808, 0x9725, 0x4d0b, {0x86, 0x95, 0xa4, 0xdd, 0x8d, 0x21, 0x7,
|
||||
0x73}
|
||||
};
|
||||
|
||||
typedef bool (*push_buffer_func) (byte *buffer, long size, gpointer src_object, UINT64 start, UINT64 stop);
|
||||
typedef bool (*push_buffer_func) (byte * buffer, long size, gpointer src_object,
|
||||
UINT64 start, UINT64 stop);
|
||||
|
||||
class CDshowFakeSink:public CBaseRenderer
|
||||
{
|
||||
public:
|
||||
CDshowFakeSink ();
|
||||
virtual ~CDshowFakeSink () {}
|
||||
virtual ~ CDshowFakeSink ()
|
||||
{
|
||||
}
|
||||
|
||||
virtual HRESULT CheckMediaType (const CMediaType * pmt);
|
||||
virtual HRESULT DoRenderSample (IMediaSample * pMediaSample);
|
||||
|
|
|
@ -45,17 +45,14 @@ const GUID MEDIASUBTYPE_I420
|
|||
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (
|
||||
GST_VIDEO_CAPS_BGR ";"
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR ";"
|
||||
GST_VIDEO_CAPS_YUV ("{ I420 }") ";"
|
||||
"video/x-dv,"
|
||||
"systemstream = (boolean) FALSE,"
|
||||
"width = (int) [ 1, MAX ],"
|
||||
"height = (int) [ 1, MAX ],"
|
||||
"framerate = (fraction) [ 0, MAX ],"
|
||||
"format = (fourcc) dvsd;"
|
||||
"video/x-dv,"
|
||||
"systemstream = (boolean) TRUE")
|
||||
"format = (fourcc) dvsd;" "video/x-dv," "systemstream = (boolean) TRUE")
|
||||
);
|
||||
|
||||
static void gst_dshowvideosrc_init_interfaces (GType type);
|
||||
|
@ -238,10 +235,14 @@ gst_dshowvideosrc_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
|
|||
if (res != -1) {
|
||||
GList *type_pin_mediatype = g_list_nth (src->pins_mediatypes, res);
|
||||
if (type_pin_mediatype) {
|
||||
GstCapturePinMediaType *pin_mediatype = (GstCapturePinMediaType *) type_pin_mediatype->data;
|
||||
gst_structure_fixate_field_nearest_int (structure, "width", pin_mediatype->defaultWidth);
|
||||
gst_structure_fixate_field_nearest_int (structure, "height", pin_mediatype->defaultHeight);
|
||||
gst_structure_fixate_field_nearest_fraction (structure, "framerate", pin_mediatype->defaultFPS, 1);
|
||||
GstCapturePinMediaType *pin_mediatype =
|
||||
(GstCapturePinMediaType *) type_pin_mediatype->data;
|
||||
gst_structure_fixate_field_nearest_int (structure, "width",
|
||||
pin_mediatype->defaultWidth);
|
||||
gst_structure_fixate_field_nearest_int (structure, "height",
|
||||
pin_mediatype->defaultHeight);
|
||||
gst_structure_fixate_field_nearest_fraction (structure, "framerate",
|
||||
pin_mediatype->defaultFPS, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -371,8 +372,7 @@ gst_dshowvideosrc_get_device_name_values (GstDshowVideoSrc * src)
|
|||
|
||||
moniker_enum->Reset ();
|
||||
|
||||
while (hres = moniker_enum->Next(1, &moniker, &fetched),
|
||||
hres == S_OK) {
|
||||
while (hres = moniker_enum->Next (1, &moniker, &fetched), hres == S_OK) {
|
||||
IPropertyBag *property_bag = NULL;
|
||||
|
||||
hres =
|
||||
|
@ -500,7 +500,8 @@ gst_dshowvideosrc_get_caps (GstBaseSrc * basesrc)
|
|||
if (!src->video_cap_filter) {
|
||||
hres = CreateBindCtx (0, &lpbc);
|
||||
if (SUCCEEDED (hres)) {
|
||||
hres = MkParseDisplayName (lpbc, (LPCOLESTR) unidevice, &dwEaten, &videom);
|
||||
hres =
|
||||
MkParseDisplayName (lpbc, (LPCOLESTR) unidevice, &dwEaten, &videom);
|
||||
if (SUCCEEDED (hres)) {
|
||||
hres = videom->BindToObject (lpbc, NULL, IID_IBaseFilter,
|
||||
(LPVOID *) & src->video_cap_filter);
|
||||
|
@ -524,7 +525,8 @@ gst_dshowvideosrc_get_caps (GstBaseSrc * basesrc)
|
|||
if (SUCCEEDED (hres)) {
|
||||
while (enumpins->Next (1, &capture_pin, NULL) == S_OK) {
|
||||
IKsPropertySet *pKs = NULL;
|
||||
hres = capture_pin->QueryInterface(IID_IKsPropertySet, (LPVOID *) &pKs);
|
||||
hres =
|
||||
capture_pin->QueryInterface (IID_IKsPropertySet, (LPVOID *) & pKs);
|
||||
if (SUCCEEDED (hres) && pKs) {
|
||||
DWORD cbReturned;
|
||||
GUID pin_category;
|
||||
|
@ -540,8 +542,8 @@ gst_dshowvideosrc_get_caps (GstBaseSrc * basesrc)
|
|||
&rpcstatus) == 0) {
|
||||
IAMStreamConfig *streamcaps = NULL;
|
||||
|
||||
if (SUCCEEDED (capture_pin->QueryInterface(
|
||||
IID_IAMStreamConfig, (LPVOID *) &streamcaps))) {
|
||||
if (SUCCEEDED (capture_pin->QueryInterface (IID_IAMStreamConfig,
|
||||
(LPVOID *) & streamcaps))) {
|
||||
GstCaps *caps =
|
||||
gst_dshowvideosrc_getcaps_from_streamcaps (src, capture_pin,
|
||||
streamcaps);
|
||||
|
@ -618,14 +620,18 @@ gst_dshowvideosrc_start (GstBaseSrc * bsrc)
|
|||
hres = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC,
|
||||
IID_IFilterGraph, (LPVOID *) & src->filter_graph);
|
||||
if (hres != S_OK || !src->filter_graph) {
|
||||
GST_ERROR ("Can't create an instance of the dshow graph manager (error=0x%x)", hres);
|
||||
GST_ERROR
|
||||
("Can't create an instance of the dshow graph manager (error=0x%x)",
|
||||
hres);
|
||||
goto error;
|
||||
}
|
||||
|
||||
hres = src->filter_graph->QueryInterface (IID_IMediaFilter,
|
||||
(LPVOID *) & src->media_filter);
|
||||
if (hres != S_OK || !src->media_filter) {
|
||||
GST_ERROR ("Can't get IMediacontrol interface from the graph manager (error=0x%x)", hres);
|
||||
GST_ERROR
|
||||
("Can't get IMediacontrol interface from the graph manager (error=0x%x)",
|
||||
hres);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -634,7 +640,8 @@ gst_dshowvideosrc_start (GstBaseSrc * bsrc)
|
|||
|
||||
hres = src->filter_graph->AddFilter (src->video_cap_filter, L"capture");
|
||||
if (hres != S_OK) {
|
||||
GST_ERROR ("Can't add video capture filter to the graph (error=0x%x)", hres);
|
||||
GST_ERROR ("Can't add video capture filter to the graph (error=0x%x)",
|
||||
hres);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -691,7 +698,8 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
|
|||
GList *type_pin_mediatype = g_list_nth (src->pins_mediatypes, res);
|
||||
|
||||
if (type_pin_mediatype) {
|
||||
GstCapturePinMediaType *pin_mediatype = (GstCapturePinMediaType *) type_pin_mediatype->data;
|
||||
GstCapturePinMediaType *pin_mediatype =
|
||||
(GstCapturePinMediaType *) type_pin_mediatype->data;
|
||||
gchar *caps_string = NULL;
|
||||
gchar *src_caps_string = NULL;
|
||||
|
||||
|
@ -708,16 +716,21 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
|
|||
/* check if the desired video size is valid about granularity */
|
||||
/* This check will be removed when GST_TYPE_INT_RANGE_STEP exits */
|
||||
/* See remarks in gst_dshowvideosrc_getcaps_from_streamcaps function */
|
||||
if (pin_mediatype->granularityWidth != 0 && width % pin_mediatype->granularityWidth != 0)
|
||||
g_warning ("your desired video size is not valid : %d mod %d !=0\n", width, pin_mediatype->granularityWidth) ;
|
||||
if (pin_mediatype->granularityHeight !=0 && height % pin_mediatype->granularityHeight != 0)
|
||||
g_warning ("your desired video size is not valid : %d mod %d !=0\n", height, pin_mediatype->granularityHeight) ;
|
||||
if (pin_mediatype->granularityWidth != 0
|
||||
&& width % pin_mediatype->granularityWidth != 0)
|
||||
g_warning ("your desired video size is not valid : %d mod %d !=0\n",
|
||||
width, pin_mediatype->granularityWidth);
|
||||
if (pin_mediatype->granularityHeight != 0
|
||||
&& height % pin_mediatype->granularityHeight != 0)
|
||||
g_warning ("your desired video size is not valid : %d mod %d !=0\n",
|
||||
height, pin_mediatype->granularityHeight);
|
||||
|
||||
/* update mediatype */
|
||||
video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat;
|
||||
video_info->bmiHeader.biWidth = width;
|
||||
video_info->bmiHeader.biHeight = height;
|
||||
video_info->AvgTimePerFrame = (LONGLONG) (10000000 * denominator / (double)numerator);
|
||||
video_info->AvgTimePerFrame =
|
||||
(LONGLONG) (10000000 * denominator / (double) numerator);
|
||||
video_info->bmiHeader.biSizeImage = DIBSIZE (video_info->bmiHeader);
|
||||
pin_mediatype->mediatype->lSampleSize = DIBSIZE (video_info->bmiHeader);
|
||||
|
||||
|
@ -737,7 +750,9 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
|
|||
input_pin->Release ();
|
||||
|
||||
if (hres != S_OK) {
|
||||
GST_ERROR ("Can't connect capture filter with fakesink filter (error=0x%x)", hres);
|
||||
GST_ERROR
|
||||
("Can't connect capture filter with fakesink filter (error=0x%x)",
|
||||
hres);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -888,20 +903,30 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
|
|||
|
||||
GstCaps *mediacaps = NULL;
|
||||
|
||||
if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_I420, FORMAT_VideoInfo)) {
|
||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_I420, NULL, pin_mediatype);
|
||||
|
||||
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_RGB24, FORMAT_VideoInfo)) {
|
||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_BGR, NULL, pin_mediatype);
|
||||
|
||||
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_dvsd, FORMAT_VideoInfo)) {
|
||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN, "video/x-dv, systemstream=FALSE",
|
||||
if (gst_dshow_check_mediatype (pin_mediatype->mediatype,
|
||||
MEDIASUBTYPE_I420, FORMAT_VideoInfo)) {
|
||||
mediacaps =
|
||||
gst_dshow_new_video_caps (GST_VIDEO_FORMAT_I420, NULL,
|
||||
pin_mediatype);
|
||||
|
||||
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_dvsd, FORMAT_DvInfo)) {
|
||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN, "video/x-dv, systemstream=TRUE",
|
||||
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype,
|
||||
MEDIASUBTYPE_RGB24, FORMAT_VideoInfo)) {
|
||||
mediacaps =
|
||||
gst_dshow_new_video_caps (GST_VIDEO_FORMAT_BGR, NULL,
|
||||
pin_mediatype);
|
||||
|
||||
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype,
|
||||
MEDIASUBTYPE_dvsd, FORMAT_VideoInfo)) {
|
||||
mediacaps =
|
||||
gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN,
|
||||
"video/x-dv, systemstream=FALSE", pin_mediatype);
|
||||
|
||||
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype,
|
||||
MEDIASUBTYPE_dvsd, FORMAT_DvInfo)) {
|
||||
mediacaps =
|
||||
gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN,
|
||||
"video/x-dv, systemstream=TRUE", pin_mediatype);
|
||||
|
||||
pin_mediatype->granularityWidth = 0;
|
||||
pin_mediatype->granularityHeight = 0;
|
||||
}
|
||||
|
@ -964,8 +989,9 @@ gst_dshowvideosrc_push_buffer (byte * buffer, long size, gpointer src_object,
|
|||
memcpy (GST_BUFFER_DATA (buf), buffer, size);
|
||||
}
|
||||
|
||||
GST_DEBUG ("push_buffer => pts %" GST_TIME_FORMAT "duration %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_TIME_ARGS (stop - start));
|
||||
GST_DEBUG ("push_buffer => pts %" GST_TIME_FORMAT "duration %"
|
||||
GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
||||
GST_TIME_ARGS (stop - start));
|
||||
|
||||
/* the negotiate() method already set caps on the source pad */
|
||||
gst_buffer_set_caps (buf, GST_PAD_CAPS (GST_BASE_SRC_PAD (src)));
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
#include "gstdshowfakesink.h"
|
||||
|
||||
// 30323449-0000-0010-8000-00AA00389B71 MEDIASUBTYPE_I420
|
||||
DEFINE_GUID(MEDIASUBTYPE_I420, 0x30323449, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
|
||||
DEFINE_GUID (MEDIASUBTYPE_I420, 0x30323449, 0x0000, 0x0010, 0x80, 0x00, 0x00,
|
||||
0xAA, 0x00, 0x38, 0x9B, 0x71);
|
||||
|
||||
G_BEGIN_DECLS
|
||||
#define GST_TYPE_DSHOWVIDEOSRC (gst_dshowvideosrc_get_type())
|
||||
|
|
Loading…
Reference in a new issue