dshowsrcwrapper: use of default debug category and better dshow errors readability

This commit is contained in:
Julien Isorce 2009-08-24 14:37:28 +02:00
parent 222cc7ef43
commit 2004db26d7
2 changed files with 29 additions and 60 deletions

View file

@ -273,9 +273,7 @@ gst_dshowaudiosrc_get_device_name_values (GstDshowAudioSrc * src)
hres = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, hres = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum, (LPVOID *) &devices_enum); IID_ICreateDevEnum, (LPVOID *) &devices_enum);
if (hres != S_OK) { if (hres != S_OK) {
GST_CAT_ERROR (dshowaudiosrc_debug, GST_ERROR ("Can't create an instance of the system device enumerator (error=0x%x)", hres);
"Can't create an instance of the system device enumerator (error=%d)",
hres);
array = NULL; array = NULL;
goto clean; goto clean;
} }
@ -283,8 +281,7 @@ gst_dshowaudiosrc_get_device_name_values (GstDshowAudioSrc * src)
hres = devices_enum->CreateClassEnumerator(CLSID_AudioInputDeviceCategory, hres = devices_enum->CreateClassEnumerator(CLSID_AudioInputDeviceCategory,
&moniker_enum, 0); &moniker_enum, 0);
if (hres != S_OK || !moniker_enum) { if (hres != S_OK || !moniker_enum) {
GST_CAT_ERROR (dshowaudiosrc_debug, GST_ERROR ("Can't get enumeration of audio devices (error=0x%x)", hres);
"Can't get enumeration of audio devices (error=%d)", hres);
array = NULL; array = NULL;
goto clean; goto clean;
} }
@ -410,7 +407,7 @@ gst_dshowaudiosrc_get_caps (GstBaseSrc * basesrc)
gst_dshow_getdevice_from_devicename (&CLSID_AudioInputDeviceCategory, gst_dshow_getdevice_from_devicename (&CLSID_AudioInputDeviceCategory,
&src->device_name); &src->device_name);
if (!src->device) { if (!src->device) {
GST_CAT_ERROR (dshowaudiosrc_debug, "No audio device found."); GST_ERROR ("No audio device found.");
return NULL; return NULL;
} }
unidevice = unidevice =
@ -497,8 +494,7 @@ gst_dshowaudiosrc_change_state (GstElement * element, GstStateChange transition)
if (src->media_filter) if (src->media_filter)
hres = src->media_filter->Run(0); hres = src->media_filter->Run(0);
if (hres != S_OK) { if (hres != S_OK) {
GST_CAT_ERROR (dshowaudiosrc_debug, GST_ERROR ("Can't RUN the directshow capture graph (error=0x%x)", hres);
"Can't RUN the directshow capture graph (error=%d)", hres);
src->is_running = FALSE; src->is_running = FALSE;
return GST_STATE_CHANGE_FAILURE; return GST_STATE_CHANGE_FAILURE;
} else { } else {
@ -509,8 +505,7 @@ gst_dshowaudiosrc_change_state (GstElement * element, GstStateChange transition)
if (src->media_filter) if (src->media_filter)
hres = src->media_filter->Stop(); hres = src->media_filter->Stop();
if (hres != S_OK) { if (hres != S_OK) {
GST_CAT_ERROR (dshowaudiosrc_debug, GST_ERROR ("Can't STOP the directshow capture graph (error=0x%x)", hres);
"Can't STOP the directshow capture graph (error=%d)", hres);
return GST_STATE_CHANGE_FAILURE; return GST_STATE_CHANGE_FAILURE;
} }
src->is_running = FALSE; src->is_running = FALSE;
@ -536,17 +531,13 @@ gst_dshowaudiosrc_open (GstAudioSrc * asrc)
hres = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC, hres = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IFilterGraph, (LPVOID *) & src->filter_graph); IID_IFilterGraph, (LPVOID *) & src->filter_graph);
if (hres != S_OK || !src->filter_graph) { if (hres != S_OK || !src->filter_graph) {
GST_CAT_ERROR (dshowaudiosrc_debug, GST_ERROR ("Can't create an instance of the directshow graph manager (error=0x%x)", hres);
"Can't create an instance of the directshow graph manager (error=%d)",
hres);
goto error; 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) { if (hres != S_OK || !src->media_filter) {
GST_CAT_ERROR (dshowaudiosrc_debug, GST_ERROR ("Can't get IMediacontrol interface from the graph manager (error=0x%x)", hres);
"Can't get IMediacontrol interface from the graph manager (error=%d)",
hres);
goto error; goto error;
} }
@ -555,16 +546,13 @@ gst_dshowaudiosrc_open (GstAudioSrc * asrc)
hres = src->filter_graph->AddFilter(src->audio_cap_filter, L"capture"); hres = src->filter_graph->AddFilter(src->audio_cap_filter, L"capture");
if (hres != S_OK) { if (hres != S_OK) {
GST_CAT_ERROR (dshowaudiosrc_debug, GST_ERROR ("Can't add the directshow capture filter to the graph (error=0x%x)", hres);
"Can't add the directshow capture filter to the graph (error=%d)",
hres);
goto error; goto error;
} }
hres = src->filter_graph->AddFilter(src->dshow_fakesink, L"fakesink"); hres = src->filter_graph->AddFilter(src->dshow_fakesink, L"fakesink");
if (hres != S_OK) { if (hres != S_OK) {
GST_CAT_ERROR (dshowaudiosrc_debug, GST_ERROR ("Can't add our fakesink filter to the graph (error=0x%x)", hres);
"Can't add our fakesink filter to the graph (error=%d)", hres);
goto error; goto error;
} }
@ -624,8 +612,7 @@ gst_dshowaudiosrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
gst_dshow_get_pin_from_filter (src->dshow_fakesink, PINDIR_INPUT, gst_dshow_get_pin_from_filter (src->dshow_fakesink, PINDIR_INPUT,
&input_pin); &input_pin);
if (!input_pin) { if (!input_pin) {
GST_CAT_ERROR (dshowaudiosrc_debug, GST_ERROR ("Can't get input pin from our directshow fakesink filter");
"Can't get input pin from our directshow fakesink filter");
goto error; goto error;
} }
@ -634,9 +621,7 @@ gst_dshowaudiosrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
input_pin->Release(); input_pin->Release();
if (hres != S_OK) { if (hres != S_OK) {
GST_CAT_ERROR (dshowaudiosrc_debug, GST_ERROR ("Can't connect capture filter with fakesink filter (error=0x%x)", hres);
"Can't connect capture filter with fakesink filter (error=%d)",
hres);
goto error; goto error;
} }

View file

@ -362,9 +362,7 @@ gst_dshowvideosrc_get_device_name_values (GstDshowVideoSrc * src)
hres = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, hres = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum, (LPVOID *) &devices_enum); IID_ICreateDevEnum, (LPVOID *) &devices_enum);
if (hres != S_OK) { if (hres != S_OK) {
GST_CAT_ERROR (dshowvideosrc_debug, GST_ERROR ("Can't create system device enumerator (error=0x%x)", hres);
"Can't create an instance of the system device enumerator (error=%d)",
hres);
array = NULL; array = NULL;
goto clean; goto clean;
} }
@ -372,8 +370,7 @@ gst_dshowvideosrc_get_device_name_values (GstDshowVideoSrc * src)
hres = devices_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, hres = devices_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
&moniker_enum, 0); &moniker_enum, 0);
if (hres != S_OK || !moniker_enum) { if (hres != S_OK || !moniker_enum) {
GST_CAT_ERROR (dshowvideosrc_debug, GST_ERROR ("Can't get enumeration of video devices (error=0x%x)", hres);
"Can't get enumeration of video devices (error=%d)", hres);
array = NULL; array = NULL;
goto clean; goto clean;
} }
@ -500,7 +497,7 @@ gst_dshowvideosrc_get_caps (GstBaseSrc * basesrc)
gst_dshow_getdevice_from_devicename (&CLSID_VideoInputDeviceCategory, gst_dshow_getdevice_from_devicename (&CLSID_VideoInputDeviceCategory,
&src->device_name); &src->device_name);
if (!src->device) { if (!src->device) {
GST_CAT_ERROR (dshowvideosrc_debug, "No video device found."); GST_ERROR ("No video device found.");
return NULL; return NULL;
} }
unidevice = unidevice =
@ -576,8 +573,7 @@ gst_dshowvideosrc_get_caps (GstBaseSrc * basesrc)
} }
if (src->caps) { if (src->caps) {
GST_CAT_LOG (dshowvideosrc_debug, "getcaps returned %s", GST_LOG ("getcaps returned %s", gst_caps_to_string (src->caps));
gst_caps_to_string (src->caps));
return gst_caps_ref (src->caps); return gst_caps_ref (src->caps);
} }
@ -599,8 +595,7 @@ gst_dshowvideosrc_change_state (GstElement * element, GstStateChange transition)
if (src->media_filter) if (src->media_filter)
hres = src->media_filter->Run(0); hres = src->media_filter->Run(0);
if (hres != S_OK) { if (hres != S_OK) {
GST_CAT_ERROR (dshowvideosrc_debug, GST_ERROR ("Can't RUN the directshow capture graph (error=0x%x)", hres);
"Can't RUN the directshow capture graph (error=%d)", hres);
return GST_STATE_CHANGE_FAILURE; return GST_STATE_CHANGE_FAILURE;
} }
break; break;
@ -608,8 +603,7 @@ gst_dshowvideosrc_change_state (GstElement * element, GstStateChange transition)
if (src->media_filter) if (src->media_filter)
hres = src->media_filter->Stop(); hres = src->media_filter->Stop();
if (hres != S_OK) { if (hres != S_OK) {
GST_CAT_ERROR (dshowvideosrc_debug, GST_ERROR ("Can't STOP the directshow capture graph (error=%d)", hres);
"Can't STOP the directshow capture graph (error=%d)", hres);
return GST_STATE_CHANGE_FAILURE; return GST_STATE_CHANGE_FAILURE;
} }
break; break;
@ -631,17 +625,14 @@ gst_dshowvideosrc_start (GstBaseSrc * bsrc)
hres = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC, hres = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IFilterGraph, (LPVOID *) & src->filter_graph); IID_IFilterGraph, (LPVOID *) & src->filter_graph);
if (hres != S_OK || !src->filter_graph) { if (hres != S_OK || !src->filter_graph) {
GST_CAT_ERROR (dshowvideosrc_debug, GST_ERROR ("Can't create an instance of the dshow graph manager (error=0x%x)", hres);
"Can't create an instance of the dshow graph manager (error=%d)", hres);
goto error; goto error;
} }
hres = src->filter_graph->QueryInterface(IID_IMediaFilter, hres = src->filter_graph->QueryInterface(IID_IMediaFilter,
(LPVOID *) &src->media_filter); (LPVOID *) &src->media_filter);
if (hres != S_OK || !src->media_filter) { if (hres != S_OK || !src->media_filter) {
GST_CAT_ERROR (dshowvideosrc_debug, GST_ERROR ("Can't get IMediacontrol interface from the graph manager (error=0x%x)", hres);
"Can't get IMediacontrol interface from the graph manager (error=%d)",
hres);
goto error; goto error;
} }
@ -650,15 +641,13 @@ gst_dshowvideosrc_start (GstBaseSrc * bsrc)
hres = src->filter_graph->AddFilter(src->video_cap_filter, L"capture"); hres = src->filter_graph->AddFilter(src->video_cap_filter, L"capture");
if (hres != S_OK) { if (hres != S_OK) {
GST_CAT_ERROR (dshowvideosrc_debug, GST_ERROR ("Can't add video capture filter to the graph (error=0x%x)", hres);
"Can't add video capture filter to the graph (error=%d)", hres);
goto error; goto error;
} }
hres = src->filter_graph->AddFilter(src->dshow_fakesink, L"sink"); hres = src->filter_graph->AddFilter(src->dshow_fakesink, L"sink");
if (hres != S_OK) { if (hres != S_OK) {
GST_CAT_ERROR (dshowvideosrc_debug, GST_ERROR ("Can't add our fakesink filter to the graph (error=0x%x)", hres);
"Can't add our fakesink filter to the graph (error=%d)", hres);
goto error; goto error;
} }
@ -738,7 +727,7 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
/* display all capabilities when using --gst-debug-level=3 */ /* display all capabilities when using --gst-debug-level=3 */
src_caps_string = gst_caps_to_string (src->caps); src_caps_string = gst_caps_to_string (src->caps);
GST_CAT_LEVEL_LOG (dshowvideosrc_debug, GST_LEVEL_INFO, src, src_caps_string); GST_LOG (src_caps_string);
g_free (src_caps_string); g_free (src_caps_string);
pin_mediatype = (GstCapturePinMediaType *) type->data; pin_mediatype = (GstCapturePinMediaType *) type->data;
@ -758,8 +747,7 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
gst_dshow_get_pin_from_filter (src->dshow_fakesink, PINDIR_INPUT, gst_dshow_get_pin_from_filter (src->dshow_fakesink, PINDIR_INPUT,
&input_pin); &input_pin);
if (!input_pin) { if (!input_pin) {
GST_CAT_ERROR (dshowvideosrc_debug, GST_ERROR ("Can't get input pin from our dshow fakesink");
"Can't get input pin from our dshow fakesink");
goto error; goto error;
} }
@ -768,9 +756,7 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
input_pin->Release(); input_pin->Release();
if (hres != S_OK) { if (hres != S_OK) {
GST_CAT_ERROR (dshowvideosrc_debug, GST_ERROR ("Can't connect capture filter with fakesink filter (error=0x%x)", hres);
"Can't connect capture filter with fakesink filter (error=%d)",
hres);
goto error; goto error;
} }
@ -884,8 +870,7 @@ gst_dshowvideosrc_create (GstPushSrc * psrc, GstBuffer ** buf)
return GST_FLOW_WRONG_STATE; return GST_FLOW_WRONG_STATE;
} }
GST_CAT_DEBUG (dshowvideosrc_debug, GST_DEBUG ("dshowvideosrc_create => pts %" GST_TIME_FORMAT " duration %"
"dshowvideosrc_create => pts %" GST_TIME_FORMAT " duration %"
GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*buf)), GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*buf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (*buf))); GST_TIME_ARGS (GST_BUFFER_DURATION (*buf)));
@ -1115,8 +1100,7 @@ gst_dshowvideosrc_push_buffer (byte * buffer, long size, gpointer src_object,
memcpy (GST_BUFFER_DATA (buf), buffer, size); memcpy (GST_BUFFER_DATA (buf), buffer, size);
} }
GST_CAT_DEBUG (dshowvideosrc_debug, GST_DEBUG ("push_buffer => pts %" GST_TIME_FORMAT "duration %" GST_TIME_FORMAT,
"push_buffer => pts %" GST_TIME_FORMAT "duration %" GST_TIME_FORMAT,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_TIME_ARGS (stop - start)); GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_TIME_ARGS (stop - start));
/* the negotiate() method already set caps on the source pad */ /* the negotiate() method already set caps on the source pad */