summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorDave Robillard <dave@drobilla.net>2009-07-22 14:36:14 -0400
committerDave Robillard <dave@drobilla.net>2009-07-22 14:36:14 -0400
commitadadf06b0a9e26005ba9363aa0049dc0b740c94d (patch)
treeb61e688d7ed775acff14763d0453102f80cc6c09 /sys
parent23ef5d4ac3487345c1c91db57c76554363e6c0f5 (diff)
parent5d9d4a7b518c42bda88c7f6c87ce7c3c01233562 (diff)
downloadgst-plugins-bad-adadf06b0a9e26005ba9363aa0049dc0b740c94d.tar.gz
gst-plugins-bad-adadf06b0a9e26005ba9363aa0049dc0b740c94d.tar.bz2
gst-plugins-bad-adadf06b0a9e26005ba9363aa0049dc0b740c94d.zip
Merge branch 'fdo' into lv2
Diffstat (limited to 'sys')
-rwxr-xr-x[-rw-r--r--]sys/dshowsrcwrapper/Makefile.am22
-rwxr-xr-xsys/dshowsrcwrapper/gstdshow.cpp346
-rwxr-xr-xsys/dshowsrcwrapper/gstdshow.h76
-rwxr-xr-x[-rw-r--r--]sys/dshowsrcwrapper/gstdshowaudiosrc.cpp (renamed from sys/dshowsrcwrapper/gstdshowaudiosrc.c)176
-rwxr-xr-x[-rw-r--r--]sys/dshowsrcwrapper/gstdshowaudiosrc.h3
-rwxr-xr-xsys/dshowsrcwrapper/gstdshowfakesink.cpp127
-rwxr-xr-xsys/dshowsrcwrapper/gstdshowfakesink.h50
-rwxr-xr-xsys/dshowsrcwrapper/gstdshowinterface.h163
-rwxr-xr-x[-rw-r--r--]sys/dshowsrcwrapper/gstdshowsrcwrapper.cpp (renamed from sys/dshowsrcwrapper/gstdshowsrcwrapper.c)11
-rw-r--r--sys/dshowsrcwrapper/gstdshowsrcwrapper.h34
-rwxr-xr-x[-rw-r--r--]sys/dshowsrcwrapper/gstdshowvideosrc.cpp (renamed from sys/dshowsrcwrapper/gstdshowvideosrc.c)185
-rwxr-xr-x[-rw-r--r--]sys/dshowsrcwrapper/gstdshowvideosrc.h4
-rwxr-xr-xsys/dshowsrcwrapper/libgstdshow.def8
-rw-r--r--sys/dvb/gstdvbsrc.c4
-rw-r--r--sys/oss4/oss4-audio.c45
-rw-r--r--sys/oss4/oss4-mixer-slider.c17
-rw-r--r--sys/oss4/oss4-mixer-switch.c68
-rw-r--r--sys/oss4/oss4-mixer.c376
-rw-r--r--sys/vdpau/gstvdpmpegdec.c5
19 files changed, 1232 insertions, 488 deletions
diff --git a/sys/dshowsrcwrapper/Makefile.am b/sys/dshowsrcwrapper/Makefile.am
index 38895a1e..74bf83ed 100644..100755
--- a/sys/dshowsrcwrapper/Makefile.am
+++ b/sys/dshowsrcwrapper/Makefile.am
@@ -1,10 +1,14 @@
-plugin_LTLIBRARIES = libgstdshowsrcwrapper.la
+# This plugin isn't buildable with autotools at this point in time, so just
+# ensure everything's listed in EXTRA_DIST
-libgstdshowsrcwrapper_la_SOURCES = gstdshowaudiosrc.c gstdshowsrcwrapper.c gstdshowvideosrc.c
-
-libgstdshowsrcwrapper_la_CFLAGS = $(GST_CFLAGS)
-libgstdshowsrcwrapper_la_LIBADD = $(GST_LIBS)
-libgstdshowsrcwrapper_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-libgstdshowsrcwrapper_la_LIBTOOLFLAGS = --tag=disable-static
-
-noinst_HEADERS = gstdshowaudiosrc.h gstdshowsrcwrapper.h gstdshowvideosrc.h
+EXTRA_DIST = \
+ gstdshowaudiosrc.cpp \
+ gstdshowaudiosrc.h \
+ gstdshow.cpp \
+ gstdshowfakesink.cpp \
+ gstdshowfakesink.h \
+ gstdshow.h \
+ gstdshowinterface.h \
+ gstdshowsrcwrapper.cpp \
+ gstdshowvideosrc.cpp \
+ gstdshowvideosrc.h
diff --git a/sys/dshowsrcwrapper/gstdshow.cpp b/sys/dshowsrcwrapper/gstdshow.cpp
new file mode 100755
index 00000000..ed27d631
--- /dev/null
+++ b/sys/dshowsrcwrapper/gstdshow.cpp
@@ -0,0 +1,346 @@
+/* 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 "gstdshow.h"
+#include "gstdshowfakesink.h"
+
+CFactoryTemplate g_Templates[]=
+{
+ {
+ L"DSHOW fake sink filter"
+ , &CLSID_DshowFakeSink
+ , CDshowFakeSink::CreateInstance
+ , NULL
+ , NULL
+ }
+};
+
+int g_cTemplates = sizeof(g_Templates)/sizeof(g_Templates[0]);
+static HINSTANCE g_hModule = NULL;
+
+extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
+BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
+{
+ if (!g_hModule)
+ g_hModule = (HINSTANCE)hModule;
+
+ return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved);
+}
+
+STDAPI DllRegisterServer()
+{
+ return AMovieDllRegisterServer2 (TRUE);
+}
+
+STDAPI DllUnregisterServer()
+{
+ return AMovieDllRegisterServer2 (FALSE);
+}
+
+HRESULT gst_dshow_register_fakefilters ()
+{
+ return DllRegisterServer();
+}
+
+void
+gst_dshow_free_mediatype (AM_MEDIA_TYPE *pmt)
+{
+ if (pmt != NULL) {
+ if (pmt->cbFormat != 0) {
+ CoTaskMemFree((PVOID)pmt->pbFormat);
+ pmt->cbFormat = 0;
+ pmt->pbFormat = NULL;
+ }
+ if (pmt->pUnk != NULL) {
+ /* Unecessary because pUnk should not be used, but safest. */
+ pmt->pUnk->Release();
+ pmt->pUnk = NULL;
+ }
+
+ CoTaskMemFree(pmt);
+ }
+}
+
+void
+gst_dshow_free_pin_mediatype (gpointer pt)
+{
+ GstCapturePinMediaType * pin_mediatype = (GstCapturePinMediaType *) pt;
+ if (pin_mediatype) {
+ if (pin_mediatype->capture_pin) {
+ pin_mediatype->capture_pin->Release();
+ pin_mediatype->capture_pin = NULL;
+ }
+ if (pin_mediatype->mediatype) {
+ gst_dshow_free_mediatype (pin_mediatype->mediatype);
+ pin_mediatype->mediatype = NULL;
+ }
+ }
+}
+
+
+void
+gst_dshow_free_pins_mediatypes (GList *pins_mediatypes)
+{
+ guint i = 0;
+ for (; i < g_list_length (pins_mediatypes); i++) {
+ GList *mylist = g_list_nth (pins_mediatypes, i);
+ if (mylist && mylist->data)
+ gst_dshow_free_pin_mediatype ((GstCapturePinMediaType *)mylist->data);
+ }
+ g_list_free (pins_mediatypes);
+}
+
+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;
+ *pin = NULL;
+
+ hres = filter->EnumPins (&enumpins);
+ if (FAILED(hres)) {
+ return ret;
+ }
+
+ while (enumpins->Next (1, &pintmp, NULL) == S_OK)
+ {
+ PIN_DIRECTION pindirtmp;
+ hres = pintmp->QueryDirection (&pindirtmp);
+ if (hres == S_OK && pindir == pindirtmp) {
+ *pin = pintmp;
+ ret = TRUE;
+ break;
+ }
+ pintmp->Release ();
+ }
+ enumpins->Release ();
+
+ return ret;
+}
+
+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;
+}
+
+
+gchar *
+gst_dshow_getdevice_from_devicename (const GUID *device_category, gchar **device_name)
+{
+ gchar *ret = NULL;
+ ICreateDevEnum *devices_enum = NULL;
+ IEnumMoniker *enum_moniker = NULL;
+ IMoniker *moniker = NULL;
+ 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) {
+ /*error*/
+ goto clean;
+ }
+
+ hres = devices_enum->CreateClassEnumerator (*device_category,
+ &enum_moniker, 0);
+ if (hres != S_OK || !enum_moniker) {
+ /*error*/
+ goto clean;
+ }
+
+ enum_moniker->Reset ();
+
+ 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);
+ 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,
+ wcslen(varFriendlyName.bstrVal), NULL, NULL, NULL);
+
+ if (!*device_name) {
+ *device_name = g_strdup (friendly_name);
+ }
+
+ if (_stricmp(*device_name, friendly_name) == 0) {
+ WCHAR *wszDisplayName = NULL;
+ hres = moniker->GetDisplayName (NULL, NULL, &wszDisplayName);
+ if(hres == S_OK && wszDisplayName) {
+ ret = g_utf16_to_utf8((const gunichar2*)wszDisplayName,
+ wcslen(wszDisplayName), NULL, NULL, NULL);
+ CoTaskMemFree (wszDisplayName);
+ }
+ bfound = TRUE;
+ }
+ SysFreeString (varFriendlyName.bstrVal);
+ }
+ property_bag->Release ();
+ }
+ moniker->Release ();
+ }
+
+clean:
+ if (enum_moniker) {
+ enum_moniker->Release ();
+ }
+
+ if (devices_enum) {
+ devices_enum->Release ();
+ }
+
+ return ret;
+}
+
+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))
+ {
+ /* Get the filter's name and IUnknown pointer.*/
+ FILTER_INFO FilterInfo;
+ CAUUID caGUID;
+ IUnknown *pFilterUnk = NULL;
+ hres = base_filter->QueryFilterInfo (&FilterInfo);
+ base_filter->QueryInterface (IID_IUnknown, (void **)&pFilterUnk);
+
+ /* Show the page. */
+ pProp->GetPages (&caGUID);
+ pProp->Release ();
+ OleCreatePropertyFrame(GetDesktopWindow(), 0, 0, FilterInfo.achName,
+ 1, &pFilterUnk, caGUID.cElems, caGUID.pElems, 0, 0, NULL);
+
+ pFilterUnk->Release ();
+ FilterInfo.pGraph->Release ();
+ CoTaskMemFree(caGUID.pElems);
+ }
+ return ret;
+}
diff --git a/sys/dshowsrcwrapper/gstdshow.h b/sys/dshowsrcwrapper/gstdshow.h
new file mode 100755
index 00000000..ec360b32
--- /dev/null
+++ b/sys/dshowsrcwrapper/gstdshow.h
@@ -0,0 +1,76 @@
+/* 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 _GSTDSHOW_
+#define _GSTDSHOW_
+
+#ifdef __cplusplus
+#include <streams.h>
+#endif
+#include <windows.h>
+#include <objbase.h>
+#include <dshow.h>
+#include <Rpc.h>
+
+#include <glib.h>
+
+typedef struct _GstCapturePinMediaType
+{
+ AM_MEDIA_TYPE *mediatype;
+ IPin *capture_pin;
+} GstCapturePinMediaType;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* register fake filters as COM object and as Direct Show filters in the registry */
+HRESULT gst_dshow_register_fakefilters ();
+
+/* free memory of the input pin mediatype */
+void gst_dshow_free_pin_mediatype (gpointer pt);
+
+/* free memory of the input dshow mediatype */
+void gst_dshow_free_mediatype (AM_MEDIA_TYPE *pmt);
+
+/* free the memory of all mediatypes of the input list if pin mediatype */
+void gst_dshow_free_pins_mediatypes (GList *mediatypes);
+
+/* get a pin from directshow filter */
+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,
+ CLSID output_majortype, CLSID output_subtype,
+ gchar * prefered_filter_name, IBaseFilter **filter);
+
+/* 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);
+
+/* show the capture filter property page (generally used to setup the device). the page is modal*/
+gboolean gst_dshow_show_propertypage (IBaseFilter *base_filter);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GSTDSHOW_ */ \ No newline at end of file
diff --git a/sys/dshowsrcwrapper/gstdshowaudiosrc.c b/sys/dshowsrcwrapper/gstdshowaudiosrc.cpp
index d6edf47d..c213aae5 100644..100755
--- a/sys/dshowsrcwrapper/gstdshowaudiosrc.c
+++ b/sys/dshowsrcwrapper/gstdshowaudiosrc.cpp
@@ -19,12 +19,12 @@
* Boston, MA 02111-1307, USA.
*/
-#include "gstdshowaudiosrc.h"
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include "gstdshowaudiosrc.h"
+
static const GstElementDetails gst_dshowaudiosrc_details =
GST_ELEMENT_DETAILS ("Directshow audio capture source",
"Source/Audio",
@@ -166,13 +166,14 @@ gst_dshowaudiosrc_class_init (GstDshowAudioSrcClass * klass)
g_object_class_install_property
(gobject_class, PROP_DEVICE,
g_param_spec_string ("device", "Device",
- "Directshow device reference (classID/name)",
- NULL, G_PARAM_READWRITE));
+ "Directshow device reference (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, G_PARAM_READWRITE));
+ "Human-readable name of the sound device", NULL,
+ static_cast<GParamFlags>(G_PARAM_READWRITE)));
GST_DEBUG_CATEGORY_INIT (dshowaudiosrc_debug, "dshowaudiosrc", 0,
"Directshow audio source");
@@ -234,9 +235,8 @@ gst_dshowaudiosrc_dispose (GObject * gobject)
}
/* clean dshow */
- if (src->audio_cap_filter) {
- IBaseFilter_Release (src->audio_cap_filter);
- }
+ if (src->audio_cap_filter)
+ src->audio_cap_filter->Release();
CoUninitialize ();
@@ -273,8 +273,8 @@ gst_dshowaudiosrc_get_device_name_values (GstDshowAudioSrc * src)
g_value_init (&value, G_TYPE_STRING);
- hres = CoCreateInstance (&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
- &IID_ICreateDevEnum, (void **) &devices_enum);
+ hres = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
+ IID_ICreateDevEnum, (LPVOID *) &devices_enum);
if (hres != S_OK) {
GST_CAT_ERROR (dshowaudiosrc_debug,
"Can't create an instance of the system device enumerator (error=%d)",
@@ -283,9 +283,8 @@ gst_dshowaudiosrc_get_device_name_values (GstDshowAudioSrc * src)
goto clean;
}
- hres =
- ICreateDevEnum_CreateClassEnumerator (devices_enum,
- &CLSID_AudioInputDeviceCategory, &moniker_enum, 0);
+ hres = devices_enum->CreateClassEnumerator(CLSID_AudioInputDeviceCategory,
+ &moniker_enum, 0);
if (hres != S_OK || !moniker_enum) {
GST_CAT_ERROR (dshowaudiosrc_debug,
"Can't get enumeration of audio devices (error=%d)", hres);
@@ -293,22 +292,19 @@ gst_dshowaudiosrc_get_device_name_values (GstDshowAudioSrc * src)
goto clean;
}
- IEnumMoniker_Reset (moniker_enum);
+ moniker_enum->Reset();
- while (hres = IEnumMoniker_Next (moniker_enum, 1, &moniker, &fetched),
+ while (hres = moniker_enum->Next(1, &moniker, &fetched),
hres == S_OK) {
IPropertyBag *property_bag = NULL;
- hres =
- IMoniker_BindToStorage (moniker, NULL, NULL, &IID_IPropertyBag,
- (void **) &property_bag);
+ hres = moniker->BindToStorage(NULL, NULL, IID_IPropertyBag,
+ (LPVOID *) &property_bag);
if (SUCCEEDED (hres) && property_bag) {
VARIANT varFriendlyName;
VariantInit (&varFriendlyName);
- hres =
- IPropertyBag_Read (property_bag, L"FriendlyName", &varFriendlyName,
- NULL);
+ 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,
@@ -320,19 +316,17 @@ gst_dshowaudiosrc_get_device_name_values (GstDshowAudioSrc * src)
g_free (friendly_name);
SysFreeString (varFriendlyName.bstrVal);
}
- IPropertyBag_Release (property_bag);
+ property_bag->Release();
}
- IMoniker_Release (moniker);
+ moniker->Release();
}
clean:
- if (moniker_enum) {
- IEnumMoniker_Release (moniker_enum);
- }
+ if (moniker_enum)
+ moniker_enum->Release();
- if (devices_enum) {
- ICreateDevEnum_Release (devices_enum);
- }
+ if (devices_enum)
+ devices_enum->Release();
return array;
}
@@ -415,14 +409,13 @@ gst_dshowaudiosrc_get_caps (GstBaseSrc * basesrc)
if (!src->audio_cap_filter) {
hres = CreateBindCtx (0, &lpbc);
if (SUCCEEDED (hres)) {
- hres = MkParseDisplayName (lpbc, unidevice, &dwEaten, &audiom);
+ hres = MkParseDisplayName (lpbc, (LPCOLESTR) unidevice, &dwEaten, &audiom);
if (SUCCEEDED (hres)) {
- hres =
- IMoniker_BindToObject (audiom, lpbc, NULL, &IID_IBaseFilter,
- &src->audio_cap_filter);
- IMoniker_Release (audiom);
+ hres = audiom->BindToObject(lpbc, NULL, IID_IBaseFilter,
+ (LPVOID *) &src->audio_cap_filter);
+ audiom->Release();
}
- IBindCtx_Release (lpbc);
+ lpbc->Release();
}
}
@@ -432,42 +425,39 @@ gst_dshowaudiosrc_get_caps (GstBaseSrc * basesrc)
IEnumPins *enumpins = NULL;
HRESULT hres;
- hres = IBaseFilter_EnumPins (src->audio_cap_filter, &enumpins);
+ hres = src->audio_cap_filter->EnumPins(&enumpins);
if (SUCCEEDED (hres)) {
- while (IEnumPins_Next (enumpins, 1, &capture_pin, NULL) == S_OK) {
+ while (enumpins->Next(1, &capture_pin, NULL) == S_OK) {
IKsPropertySet *pKs = NULL;
- hres =
- IPin_QueryInterface (capture_pin, &IID_IKsPropertySet,
- (void **) &pKs);
+ hres = capture_pin->QueryInterface(IID_IKsPropertySet, (LPVOID *) &pKs);
if (SUCCEEDED (hres) && pKs) {
DWORD cbReturned;
GUID pin_category;
RPC_STATUS rpcstatus;
hres =
- IKsPropertySet_Get (pKs, &AMPROPSETID_Pin,
+ pKs->Get(AMPROPSETID_Pin,
AMPROPERTY_PIN_CATEGORY, NULL, 0, &pin_category, sizeof (GUID),
&cbReturned);
/* we only want capture pins */
- if (UuidCompare (&pin_category, &PIN_CATEGORY_CAPTURE,
+ if (UuidCompare (&pin_category, (UUID *) &PIN_CATEGORY_CAPTURE,
&rpcstatus) == 0) {
IAMStreamConfig *streamcaps = NULL;
- if (SUCCEEDED (IPin_QueryInterface (capture_pin,
- &IID_IAMStreamConfig, (void **) &streamcaps))) {
+ if (SUCCEEDED (capture_pin->QueryInterface(IID_IAMStreamConfig, (LPVOID *) &streamcaps))) {
src->caps =
gst_dshowaudiosrc_getcaps_from_streamcaps (src, capture_pin,
streamcaps);
- IAMStreamConfig_Release (streamcaps);
+ streamcaps->Release();
}
}
- IKsPropertySet_Release (pKs);
+ pKs->Release();
}
- IPin_Release (capture_pin);
+ capture_pin->Release();
}
- IEnumPins_Release (enumpins);
+ enumpins->Release();
}
}
@@ -495,7 +485,7 @@ gst_dshowaudiosrc_change_state (GstElement * element, GstStateChange transition)
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
if (src->media_filter)
- hres = IMediaFilter_Run (src->media_filter, 0);
+ hres = src->media_filter->Run(0);
if (hres != S_OK) {
GST_CAT_ERROR (dshowaudiosrc_debug,
"Can't RUN the directshow capture graph (error=%d)", hres);
@@ -507,7 +497,7 @@ gst_dshowaudiosrc_change_state (GstElement * element, GstStateChange transition)
break;
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
if (src->media_filter)
- hres = IMediaFilter_Stop (src->media_filter);
+ hres = src->media_filter->Stop();
if (hres != S_OK) {
GST_CAT_ERROR (dshowaudiosrc_debug,
"Can't STOP the directshow capture graph (error=%d)", hres);
@@ -533,8 +523,8 @@ gst_dshowaudiosrc_open (GstAudioSrc * asrc)
HRESULT hres = S_FALSE;
GstDshowAudioSrc *src = GST_DSHOWAUDIOSRC (asrc);
- hres = CoCreateInstance (&CLSID_FilterGraph, NULL, CLSCTX_INPROC,
- &IID_IFilterGraph, (LPVOID *) & src->filter_graph);
+ hres = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC,
+ IID_IFilterGraph, (LPVOID *) & src->filter_graph);
if (hres != S_OK || !src->filter_graph) {
GST_CAT_ERROR (dshowaudiosrc_debug,
"Can't create an instance of the directshow graph manager (error=%d)",
@@ -542,8 +532,7 @@ gst_dshowaudiosrc_open (GstAudioSrc * asrc)
goto error;
}
- hres = IFilterGraph_QueryInterface (src->filter_graph, &IID_IMediaFilter,
- (void **) &src->media_filter);
+ hres = src->filter_graph->QueryInterface(IID_IMediaFilter, (LPVOID *) &src->media_filter);
if (hres != S_OK || !src->media_filter) {
GST_CAT_ERROR (dshowaudiosrc_debug,
"Can't get IMediacontrol interface from the graph manager (error=%d)",
@@ -551,17 +540,15 @@ gst_dshowaudiosrc_open (GstAudioSrc * asrc)
goto error;
}
- hres = CoCreateInstance (&CLSID_DshowFakeSink, NULL, CLSCTX_INPROC,
- &IID_IBaseFilter, (LPVOID *) & src->dshow_fakesink);
+ hres = CoCreateInstance (CLSID_DshowFakeSink, NULL, CLSCTX_INPROC,
+ IID_IBaseFilter, (LPVOID *) & src->dshow_fakesink);
if (hres != S_OK || !src->dshow_fakesink) {
GST_CAT_ERROR (dshowaudiosrc_debug,
"Can't create an instance of the directshow fakesink (error=%d)", hres);
goto error;
}
- hres =
- IFilterGraph_AddFilter (src->filter_graph, src->audio_cap_filter,
- L"capture");
+ hres = src->filter_graph->AddFilter(src->audio_cap_filter, L"capture");
if (hres != S_OK) {
GST_CAT_ERROR (dshowaudiosrc_debug,
"Can't add the directshow capture filter to the graph (error=%d)",
@@ -569,9 +556,7 @@ gst_dshowaudiosrc_open (GstAudioSrc * asrc)
goto error;
}
- hres =
- IFilterGraph_AddFilter (src->filter_graph, src->dshow_fakesink,
- L"fakesink");
+ hres = src->filter_graph->AddFilter(src->dshow_fakesink, L"fakesink");
if (hres != S_OK) {
GST_CAT_ERROR (dshowaudiosrc_debug,
"Can't add our fakesink filter to the graph (error=%d)", hres);
@@ -582,16 +567,16 @@ gst_dshowaudiosrc_open (GstAudioSrc * asrc)
error:
if (src->dshow_fakesink) {
- IBaseFilter_Release (src->dshow_fakesink);
+ src->dshow_fakesink->Release();
src->dshow_fakesink = NULL;
}
if (src->media_filter) {
- IMediaFilter_Release (src->media_filter);
+ src->media_filter->Release();
src->media_filter = NULL;
}
if (src->filter_graph) {
- IFilterGraph_Release (src->filter_graph);
+ src->filter_graph->Release();
src->filter_graph = NULL;
}
@@ -628,9 +613,7 @@ gst_dshowaudiosrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
if (type) {
pin_mediatype = (GstCapturePinMediaType *) type->data;
- hres =
- IBaseFilter_QueryInterface (src->dshow_fakesink,
- &IID_IGstDshowInterface, (void **) &srcinterface);
+ hres = src->dshow_fakesink->QueryInterface(IID_IGstDshowInterface, (LPVOID *) &srcinterface);
if (hres != S_OK || !srcinterface) {
GST_CAT_ERROR (dshowaudiosrc_debug,
"Can't get IGstDshowInterface interface from our dshow fakesink filter (error=%d)",
@@ -638,14 +621,12 @@ gst_dshowaudiosrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
goto error;
}
- IGstDshowInterface_gst_set_media_type (srcinterface,
- pin_mediatype->mediatype);
- IGstDshowInterface_gst_set_buffer_callback (srcinterface,
- (byte *) gst_dshowaudiosrc_push_buffer, (byte *) src);
+ srcinterface->gst_set_media_type(pin_mediatype->mediatype);
+ srcinterface->gst_set_buffer_callback(
+ (push_buffer_func) gst_dshowaudiosrc_push_buffer, (byte *) src);
- if (srcinterface) {
- IGstDshowInterface_Release (srcinterface);
- }
+ if (srcinterface)
+ srcinterface->Release();
gst_dshow_get_pin_from_filter (src->dshow_fakesink, PINDIR_INPUT,
&input_pin);
@@ -655,10 +636,9 @@ gst_dshowaudiosrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
goto error;
}
- hres =
- IFilterGraph_ConnectDirect (src->filter_graph,
- pin_mediatype->capture_pin, input_pin, NULL);
- IPin_Release (input_pin);
+ hres = src->filter_graph->ConnectDirect(pin_mediatype->capture_pin,
+ input_pin, NULL);
+ input_pin->Release();
if (hres != S_OK) {
GST_CAT_ERROR (dshowaudiosrc_debug,
@@ -676,9 +656,8 @@ gst_dshowaudiosrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
return TRUE;
error:
- if (srcinterface) {
- IGstDshowInterface_Release (srcinterface);
- }
+ if (srcinterface)
+ srcinterface->Release();
return FALSE;
}
@@ -694,14 +673,14 @@ gst_dshowaudiosrc_unprepare (GstAudioSrc * asrc)
gst_dshow_get_pin_from_filter (src->audio_cap_filter, PINDIR_OUTPUT,
&output_pin);
if (output_pin) {
- hres = IFilterGraph_Disconnect (src->filter_graph, output_pin);
- IPin_Release (output_pin);
+ hres = src->filter_graph->Disconnect(output_pin);
+ output_pin->Release();
}
gst_dshow_get_pin_from_filter (src->dshow_fakesink, PINDIR_INPUT, &input_pin);
if (input_pin) {
- hres = IFilterGraph_Disconnect (src->filter_graph, input_pin);
- IPin_Release (input_pin);
+ hres = src->filter_graph->Disconnect(input_pin);
+ input_pin->Release();
}
return TRUE;
@@ -716,19 +695,19 @@ gst_dshowaudiosrc_close (GstAudioSrc * asrc)
return TRUE;
/*remove filters from the graph */
- IFilterGraph_RemoveFilter (src->filter_graph, src->audio_cap_filter);
- IFilterGraph_RemoveFilter (src->filter_graph, src->dshow_fakesink);
+ src->filter_graph->RemoveFilter(src->audio_cap_filter);
+ src->filter_graph->RemoveFilter(src->dshow_fakesink);
/*release our gstreamer dshow sink */
- IBaseFilter_Release (src->dshow_fakesink);
+ src->dshow_fakesink->Release();
src->dshow_fakesink = NULL;
/*release media filter interface */
- IMediaFilter_Release (src->media_filter);
+ src->media_filter->Release();
src->media_filter = NULL;
/*release the filter graph manager */
- IFilterGraph_Release (src->filter_graph);
+ src->filter_graph->Release();
src->filter_graph = NULL;
return TRUE;
@@ -786,7 +765,9 @@ gst_dshowaudiosrc_reset (GstAudioSrc * asrc)
GstDshowAudioSrc *src = GST_DSHOWAUDIOSRC (asrc);
g_mutex_lock (src->gbarray_lock);
- g_byte_array_remove_range (src->gbarray, 0, src->gbarray->len);
+ GST_DEBUG ("byte array size= %d", src->gbarray->len);
+ if (src->gbarray->len > 0)
+ g_byte_array_remove_range (src->gbarray, 0, src->gbarray->len);
g_mutex_unlock (src->gbarray_lock);
}
@@ -805,7 +786,7 @@ gst_dshowaudiosrc_getcaps_from_streamcaps (GstDshowAudioSrc * src, IPin * pin,
if (!streamcaps)
return NULL;
- IAMStreamConfig_GetNumberOfCapabilities (streamcaps, &icount, &isize);
+ streamcaps->GetNumberOfCapabilities(&icount, &isize);
if (isize != sizeof (ascc))
return NULL;
@@ -813,11 +794,10 @@ gst_dshowaudiosrc_getcaps_from_streamcaps (GstDshowAudioSrc * src, IPin * pin,
for (; i < icount; i++) {
GstCapturePinMediaType *pin_mediatype = g_new0 (GstCapturePinMediaType, 1);
- IPin_AddRef (pin);
+ pin->AddRef();
pin_mediatype->capture_pin = pin;
- hres =
- IAMStreamConfig_GetStreamCaps (streamcaps, i, &pin_mediatype->mediatype,
+ hres = streamcaps->GetStreamCaps(i, &pin_mediatype->mediatype,
(BYTE *) & ascc);
if (hres == S_OK && pin_mediatype->mediatype) {
GstCaps *mediacaps = NULL;
@@ -825,10 +805,10 @@ gst_dshowaudiosrc_getcaps_from_streamcaps (GstDshowAudioSrc * src, IPin * pin,
if (!caps)
caps = gst_caps_new_empty ();
- if ((UuidCompare (&pin_mediatype->mediatype->subtype, &MEDIASUBTYPE_PCM,
+ if ((UuidCompare (&pin_mediatype->mediatype->subtype, (UUID *) &MEDIASUBTYPE_PCM,
&rpcstatus) == 0 && rpcstatus == RPC_S_OK)
&& (UuidCompare (&pin_mediatype->mediatype->formattype,
- &FORMAT_WaveFormatEx, &rpcstatus) == 0
+ (UUID *) &FORMAT_WaveFormatEx, &rpcstatus) == 0
&& rpcstatus == RPC_S_OK)) {
WAVEFORMATEX *wavformat =
(WAVEFORMATEX *) pin_mediatype->mediatype->pbFormat;
diff --git a/sys/dshowsrcwrapper/gstdshowaudiosrc.h b/sys/dshowsrcwrapper/gstdshowaudiosrc.h
index fb571015..b8147011 100644..100755
--- a/sys/dshowsrcwrapper/gstdshowaudiosrc.h
+++ b/sys/dshowsrcwrapper/gstdshowaudiosrc.h
@@ -27,7 +27,8 @@
#include <gst/audio/gstaudiosrc.h>
#include <gst/interfaces/propertyprobe.h>
-#include "gstdshowsrcwrapper.h"
+#include "gstdshow.h"
+#include "gstdshowinterface.h"
G_BEGIN_DECLS
#define GST_TYPE_DSHOWAUDIOSRC (gst_dshowaudiosrc_get_type())
diff --git a/sys/dshowsrcwrapper/gstdshowfakesink.cpp b/sys/dshowsrcwrapper/gstdshowfakesink.cpp
new file mode 100755
index 00000000..afc0a5ef
--- /dev/null
+++ b/sys/dshowsrcwrapper/gstdshowfakesink.cpp
@@ -0,0 +1,127 @@
+/* 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"
+
+
+CDshowFakeSink::CDshowFakeSink()
+ : m_hres(S_OK), CBaseRenderer(CLSID_DshowFakeSink, "DshowFakeSink", NULL, &m_hres)
+{
+ m_callback = NULL;
+}
+
+CDshowFakeSink::~CDshowFakeSink()
+{
+
+}
+
+//Object creation.
+CUnknown* WINAPI CDshowFakeSink::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr)
+{
+ CDshowFakeSink *pNewObject = new CDshowFakeSink();
+ g_print ("CDshowFakeSink::CreateInstance\n");
+ if (pNewObject == NULL) {
+ *pHr = E_OUTOFMEMORY;
+ }
+ return pNewObject;
+}
+
+STDMETHODIMP CDshowFakeSink::QueryInterface(REFIID riid, void **ppvObject)
+{
+ if (riid == IID_IGstDshowInterface) {
+ *ppvObject = (IGstDshowInterface*) this;
+ AddRef();
+ return S_OK;
+ }
+ else
+ return CBaseRenderer::QueryInterface (riid, ppvObject);
+}
+
+ULONG STDMETHODCALLTYPE CDshowFakeSink::AddRef()
+{
+ return CBaseRenderer::AddRef();
+}
+
+ULONG STDMETHODCALLTYPE CDshowFakeSink::Release()
+{
+ return CBaseRenderer::Release();
+}
+
+
+STDMETHODIMP CDshowFakeSink::gst_set_media_type (AM_MEDIA_TYPE *pmt)
+{
+ m_MediaType.Set (*pmt);
+ return S_OK;
+}
+
+STDMETHODIMP CDshowFakeSink::gst_set_buffer_callback (push_buffer_func push, byte *data)
+{
+ m_callback = push;
+ m_data = data;
+ return S_OK;
+}
+
+STDMETHODIMP CDshowFakeSink::gst_push_buffer (byte *buffer, __int64 start, __int64 stop, unsigned int size, bool discount)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CDshowFakeSink::gst_flush ()
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CDshowFakeSink::gst_set_sample_size(unsigned int size)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT CDshowFakeSink::CheckMediaType(const CMediaType *pmt)
+{
+ VIDEOINFOHEADER *p1;
+ VIDEOINFOHEADER *p2;
+ if(pmt != NULL)
+ {
+ p1 = (VIDEOINFOHEADER *)pmt->Format();
+ p2 = (VIDEOINFOHEADER *)m_MediaType.Format();
+ if (*pmt == m_MediaType)
+ return S_OK;
+ }
+
+ return S_FALSE;
+}
+
+HRESULT CDshowFakeSink::DoRenderSample(IMediaSample *pMediaSample)
+{
+ 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);
+ }
+
+ return S_OK;
+}
diff --git a/sys/dshowsrcwrapper/gstdshowfakesink.h b/sys/dshowsrcwrapper/gstdshowfakesink.h
new file mode 100755
index 00000000..7f419b27
--- /dev/null
+++ b/sys/dshowsrcwrapper/gstdshowfakesink.h
@@ -0,0 +1,50 @@
+/* GStreamer
+ * Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
+ *
+ * gstdshowfakesink.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.
+ */
+
+#include "gstdshowinterface.h"
+
+class CDshowFakeSink : public CBaseRenderer,
+ public IGstDshowInterface
+{
+public:
+ CDshowFakeSink ();
+ virtual ~CDshowFakeSink ();
+
+ static CUnknown * WINAPI CreateInstance (LPUNKNOWN pUnk, HRESULT *pHr);
+
+ virtual HRESULT CheckMediaType (const CMediaType *pmt);
+ virtual HRESULT DoRenderSample (IMediaSample *pMediaSample);
+
+ STDMETHOD (QueryInterface)(REFIID riid, void **ppvObject);
+ ULONG STDMETHODCALLTYPE AddRef();
+ ULONG STDMETHODCALLTYPE Release();
+ STDMETHOD (gst_set_media_type) (AM_MEDIA_TYPE *pmt);
+ STDMETHOD (gst_set_buffer_callback) (push_buffer_func push, byte *data);
+ STDMETHOD (gst_push_buffer) (byte *buffer, __int64 start, __int64 stop, unsigned int size, bool discount);
+ STDMETHOD (gst_flush) ();
+ STDMETHOD (gst_set_sample_size) (unsigned int size);
+
+protected:
+ HRESULT m_hres;
+ CMediaType m_MediaType;
+ push_buffer_func m_callback;
+ byte *m_data;
+}; \ No newline at end of file
diff --git a/sys/dshowsrcwrapper/gstdshowinterface.h b/sys/dshowsrcwrapper/gstdshowinterface.h
new file mode 100755
index 00000000..68328b95
--- /dev/null
+++ b/sys/dshowsrcwrapper/gstdshowinterface.h
@@ -0,0 +1,163 @@
+/* GStreamer
+ * Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
+ *
+ * gstdshowinterface.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_DHOW_INTERFACE_H__
+#define __GST_DHOW_INTERFACE_H__
+
+#include "gstdshow.h"
+
+#ifdef __cplusplus
+typedef bool (*push_buffer_func) (byte *buffer, long size, byte *src_object, UINT64 start, UINT64 stop);
+#endif
+
+/* verify that the <rpcndr.h> version is high enough to compile this file*/
+#ifndef __REQUIRED_RPCNDR_H_VERSION__
+#define __REQUIRED_RPCNDR_H_VERSION__ 440
+#endif
+
+#include "rpc.h"
+#include "rpcndr.h"
+
+#ifndef __RPCNDR_H_VERSION__
+#error this stub requires an updated version of <rpcndr.h>
+#endif // __RPCNDR_H_VERSION__
+
+#ifndef COM_NO_WINDOWS_H
+#include "windows.h"
+#include "ole2.h"
+#endif /*COM_NO_WINDOWS_H*/
+
+//{6A780808-9725-4d0b-8695-A4DD8D210773}
+static const GUID CLSID_DshowFakeSink
+ = { 0x6a780808, 0x9725, 0x4d0b, { 0x86, 0x95, 0xa4, 0xdd, 0x8d, 0x21, 0x7, 0x73 } };
+
+// {FC36764C-6CD4-4C73-900F-3F40BF3F191A}
+static const GUID IID_IGstDshowInterface =
+ { 0xfc36764c, 0x6cd4, 0x4c73, { 0x90, 0xf, 0x3f, 0x40, 0xbf, 0x3f, 0x19, 0x1a } };
+
+#define CLSID_DSHOWFAKESINK_STRING "{6A780808-9725-4d0b-8695-A4DD8D210773}"
+
+typedef interface IGstDshowInterface IGstDshowInterface;
+
+/* header files for imported files */
+#include "oaidl.h"
+#include "ocidl.h"
+
+void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);
+void __RPC_USER MIDL_user_free( void __RPC_FAR * );
+
+#ifndef __IGstDshowInterface_INTERFACE_DEFINED__
+#define __IGstDshowInterface_INTERFACE_DEFINED__
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("542C0A24-8BD1-46cb-AA57-3E46D006D2F3")
+ IGstDshowInterface : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE gst_set_media_type(
+ AM_MEDIA_TYPE __RPC_FAR *pmt) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE gst_set_buffer_callback(
+ push_buffer_func push, byte *data) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE gst_push_buffer(
+ byte *buffer, __int64 start, __int64 stop, unsigned int size, bool discount) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE gst_flush() = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE gst_set_sample_size(unsigned int size) = 0;
+ };
+
+#else /* C style interface */
+
+ typedef struct IGstDshowInterfaceVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
+ IGstDshowInterface __RPC_FAR * This,
+ REFIID riid,
+ void __RPC_FAR *__RPC_FAR *ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
+ IGstDshowInterface __RPC_FAR * This);
+
+ ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
+ IGstDshowInterface __RPC_FAR * This);
+
+ HRESULT (STDMETHODCALLTYPE *gst_set_media_type )(
+ IGstDshowInterface __RPC_FAR * This,
+ AM_MEDIA_TYPE *pmt);
+
+ HRESULT (STDMETHODCALLTYPE *gst_set_buffer_callback) (
+ IGstDshowInterface __RPC_FAR * This,
+ byte * push, byte *data);
+
+ HRESULT (STDMETHODCALLTYPE *gst_push_buffer) (
+ IGstDshowInterface __RPC_FAR * This,
+ byte *buffer, __int64 start, __int64 stop,
+ unsigned int size, boolean discount);
+
+ HRESULT (STDMETHODCALLTYPE *gst_flush) (
+ IGstDshowInterface __RPC_FAR * This);
+
+ HRESULT (STDMETHODCALLTYPE *gst_set_sample_size) (
+ IGstDshowInterface __RPC_FAR * This,
+ unsigned int size);
+
+ END_INTERFACE
+ } IGstDshowInterfaceVtbl;
+
+ interface IGstDshowInterface
+ {
+ CONST_VTBL struct IGstDshowInterfaceVtbl __RPC_FAR *lpVtbl;
+ };
+
+#define IGstDshowInterface_QueryInterface(This,riid,ppvObject) \
+ (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
+
+#define IGstDshowInterface_AddRef(This) \
+ (This)->lpVtbl -> AddRef(This)
+
+#define IGstDshowInterface_Release(This) \
+ (This)->lpVtbl -> Release(This)
+
+#define IGstDshowInterface_gst_set_media_type(This, mediatype) \
+ (This)->lpVtbl -> gst_set_media_type(This, mediatype)
+
+#define IGstDshowInterface_gst_set_buffer_callback(This, push, data) \
+ (This)->lpVtbl -> gst_set_buffer_callback(This, push, data)
+
+#define IGstDshowInterface_gst_push_buffer(This, buffer, start, stop, size, discount) \
+ (This)->lpVtbl -> gst_push_buffer(This, buffer, start, stop, size, discount)
+
+#define IGstDshowInterface_gst_flush(This) \
+ (This)->lpVtbl -> gst_flush(This)
+
+#define IGstDshowInterface_gst_set_sample_size(This, size) \
+ (This)->lpVtbl -> gst_set_sample_size(This, size)
+
+#endif /* C style interface */
+
+#endif /* __IGstDshowInterface_INTERFACE_DEFINED__ */
+
+#endif /* __GST_DSHOW_INTERFACE_H__ */ \ No newline at end of file
diff --git a/sys/dshowsrcwrapper/gstdshowsrcwrapper.c b/sys/dshowsrcwrapper/gstdshowsrcwrapper.cpp
index 803fd807..1e9a8aa2 100644..100755
--- a/sys/dshowsrcwrapper/gstdshowsrcwrapper.c
+++ b/sys/dshowsrcwrapper/gstdshowsrcwrapper.cpp
@@ -35,12 +35,15 @@ const GUID IID_IGstSrcInterface =
{ 0x542c0a24, 0x8bd1, 0x46cb, {0xaa, 0x57, 0x3e, 0x46, 0xd0, 0x6, 0xd2,
0xf3} };
-
static gboolean
plugin_init (GstPlugin * plugin)
{
/* register fake filters */
- gst_dshow_register_fakefilters ();
+ HRESULT hr = gst_dshow_register_fakefilters ();
+ if (FAILED (hr)) {
+ g_warning ("failed to register directshow fakesink filter: 0x%x\n", hr);
+ return FALSE;
+ }
if (!gst_element_register (plugin, "dshowaudiosrc",
GST_RANK_NONE,
@@ -52,8 +55,12 @@ plugin_init (GstPlugin * plugin)
return TRUE;
}
+extern "C" {
+
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"dshowsrcwrapper",
"DirectShow sources wrapper plugin",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
+
+}
diff --git a/sys/dshowsrcwrapper/gstdshowsrcwrapper.h b/sys/dshowsrcwrapper/gstdshowsrcwrapper.h
deleted file mode 100644
index d94d49f7..00000000
--- a/sys/dshowsrcwrapper/gstdshowsrcwrapper.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* GStreamer
- * Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
- *
- * gstdshowsrcwrapper.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_H__
-#define __GST_DSHOW_H__
-
-#include <windows.h>
-#include <objbase.h>
-#include <dshow.h>
-#include <Rpc.h>
-
-#include <gst/dshow/gstdshowinterface.h>
-
-#pragma warning( disable : 4090 4024)
-
-#endif /* __GST_DSHOW_H__ */
diff --git a/sys/dshowsrcwrapper/gstdshowvideosrc.c b/sys/dshowsrcwrapper/gstdshowvideosrc.cpp
index 4a37778c..67e70d96 100644..100755
--- a/sys/dshowsrcwrapper/gstdshowvideosrc.c
+++ b/sys/dshowsrcwrapper/gstdshowvideosrc.cpp
@@ -19,12 +19,12 @@
* Boston, MA 02111-1307, USA.
*/
-#include "gstdshowvideosrc.h"
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include "gstdshowvideosrc.h"
+
static const GstElementDetails gst_dshowvideosrc_details =
GST_ELEMENT_DETAILS ("DirectShow video capture source",
"Source/Video",
@@ -181,12 +181,14 @@ gst_dshowvideosrc_class_init (GstDshowVideoSrcClass * klass)
g_object_class_install_property
(gobject_class, PROP_DEVICE,
g_param_spec_string ("device", "Device",
- "Directshow device path (@..classID/name)", NULL, G_PARAM_READWRITE));
+ "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, G_PARAM_READWRITE));
+ "Human-readable name of the sound device", NULL,
+ static_cast<GParamFlags>(G_PARAM_READWRITE)));
GST_DEBUG_CATEGORY_INIT (dshowvideosrc_debug, "dshowvideosrc", 0,
"Directshow video source");
@@ -243,7 +245,7 @@ gst_dshowvideosrc_dispose (GObject * gobject)
/* clean dshow */
if (src->video_cap_filter) {
- IBaseFilter_Release (src->video_cap_filter);
+ src->video_cap_filter->Release();
src->video_cap_filter = NULL;
}
@@ -327,8 +329,8 @@ gst_dshowvideosrc_get_device_name_values (GstDshowVideoSrc * src)
g_value_init (&value, G_TYPE_STRING);
- hres = CoCreateInstance (&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
- &IID_ICreateDevEnum, (void **) &devices_enum);
+ hres = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
+ IID_ICreateDevEnum, (LPVOID *) &devices_enum);
if (hres != S_OK) {
GST_CAT_ERROR (dshowvideosrc_debug,
"Can't create an instance of the system device enumerator (error=%d)",
@@ -337,9 +339,8 @@ gst_dshowvideosrc_get_device_name_values (GstDshowVideoSrc * src)
goto clean;
}
- hres =
- ICreateDevEnum_CreateClassEnumerator (devices_enum,
- &CLSID_VideoInputDeviceCategory, &moniker_enum, 0);
+ hres = devices_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
+ &moniker_enum, 0);
if (hres != S_OK || !moniker_enum) {
GST_CAT_ERROR (dshowvideosrc_debug,
"Can't get enumeration of video devices (error=%d)", hres);
@@ -347,22 +348,20 @@ gst_dshowvideosrc_get_device_name_values (GstDshowVideoSrc * src)
goto clean;
}
- IEnumMoniker_Reset (moniker_enum);
+ moniker_enum->Reset();
- while (hres = IEnumMoniker_Next (moniker_enum, 1, &moniker, &fetched),
+ while (hres = moniker_enum->Next(1, &moniker, &fetched),
hres == S_OK) {
IPropertyBag *property_bag = NULL;
hres =
- IMoniker_BindToStorage (moniker, NULL, NULL, &IID_IPropertyBag,
- (void **) &property_bag);
+ moniker->BindToStorage(NULL, NULL, IID_IPropertyBag,
+ (LPVOID *) &property_bag);
if (SUCCEEDED (hres) && property_bag) {
VARIANT varFriendlyName;
VariantInit (&varFriendlyName);
- hres =
- IPropertyBag_Read (property_bag, L"FriendlyName", &varFriendlyName,
- NULL);
+ 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,
@@ -374,19 +373,17 @@ gst_dshowvideosrc_get_device_name_values (GstDshowVideoSrc * src)
g_free (friendly_name);
SysFreeString (varFriendlyName.bstrVal);
}
- IPropertyBag_Release (property_bag);
+ property_bag->Release();
}
- IMoniker_Release (moniker);
+ moniker->Release();
}
clean:
- if (moniker_enum) {
- IEnumMoniker_Release (moniker_enum);
- }
+ if (moniker_enum)
+ moniker_enum->Release();
- if (devices_enum) {
- ICreateDevEnum_Release (devices_enum);
- }
+ if (devices_enum)
+ devices_enum->Release();
return array;
}
@@ -480,14 +477,13 @@ gst_dshowvideosrc_get_caps (GstBaseSrc * basesrc)
if (!src->video_cap_filter) {
hres = CreateBindCtx (0, &lpbc);
if (SUCCEEDED (hres)) {
- hres = MkParseDisplayName (lpbc, unidevice, &dwEaten, &videom);
+ hres = MkParseDisplayName (lpbc, (LPCOLESTR) unidevice, &dwEaten, &videom);
if (SUCCEEDED (hres)) {
- hres =
- IMoniker_BindToObject (videom, lpbc, NULL, &IID_IBaseFilter,
- &src->video_cap_filter);
- IMoniker_Release (videom);
+ hres = videom->BindToObject(lpbc, NULL, IID_IBaseFilter,
+ (LPVOID *) &src->video_cap_filter);
+ videom->Release();
}
- IBindCtx_Release (lpbc);
+ lpbc->Release();
}
}
@@ -501,31 +497,28 @@ gst_dshowvideosrc_get_caps (GstBaseSrc * basesrc)
IEnumPins *enumpins = NULL;
HRESULT hres;
- hres = IBaseFilter_EnumPins (src->video_cap_filter, &enumpins);
+ hres = src->video_cap_filter->EnumPins(&enumpins);
if (SUCCEEDED (hres)) {
- while (IEnumPins_Next (enumpins, 1, &capture_pin, NULL) == S_OK) {
+ while (enumpins->Next(1, &capture_pin, NULL) == S_OK) {
IKsPropertySet *pKs = NULL;
-
- hres =
- IPin_QueryInterface (capture_pin, &IID_IKsPropertySet,
- (void **) &pKs);
+ hres = capture_pin->QueryInterface(IID_IKsPropertySet, (LPVOID *) &pKs);
if (SUCCEEDED (hres) && pKs) {
DWORD cbReturned;
GUID pin_category;
RPC_STATUS rpcstatus;
hres =
- IKsPropertySet_Get (pKs, &AMPROPSETID_Pin,
+ pKs->Get(AMPROPSETID_Pin,
AMPROPERTY_PIN_CATEGORY, NULL, 0, &pin_category, sizeof (GUID),
&cbReturned);
/* we only want capture pins */
- if (UuidCompare (&pin_category, &PIN_CATEGORY_CAPTURE,
+ if (UuidCompare (&pin_category, (UUID *) &PIN_CATEGORY_CAPTURE,
&rpcstatus) == 0) {
IAMStreamConfig *streamcaps = NULL;
- if (SUCCEEDED (IPin_QueryInterface (capture_pin,
- &IID_IAMStreamConfig, (void **) &streamcaps))) {
+ if (SUCCEEDED (capture_pin->QueryInterface(
+ IID_IAMStreamConfig, (LPVOID *) &streamcaps))) {
GstCaps *caps =
gst_dshowvideosrc_getcaps_from_streamcaps (src, capture_pin,
streamcaps);
@@ -533,16 +526,16 @@ gst_dshowvideosrc_get_caps (GstBaseSrc * basesrc)
if (caps) {
gst_caps_append (src->caps, caps);
}
- IAMStreamConfig_Release (streamcaps);
+ streamcaps->Release();
}
}
- IKsPropertySet_Release (pKs);
+ pKs->Release();
}
- IPin_Release (capture_pin);
+ capture_pin->Release();
}
- IEnumPins_Release (enumpins);
+ enumpins->Release();
}
}
@@ -573,7 +566,7 @@ gst_dshowvideosrc_change_state (GstElement * element, GstStateChange transition)
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
if (src->media_filter)
- hres = IMediaFilter_Run (src->media_filter, 0);
+ hres = src->media_filter->Run(0);
if (hres != S_OK) {
GST_CAT_ERROR (dshowvideosrc_debug,
"Can't RUN the directshow capture graph (error=%d)", hres);
@@ -582,7 +575,7 @@ gst_dshowvideosrc_change_state (GstElement * element, GstStateChange transition)
break;
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
if (src->media_filter)
- hres = IMediaFilter_Stop (src->media_filter);
+ hres = src->media_filter->Stop();
if (hres != S_OK) {
GST_CAT_ERROR (dshowvideosrc_debug,
"Can't STOP the directshow capture graph (error=%d)", hres);
@@ -604,16 +597,16 @@ gst_dshowvideosrc_start (GstBaseSrc * bsrc)
HRESULT hres = S_FALSE;
GstDshowVideoSrc *src = GST_DSHOWVIDEOSRC (bsrc);
- hres = CoCreateInstance (&CLSID_FilterGraph, NULL, CLSCTX_INPROC,
- &IID_IFilterGraph, (LPVOID *) & src->filter_graph);
+ hres = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC,
+ IID_IFilterGraph, (LPVOID *) & src->filter_graph);
if (hres != S_OK || !src->filter_graph) {
GST_CAT_ERROR (dshowvideosrc_debug,
"Can't create an instance of the dshow graph manager (error=%d)", hres);
goto error;
}
- hres = IFilterGraph_QueryInterface (src->filter_graph, &IID_IMediaFilter,
- (void **) &src->media_filter);
+ hres = src->filter_graph->QueryInterface(IID_IMediaFilter,
+ (LPVOID *) &src->media_filter);
if (hres != S_OK || !src->media_filter) {
GST_CAT_ERROR (dshowvideosrc_debug,
"Can't get IMediacontrol interface from the graph manager (error=%d)",
@@ -621,26 +614,23 @@ gst_dshowvideosrc_start (GstBaseSrc * bsrc)
goto error;
}
- hres = CoCreateInstance (&CLSID_DshowFakeSink, NULL, CLSCTX_INPROC,
- &IID_IBaseFilter, (LPVOID *) & src->dshow_fakesink);
+ hres = CoCreateInstance (CLSID_DshowFakeSink, NULL, CLSCTX_INPROC,
+ IID_IBaseFilter, (LPVOID *) & src->dshow_fakesink);
if (hres != S_OK || !src->dshow_fakesink) {
GST_CAT_ERROR (dshowvideosrc_debug,
- "Can't create an instance of our dshow fakesink filter (error=%d)",
+ "Can't create an instance of our dshow fakesink filter (error=0x%x)",
hres);
goto error;
}
- hres =
- IFilterGraph_AddFilter (src->filter_graph, src->video_cap_filter,
- L"capture");
+ hres = src->filter_graph->AddFilter(src->video_cap_filter, L"capture");
if (hres != S_OK) {
GST_CAT_ERROR (dshowvideosrc_debug,
"Can't add video capture filter to the graph (error=%d)", hres);
goto error;
}
- hres =
- IFilterGraph_AddFilter (src->filter_graph, src->dshow_fakesink, L"sink");
+ hres = src->filter_graph->AddFilter(src->dshow_fakesink, L"sink");
if (hres != S_OK) {
GST_CAT_ERROR (dshowvideosrc_debug,
"Can't add our fakesink filter to the graph (error=%d)", hres);
@@ -651,16 +641,16 @@ gst_dshowvideosrc_start (GstBaseSrc * bsrc)
error:
if (src->dshow_fakesink) {
- IBaseFilter_Release (src->dshow_fakesink);
+ src->dshow_fakesink->Release();
src->dshow_fakesink = NULL;
}
if (src->media_filter) {
- IMediaFilter_Release (src->media_filter);
+ src->media_filter->Release();
src->media_filter = NULL;
}
if (src->filter_graph) {
- IFilterGraph_Release (src->filter_graph);
+ src->filter_graph->Release();
src->filter_graph = NULL;
}
@@ -699,9 +689,8 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
if (type) {
pin_mediatype = (GstCapturePinMediaType *) type->data;
- hres =
- IBaseFilter_QueryInterface (src->dshow_fakesink,
- &IID_IGstDshowInterface, (void **) &srcinterface);
+ hres = src->dshow_fakesink->QueryInterface(
+ IID_IGstDshowInterface, (LPVOID *) &srcinterface);
if (hres != S_OK || !srcinterface) {
GST_CAT_ERROR (dshowvideosrc_debug,
@@ -710,14 +699,12 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
goto error;
}
- IGstDshowInterface_gst_set_media_type (srcinterface,
- pin_mediatype->mediatype);
- IGstDshowInterface_gst_set_buffer_callback (srcinterface,
- (byte *) gst_dshowvideosrc_push_buffer, (byte *) src);
+ srcinterface->gst_set_media_type(pin_mediatype->mediatype);
+ srcinterface->gst_set_buffer_callback(
+ (push_buffer_func) gst_dshowvideosrc_push_buffer, (byte *) src);
- if (srcinterface) {
- IGstDshowInterface_Release (srcinterface);
- }
+ if (srcinterface)
+ srcinterface->Release();
gst_dshow_get_pin_from_filter (src->dshow_fakesink, PINDIR_INPUT,
&input_pin);
@@ -727,10 +714,9 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
goto error;
}
- hres =
- IFilterGraph_ConnectDirect (src->filter_graph,
- pin_mediatype->capture_pin, input_pin, NULL);
- IPin_Release (input_pin);
+ hres = src->filter_graph->ConnectDirect(pin_mediatype->capture_pin,
+ input_pin, NULL);
+ input_pin->Release();
if (hres != S_OK) {
GST_CAT_ERROR (dshowvideosrc_debug,
@@ -760,9 +746,8 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
return TRUE;
error:
- if (srcinterface) {
- IGstDshowInterface_Release (srcinterface);
- }
+ if (srcinterface)
+ srcinterface->Release();
return FALSE;
}
@@ -781,30 +766,30 @@ gst_dshowvideosrc_stop (GstBaseSrc * bsrc)
gst_dshow_get_pin_from_filter (src->video_cap_filter, PINDIR_OUTPUT,
&output_pin);
if (output_pin) {
- hres = IFilterGraph_Disconnect (src->filter_graph, output_pin);
- IPin_Release (output_pin);
+ hres = src->filter_graph->Disconnect(output_pin);
+ output_pin->Release();
}
gst_dshow_get_pin_from_filter (src->dshow_fakesink, PINDIR_INPUT, &input_pin);
if (input_pin) {
- hres = IFilterGraph_Disconnect (src->filter_graph, input_pin);
- IPin_Release (input_pin);
+ hres = src->filter_graph->Disconnect(input_pin);
+ input_pin->Release();
}
/*remove filters from the graph */
- IFilterGraph_RemoveFilter (src->filter_graph, src->video_cap_filter);
- IFilterGraph_RemoveFilter (src->filter_graph, src->dshow_fakesink);
+ src->filter_graph->RemoveFilter(src->video_cap_filter);
+ src->filter_graph->RemoveFilter(src->dshow_fakesink);
/*release our gstreamer dshow sink */
- IBaseFilter_Release (src->dshow_fakesink);
+ src->dshow_fakesink->Release();
src->dshow_fakesink = NULL;
/*release media filter interface */
- IMediaFilter_Release (src->media_filter);
+ src->media_filter->Release();
src->media_filter = NULL;
/*release the filter graph manager */
- IFilterGraph_Release (src->filter_graph);
+ src->filter_graph->Release();
src->filter_graph = NULL;
return TRUE;
@@ -876,7 +861,7 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
if (!streamcaps)
return NULL;
- IAMStreamConfig_GetNumberOfCapabilities (streamcaps, &icount, &isize);
+ streamcaps->GetNumberOfCapabilities(&icount, &isize);
if (isize != sizeof (vscc))
return NULL;
@@ -884,12 +869,10 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
for (; i < icount; i++) {
GstCapturePinMediaType *pin_mediatype = g_new0 (GstCapturePinMediaType, 1);
- IPin_AddRef (pin);
+ pin->AddRef();
pin_mediatype->capture_pin = pin;
- hres =
- IAMStreamConfig_GetStreamCaps (streamcaps, i, &pin_mediatype->mediatype,
- (BYTE *) & vscc);
+ hres = streamcaps->GetStreamCaps(i, &pin_mediatype->mediatype, (BYTE *) & vscc);
if (hres == S_OK && pin_mediatype->mediatype) {
VIDEOINFOHEADER *video_info;
GstCaps *mediacaps = NULL;
@@ -898,10 +881,10 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
caps = gst_caps_new_empty ();
/* I420 */
- if ((UuidCompare (&pin_mediatype->mediatype->subtype, &MEDIASUBTYPE_I420,
+ if ((UuidCompare (&pin_mediatype->mediatype->subtype, (UUID *) &MEDIASUBTYPE_I420,
&rpcstatus) == 0 && rpcstatus == RPC_S_OK)
&& (UuidCompare (&pin_mediatype->mediatype->formattype,
- &FORMAT_VideoInfo, &rpcstatus) == 0
+ (UUID *) &FORMAT_VideoInfo, &rpcstatus) == 0
&& rpcstatus == RPC_S_OK)) {
video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat;
@@ -923,10 +906,10 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
}
/* RGB24 */
- if ((UuidCompare (&pin_mediatype->mediatype->subtype, &MEDIASUBTYPE_RGB24,
+ if ((UuidCompare (&pin_mediatype->mediatype->subtype, (UUID *) &MEDIASUBTYPE_RGB24,
&rpcstatus) == 0 && rpcstatus == RPC_S_OK)
&& (UuidCompare (&pin_mediatype->mediatype->formattype,
- &FORMAT_VideoInfo, &rpcstatus) == 0
+ (UUID *) &FORMAT_VideoInfo, &rpcstatus) == 0
&& rpcstatus == RPC_S_OK)) {
video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat;
@@ -952,10 +935,10 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
}
/* DVSD */
- if ((UuidCompare (&pin_mediatype->mediatype->subtype, &MEDIASUBTYPE_dvsd,
+ if ((UuidCompare (&pin_mediatype->mediatype->subtype, (UUID *) &MEDIASUBTYPE_dvsd,
&rpcstatus) == 0 && rpcstatus == RPC_S_OK)
&& (UuidCompare (&pin_mediatype->mediatype->formattype,
- &FORMAT_VideoInfo, &rpcstatus) == 0
+ (UUID *) &FORMAT_VideoInfo, &rpcstatus) == 0
&& rpcstatus == RPC_S_OK)) {
video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat;
@@ -978,10 +961,10 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
}
/* DV stream */
- if ((UuidCompare (&pin_mediatype->mediatype->subtype, &MEDIASUBTYPE_dvsd,
+ if ((UuidCompare (&pin_mediatype->mediatype->subtype, (UUID *) &MEDIASUBTYPE_dvsd,
&rpcstatus) == 0 && rpcstatus == RPC_S_OK)
&& (UuidCompare (&pin_mediatype->mediatype->formattype,
- &FORMAT_DvInfo, &rpcstatus) == 0 && rpcstatus == RPC_S_OK)) {
+ (UUID *) &FORMAT_DvInfo, &rpcstatus) == 0 && rpcstatus == RPC_S_OK)) {
mediacaps = gst_caps_new_simple ("video/x-dv",
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
diff --git a/sys/dshowsrcwrapper/gstdshowvideosrc.h b/sys/dshowsrcwrapper/gstdshowvideosrc.h
index 8bc52fa9..b7bfbb19 100644..100755
--- a/sys/dshowsrcwrapper/gstdshowvideosrc.h
+++ b/sys/dshowsrcwrapper/gstdshowvideosrc.h
@@ -22,11 +22,13 @@
#ifndef __GST_DSHOWVIDEOSRC_H__
#define __GST_DSHOWVIDEOSRC_H__
+#include <glib.h>
#include <gst/gst.h>
#include <gst/base/gstpushsrc.h>
#include <gst/interfaces/propertyprobe.h>
-#include "gstdshowsrcwrapper.h"
+#include "gstdshow.h"
+#include "gstdshowinterface.h"
// 30323449-0000-0010-8000-00AA00389B71 MEDIASUBTYPE_I420
DEFINE_GUID(MEDIASUBTYPE_I420, 0x30323449, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
diff --git a/sys/dshowsrcwrapper/libgstdshow.def b/sys/dshowsrcwrapper/libgstdshow.def
new file mode 100755
index 00000000..ee8586c9
--- /dev/null
+++ b/sys/dshowsrcwrapper/libgstdshow.def
@@ -0,0 +1,8 @@
+EXPORTS
+ DllMain PRIVATE
+ DllGetClassObject PRIVATE
+ DllCanUnloadNow PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
+
+
diff --git a/sys/dvb/gstdvbsrc.c b/sys/dvb/gstdvbsrc.c
index 37b46f42..fd76a4ea 100644
--- a/sys/dvb/gstdvbsrc.c
+++ b/sys/dvb/gstdvbsrc.c
@@ -1326,13 +1326,15 @@ gst_dvbsrc_tune (GstDvbSrc * object)
#endif
g_warning ("Error tuning channel: %s", strerror (errno));
}
- for (i = 0; i < 5; i++) {
+ for (i = 0; i < 50; i++) {
usleep (100000);
if (ioctl (object->fd_frontend, FE_READ_STATUS, &status) == -1) {
perror ("FE_READ_STATUS");
break;
}
GST_LOG_OBJECT (object, "status == 0x%02x", status);
+ if (status & FE_HAS_LOCK)
+ break;
}
if (status & FE_HAS_LOCK)
break;
diff --git a/sys/oss4/oss4-audio.c b/sys/oss4/oss4-audio.c
index 0a3c0af1..297ea7ff 100644
--- a/sys/oss4/oss4-audio.c
+++ b/sys/oss4/oss4-audio.c
@@ -494,29 +494,12 @@ gst_oss4_audio_get_template_caps (void)
return caps;
}
-static gint
-gst_oss4_audio_ilog2 (gint x)
-{
- /* well... hacker's delight explains... */
- x = x | (x >> 1);
- x = x | (x >> 2);
- x = x | (x >> 4);
- x = x | (x >> 8);
- x = x | (x >> 16);
- x = x - ((x >> 1) & 0x55555555);
- x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
- x = (x + (x >> 4)) & 0x0f0f0f0f;
- x = x + (x >> 8);
- x = x + (x >> 16);
- return (x & 0x0000003f) - 1;
-}
-
/* called by gst_oss4_sink_prepare() and gst_oss4_source_prepare() */
gboolean
gst_oss4_audio_set_format (GstObject * obj, int fd, GstRingBufferSpec * spec)
{
struct audio_buf_info info = { 0, };
- int fmt, chans, rate, fragsize;
+ int fmt, chans, rate;
fmt = gst_oss4_audio_get_oss_format (spec->format);
if (fmt == 0)
@@ -555,17 +538,6 @@ gst_oss4_audio_set_format (GstObject * obj, int fd, GstRingBufferSpec * spec)
goto format_not_what_was_requested;
}
- /* CHECKME: maybe we should just leave the fragsize alone? (tpm) */
- fragsize = gst_oss4_audio_ilog2 (spec->segsize);
- fragsize = ((spec->segtotal & 0x7fff) << 16) | fragsize;
- GST_DEBUG_OBJECT (obj, "setting segsize: %d, segtotal: %d, value: %08x",
- spec->segsize, spec->segtotal, fragsize);
-
- /* we could also use the new SNDCTL_DSP_POLICY if there's something in
- * particular we're trying to achieve here */
- if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &fragsize) == -1)
- goto set_fragsize_failed;
-
if (GST_IS_OSS4_SOURCE (obj)) {
if (ioctl (fd, SNDCTL_DSP_GETISPACE, &info) == -1)
goto get_ispace_failed;
@@ -575,12 +547,17 @@ gst_oss4_audio_set_format (GstObject * obj, int fd, GstRingBufferSpec * spec)
}
spec->segsize = info.fragsize;
- spec->segtotal = info.fragstotal;
+
+ /* we add some extra fragments -- this helps us account for delays due to
+ * conversion buffer, streams queueing, etc. It is important that these
+ * be taken into account because otherwise the delay counter can wind up
+ * being too large, and the buffer will wrap. */
+ spec->segtotal = info.fragstotal + 4;
spec->bytes_per_sample = (spec->width / 8) * spec->channels;
GST_DEBUG_OBJECT (obj, "got segsize: %d, segtotal: %d, value: %08x",
- spec->segsize, spec->segtotal, fragsize);
+ spec->segsize, spec->segtotal, info.fragsize);
return TRUE;
@@ -615,12 +592,6 @@ set_rate_failed:
("DSP_SPEED(%d) failed: %s", rate, g_strerror (errno)));
return FALSE;
}
-set_fragsize_failed:
- {
- GST_ELEMENT_ERROR (obj, RESOURCE, SETTINGS, (NULL),
- ("DSP_SETFRAGMENT(%d) failed: %s", fragsize, g_strerror (errno)));
- return FALSE;
- }
get_ospace_failed:
{
GST_ELEMENT_ERROR (obj, RESOURCE, SETTINGS, (NULL),
diff --git a/sys/oss4/oss4-mixer-slider.c b/sys/oss4/oss4-mixer-slider.c
index f8e7f661..cdc91049 100644
--- a/sys/oss4/oss4-mixer-slider.c
+++ b/sys/oss4/oss4-mixer-slider.c
@@ -159,8 +159,10 @@ gst_oss4_mixer_slider_set_volume (GstOss4MixerSlider * s, const gint * volumes)
/* if we're supposed to be muted, and are 'simulating' the mute because
* we don't have a mute control, don't actually change the volume, just
* save it as the new desired volume for later when we get unmuted again */
- if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_MUTE) && !s->mc->mute)
- goto done;
+ if (!GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_NO_MUTE)) {
+ if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_MUTE) && !s->mc->mute)
+ goto done;
+ }
val = gst_oss4_mixer_slider_pack_volume (s, volumes);
@@ -196,14 +198,21 @@ gst_oss4_mixer_slider_set_mute (GstOss4MixerSlider * s, gboolean mute)
GstMixerTrack *track = GST_MIXER_TRACK (s);
gboolean ret;
- /* if we don't have a mute control, simulate mute (which is a bit broken,
- * since we can't differentiate between capture/playback volume etc., so
+ /* if the control does not support muting, then do not do anything */
+ if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_NO_MUTE)) {
+ return TRUE;
+ }
+
+ /* If we do not have a mute control, simulate mute (which is a bit broken,
+ * since we can not differentiate between capture/playback volume etc., so
* we just assume that setting the volume to 0 would be the same as muting
* this control) */
if (s->mc->mute == NULL) {
int volume;
if (mute) {
+ /* make sure the current volume values get saved. */
+ gst_oss4_mixer_slider_get_volume (s, s->volumes);
volume = 0;
} else {
volume = gst_oss4_mixer_slider_pack_volume (s, s->volumes);
diff --git a/sys/oss4/oss4-mixer-switch.c b/sys/oss4/oss4-mixer-switch.c
index 403abbc5..11d74b46 100644
--- a/sys/oss4/oss4-mixer-switch.c
+++ b/sys/oss4/oss4-mixer-switch.c
@@ -49,45 +49,30 @@ gst_oss4_mixer_switch_init (GstOss4MixerSwitch * s)
/* nothing to do here */
}
-static GstMixerTrackFlags
-gst_oss4_mixer_switch_get_switch_flag (GstMixerTrack * track)
-{
- if ((track->flags & GST_MIXER_TRACK_INPUT)) {
- return GST_MIXER_TRACK_RECORD;
- } else if ((track->flags & GST_MIXER_TRACK_OUTPUT)) {
- return GST_MIXER_TRACK_MUTE;
- } else {
- GST_ERROR_OBJECT (track, "switch neither input nor output track!?");
- }
- return 0;
-}
-
gboolean
-gst_oss4_mixer_switch_set (GstOss4MixerSwitch * s, gboolean enabled)
+gst_oss4_mixer_switch_set (GstOss4MixerSwitch * s, gboolean disabled)
{
- GstMixerTrackFlags switch_flag;
GstMixerTrack *track;
int newval;
track = GST_MIXER_TRACK (s);
- switch_flag = gst_oss4_mixer_switch_get_switch_flag (track);
- newval = (enabled) ? 1 : 0;
+ newval = disabled ? GST_MIXER_TRACK_MUTE : 0;
- if (!!newval == !!(track->flags & switch_flag)) {
+ if (newval == (track->flags & GST_MIXER_TRACK_MUTE)) {
GST_LOG_OBJECT (s, "switch is already %d, doing nothing", newval);
return TRUE;
}
- if (!gst_oss4_mixer_set_control_val (s->mixer, s->mc, newval)) {
- GST_WARNING_OBJECT (s, "could not set switch to %d", newval);
+ if (!gst_oss4_mixer_set_control_val (s->mixer, s->mc, !disabled)) {
+ GST_WARNING_OBJECT (s, "could not set switch to %d", !disabled);
return FALSE;
}
- if (newval) {
- track->flags |= switch_flag;
+ if (disabled) {
+ track->flags |= GST_MIXER_TRACK_MUTE;
} else {
- track->flags &= ~switch_flag;
+ track->flags &= ~GST_MIXER_TRACK_MUTE;
}
GST_LOG_OBJECT (s, "set switch to %d", newval);
@@ -96,31 +81,28 @@ gst_oss4_mixer_switch_set (GstOss4MixerSwitch * s, gboolean enabled)
}
gboolean
-gst_oss4_mixer_switch_get (GstOss4MixerSwitch * s, gboolean * enabled)
+gst_oss4_mixer_switch_get (GstOss4MixerSwitch * s, gboolean * disabled)
{
- GstMixerTrackFlags switch_flag;
GstMixerTrack *track;
- int val = -1;
+ int flag;
+ int enabled = -1;
track = GST_MIXER_TRACK (s);
- switch_flag = gst_oss4_mixer_switch_get_switch_flag (track);
- if (!gst_oss4_mixer_get_control_val (s->mixer, s->mc, &val) || val < 0) {
+ if (!gst_oss4_mixer_get_control_val (s->mixer, s->mc, &enabled)
+ || (enabled < 0)) {
GST_WARNING_OBJECT (s, "could not get switch state");
return FALSE;
}
- *enabled = (val != 0);
+ flag = (enabled == 0) ? GST_MIXER_TRACK_MUTE : 0;
- if (!!val != !!(track->flags & switch_flag)) {
- GST_INFO_OBJECT (s, "updating inconsistent switch state to %d", !!val);
- if (*enabled) {
- track->flags |= switch_flag;
- } else {
- track->flags &= ~switch_flag;
- }
+ if (enabled) {
+ track->flags &= ~GST_MIXER_TRACK_MUTE;
+ } else {
+ track->flags |= GST_MIXER_TRACK_MUTE;
}
-
+ *disabled = (enabled == 0);
return TRUE;
}
@@ -149,6 +131,12 @@ gst_oss4_mixer_switch_new (GstOss4Mixer * mixer, GstOss4MixerControl * mc)
if (!gst_oss4_mixer_get_control_val (s->mixer, s->mc, &cur) || cur < 0)
return NULL;
+ if (cur) {
+ track->flags &= ~GST_MIXER_TRACK_MUTE;
+ } else {
+ track->flags |= GST_MIXER_TRACK_MUTE;
+ }
+
return track;
}
@@ -161,9 +149,5 @@ gst_oss4_mixer_switch_process_change_unlocked (GstMixerTrack * track)
if (!s->mc->changed)
return;
- if ((track->flags & GST_MIXER_TRACK_INPUT)) {
- gst_mixer_record_toggled (GST_MIXER (s->mixer), track, !!s->mc->last_val);
- } else {
- gst_mixer_mute_toggled (GST_MIXER (s->mixer), track, !!s->mc->last_val);
- }
+ gst_mixer_mute_toggled (GST_MIXER (s->mixer), track, !s->mc->last_val);
}
diff --git a/sys/oss4/oss4-mixer.c b/sys/oss4/oss4-mixer.c
index 031549b3..a67bb102 100644
--- a/sys/oss4/oss4-mixer.c
+++ b/sys/oss4/oss4-mixer.c
@@ -673,12 +673,12 @@ gst_oss4_mixer_set_control_val (GstOss4Mixer * mixer, GstOss4MixerControl * mc,
return TRUE;
}
+#if 0
static gchar *
gst_oss4_mixer_control_get_pretty_name (GstOss4MixerControl * mc)
{
gchar *name;
-#if 0
const gchar *name, *u;
/* "The id field is the original name given by the driver when it called
@@ -694,7 +694,6 @@ gst_oss4_mixer_control_get_pretty_name (GstOss4MixerControl * mc)
/* maybe capitalize the first letter? */
return g_ascii_strdown (name, -1);
-#endif
/* the .id thing doesn't really seem to work right, ie. for some sliders
* it's just '-' so you have to use the name of the parent control etc.
* let's not use it for now, much too painful. */
@@ -708,102 +707,119 @@ gst_oss4_mixer_control_get_pretty_name (GstOss4MixerControl * mc)
g_strdelimit (name, ".", ' ');
return name;
}
+#endif
-#if 0
-/* FIXME: translations for common option strings */
+/* these translations are a bit ad-hoc and horribly incomplete; it is not
+ * really going to work this way with all the different chipsets and drivers.
+ * We also use these for translating option values. */
static struct
{
const gchar oss_name[32];
const gchar *label;
-} option_labels[] = {
+} labels[] = {
{
- "Fast", N_("Fast")}, {
- "Low", N_("Low")}, {
- "Medium", N_("Medium")}, {
- "High", N_("High")}, {
- "High+", N_("Very high")}, {
- "Production", N_("Production")}, {
- "OFF", N_("Off")}, {
- "ON", N_("On")}, {
- "Stereo", N_("Stereo")}, {
- "Multich", N_("Surround sound")}, {
- "input-mix", N_("Input mix")}, {
+ "volume", N_("Volume")}, {
+ "master", N_("Master")}, {
"front", N_("Front")}, {
"rear", N_("Rear")}, {
+ "headphones", N_("Headphones")}, {
+ "center", N_("Center")}, {
+ "lfe", N_("LFE")}, {
+ "surround", N_("Surround")}, {
"side", N_("Side")}, {
- "center/LFE", N_("Center / LFE")}, {
+ "speaker", N_("Built-in Speaker")}, {
+ "aux1-out", N_("AUX 1 Out")}, {
+ "aux2-out", N_("AUX 2 Out")}, {
+ "aux-out", N_("AUX Out")}, {
+ "bass", N_("Bass")}, {
+ "treble", N_("Treble")}, {
+ "3d-depth", N_("3D Depth")}, {
+ "3d-center", N_("3D Center")}, {
+ "3d-enhance", N_("3D Enhance")}, {
+ "phone", N_("Telephone")}, {
"mic", N_("Microphone")}, {
- "fp-mic", N_("Front panel microphone")}, {
+ "line-out", N_("Line Out")}, {
+ "line-in", N_("Line In")}, {
+ "linein", N_("Line In")}, {
+ "cd", N_("Internal CD")}, {
+ "video", N_("Video In")}, {
+ "aux1-in", N_("AUX 1 In")}, {
+ "aux2-in", N_("AUX 2 In")}, {
+ "aux-in", N_("AUX In")}, {
+ "pcm", N_("PCM")}, {
+ "record-gain", N_("Record Gain")}, {
+ "igain", N_("Record Gain")}, {
+ "ogain", N_("Output Gain")}, {
+ "micboost", N_("Microphone Boost")}, {
+ "loopback", N_("Loopback")}, {
+ "diag", N_("Diagnostic")}, {
+ "loudness", N_("Bass Boost")}, {
+ "outputs", N_("Playback Ports")}, {
"input", N_("Input")}, {
- "linein", N_("Line-in")}, {
- "pcm1", N_("PCM 1")}, {
- "pcm2", N_("PCM 2")}, {
- "pcm3", N_("PCM 3")}, {
-"pcm4", N_("PCM 4")},};
-#endif
-
-/* these translations are a bit ad-hoc and horribly incomplete; it's not
- * really going to work this way with all the different chipsets and drivers */
-static struct
-{
- const gchar oss_name[32];
- const gchar *label;
-} labels[] = {
- /* connectors (e.g. hdaudio) */
- {
- "jack.green", N_("Green connector")}, {
- "jack.fp-green", N_("Green front panel connector")}, {
- "jack.pink", N_("Pink connector")}, {
- "jack.fp-pink", N_("Pink front panel connector")}, {
- "jack.blue", N_("Blue connector")}, {
- "jack.fp-blue", N_("Blue front panel connector")}, {
- "jack.orange", N_("Orange connector")}, {
- "jack.fp-orange", N_("Orange front panel connector")}, {
- "jack.black", N_("Black connector")}, {
- "jack.fp-black", N_("Black front panel connector")}, {
- "jack.gray", N_("Gray connector")}, {
- "jack.fp-gray", N_("Gray front panel connector")}, {
- "jack.white", N_("White connector")}, {
- "jack.fp-white", N_("White front panel connector")}, {
- "jack.red", N_("Red connector")}, {
- "jack.fp-red", N_("Red front panel connector")}, {
- "jack.yellow", N_("Yellow connector")}, {
- "jack.fp-yellow", N_("Yellow front panel connector")},
- /* connector functions (e.g. hdaudio) */
- {
- "jack.green.mode", N_("Green connector function")}, {
- "jack.fp-green.mode", N_("Green front panel connector function")}, {
- "jack.pink.mode", N_("Pink connector function")}, {
- "jack.fp-pink.mode", N_("Pink front panel connector function")}, {
- "jack.blue.mode", N_("Blue connector function")}, {
- "jack.fp-blue.mode", N_("Blue front panel connector function")}, {
- "jack.orange.mode", N_("Orange connector function")}, {
- "jack.fp-orange.mode", N_("Orange front panel connector function")}, {
- "jack.black.mode", N_("Black connector function")}, {
- "jack.fp-black.mode", N_("Black front panel connector function")}, {
- "jack.gray.mode", N_("Gray connector function")}, {
- "jack.fp-gray.mode", N_("Gray front panel connector function")}, {
- "jack.white.mode", N_("White connector function")}, {
- "jack.fp-white.mode", N_("White front panel connector function")}, {
- "jack.red.mode", N_("Red connector function")}, {
- "jack.fp-red.mode", N_("Red front panel connector function")}, {
- "jack.yellow.mode", N_("Yellow connector function")}, {
- "jack.fp-yellow.mode", N_("Yellow front panel connector function")},
- /* other */
- {
- "misc.mic", N_("Microphone")}, {
- "misc.fp-mic", N_("Front panel microphone")}, {
- "misc.linein", N_("Line-in")}, {
- "misc.fp-linein", N_("Front panel line-in")}, {
- "misc.headphone", N_("Headphones")}, {
- "misc.fp-headphone", N_("Front panel headphones")}, {
- "misc.front", N_("Front")}, {
- "misc.rear", N_("Rear")}, {
- "misc.side", N_("Side")}, {
- "misc.center/lfe", N_("Center / LFE")}, {
- "misc.pcm", N_("PCM")}, {
- "misc.input-mix", N_("Input mix")}
- /* FIXME translate Audigy NX USB labels) */
+ "inputs", N_("Record Source")}, {
+ "record-source", N_("Record Source")}, {
+ "monitor-source", N_("Monitor Source")}, {
+ "beep", N_("Keyboard Beep")}, {
+ "monitor-gain", N_("Monitor")}, {
+ "stereo-simulate", N_("Simulate Stereo")}, {
+ "stereo", N_("Stereo")}, {
+ "multich", N_("Surround Sound")}, {
+ "mic-gain", N_("Microphone Gain")}, {
+ "speaker-source", N_("Speaker Source")}, {
+ "mic-source", N_("Microphone Source")}, {
+ "jack", N_("Jack")}, {
+ "center/lfe", N_("Center / LFE")}, {
+ "stereo-mix", N_("Stereo Mix")}, {
+ "mono-mix", N_("Mono Mix")}, {
+ "input-mix", N_("Input Mix")}, {
+ "spdif-in", N_("SPDIF In")}, {
+ "spdif-out", N_("SPDIF Out")}, {
+ "mic1", N_("Microphone 1")}, {
+ "mic2", N_("Microphone 2")}, {
+ "digital-out", N_("Digital Out")}, {
+ "digital-in", N_("Digital In")}, {
+ "hdmi", N_("HDMI")}, {
+ "modem", N_("Modem")}, {
+ "handset", N_("Handset")}, {
+ "other", N_("Other")}, {
+ "stereo", N_("Stereo")}, {
+ "none", N_("None")}, {
+ "on", N_("On")}, {
+ "off", N_("Off")}, {
+ "mute", N_("Mute")}, {
+ "fast", N_("Fast")}, {
+ "very-low", N_("Very Low")}, {
+ "low", N_("Low")}, {
+ "medium", N_("Medium")}, {
+ "high", N_("High")}, {
+ "very-high", N_("Very High")}, {
+ "high+", N_("Very High")}, {
+ "production", N_("Production")}, {
+ "fp-mic", N_("Front Panel Microphone")}, {
+ "fp-linein", N_("Front Panel Line In")}, {
+ "fp-headphones", N_("Front Panel Headphones")}, {
+ "fp-lineout", N_("Front Panel Line Out")}, {
+ "green", N_("Green Connector")}, {
+ "pink", N_("Pink Connector")}, {
+ "blue", N_("Blue Connector")}, {
+ "white", N_("White Connector")}, {
+ "black", N_("Black Connector")}, {
+ "gray", N_("Gray Connector")}, {
+ "orange", N_("Orange Connector")}, {
+ "red", N_("Red Connector")}, {
+ "yellow", N_("Yellow Connector")}, {
+ "fp-green", N_("Green Front Panel Connector")}, {
+ "fp-pink", N_("Pink Front Panel Connector")}, {
+ "fp-blue", N_("Blue Front Panel Connector")}, {
+ "fp-white", N_("White Front Panel Connector")}, {
+ "fp-black", N_("Black Front Panel Connector")}, {
+ "fp-gray", N_("Gray Front Panel Connector")}, {
+ "fp-orange", N_("Orange Front Panel Connector")}, {
+ "fp-red", N_("Red Front Panel Connector")}, {
+ "fp-yellow", N_("Yellow Front Panel Connector")}, {
+ "spread", N_("Spread Output")}, {
+ "downmix", N_("Downmix")},
+ /* FIXME translate Audigy NX USB labels) */
/*
{ "rec.src", N_("Record Source") },
{ "output.mute", N_("Mute output") }
@@ -836,42 +852,88 @@ static struct
const gchar *
gst_oss4_mixer_control_get_translated_name (GstOss4MixerControl * mc)
{
- gchar name[33] = { 0, };
- char vmix_str[32] = { '\0', };
+ gchar name[128] = { 0, };
+ gchar scratch[128] = { 0, };
+ gchar fmtbuf[128] = { 0, };
+ gchar vmix_str[32] = { '\0', };
+ gchar *ptr;
int dummy, i;
+ int num = -1;
+
+ g_strlcpy (fmtbuf, "%s", sizeof (fmtbuf));
/* main virtual mixer controls (we hide the stream volumes) */
if (sscanf (mc->mixext.extname, "vmix%d-%32c", &dummy, vmix_str) == 2) {
if (strcmp (vmix_str, "src") == 0)
- return _("Virtual mixer input");
+ return _("Virtual Mixer Input");
else if (strcmp (vmix_str, "vol") == 0)
- return _("Virtual mixer output");
+ return _("Virtual Mixer Output");
else if (strcmp (vmix_str, "channels") == 0)
- return _("Virtual mixer channel configuration");
+ return _("Virtual Mixer Channels");
}
- /* munge connector.foo => jack.foo (change from 4.0 -> 4.1) */
- if (g_str_has_prefix (mc->mixext.extname, "connector.")) {
- g_snprintf (name, sizeof (name), "jack.%s", mc->mixext.extname + 10);
- } else {
- g_strlcpy (name, mc->mixext.extname, sizeof (name));
+ g_strlcpy (name, mc->mixext.extname, sizeof (name));
+
+ /* we deal with either "connector." or "jack." */
+ if ((g_str_has_prefix (name, "connector.")) ||
+ (g_str_has_prefix (name, "jack."))) {
+ ptr = strchr (mc->mixext.extname, '.');
+ ptr++;
+ g_strlcpy (scratch, ptr, sizeof (scratch));
+ g_strlcpy (name, scratch, sizeof (name));
}
- /* munge foo.function => foo.mode (change from 4.0 -> 4.1) */
- if (g_str_has_suffix (name, ".function"))
- memcpy (name + strlen (name) - strlen (".function"), ".mode", 5 + 1);
+ /* special handling for jack retasking suffixes */
+ if (g_str_has_suffix (name, ".function") || g_str_has_suffix (name, ".mode")) {
+ g_strlcpy (fmtbuf, _("%s Function"), sizeof (fmtbuf));
+ ptr = strrchr (name, '.');
+ *ptr = 0;
+ }
- /* chop off trailing numbers */
- while (strlen (name) > 0 && g_ascii_isdigit (name[strlen (name) - 1]))
- name[strlen (name) - 1] = '\0';
+ /* parse off trailing numbers */
+ i = strlen (name);
+ while ((i > 0) && (g_ascii_isdigit (name[i - 1]))) {
+ i--;
+ }
+ /* the check catches the case where the control name is just a number */
+ if ((i > 0) && (name[i] != '\0')) {
+ num = atoi (name + i);
+ name[i] = '\0';
+ /* format appends a number to the base, but preserves any surrounding
+ format */
+ g_snprintf (scratch, sizeof (scratch), fmtbuf, _("%s %d"));
+ g_strlcpy (fmtbuf, scratch, sizeof (fmtbuf));
+ }
+ /* look for a match, progressively skipping '.' delimited prefixes as we go */
+ ptr = name;
+ do {
+ if (*ptr == '.')
+ ptr++;
+ for (i = 0; i < G_N_ELEMENTS (labels); ++i) {
+ if (g_strcasecmp (ptr, labels[i].oss_name) == 0) {
+ g_snprintf (name, sizeof (name), fmtbuf, _(labels[i].label), num);
+ return g_quark_to_string (g_quark_from_string (name));
+ }
+ }
+ } while ((ptr = strchr (ptr, '.')) != NULL);
+
+ /* failing that, just replace periods with spaces */
+ g_strdelimit (name, ".", ' ');
+ g_snprintf (scratch, sizeof (scratch), fmtbuf, name);
+ return g_quark_to_string (g_quark_from_string (scratch)); /* eek */
+}
+
+static const gchar *
+gst_oss4_mixer_control_get_translated_option (const gchar * name)
+{
+ int i;
for (i = 0; i < G_N_ELEMENTS (labels); ++i) {
- if (strcmp (name, labels[i].oss_name) == 0)
+ if (g_strcasecmp (name, labels[i].oss_name) == 0) {
return _(labels[i].label);
+ }
}
-
- g_strdelimit (name, ".", ' ');
- return g_quark_to_string (g_quark_from_string (name)); /* eek */
+ return (name);
}
#ifndef GST_DISABLE_GST_DEBUG
@@ -1063,21 +1125,6 @@ gst_oss4_mixer_get_controls (GstOss4Mixer * mixer)
mixer_ext_flags_get_string (mix_ext.flags), mix_ext.flags);
GST_INFO (" parent : %d", mix_ext.parent);
- /* get tooltip (just for informational purposes for now) */
- if (MIXEXT_HAS_DESCRIPTION (mix_ext)) {
- oss_mixer_enuminfo desc = { 0, };
-
- desc.dev = mix_ext.dev;
- desc.ctrl = mix_ext.ctrl;
- if (ioctl (mixer->fd, SNDCTL_MIX_DESCRIPTION, &desc) >= 0) {
- /* "The string may contain multiple lines. The first line is the
- * 'tooltip'. Optional subsequent lines may contain more detailed
- * help text. Lines are separated by a linefeed character." */
- g_strdelimit (&desc.strings[desc.strindex[0]], "\n\r", '\0');
- GST_INFO (" tooltip: %s", &desc.strings[desc.strindex[0]]);
- }
- }
-
if (!MIXEXT_IS_ROOT (mix_ext)) {
/* find parent (we assume it comes in the list before the child) */
for (l = controls; l != NULL; l = l->next) {
@@ -1122,30 +1169,24 @@ static void
gst_oss4_mixer_controls_guess_master (GstOss4Mixer * mixer,
const GList * controls)
{
- GstOss4MixerControl *firstpcm_mc = NULL;
GstOss4MixerControl *master_mc = NULL;
const GList *l;
for (l = controls; l != NULL; l = l->next) {
GstOss4MixerControl *mc = (GstOss4MixerControl *) l->data;
- if (((mc->mixext.flags & MIXF_MAINVOL)) && master_mc == NULL) {
- GST_INFO_OBJECT (mixer, "Master control: %s", mc->mixext.extname);
- master_mc = mc;
- break;
- }
/* do we need to check if it's a slider type here? */
- if (((mc->mixext.flags & MIXF_PCMVOL)) && firstpcm_mc == NULL) {
+ if ((mc->mixext.flags & MIXF_PCMVOL)) {
GST_INFO_OBJECT (mixer, "First PCM control: %s", mc->mixext.extname);
- firstpcm_mc = mc;
+ master_mc = mc;
+ break;
}
- }
- /* if no control with MIXF_MAINVOL found, use first one with PCMVOL */
- if (master_mc == NULL && firstpcm_mc != NULL) {
- GST_INFO_OBJECT (mixer, "Marking first PCM control as master: %s",
- firstpcm_mc->mixext.extname);
- master_mc = firstpcm_mc;
+ if (((mc->mixext.flags & MIXF_MAINVOL)) && master_mc == NULL) {
+ GST_INFO_OBJECT (mixer, "First main volume control: %s",
+ mc->mixext.extname);
+ master_mc = mc;
+ }
}
if (master_mc != NULL)
@@ -1308,7 +1349,9 @@ gst_oss4_mixer_enum_control_update_enum_list (GstOss4Mixer * mixer,
mc->enum_vals = g_new0 (GQuark, mc->mixext.maxvalue + 1);
for (i = 0; i < mc->mixext.maxvalue; ++i) {
GST_LOG (" %s", ei.strings + ei.strindex[i]);
- mc->enum_vals[i] = g_quark_from_string (ei.strings + ei.strindex[i]);
+ mc->enum_vals[i] =
+ g_quark_from_string (gst_oss4_mixer_control_get_translated_option
+ (ei.strings + ei.strindex[i]));
}
}
@@ -1461,7 +1504,8 @@ gst_oss4_mixer_create_tracks (GstOss4Mixer * mixer, const GList * controls)
if (track == NULL)
continue;
- track->label = gst_oss4_mixer_control_get_pretty_name (mc);
+ /* The mixer API requires this to be g_strdup'd */
+ track->label = g_strdup (gst_oss4_mixer_control_get_translated_name (mc));
track->flags = 0;
GST_LOG ("translated label: %s [%s] = %s", track->label, mc->mixext.id,
@@ -1471,20 +1515,41 @@ gst_oss4_mixer_create_tracks (GstOss4Mixer * mixer, const GList * controls)
* esp. if a slider's role can be changed on the fly, like when you change
* function of a connector. What should we do in that case? Change the flag
* and make the app rebuild the interface? Ignore it? */
- if (g_str_has_prefix (mc->mixext.extname, "record.")) {
- mc->is_output = FALSE;
- mc->is_input = TRUE;
+ if (mc->mixext.flags & (MIXF_MAINVOL | MIXF_PCMVOL)) {
+ track->flags = GST_MIXER_TRACK_OUTPUT | GST_MIXER_TRACK_WHITELIST;
+
+ } else if (mc->mixext.flags & MIXF_RECVOL) {
+ /* record gain whitelisted by default */
+ track->flags = GST_MIXER_TRACK_INPUT | GST_MIXER_TRACK_NO_RECORD |
+ GST_MIXER_TRACK_WHITELIST;
+
+ } else if (mc->mixext.flags & MIXF_MONVOL) {
+ /* monitor sources not whitelisted by default */
+ track->flags = GST_MIXER_TRACK_INPUT | GST_MIXER_TRACK_NO_RECORD;
}
- /* FIXME: determine is_input and is_output */
- /* must be either INPUT or OUTPUT (but not both and not neither) for now,
- * or gnome-volume-control aborts */
- if (mc->is_input)
- track->flags |= GST_MIXER_TRACK_INPUT;
- else if (mc->is_output)
- track->flags |= GST_MIXER_TRACK_OUTPUT;
- else
+ /*
+ * The kernel may give us better clues about the scope of a control.
+ * If so, try to honor it.
+ */
+ switch (mc->mixext.desc & MIXEXT_SCOPE_MASK) {
+ case MIXEXT_SCOPE_INPUT:
+ case MIXEXT_SCOPE_RECSWITCH:
+ track->flags |= GST_MIXER_TRACK_INPUT | GST_MIXER_TRACK_NO_RECORD |
+ GST_MIXER_TRACK_WHITELIST;
+ break;
+ case MIXEXT_SCOPE_MONITOR:
+ /* don't whitelist monitor tracks by default */
+ track->flags |= GST_MIXER_TRACK_INPUT | GST_MIXER_TRACK_NO_RECORD;
+ break;
+ case MIXEXT_SCOPE_OUTPUT:
+ track->flags = GST_MIXER_TRACK_OUTPUT | GST_MIXER_TRACK_WHITELIST;
+ break;
+ }
+
+ if (mc->is_master) {
track->flags |= GST_MIXER_TRACK_OUTPUT;
+ }
if (mc->is_master)
track->flags |= GST_MIXER_TRACK_MASTER;
@@ -1597,6 +1662,10 @@ gst_oss4_mixer_get_volume (GstMixer * mixer, GstMixerTrack * track,
memset (volumes, 0, track->num_channels * sizeof (gint));
+ if (GST_IS_OSS4_MIXER_SWITCH (track)) {
+ gboolean enabled = FALSE;
+ gst_oss4_mixer_switch_get (GST_OSS4_MIXER_SWITCH (track), &enabled);
+ }
if (GST_IS_OSS4_MIXER_SLIDER (track)) {
gst_oss4_mixer_slider_get_volume (GST_OSS4_MIXER_SLIDER (track), volumes);
}
@@ -1649,11 +1718,7 @@ gst_oss4_mixer_set_mute (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
if (GST_IS_OSS4_MIXER_SLIDER (track)) {
gst_oss4_mixer_slider_set_mute (GST_OSS4_MIXER_SLIDER (track), mute);
} else if (GST_IS_OSS4_MIXER_SWITCH (track)) {
- if ((track->flags & GST_MIXER_TRACK_OUTPUT)) {
- gst_oss4_mixer_switch_set (GST_OSS4_MIXER_SWITCH (track), mute);
- } else {
- GST_WARNING_OBJECT (track, "set_mute called on non-OUTPUT track");
- }
+ gst_oss4_mixer_switch_set (GST_OSS4_MIXER_SWITCH (track), mute);
}
GST_OBJECT_UNLOCK (oss);
@@ -1717,7 +1782,8 @@ gst_oss4_mixer_get_option (GstMixer * mixer, GstMixerOptions * options)
static GstMixerFlags
gst_oss4_mixer_get_mixer_flags (GstMixer * mixer)
{
- return GST_MIXER_FLAG_AUTO_NOTIFICATIONS;
+ return GST_MIXER_FLAG_AUTO_NOTIFICATIONS | GST_MIXER_FLAG_HAS_WHITELIST |
+ GST_MIXER_FLAG_GROUPING;
}
static void
diff --git a/sys/vdpau/gstvdpmpegdec.c b/sys/vdpau/gstvdpmpegdec.c
index 674146c4..c3fb324e 100644
--- a/sys/vdpau/gstvdpmpegdec.c
+++ b/sys/vdpau/gstvdpmpegdec.c
@@ -172,7 +172,8 @@ gst_vdp_mpeg_dec_set_caps (GstPad * pad, GstCaps * caps)
gboolean res;
const GValue *value;
- VdpDecoderProfile profile;
+ /* Default to MPEG1 until we find otherwise */
+ VdpDecoderProfile profile = VDP_DECODER_PROFILE_MPEG1;
GstVdpDevice *device;
VdpStatus status;
@@ -210,8 +211,6 @@ gst_vdp_mpeg_dec_set_caps (GstPad * pad, GstCaps * caps)
/* parse caps to setup decoder */
gst_structure_get_int (structure, "mpegversion", &mpeg_dec->version);
- if (mpeg_dec->version == 1)
- profile = VDP_DECODER_PROFILE_MPEG1;
value = gst_structure_get_value (structure, "codec_data");
if (value) {