summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorDave Robillard <dave@drobilla.net>2009-08-09 00:14:27 -0400
committerDave Robillard <dave@drobilla.net>2009-08-09 00:14:27 -0400
commitdd5afbf0c6557ad89994cbfd91e4117e8503b81a (patch)
tree4f18322a717c6dbe64b8b38194e302b1668dcb3d /sys
parent5d9d4a7b518c42bda88c7f6c87ce7c3c01233562 (diff)
parent6115e0cb0ef3ae85397297c7e30c2e9b4a0a181e (diff)
downloadgst-plugins-bad-dd5afbf0c6557ad89994cbfd91e4117e8503b81a.tar.gz
gst-plugins-bad-dd5afbf0c6557ad89994cbfd91e4117e8503b81a.tar.bz2
gst-plugins-bad-dd5afbf0c6557ad89994cbfd91e4117e8503b81a.zip
Merge branch 'master' of git://anongit.freedesktop.org/gstreamer/gst-plugins-bad into fdo
Diffstat (limited to 'sys')
-rw-r--r--sys/Makefile.am10
-rw-r--r--sys/directdraw/gstdirectdrawsink.c196
-rw-r--r--sys/directdraw/gstdirectdrawsink.h1
-rw-r--r--sys/directsound/Makefile.am12
-rw-r--r--sys/directsound/gstdirectsoundplugin.c49
-rw-r--r--sys/directsound/gstdirectsoundsrc.c587
-rw-r--r--sys/directsound/gstdirectsoundsrc.h112
-rwxr-xr-xsys/dshowsrcwrapper/Makefile.am1
-rwxr-xr-xsys/dshowsrcwrapper/gstdshow.cpp38
-rwxr-xr-xsys/dshowsrcwrapper/gstdshow.h2
-rwxr-xr-xsys/dshowsrcwrapper/gstdshowaudiosrc.cpp34
-rwxr-xr-xsys/dshowsrcwrapper/gstdshowaudiosrc.h4
-rwxr-xr-xsys/dshowsrcwrapper/gstdshowfakesink.cpp71
-rwxr-xr-xsys/dshowsrcwrapper/gstdshowfakesink.h32
-rwxr-xr-xsys/dshowsrcwrapper/gstdshowinterface.h163
-rwxr-xr-xsys/dshowsrcwrapper/gstdshowsrcwrapper.cpp19
-rwxr-xr-xsys/dshowsrcwrapper/gstdshowvideosrc.cpp37
-rwxr-xr-xsys/dshowsrcwrapper/gstdshowvideosrc.h4
-rwxr-xr-xsys/dshowsrcwrapper/libgstdshow.def8
19 files changed, 1005 insertions, 375 deletions
diff --git a/sys/Makefile.am b/sys/Makefile.am
index 15c89e17..5608a8e7 100644
--- a/sys/Makefile.am
+++ b/sys/Makefile.am
@@ -28,6 +28,12 @@ else
DIRECTDRAW_DIR=
endif
+if USE_DIRECTSOUND
+DIRECTSOUND_DIR=directsound
+else
+DIRECTSOUND_DIR=
+endif
+
if USE_FBDEV
FBDEV_DIR=fbdev
else
@@ -76,8 +82,8 @@ else
VDPAU_DIR=
endif
-SUBDIRS = $(ACM_DIR) $(DIRECTDRAW_DIR) $(DVB_DIR) $(FBDEV_DIR) $(OSS4_DIR) $(OSX_VIDEO_DIR) $(QT_DIR) $(VCD_DIR) $(VDPAU_DIR) $(WININET_DIR)
+SUBDIRS = $(ACM_DIR) $(DIRECTDRAW_DIR) $(DIRECTSOUND_DIR) $(DVB_DIR) $(FBDEV_DIR) $(OSS4_DIR) $(OSX_VIDEO_DIR) $(QT_DIR) $(VCD_DIR) $(VDPAU_DIR) $(WININET_DIR)
-DIST_SUBDIRS = acmenc acmmp3dec directdraw dvb fbdev dshowdecwrapper dshowsrcwrapper dshowvideosink \
+DIST_SUBDIRS = acmenc acmmp3dec directdraw directsound dvb fbdev dshowdecwrapper dshowsrcwrapper dshowvideosink \
oss4 osxvideo qtwrapper vcd vdpau wasapi wininet winks winscreencap
diff --git a/sys/directdraw/gstdirectdrawsink.c b/sys/directdraw/gstdirectdrawsink.c
index 144f6595..538227de 100644
--- a/sys/directdraw/gstdirectdrawsink.c
+++ b/sys/directdraw/gstdirectdrawsink.c
@@ -127,8 +127,11 @@ static gboolean
gst_directdraw_sink_interface_supported (GstImplementsInterface * iface,
GType type)
{
- g_assert (type == GST_TYPE_X_OVERLAY);
- return TRUE;
+ if (type == GST_TYPE_X_OVERLAY)
+ return TRUE;
+ else if (type == GST_TYPE_NAVIGATION)
+ return TRUE;
+ return FALSE;
}
static void
@@ -189,6 +192,71 @@ gst_directdraw_sink_xoverlay_interface_init (GstXOverlayClass * iface)
}
static void
+gst_directdraw_sink_navigation_send_event (GstNavigation * navigation,
+ GstStructure * structure)
+{
+ GstDirectDrawSink *ddrawsink = GST_DIRECTDRAW_SINK (navigation);
+ GstEvent *event;
+ GstVideoRectangle src, dst, result;
+ double x, y, old_x, old_y;
+ GstPad *pad = NULL;
+
+ src.w = GST_VIDEO_SINK_WIDTH (ddrawsink);
+ src.h = GST_VIDEO_SINK_HEIGHT (ddrawsink);
+ dst.w = ddrawsink->out_width;
+ dst.h = ddrawsink->out_height;
+ gst_video_sink_center_rect (src, dst, &result, FALSE);
+
+ event = gst_event_new_navigation (structure);
+
+ /* Our coordinates can be wrong here if we centered the video */
+
+ /* Converting pointer coordinates to the non scaled geometry */
+ if (gst_structure_get_double (structure, "pointer_x", &old_x)) {
+ x = old_x;
+
+ if (x >= result.x && x <= (result.x + result.w)) {
+ x -= result.x;
+ x *= ddrawsink->video_width;
+ x /= result.w;
+ } else {
+ x = 0;
+ }
+ GST_DEBUG_OBJECT (ddrawsink, "translated navigation event x "
+ "coordinate from %f to %f", old_x, x);
+ gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, x, NULL);
+ }
+ if (gst_structure_get_double (structure, "pointer_y", &old_y)) {
+ y = old_y;
+
+ if (y >= result.y && y <= (result.y + result.h)) {
+ y -= result.y;
+ y *= ddrawsink->video_height;
+ y /= result.h;
+ } else {
+ y = 0;
+ }
+ GST_DEBUG_OBJECT (ddrawsink, "translated navigation event y "
+ "coordinate from %f to %f", old_y, y);
+ gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
+ }
+
+ pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (ddrawsink));
+
+ if (GST_IS_PAD (pad) && GST_IS_EVENT (event)) {
+ gst_pad_send_event (pad, event);
+
+ gst_object_unref (pad);
+ }
+}
+
+static void
+gst_directdraw_sink_navigation_interface_init (GstNavigationInterface * iface)
+{
+ iface->send_event = gst_directdraw_sink_navigation_send_event;
+}
+
+static void
gst_directdraw_sink_init_interfaces (GType type)
{
static const GInterfaceInfo iface_info = {
@@ -203,9 +271,16 @@ gst_directdraw_sink_init_interfaces (GType type)
NULL,
};
+ static const GInterfaceInfo navigation_info = {
+ (GInterfaceInitFunc) gst_directdraw_sink_navigation_interface_init,
+ NULL,
+ NULL,
+ };
+
g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE,
&iface_info);
g_type_add_interface_static (type, GST_TYPE_X_OVERLAY, &xoverlay_info);
+ g_type_add_interface_static (type, GST_TYPE_NAVIGATION, &navigation_info);
}
/* Subclass of GstBuffer which manages buffer_pool surfaces lifetime */
@@ -484,6 +559,8 @@ gst_directdraw_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
("Failed to get caps properties from caps"), (NULL));
return FALSE;
}
+ GST_VIDEO_SINK_WIDTH (ddrawsink) = ddrawsink->video_width;
+ GST_VIDEO_SINK_HEIGHT (ddrawsink) = ddrawsink->video_height;
ddrawsink->fps_n = gst_value_get_fraction_numerator (fps);
ddrawsink->fps_d = gst_value_get_fraction_denominator (fps);
@@ -1277,7 +1354,6 @@ gst_directdraw_sink_setup_ddraw (GstDirectDrawSink * ddrawsink)
{
gboolean bRet = TRUE;
HRESULT hRes;
-
/* create an instance of the ddraw object use DDCREATE_EMULATIONONLY as first
* parameter to force Directdraw to use the hardware emulation layer */
hRes = DirectDrawCreateEx ( /*DDCREATE_EMULATIONONLY */ 0,
@@ -1320,6 +1396,118 @@ long FAR PASCAL
WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
+ case WM_CREATE:{
+ LPCREATESTRUCT crs = (LPCREATESTRUCT) lParam;
+ /* Nail pointer to the video sink down to this window */
+ SetWindowLongPtr (hWnd, GWLP_USERDATA, (LONG_PTR) crs->lpCreateParams);
+ break;
+ }
+ case WM_SIZE:
+ case WM_CHAR:
+ case WM_KEYDOWN:
+ case WM_KEYUP:
+ case WM_LBUTTONDOWN:
+ case WM_RBUTTONDOWN:
+ case WM_MBUTTONDOWN:
+ case WM_LBUTTONUP:
+ case WM_RBUTTONUP:
+ case WM_MBUTTONUP:
+ case WM_MOUSEMOVE:{
+ GstDirectDrawSink *ddrawsink;
+ ddrawsink = (GstDirectDrawSink *) GetWindowLongPtr (hWnd, GWLP_USERDATA);
+
+ if (G_UNLIKELY (!ddrawsink))
+ break;
+
+ switch (message) {
+ case WM_SIZE:{
+ GST_OBJECT_LOCK (ddrawsink);
+ ddrawsink->out_width = LOWORD (lParam);
+ ddrawsink->out_height = HIWORD (lParam);
+ GST_OBJECT_UNLOCK (ddrawsink);
+ GST_DEBUG_OBJECT (ddrawsink, "Window size is %dx%d", LOWORD (wParam),
+ HIWORD (wParam));
+ break;
+ }
+ case WM_CHAR:
+ case WM_KEYDOWN:
+ case WM_KEYUP:{
+ gunichar2 wcrep[128];
+ if (GetKeyNameTextW (lParam, wcrep, 128)) {
+ gchar *utfrep = g_utf16_to_utf8 (wcrep, 128, NULL, NULL, NULL);
+ if (utfrep) {
+ if (message == WM_CHAR || message == WM_KEYDOWN)
+ gst_navigation_send_key_event (GST_NAVIGATION (ddrawsink),
+ "key-press", utfrep);
+ if (message == WM_CHAR || message == WM_KEYUP)
+ gst_navigation_send_key_event (GST_NAVIGATION (ddrawsink),
+ "key-release", utfrep);
+ g_free (utfrep);
+ }
+ }
+ break;
+ }
+ case WM_LBUTTONDOWN:
+ case WM_LBUTTONUP:
+ case WM_RBUTTONDOWN:
+ case WM_RBUTTONUP:
+ case WM_MBUTTONDOWN:
+ case WM_MBUTTONUP:
+ case WM_MOUSEMOVE:{
+ gint x, y, button;
+ gchar *action;
+
+ switch (message) {
+ case WM_MOUSEMOVE:
+ button = 0;
+ action = "mouse-move";
+ break;
+ case WM_LBUTTONDOWN:
+ button = 1;
+ action = "mouse-button-press";
+ break;
+ case WM_LBUTTONUP:
+ button = 1;
+ action = "mouse-button-release";
+ break;
+ case WM_RBUTTONDOWN:
+ button = 2;
+ action = "mouse-button-press";
+ break;
+ case WM_RBUTTONUP:
+ button = 2;
+ action = "mouse-button-release";
+ break;
+ case WM_MBUTTONDOWN:
+ button = 3;
+ action = "mouse-button-press";
+ break;
+ case WM_MBUTTONUP:
+ button = 3;
+ action = "mouse-button-release";
+ break;
+ default:
+ button = 4;
+ }
+
+ x = LOWORD (lParam);
+ y = HIWORD (lParam);
+
+ if (button == 0) {
+ GST_DEBUG_OBJECT (ddrawsink, "Mouse moved to %dx%d", x, y);
+ } else
+ GST_DEBUG_OBJECT (ddrawsink, "Mouse button %d pressed at %dx%d",
+ button, x, y);
+
+ if (button < 4)
+ gst_navigation_send_mouse_event (GST_NAVIGATION (ddrawsink),
+ action, button, x, y);
+
+ break;
+ }
+ }
+ break;
+ }
case WM_ERASEBKGND:
return TRUE;
case WM_CLOSE:
@@ -1352,7 +1540,7 @@ gst_directdraw_sink_window_thread (GstDirectDrawSink * ddrawsink)
ddrawsink->video_window = CreateWindowEx (0, "GStreamer-DirectDraw",
"GStreamer-DirectDraw sink default window",
WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0, 0, 640, 480, NULL, NULL,
- WndClass.hInstance, NULL);
+ WndClass.hInstance, (LPVOID) ddrawsink);
if (ddrawsink->video_window == NULL)
return NULL;
diff --git a/sys/directdraw/gstdirectdrawsink.h b/sys/directdraw/gstdirectdrawsink.h
index 9cb5f788..1d7cc5d0 100644
--- a/sys/directdraw/gstdirectdrawsink.h
+++ b/sys/directdraw/gstdirectdrawsink.h
@@ -30,6 +30,7 @@
#include <gst/gst.h>
#include <gst/video/gstvideosink.h>
#include <gst/interfaces/xoverlay.h>
+#include <gst/interfaces/navigation.h>
#include <windows.h>
#include <ddraw.h>
diff --git a/sys/directsound/Makefile.am b/sys/directsound/Makefile.am
new file mode 100644
index 00000000..31994014
--- /dev/null
+++ b/sys/directsound/Makefile.am
@@ -0,0 +1,12 @@
+plugin_LTLIBRARIES = libgstdirectsoundsrc.la
+
+libgstdirectsoundsrc_la_SOURCES = gstdirectsoundsrc.c gstdirectsoundplugin.c
+libgstdirectsoundsrc_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) \
+ $(GST_PLUGINS_BASE_CFLAGS)
+libgstdirectsoundsrc_la_LIBADD = $(DIRECTDRAW_LIBS) \
+ $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) \
+ -lgstinterfaces-$(GST_MAJORMINOR) -ldsound
+libgstdirectsoundsrc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(DIRECTDRAW_LDFLAGS)
+libgstdirectsoundsrc_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS= gstdirectsoundsrc.h
diff --git a/sys/directsound/gstdirectsoundplugin.c b/sys/directsound/gstdirectsoundplugin.c
new file mode 100644
index 00000000..e3816967
--- /dev/null
+++ b/sys/directsound/gstdirectsoundplugin.c
@@ -0,0 +1,49 @@
+/* GStreamer
+* Copyright (C) 2005 Sebastien Moutte <sebastien@moutte.net>
+* Copyright (C) 2007 Pioneers of the Inevitable <songbird@songbirdnest.com>
+*
+* gstdirectsoundplugin.c:
+*
+* 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.
+*
+*
+* The development of this code was made possible due to the involvement
+* of Pioneers of the Inevitable, the creators of the Songbird Music player
+*
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstdirectsoundsrc.h"
+
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+ if (!gst_element_register (plugin, "directsoundsrc", GST_RANK_PRIMARY,
+ GST_TYPE_DIRECTSOUND_SRC))
+ return FALSE;
+
+ return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "directsoundsrc",
+ "Direct Sound Source plugin library",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/sys/directsound/gstdirectsoundsrc.c b/sys/directsound/gstdirectsoundsrc.c
new file mode 100644
index 00000000..429d6b85
--- /dev/null
+++ b/sys/directsound/gstdirectsoundsrc.c
@@ -0,0 +1,587 @@
+/*
+ * GStreamer
+ * Copyright 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright 2005 Sébastien Moutte <sebastien@moutte.net>
+ * Copyright 2006 Joni Valtanen <joni.valtanen@movial.fi>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Alternatively, the contents of this file may be used under the
+ * GNU Lesser General Public License Version 2.1 (the "LGPL"), in
+ * which case the following provisions apply instead of the ones
+ * mentioned above:
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ TODO: add device selection and check rate etc.
+*/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif /* */
+
+#include <gst/gst.h>
+#include <gst/audio/gstbaseaudiosrc.h>
+
+#include "gstdirectsoundsrc.h"
+
+#include <windows.h>
+#include <dsound.h>
+ GST_DEBUG_CATEGORY_STATIC (directsoundsrc_debug);
+
+#define GST_CAT_DEFAULT directsoundsrc_debug
+ static GstElementDetails gst_directsound_src_details =
+ GST_ELEMENT_DETAILS ("Audio Source (DIRECTCSOUND)", "Source/Audio",
+ "Capture from a soundcard via DIRECTSOUND",
+ "Joni Valtanen <joni.valtanen@movial.fi>");
+
+/* defaults here */
+#define DEFAULT_DEVICE 0
+
+/* properties */
+ enum
+{ PROP_0, PROP_DEVICE
+};
+ static HRESULT (WINAPI * pDSoundCaptureCreate) (LPGUID,
+ LPDIRECTSOUNDCAPTURE *, LPUNKNOWN);
+ static void gst_directsound_src_finalise (GObject * object);
+ static void gst_directsound_src_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+ static void gst_directsound_src_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+ static gboolean gst_directsound_src_open (GstAudioSrc * asrc);
+ static gboolean gst_directsound_src_close (GstAudioSrc * asrc);
+ static gboolean gst_directsound_src_prepare (GstAudioSrc * asrc,
+ GstRingBufferSpec * spec);
+ static gboolean gst_directsound_src_unprepare (GstAudioSrc * asrc);
+ static void gst_directsound_src_reset (GstAudioSrc * asrc);
+ static GstCaps *gst_directsound_src_getcaps (GstBaseSrc * bsrc);
+ static guint gst_directsound_src_read (GstAudioSrc * asrc, gpointer data,
+ guint length);
+ static void gst_directsound_src_dispose (GObject * object);
+ static void gst_directsound_src_do_init (GType type);
+ static guint gst_directsound_src_delay (GstAudioSrc * asrc);
+ static GstStaticPadTemplate directsound_src_src_factory =
+ GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, "
+ "signed = (boolean) { TRUE, FALSE }, " "width = (int) 16, "
+ "depth = (int) 16, " "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, 2 ]; " "audio/x-raw-int, "
+ "signed = (boolean) { TRUE, FALSE }, " "width = (int) 8, "
+ "depth = (int) 8, " "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, 2 ]"));
+ static void
+gst_directsound_src_do_init (GType type)
+{
+ GST_DEBUG_CATEGORY_INIT (directsoundsrc_debug, "directsoundsrc", 0,
+ "DirectSound Src");
+ } GST_BOILERPLATE_FULL (GstDirectSoundSrc, gst_directsound_src,
+ GstAudioSrc, GST_TYPE_AUDIO_SRC, gst_directsound_src_do_init);
+ static void
+gst_directsound_src_dispose (GObject * object)
+{
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+ } static void
+
+gst_directsound_src_finalise (GObject * object)
+{
+ GstDirectSoundSrc * dsoundsrc = GST_DIRECTSOUND_SRC (object);
+ g_mutex_free (dsoundsrc->dsound_lock);
+ } static void
+
+gst_directsound_src_base_init (gpointer g_class)
+{
+ GstElementClass * element_class = GST_ELEMENT_CLASS (g_class);
+ GST_DEBUG ("initializing directsoundsrc base\n");
+ gst_element_class_set_details (element_class, &gst_directsound_src_details);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&directsound_src_src_factory));
+ }
+
+/* initialize the plugin's class */
+static void
+gst_directsound_src_class_init (GstDirectSoundSrcClass * klass)
+{
+ GObjectClass * gobject_class;
+ GstElementClass * gstelement_class;
+ GstBaseSrcClass * gstbasesrc_class;
+ GstBaseAudioSrcClass * gstbaseaudiosrc_class;
+ GstAudioSrcClass * gstaudiosrc_class;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstbasesrc_class = (GstBaseSrcClass *) klass;
+ gstbaseaudiosrc_class = (GstBaseAudioSrcClass *) klass;
+ gstaudiosrc_class = (GstAudioSrcClass *) klass;
+ GST_DEBUG ("initializing directsoundsrc class\n");
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_directsound_src_finalise);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_directsound_src_dispose);
+ gobject_class->get_property =
+ GST_DEBUG_FUNCPTR (gst_directsound_src_get_property);
+ gobject_class->set_property =
+ GST_DEBUG_FUNCPTR (gst_directsound_src_set_property);
+ gstbasesrc_class->get_caps =
+ GST_DEBUG_FUNCPTR (gst_directsound_src_getcaps);
+ gstaudiosrc_class->open = GST_DEBUG_FUNCPTR (gst_directsound_src_open);
+ gstaudiosrc_class->close = GST_DEBUG_FUNCPTR (gst_directsound_src_close);
+ gstaudiosrc_class->read = GST_DEBUG_FUNCPTR (gst_directsound_src_read);
+ gstaudiosrc_class->prepare = GST_DEBUG_FUNCPTR (gst_directsound_src_prepare);
+ gstaudiosrc_class->unprepare =
+ GST_DEBUG_FUNCPTR (gst_directsound_src_unprepare);
+ gstaudiosrc_class->delay = GST_DEBUG_FUNCPTR (gst_directsound_src_delay);
+ gstaudiosrc_class->reset = GST_DEBUG_FUNCPTR (gst_directsound_src_reset);
+ } static GstCaps *
+
+gst_directsound_src_getcaps (GstBaseSrc * bsrc)
+{
+ GstDirectSoundSrc * dsoundsrc;
+ GstCaps * caps = NULL;
+ GST_DEBUG ("get caps\n");
+ dsoundsrc = GST_DIRECTSOUND_SRC (bsrc);
+ caps = gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD
+ (bsrc)));
+ return caps;
+ }
+
+ static void
+gst_directsound_src_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+
+ // GstDirectSoundSrc *src = GST_DIRECTSOUND_SRC (object);
+ GST_DEBUG ("set property\n");
+ switch (prop_id)
+ {
+
+#if 0
+ /* FIXME */
+ case PROP_DEVICE:
+ src->device = g_value_get_uint (value);
+ break;
+
+#endif /* */
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+ }
+
+ static void
+gst_directsound_src_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+
+#if 0
+ GstDirectSoundSrc * src = GST_DIRECTSOUND_SRC (object);
+
+#endif /* */
+ GST_DEBUG ("get property\n");
+ switch (prop_id) {
+
+#if 0
+ /* FIXME */
+ case PROP_DEVICE:
+ g_value_set_uint (value, src->device);
+ break;
+
+#endif /* */
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+ }
+
+
+/* initialize the new element
+ * instantiate pads and add them to element
+ * set functions
+ * initialize structure
+ */
+static void
+gst_directsound_src_init (GstDirectSoundSrc * src,
+ GstDirectSoundSrcClass * gclass)
+{
+ GST_DEBUG ("initializing directsoundsrc\n");
+ src->dsound_lock = g_mutex_new ();
+ } static gboolean
+
+gst_directsound_src_open (GstAudioSrc * asrc)
+{
+ GstDirectSoundSrc * dsoundsrc;
+ HRESULT hRes; /* Result for windows functions */
+ GST_DEBUG ("initializing directsoundsrc\n");
+ dsoundsrc = GST_DIRECTSOUND_SRC (asrc);
+
+ /* Open dsound.dll */
+ dsoundsrc->DSoundDLL = LoadLibrary ("dsound.dll");
+ if (!dsoundsrc->DSoundDLL) {
+ goto dsound_open;
+ }
+
+ /* Building the DLL Calls */
+ pDSoundCaptureCreate =
+ (void *) GetProcAddress (dsoundsrc->DSoundDLL,
+ TEXT ("DirectSoundCaptureCreate"));
+
+ /* If everything is not ok */
+ if (!pDSoundCaptureCreate) {
+ goto capture_function;
+ }
+
+ /* FIXME: add here device selection */
+ /* Create capture object */
+ hRes = pDSoundCaptureCreate (NULL, &dsoundsrc->pDSC, NULL);
+ if (FAILED (hRes)) {
+ goto capture_object;
+ }
+ return TRUE;
+ capture_function: {
+ FreeLibrary (dsoundsrc->DSoundDLL);
+ GST_ELEMENT_ERROR (dsoundsrc, RESOURCE, OPEN_READ,
+ ("Unable to get capturecreate function"), (NULL));
+ return FALSE;
+ }
+ capture_object: {
+ FreeLibrary (dsoundsrc->DSoundDLL);
+ GST_ELEMENT_ERROR (dsoundsrc, RESOURCE, OPEN_READ,
+ ("Unable to create capture object"), (NULL));
+ return FALSE;
+ }
+ dsound_open: {
+ GST_ELEMENT_ERROR (dsoundsrc, RESOURCE, OPEN_READ,
+ ("Unable to open dsound.dll"), (NULL));
+ return FALSE;
+ }
+ }
+
+ static gboolean
+gst_directsound_src_close (GstAudioSrc * asrc)
+{
+ GstDirectSoundSrc * dsoundsrc;
+ HRESULT hRes; /* Result for windows functions */
+ GST_DEBUG ("initializing directsoundsrc\n");
+ dsoundsrc = GST_DIRECTSOUND_SRC (asrc);
+
+ /* Release capture handler */
+ hRes = IDirectSoundCapture_Release (dsoundsrc->pDSC);
+
+ /* Close library */
+ FreeLibrary (dsoundsrc->DSoundDLL);
+ return TRUE;
+ }
+
+ static gboolean
+gst_directsound_src_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
+{
+ GstDirectSoundSrc * dsoundsrc;
+ WAVEFORMATEX wfx; /* Wave format structure */
+ HRESULT hRes; /* Result for windows functions */
+ DSCBUFFERDESC descSecondary; /* Capturebuffer decsiption */
+ int fmt = 0; /* audio format */
+ dsoundsrc = GST_DIRECTSOUND_SRC (asrc);
+ GST_DEBUG ("initializing directsoundsrc\n");
+
+ /* Define buffer */
+ memset (&wfx, 0, sizeof (WAVEFORMATEX));
+ wfx.wFormatTag = WAVE_FORMAT_PCM; /* should be WAVE_FORMAT_PCM */
+ wfx.nChannels = spec->channels;
+ wfx.nSamplesPerSec = spec->rate; /* 8000|11025|22050|44100 */
+ wfx.wBitsPerSample = spec->width; // 8|16;
+ wfx.nBlockAlign = wfx.nChannels * (wfx.wBitsPerSample / 8);
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
+ wfx.cbSize = 0; /* This size is allways for PCM-format */
+
+ /* 1 or 2 Channels etc...
+ FIXME: Never really tested. Is this ok?
+ */
+ if (spec->width == 16 && spec->channels == 1) {
+ spec->format = GST_S16_LE;
+ } else if (spec->width == 16 && spec->channels == 2) {
+ spec->format = GST_U16_LE;
+ } else if (spec->width == 8 && spec->channels == 1) {
+ spec->format = GST_S8;
+ } else if (spec->width == 8 && spec->channels == 2) {
+ spec->format = GST_U8;
+ }
+
+ /* Set the buffer size to two seconds.
+ This should never reached.
+ */
+ dsoundsrc->buffer_size = wfx.nAvgBytesPerSec * 2;
+
+ //notifysize * 16; //spec->width; /*original 16*/
+ GST_DEBUG ("Buffer size: %d", dsoundsrc->buffer_size);
+
+ /* Init secondary buffer desciption */
+ memset (&descSecondary, 0, sizeof (DSCBUFFERDESC));
+ descSecondary.dwSize = sizeof (DSCBUFFERDESC);
+ descSecondary.dwFlags = 0;
+ descSecondary.dwReserved = 0;
+
+ /* This is not primary buffer so have to set size */
+ descSecondary.dwBufferBytes = dsoundsrc->buffer_size;
+ descSecondary.lpwfxFormat = &wfx;
+
+ /* Create buffer */
+ hRes =
+ IDirectSoundCapture_CreateCaptureBuffer (dsoundsrc->pDSC, &descSecondary,
+ &dsoundsrc->pDSBSecondary, NULL);
+ if (hRes != DS_OK) {
+ goto capture_buffer;
+ }
+ spec->channels = wfx.nChannels;
+ spec->rate = wfx.nSamplesPerSec;
+ spec->bytes_per_sample = (spec->width / 8) * spec->channels;
+ dsoundsrc->bytes_per_sample = spec->bytes_per_sample;
+ GST_DEBUG ("latency time: %llu - buffer time: %llu", spec->latency_time,
+ spec->buffer_time);
+
+ /* Buffer-time should be allways more than 2*latency */
+ if (spec->buffer_time < spec->latency_time * 2) {
+ spec->buffer_time = spec->latency_time * 2;
+ GST_WARNING ("buffer-time was less than latency");
+ }
+
+ /* Save the times */
+ dsoundsrc->buffer_time = spec->buffer_time;
+ dsoundsrc->latency_time = spec->latency_time;
+ dsoundsrc->latency_size =
+ (gint) wfx.nAvgBytesPerSec * dsoundsrc->latency_time / 1000000.0;
+ spec->segsize =
+ (guint) (((double) spec->buffer_time / 1000000.0) * wfx.nAvgBytesPerSec);
+
+ /* just in case */
+ if (spec->segsize < 1)
+ spec->segsize = 1;
+ spec->segtotal = spec->width * (wfx.nAvgBytesPerSec / spec->segsize);
+ GST_DEBUG ("bytes/sec: %d, buffer size: %d, segsize: %d, segtotal: %d",
+ wfx.nAvgBytesPerSec, dsoundsrc->buffer_size, spec->segsize,
+ spec->segtotal);
+ spec->silence_sample[0] = 0;
+ spec->silence_sample[1] = 0;
+ spec->silence_sample[2] = 0;
+ spec->silence_sample[3] = 0;
+ if (spec->width != 16 && spec->width != 8)
+ goto dodgy_width;
+
+ /* Not readed anything yet */
+ dsoundsrc->current_circular_offset = 0;
+ GST_DEBUG ("GstRingBufferSpec->channels: %d, GstRingBufferSpec->rate: %d, \
+GstRingBufferSpec->bytes_per_sample: %d\n\
+WAVEFORMATEX.nSamplesPerSec: %ld, WAVEFORMATEX.wBitsPerSample: %d, \
+WAVEFORMATEX.nBlockAlign: %d, WAVEFORMATEX.nAvgBytesPerSec: %ld\n", spec->channels, spec->rate, spec->bytes_per_sample, wfx.nSamplesPerSec, wfx.wBitsPerSample, wfx.nBlockAlign, wfx.nAvgBytesPerSec);
+ return TRUE;
+ wrong_format: {
+ GST_ELEMENT_ERROR (dsoundsrc, RESOURCE, OPEN_READ,
+ ("Unable to get format %d", spec->format), (NULL));
+ return FALSE;
+ }
+ capture_buffer: {
+ GST_ELEMENT_ERROR (dsoundsrc, RESOURCE, OPEN_READ,
+ ("Unable to create capturebuffer"), (NULL));
+ return FALSE;
+ }
+ dodgy_width: {
+ GST_ELEMENT_ERROR (dsoundsrc, RESOURCE, OPEN_READ,
+ ("Unexpected width %d", spec->width), (NULL));
+ return FALSE;
+ }
+ }
+
+ static gboolean
+gst_directsound_src_unprepare (GstAudioSrc * asrc)
+{
+ GstDirectSoundSrc * dsoundsrc;
+ HRESULT hRes; /* Result for windows functions */
+
+ /* Resets */
+ GST_DEBUG ("unpreparing directsoundsrc");
+ dsoundsrc = GST_DIRECTSOUND_SRC (asrc);
+
+ /* Stop capturing */
+ hRes = IDirectSoundCaptureBuffer_Stop (dsoundsrc->pDSBSecondary);
+
+ /* Release buffer */
+ hRes = IDirectSoundCaptureBuffer_Release (dsoundsrc->pDSBSecondary);
+ return TRUE;
+ }
+
+
+/*
+return number of readed bytes */
+static guint
+gst_directsound_src_read (GstAudioSrc * asrc, gpointer data, guint length)
+{
+ GstDirectSoundSrc * dsoundsrc;
+ HRESULT hRes; /* Result for windows functions */
+ DWORD dwCurrentCaptureCursor = 0;
+ DWORD dwBufferSize = 0;
+ LPVOID pLockedBuffer1 = NULL;
+ LPVOID pLockedBuffer2 = NULL;
+ DWORD dwSizeBuffer1 = 0;
+ DWORD dwSizeBuffer2 = 0;
+ DWORD dwStatus = 0;
+ GST_DEBUG ("reading directsoundsrc\n");
+ dsoundsrc = GST_DIRECTSOUND_SRC (asrc);
+ GST_DSOUND_LOCK (dsoundsrc);
+
+ /* Get current buffer status */
+ hRes =
+ IDirectSoundCaptureBuffer_GetStatus (dsoundsrc->pDSBSecondary,
+ &dwStatus);
+
+ /* Starting capturing if not allready */
+ if (!(dwStatus & DSCBSTATUS_CAPTURING)) {
+ hRes =
+ IDirectSoundCaptureBuffer_Start (dsoundsrc->pDSBSecondary,
+ DSCBSTART_LOOPING);
+
+ // Sleep (dsoundsrc->latency_time/1000);
+ GST_DEBUG ("capture started");
+ }
+
+ // calculate_buffersize:
+ while (length > dwBufferSize) {
+ Sleep (dsoundsrc->latency_time / 1000);
+ hRes =
+ IDirectSoundCaptureBuffer_GetCurrentPosition (dsoundsrc->pDSBSecondary,
+ &dwCurrentCaptureCursor, NULL);
+
+ /* calculate the buffer */
+ if (dwCurrentCaptureCursor < dsoundsrc->current_circular_offset) {
+ dwBufferSize = dsoundsrc->buffer_size -
+ (dsoundsrc->current_circular_offset - dwCurrentCaptureCursor);
+ } else {
+ dwBufferSize =
+ dwCurrentCaptureCursor - dsoundsrc->current_circular_offset;
+ }
+ } // while (...
+
+ /* Lock the buffer */
+ hRes =
+ IDirectSoundCaptureBuffer_Lock (dsoundsrc->pDSBSecondary,
+ dsoundsrc->current_circular_offset, length, &pLockedBuffer1,
+ &dwSizeBuffer1, &pLockedBuffer2, &dwSizeBuffer2, 0L);
+
+ /* Copy buffer data to another buffer */
+ if (hRes == DS_OK) {
+ memcpy (data, pLockedBuffer1, dwSizeBuffer1);
+ }
+
+ /* ...and if something is in another buffer */
+ if (pLockedBuffer2 != NULL) {
+ memcpy ((data + dwSizeBuffer1), pLockedBuffer2, dwSizeBuffer2);
+ }
+ dsoundsrc->current_circular_offset += dwSizeBuffer1 + dwSizeBuffer2;
+ dsoundsrc->current_circular_offset %= dsoundsrc->buffer_size;
+ IDirectSoundCaptureBuffer_Unlock (dsoundsrc->pDSBSecondary, pLockedBuffer1,
+ dwSizeBuffer1, pLockedBuffer2, dwSizeBuffer2);
+ GST_DSOUND_UNLOCK (dsoundsrc);
+
+ /* return length (readed data size in bytes) */
+ return length;
+ }
+
+ static guint
+gst_directsound_src_delay (GstAudioSrc * asrc)
+{
+ GstDirectSoundSrc * dsoundsrc;
+ HRESULT hRes;
+ DWORD dwCurrentCaptureCursor;
+ DWORD dwBytesInQueue = 0;
+ gint nNbSamplesInQueue = 0;
+ GST_DEBUG ("Delay\n");
+ dsoundsrc = GST_DIRECTSOUND_SRC (asrc);
+
+ /* evaluate the number of samples in queue in the circular buffer */
+ hRes =
+ IDirectSoundCaptureBuffer_GetCurrentPosition (dsoundsrc->pDSBSecondary,
+ &dwCurrentCaptureCursor, NULL);
+
+ /* FIXME: Check is this calculated right */
+ if (hRes == S_OK) {
+ if (dwCurrentCaptureCursor < dsoundsrc->current_circular_offset) {
+ dwBytesInQueue =
+ dsoundsrc->buffer_size - (dsoundsrc->current_circular_offset -
+ dwCurrentCaptureCursor);
+ } else {
+ dwBytesInQueue =
+ dwCurrentCaptureCursor - dsoundsrc->current_circular_offset;
+ }
+ nNbSamplesInQueue = dwBytesInQueue / dsoundsrc->bytes_per_sample;
+ }
+ return nNbSamplesInQueue;
+ }
+
+ static void
+gst_directsound_src_reset (GstAudioSrc * asrc)
+{
+ GstDirectSoundSrc * dsoundsrc;
+ LPVOID pLockedBuffer = NULL;
+ DWORD dwSizeBuffer = 0;
+ GST_DEBUG ("reset directsoundsrc\n");
+ dsoundsrc = GST_DIRECTSOUND_SRC (asrc);
+
+#if 0
+ IDirectSoundCaptureBuffer_Stop (dsoundsrc->pDSBSecondary);
+
+#endif /* */
+ GST_DSOUND_LOCK (dsoundsrc);
+ if (dsoundsrc->pDSBSecondary) {
+
+ /*stop capturing */
+ HRESULT hRes =
+ IDirectSoundCaptureBuffer_Stop (dsoundsrc->pDSBSecondary);
+
+ /*reset position */
+ /* hRes = IDirectSoundCaptureBuffer_SetCurrentPosition (dsoundsrc->pDSBSecondary, 0); */
+
+ /*reset the buffer */
+ hRes =
+ IDirectSoundCaptureBuffer_Lock (dsoundsrc->pDSBSecondary,
+ dsoundsrc->current_circular_offset, dsoundsrc->buffer_size,
+ pLockedBuffer, &dwSizeBuffer, NULL, NULL, 0L);
+ if (SUCCEEDED (hRes)) {
+ memset (pLockedBuffer, 0, dwSizeBuffer);
+ hRes =
+ IDirectSoundCaptureBuffer_Unlock (dsoundsrc->pDSBSecondary,
+ pLockedBuffer, dwSizeBuffer, NULL, 0);
+ }
+ dsoundsrc->current_circular_offset = 0;
+ }
+ GST_DSOUND_UNLOCK (dsoundsrc);
+ }
+
+
diff --git a/sys/directsound/gstdirectsoundsrc.h b/sys/directsound/gstdirectsoundsrc.h
new file mode 100644
index 00000000..2d164fc8
--- /dev/null
+++ b/sys/directsound/gstdirectsoundsrc.h
@@ -0,0 +1,112 @@
+/*
+ * GStreamer
+ * Copyright 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright 2005 Sébastien Moutte <sebastien@moutte.net>
+ * Copyright 2006 Joni Valtanen <joni.valtanen@movial.fi>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Alternatively, the contents of this file may be used under the
+ * GNU Lesser General Public License Version 2.1 (the "LGPL"), in
+ * which case the following provisions apply instead of the ones
+ * mentioned above:
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_DIRECTSOUNDSRC_H__
+#define __GST_DIRECTSOUNDSRC_H__
+
+#include <gst/gst.h>
+#include <gst/audio/gstaudiosrc.h>
+
+#include <windows.h>
+#include <dsound.h>
+
+/* add here some headers if needed */
+
+
+G_BEGIN_DECLS
+
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_DIRECTSOUND_SRC (gst_directsound_src_get_type())
+#define GST_DIRECTSOUND_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DIRECTSOUND_SRC,GstDirectSoundSrc))
+#define GST_DIRECTSOUND_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DIRECTSOUND_SRC,GstDirectSoundSrcClass))
+#define GST_IS_DIRECTSOUND_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DIRECTSOUND_SRC))
+#define GST_IS_DIRECTSOUND_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DIRECTSOUND_SRC))
+
+typedef struct _GstDirectSoundSrc GstDirectSoundSrc;
+typedef struct _GstDirectSoundSrcClass GstDirectSoundSrcClass;
+
+#define GST_DSOUND_LOCK(obj) (g_mutex_lock (obj->dsound_lock))
+#define GST_DSOUND_UNLOCK(obj) (g_mutex_unlock (obj->dsound_lock))
+
+struct _GstDirectSoundSrc
+{
+
+ GstAudioSrc src;
+
+ HINSTANCE DSoundDLL; /* DLL instance */
+ LPDIRECTSOUNDCAPTURE pDSC; /* DirectSoundCapture*/
+ LPDIRECTSOUNDCAPTUREBUFFER pDSBSecondary; /*Secondaty capturebuffer*/
+ DWORD current_circular_offset;
+
+ HANDLE rghEvent;
+ DWORD notifysize;
+
+ guint buffer_size;
+ guint latency_size;
+ guint bytes_per_sample;
+
+ guint buffer_time;
+ guint latency_time;
+
+
+#if 0
+ guint device;
+#endif
+
+ GMutex *dsound_lock;
+
+};
+
+struct _GstDirectSoundSrcClass
+{
+ GstAudioSrcClass parent_class;
+};
+
+GType gst_directsound_src_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_DIRECTSOUNDSRC_H__ */
diff --git a/sys/dshowsrcwrapper/Makefile.am b/sys/dshowsrcwrapper/Makefile.am
index 74bf83ed..de78c531 100755
--- a/sys/dshowsrcwrapper/Makefile.am
+++ b/sys/dshowsrcwrapper/Makefile.am
@@ -8,7 +8,6 @@ EXTRA_DIST = \
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
index ed27d631..4b090346 100755
--- a/sys/dshowsrcwrapper/gstdshow.cpp
+++ b/sys/dshowsrcwrapper/gstdshow.cpp
@@ -22,44 +22,6 @@
#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)
{
diff --git a/sys/dshowsrcwrapper/gstdshow.h b/sys/dshowsrcwrapper/gstdshow.h
index ec360b32..e71ca789 100755
--- a/sys/dshowsrcwrapper/gstdshow.h
+++ b/sys/dshowsrcwrapper/gstdshow.h
@@ -43,7 +43,7 @@ extern "C" {
#endif
/* register fake filters as COM object and as Direct Show filters in the registry */
-HRESULT gst_dshow_register_fakefilters ();
+//HRESULT gst_dshow_register_fakefilters ();
/* free memory of the input pin mediatype */
void gst_dshow_free_pin_mediatype (gpointer pt);
diff --git a/sys/dshowsrcwrapper/gstdshowaudiosrc.cpp b/sys/dshowsrcwrapper/gstdshowaudiosrc.cpp
index c213aae5..a0e2d78c 100755
--- a/sys/dshowsrcwrapper/gstdshowaudiosrc.cpp
+++ b/sys/dshowsrcwrapper/gstdshowaudiosrc.cpp
@@ -95,7 +95,7 @@ static void gst_dshowaudiosrc_reset (GstAudioSrc * asrc);
static GstCaps *gst_dshowaudiosrc_getcaps_from_streamcaps (GstDshowAudioSrc *
src, IPin * pin, IAMStreamConfig * streamcaps);
static gboolean gst_dshowaudiosrc_push_buffer (byte * buffer, long size,
- byte * src_object, UINT64 start, UINT64 stop);
+ gpointer src_object, UINT64 start, UINT64 stop);
static void
gst_dshowaudiosrc_init_interfaces (GType type)
@@ -540,13 +540,8 @@ gst_dshowaudiosrc_open (GstAudioSrc * asrc)
goto error;
}
- 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;
- }
+ src->dshow_fakesink = new CDshowFakeSink;
+ src->dshow_fakesink->AddRef();
hres = src->filter_graph->AddFilter(src->audio_cap_filter, L"capture");
if (hres != S_OK) {
@@ -587,7 +582,6 @@ static gboolean
gst_dshowaudiosrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
{
HRESULT hres;
- IGstDshowInterface *srcinterface = NULL;
IPin *input_pin = NULL;
GstDshowAudioSrc *src = GST_DSHOWAUDIOSRC (asrc);
@@ -613,20 +607,9 @@ gst_dshowaudiosrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
if (type) {
pin_mediatype = (GstCapturePinMediaType *) type->data;
- 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)",
- hres);
- goto error;
- }
-
- srcinterface->gst_set_media_type(pin_mediatype->mediatype);
- srcinterface->gst_set_buffer_callback(
- (push_buffer_func) gst_dshowaudiosrc_push_buffer, (byte *) src);
-
- if (srcinterface)
- srcinterface->Release();
+ src->dshow_fakesink->gst_set_media_type (pin_mediatype->mediatype);
+ src->dshow_fakesink->gst_set_buffer_callback(
+ (push_buffer_func) gst_dshowaudiosrc_push_buffer, src);
gst_dshow_get_pin_from_filter (src->dshow_fakesink, PINDIR_INPUT,
&input_pin);
@@ -656,9 +639,6 @@ gst_dshowaudiosrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
return TRUE;
error:
- if (srcinterface)
- srcinterface->Release();
-
return FALSE;
}
@@ -844,7 +824,7 @@ gst_dshowaudiosrc_getcaps_from_streamcaps (GstDshowAudioSrc * src, IPin * pin,
}
static gboolean
-gst_dshowaudiosrc_push_buffer (byte * buffer, long size, byte * src_object,
+gst_dshowaudiosrc_push_buffer (byte * buffer, long size, gpointer src_object,
UINT64 start, UINT64 stop)
{
GstDshowAudioSrc *src = GST_DSHOWAUDIOSRC (src_object);
diff --git a/sys/dshowsrcwrapper/gstdshowaudiosrc.h b/sys/dshowsrcwrapper/gstdshowaudiosrc.h
index b8147011..d5cfe6e0 100755
--- a/sys/dshowsrcwrapper/gstdshowaudiosrc.h
+++ b/sys/dshowsrcwrapper/gstdshowaudiosrc.h
@@ -28,7 +28,7 @@
#include <gst/interfaces/propertyprobe.h>
#include "gstdshow.h"
-#include "gstdshowinterface.h"
+#include "gstdshowfakesink.h"
G_BEGIN_DECLS
#define GST_TYPE_DSHOWAUDIOSRC (gst_dshowaudiosrc_get_type())
@@ -59,7 +59,7 @@ struct _GstDshowAudioSrc
IBaseFilter *audio_cap_filter;
/* dshow fakesink filter */
- IBaseFilter *dshow_fakesink;
+ CDshowFakeSink *dshow_fakesink;
/* graph manager interfaces */
IMediaFilter *media_filter;
diff --git a/sys/dshowsrcwrapper/gstdshowfakesink.cpp b/sys/dshowsrcwrapper/gstdshowfakesink.cpp
index afc0a5ef..6c0c74dc 100755
--- a/sys/dshowsrcwrapper/gstdshowfakesink.cpp
+++ b/sys/dshowsrcwrapper/gstdshowfakesink.cpp
@@ -21,87 +21,30 @@
#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()
+CDshowFakeSink::CDshowFakeSink() :
+ m_hres(S_OK),
+ m_callback(NULL),
+ m_data(NULL),
+ CBaseRenderer(CLSID_DshowFakeSink, "DshowFakeSink", NULL, &m_hres)
{
- 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)
+STDMETHODIMP CDshowFakeSink::gst_set_buffer_callback (push_buffer_func push, gpointer 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 != NULL) {
if (*pmt == m_MediaType)
return S_OK;
}
diff --git a/sys/dshowsrcwrapper/gstdshowfakesink.h b/sys/dshowsrcwrapper/gstdshowfakesink.h
index 7f419b27..51291c69 100755
--- a/sys/dshowsrcwrapper/gstdshowfakesink.h
+++ b/sys/dshowsrcwrapper/gstdshowfakesink.h
@@ -19,32 +19,34 @@
* Boston, MA 02111-1307, USA.
*/
-#include "gstdshowinterface.h"
+#ifndef __GST_DHOW_FAKESINK_H__
+#define __GST_DHOW_FAKESINK_H__
-class CDshowFakeSink : public CBaseRenderer,
- public IGstDshowInterface
+#include "gstdshow.h"
+
+//{6A780808-9725-4d0b-8695-A4DD8D210773}
+static const GUID CLSID_DshowFakeSink =
+ { 0x6a780808, 0x9725, 0x4d0b, { 0x86, 0x95, 0xa4, 0xdd, 0x8d, 0x21, 0x7, 0x73 } };
+
+typedef bool (*push_buffer_func) (byte *buffer, long size, gpointer src_object, UINT64 start, UINT64 stop);
+
+class CDshowFakeSink : public CBaseRenderer
{
public:
CDshowFakeSink ();
- virtual ~CDshowFakeSink ();
-
- static CUnknown * WINAPI CreateInstance (LPUNKNOWN pUnk, HRESULT *pHr);
+ virtual ~CDshowFakeSink () {}
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);
+ STDMETHOD (gst_set_buffer_callback) (push_buffer_func push, gpointer data);
protected:
HRESULT m_hres;
CMediaType m_MediaType;
push_buffer_func m_callback;
- byte *m_data;
-}; \ No newline at end of file
+ gpointer m_data;
+};
+
+#endif /* __GST_DSHOW_FAKESINK_H__ */
diff --git a/sys/dshowsrcwrapper/gstdshowinterface.h b/sys/dshowsrcwrapper/gstdshowinterface.h
deleted file mode 100755
index 68328b95..00000000
--- a/sys/dshowsrcwrapper/gstdshowinterface.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/* 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.cpp b/sys/dshowsrcwrapper/gstdshowsrcwrapper.cpp
index 1e9a8aa2..9acfc344 100755
--- a/sys/dshowsrcwrapper/gstdshowsrcwrapper.cpp
+++ b/sys/dshowsrcwrapper/gstdshowsrcwrapper.cpp
@@ -26,28 +26,11 @@
#include "gstdshowaudiosrc.h"
#include "gstdshowvideosrc.h"
-const GUID CLSID_GstreamerSrcFilter
- =
- { 0x6a780808, 0x9725, 0x4d0b, {0x86, 0x95, 0xa4, 0xdd, 0x8d, 0x21, 0x7,
- 0x73} };
-
-const GUID IID_IGstSrcInterface =
- { 0x542c0a24, 0x8bd1, 0x46cb, {0xaa, 0x57, 0x3e, 0x46, 0xd0, 0x6, 0xd2,
- 0xf3} };
-
static gboolean
plugin_init (GstPlugin * plugin)
{
- /* register fake filters */
- 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,
- GST_TYPE_DSHOWAUDIOSRC) ||
+ GST_RANK_NONE, GST_TYPE_DSHOWAUDIOSRC) ||
!gst_element_register (plugin, "dshowvideosrc",
GST_RANK_NONE, GST_TYPE_DSHOWVIDEOSRC))
return FALSE;
diff --git a/sys/dshowsrcwrapper/gstdshowvideosrc.cpp b/sys/dshowsrcwrapper/gstdshowvideosrc.cpp
index 67e70d96..14654f60 100755
--- a/sys/dshowsrcwrapper/gstdshowvideosrc.cpp
+++ b/sys/dshowsrcwrapper/gstdshowvideosrc.cpp
@@ -111,7 +111,7 @@ static GstFlowReturn gst_dshowvideosrc_create (GstPushSrc * psrc,
static GstCaps *gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc *
src, IPin * pin, IAMStreamConfig * streamcaps);
static gboolean gst_dshowvideosrc_push_buffer (byte * buffer, long size,
- byte * src_object, UINT64 start, UINT64 stop);
+ gpointer src_object, UINT64 start, UINT64 stop);
static void
gst_dshowvideosrc_init_interfaces (GType type)
@@ -614,14 +614,8 @@ gst_dshowvideosrc_start (GstBaseSrc * bsrc)
goto error;
}
- 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=0x%x)",
- hres);
- goto error;
- }
+ src->dshow_fakesink = new CDshowFakeSink;
+ src->dshow_fakesink->AddRef();
hres = src->filter_graph->AddFilter(src->video_cap_filter, L"capture");
if (hres != S_OK) {
@@ -661,7 +655,6 @@ static gboolean
gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
{
HRESULT hres;
- IGstDshowInterface *srcinterface = NULL;
IPin *input_pin = NULL;
GstDshowVideoSrc *src = GST_DSHOWVIDEOSRC (bsrc);
GstStructure *s = gst_caps_get_structure (caps, 0);
@@ -689,22 +682,9 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
if (type) {
pin_mediatype = (GstCapturePinMediaType *) type->data;
- hres = src->dshow_fakesink->QueryInterface(
- IID_IGstDshowInterface, (LPVOID *) &srcinterface);
-
- if (hres != S_OK || !srcinterface) {
- GST_CAT_ERROR (dshowvideosrc_debug,
- "Can't get IGstDshowInterface interface from our dshow fakesink filter (error=%d)",
- hres);
- goto error;
- }
-
- srcinterface->gst_set_media_type(pin_mediatype->mediatype);
- srcinterface->gst_set_buffer_callback(
- (push_buffer_func) gst_dshowvideosrc_push_buffer, (byte *) src);
-
- if (srcinterface)
- srcinterface->Release();
+ src->dshow_fakesink->gst_set_media_type (pin_mediatype->mediatype);
+ src->dshow_fakesink->gst_set_buffer_callback(
+ (push_buffer_func) gst_dshowvideosrc_push_buffer, src);
gst_dshow_get_pin_from_filter (src->dshow_fakesink, PINDIR_INPUT,
&input_pin);
@@ -746,9 +726,6 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
return TRUE;
error:
- if (srcinterface)
- srcinterface->Release();
-
return FALSE;
}
@@ -992,7 +969,7 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
}
static gboolean
-gst_dshowvideosrc_push_buffer (byte * buffer, long size, byte * src_object,
+gst_dshowvideosrc_push_buffer (byte * buffer, long size, gpointer src_object,
UINT64 start, UINT64 stop)
{
GstDshowVideoSrc *src = GST_DSHOWVIDEOSRC (src_object);
diff --git a/sys/dshowsrcwrapper/gstdshowvideosrc.h b/sys/dshowsrcwrapper/gstdshowvideosrc.h
index b7bfbb19..bf94e61f 100755
--- a/sys/dshowsrcwrapper/gstdshowvideosrc.h
+++ b/sys/dshowsrcwrapper/gstdshowvideosrc.h
@@ -28,7 +28,7 @@
#include <gst/interfaces/propertyprobe.h>
#include "gstdshow.h"
-#include "gstdshowinterface.h"
+#include "gstdshowfakesink.h"
// 30323449-0000-0010-8000-00AA00389B71 MEDIASUBTYPE_I420
DEFINE_GUID(MEDIASUBTYPE_I420, 0x30323449, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
@@ -62,7 +62,7 @@ struct _GstDshowVideoSrc
IBaseFilter *video_cap_filter;
/* dshow sink filter */
- IBaseFilter *dshow_fakesink;
+ CDshowFakeSink *dshow_fakesink;
/* graph manager interfaces */
IMediaFilter *media_filter;
diff --git a/sys/dshowsrcwrapper/libgstdshow.def b/sys/dshowsrcwrapper/libgstdshow.def
deleted file mode 100755
index ee8586c9..00000000
--- a/sys/dshowsrcwrapper/libgstdshow.def
+++ /dev/null
@@ -1,8 +0,0 @@
-EXPORTS
- DllMain PRIVATE
- DllGetClassObject PRIVATE
- DllCanUnloadNow PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
-
-