#include "gstdshow.h"
#include "gstdshowfakesink.h"
-void
+void
gst_dshow_free_mediatype (AM_MEDIA_TYPE *pmt)
{
- if (pmt != NULL) {
+ if (pmt != NULL) {
if (pmt->cbFormat != 0) {
CoTaskMemFree((PVOID)pmt->pbFormat);
pmt->cbFormat = 0;
}
}
-void
+void
gst_dshow_free_pin_mediatype (gpointer pt)
{
GstCapturePinMediaType * pin_mediatype = (GstCapturePinMediaType *) pt;
}
}
-GstCapturePinMediaType *
+GstCapturePinMediaType *
gst_dshow_new_pin_mediatype (IPin *pin, gint id, IAMStreamConfig * streamcaps)
{
GstCapturePinMediaType *pin_mediatype = g_new0 (GstCapturePinMediaType, 1);
return pin_mediatype;
}
-void
+void
gst_dshow_free_pins_mediatypes (GList *pins_mediatypes)
{
guint i = 0;
}
gboolean
-gst_dshow_check_mediatype (AM_MEDIA_TYPE *media_type, const GUID sub_type,
+gst_dshow_check_mediatype (AM_MEDIA_TYPE *media_type, const GUID sub_type,
const GUID format_type)
{
RPC_STATUS rpcstatus;
-
+
g_return_val_if_fail (media_type != NULL, FALSE);
-
- return
+
+ return
UuidCompare (&media_type->subtype, (UUID *) &sub_type,
&rpcstatus) == 0 && rpcstatus == RPC_S_OK &&
UuidCompare (&media_type->formattype, (UUID *) &format_type,
&rpcstatus) == 0 && rpcstatus == RPC_S_OK;
}
-gboolean
+gboolean
gst_dshow_get_pin_from_filter (IBaseFilter *filter, PIN_DIRECTION pindir, IPin **pin)
{
gboolean ret = FALSE;
IEnumPins *enumpins = NULL;
IPin *pintmp = NULL;
- HRESULT hres;
+ HRESULT hres;
*pin = NULL;
hres = filter->EnumPins (&enumpins);
return ret;
}
-gboolean gst_dshow_find_filter(CLSID input_majortype, CLSID input_subtype,
- CLSID output_majortype, CLSID output_subtype,
+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;
_strupr (prefered_filter_upper);
}
- hres = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC,
+ 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,
+ 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;
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);
+ 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);
+ hres = moniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&filter_temp);
if(SUCCEEDED(hres) && filter_temp) {
ret = TRUE;
if (filter) {
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
+ /* 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;
HRESULT hres = S_FALSE;
ULONG fetched;
gboolean bfound = FALSE;
-
+
hres = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum, (void**)&devices_enum);
if(hres != S_OK) {
}
enum_moniker->Reset ();
-
+
while(hres = enum_moniker->Next (1, &moniker, &fetched),hres == S_OK
&& !bfound) {
IPropertyBag *property_bag = NULL;
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) {
WCHAR *wszDisplayName = NULL;
hres = moniker->GetDisplayName (NULL, NULL, &wszDisplayName);
if(hres == S_OK && wszDisplayName) {
- ret = g_utf16_to_utf8((const gunichar2*)wszDisplayName,
+ ret = g_utf16_to_utf8((const gunichar2*)wszDisplayName,
wcslen(wszDisplayName), NULL, NULL, NULL);
CoTaskMemFree (wszDisplayName);
}
return ret;
}
-gboolean
+gboolean
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))
+ if (SUCCEEDED(hres))
{
/* Get the filter's name and IUnknown pointer.*/
FILTER_INFO FilterInfo;
CAUUID caGUID;
IUnknown *pFilterUnk = NULL;
- hres = base_filter->QueryFilterInfo (&FilterInfo);
+ hres = base_filter->QueryFilterInfo (&FilterInfo);
base_filter->QueryInterface (IID_IUnknown, (void **)&pFilterUnk);
/* Show the page. */
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;
-
+
pin_mediatype->defaultWidth = video_info->bmiHeader.biWidth;
pin_mediatype->defaultHeight = video_info->bmiHeader.biHeight;
pin_mediatype->defaultFPS = (gint) (10000000 / video_info->AvgTimePerFrame);
/* other video format */
if (!video_caps){
if (g_strcasecmp (name, "video/x-dv, systemstream=FALSE") == 0) {
- video_caps = gst_caps_new_simple ("video/x-dv",
+ video_caps = gst_caps_new_simple ("video/x-dv",
"systemstream", G_TYPE_BOOLEAN, FALSE,
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('d', 'v', 's', 'd'),
NULL);
} else if (g_strcasecmp (name, "video/x-dv, systemstream=TRUE") == 0) {
- video_caps = gst_caps_new_simple ("video/x-dv",
+ video_caps = gst_caps_new_simple ("video/x-dv",
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
return video_caps;
}
/* For framerate we do not need a step (granularity) because */
/* "The IAMStreamConfig::SetFormat method will set the frame rate to the closest */
- /* value that the filter supports" as it said in the VIDEO_STREAM_CONFIG_CAPS dshwo doc */\r
- \r
- gst_structure_set (video_structure,\r
- "width", GST_TYPE_INT_RANGE, pin_mediatype->vscc.MinOutputSize.cx, pin_mediatype->vscc.MaxOutputSize.cx,\r
+ /* 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,
+ "framerate", GST_TYPE_FRACTION_RANGE,
(gint) (10000000 / pin_mediatype->vscc.MaxFrameInterval), 1,
(gint) (10000000 / pin_mediatype->vscc.MinFrameInterval), 1,
NULL);
/* GStreamer
* Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
*
- * gstdshowaudiosrc.c:
+ * gstdshowaudiosrc.c:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
g_object_class_install_property
(gobject_class, PROP_DEVICE_NAME,
g_param_spec_string ("device-name", "Device name",
- "Human-readable name of the sound device", NULL,
+ "Human-readable name of the sound device", NULL,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
GST_DEBUG_CATEGORY_INIT (dshowaudiosrc_debug, "dshowaudiosrc", 0,
goto clean;
}
- hres = devices_enum->CreateClassEnumerator(CLSID_AudioInputDeviceCategory,
+ hres = devices_enum->CreateClassEnumerator(CLSID_AudioInputDeviceCategory,
&moniker_enum, 0);
if (hres != S_OK || !moniker_enum) {
GST_ERROR ("Can't get enumeration of audio devices (error=0x%x)", hres);
hres == S_OK) {
IPropertyBag *property_bag = NULL;
- hres = moniker->BindToStorage(NULL, NULL, IID_IPropertyBag,
+ hres = moniker->BindToStorage(NULL, NULL, IID_IPropertyBag,
(LPVOID *) &property_bag);
if (SUCCEEDED (hres) && property_bag) {
VARIANT varFriendlyName;
g_utf16_to_utf8 ((const gunichar2 *) varFriendlyName.bstrVal,
wcslen (varFriendlyName.bstrVal), NULL, NULL, NULL);
- GValue value = { 0 };\r
+ GValue value = { 0 };
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, friendly_name);
g_value_array_append (array, &value);
}
break;
}
- case PROP_DEVICE_NAME:\r
- {\r
- if (src->device_name) {\r
- g_free (src->device_name);\r
- src->device_name = NULL;\r
- }\r
- if (g_value_get_string (value)) {\r
- src->device_name = g_strdup (g_value_get_string (value));\r
- }\r
- break;\r
+ case PROP_DEVICE_NAME:
+ {
+ if (src->device_name) {
+ g_free (src->device_name);
+ src->device_name = NULL;
+ }
+ if (g_value_get_string (value)) {
+ src->device_name = g_strdup (g_value_get_string (value));
+ }
+ break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
if (SUCCEEDED (hres)) {
hres = MkParseDisplayName (lpbc, (LPCOLESTR) unidevice, &dwEaten, &audiom);
if (SUCCEEDED (hres)) {
- hres = audiom->BindToObject(lpbc, NULL, IID_IBaseFilter,
+ hres = audiom->BindToObject(lpbc, NULL, IID_IBaseFilter,
(LPVOID *) &src->audio_cap_filter);
audiom->Release();
}
goto error;
}
- hres = src->filter_graph->ConnectDirect(pin_mediatype->capture_pin,
+ hres = src->filter_graph->ConnectDirect(pin_mediatype->capture_pin,
input_pin, NULL);
input_pin->Release();
* Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
* Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com>
*
- * gstdshowvideosrc.c:
+ * gstdshowvideosrc.c:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
g_object_class_install_property
(gobject_class, PROP_DEVICE,
g_param_spec_string ("device", "Device",
- "Directshow device path (@..classID/name)", NULL,
+ "Directshow device path (@..classID/name)", NULL,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class, PROP_DEVICE_NAME,
g_param_spec_string ("device-name", "Device name",
- "Human-readable name of the sound device", NULL,
+ "Human-readable name of the sound device", NULL,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
GST_DEBUG_CATEGORY_INIT (dshowvideosrc_debug, "dshowvideosrc", 0,
goto clean;
}
- hres = devices_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
+ hres = devices_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
&moniker_enum, 0);
if (hres != S_OK || !moniker_enum) {
GST_ERROR ("Can't get enumeration of video devices (error=0x%x)", hres);
g_utf16_to_utf8 ((const gunichar2 *) varFriendlyName.bstrVal,
wcslen (varFriendlyName.bstrVal), NULL, NULL, NULL);
- GValue value = { 0 };\r
+ GValue value = { 0 };
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, friendly_name);
g_value_array_append (array, &value);
if (SUCCEEDED (hres)) {
hres = MkParseDisplayName (lpbc, (LPCOLESTR) unidevice, &dwEaten, &videom);
if (SUCCEEDED (hres)) {
- hres = videom->BindToObject(lpbc, NULL, IID_IBaseFilter,
+ hres = videom->BindToObject(lpbc, NULL, IID_IBaseFilter,
(LPVOID *) &src->video_cap_filter);
videom->Release();
}
goto error;
}
- hres = src->filter_graph->QueryInterface(IID_IMediaFilter,
+ 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);
goto error;
}
- hres = src->filter_graph->ConnectDirect(pin_mediatype->capture_pin,
+ hres = src->filter_graph->ConnectDirect(pin_mediatype->capture_pin,
input_pin, pin_mediatype->mediatype);
input_pin->Release();
caps = gst_caps_new_empty ();
for (; i < icount; i++) {
-
- GstCapturePinMediaType *pin_mediatype =
+
+ GstCapturePinMediaType *pin_mediatype =
gst_dshow_new_pin_mediatype (pin, i, streamcaps);
if (pin_mediatype) {
-
+
GstCaps *mediacaps = NULL;
if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_I420, 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",
+ 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",
+ } 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;
GST_BUFFER_DURATION (buf) = stop - start;
if (src->is_rgb) {
- /* FOR RGB directshow decoder will return bottom-up BITMAP
+ /* FOR RGB directshow decoder will return bottom-up BITMAP
* There is probably a way to get top-bottom video frames from
* the decoder...
*/