From 5edd64eec6376aab7d98406b804f056e67650a31 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Mon, 23 Jan 2012 08:04:20 -0300 Subject: [PATCH 01/37] camerabin2: Removing solved TODO and fixing a typo --- gst/camerabin2/gstcamerabin2.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gst/camerabin2/gstcamerabin2.c b/gst/camerabin2/gstcamerabin2.c index ff9f13423a..7d5f8f4c78 100644 --- a/gst/camerabin2/gstcamerabin2.c +++ b/gst/camerabin2/gstcamerabin2.c @@ -816,15 +816,13 @@ gst_camera_bin_class_init (GstCameraBin2Class * klass) /* TODO * Review before stable - * - We use a profile for video recording properties and here we have - * elements for image capture. This is slightly inconsistent. * - One problem with using encodebin for images here is how jifmux * autoplugging works. We need to give it a higher rank and fix its * caps (it has image/jpeg on sink and src pads). Preliminary tests * show that jifmux is picked if image/jpeg is the caps of a container * profile. So this could work. * - There seems to be a problem with encodebin for images currently as - * it autoplugs a videorate that ony starts outputing buffers after + * it autoplugs a videorate that only starts outputing buffers after * getting the 2nd buffer. */ g_object_class_install_property (object_class, PROP_IMAGE_ENCODING_PROFILE, From f4d6e03b9b36e76d57745438178d3ddacddb9247 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Fri, 27 Jan 2012 07:36:19 -0300 Subject: [PATCH 02/37] camerabin: Add viewfinder colorspace conversion to default flags This make the default settings more likely to work. If needed, one can optimize by disabling conversions with the flags. --- gst/camerabin/gstcamerabin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index be13b65d7c..c9f342bedc 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -210,9 +210,10 @@ static guint camerabin_signals[LAST_SIGNAL]; #define DEFAULT_FLAGS GST_CAMERABIN_FLAG_SOURCE_RESIZE | \ GST_CAMERABIN_FLAG_VIEWFINDER_SCALE | \ - GST_CAMERABIN_FLAG_AUDIO_CONVERSION | \ + GST_CAMERABIN_FLAG_VIEWFINDER_COLOR_CONVERSION | \ GST_CAMERABIN_FLAG_IMAGE_COLOR_CONVERSION | \ - GST_CAMERABIN_FLAG_VIDEO_COLOR_CONVERSION + GST_CAMERABIN_FLAG_VIDEO_COLOR_CONVERSION | \ + GST_CAMERABIN_FLAG_AUDIO_CONVERSION /* Using "bilinear" as default zoom method */ #define CAMERABIN_DEFAULT_ZOOM_METHOD 1 From 8147669971151c33d12c645a242406e518291ff0 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Fri, 27 Jan 2012 14:49:58 +0000 Subject: [PATCH 03/37] plenty: fixup glib deprecations --- ext/cog/Makefile.am | 1 + ext/cog/gstcogmse.c | 1 + ext/curl/Makefile.am | 1 + ext/curl/gstcurlsink.c | 2 + ext/gsettings/Makefile.am | 2 +- ext/gsettings/gstgsettingsaudiosink.c | 1 + ext/gsettings/gstgsettingsaudiosrc.c | 1 + ext/gsettings/gstgsettingsvideosink.c | 1 + ext/gsettings/gstgsettingsvideosrc.c | 1 + ext/kate/Makefile.am | 2 +- ext/kate/gstkatetiger.c | 1 + ext/modplug/gstmodplug.cc | 4 + ext/mpeg2enc/Makefile.am | 2 +- ext/mpeg2enc/gstmpeg2enc.cc | 1 + ext/mplex/Makefile.am | 2 +- ext/mplex/gstmplex.cc | 1 + ext/opus/Makefile.am | 1 + ext/opus/gstopusenc.c | 1 + ext/resindvd/resindvdbin.c | 1 + ext/resindvd/resindvdsrc.c | 1 + ext/resindvd/rsnparsetter.c | 1 + ext/sdl/Makefile.am | 2 +- ext/sdl/sdlaudiosink.c | 2 + ext/sdl/sdlvideosink.c | 1 + .../gst/basecamerabinsrc/gstbasecamerasrc.c | 1 + .../basecamerabinsrc/gstcamerabinpreview.c | 1 + gst-libs/gst/glib-compat-private.h | 148 ++++++++++++++++++ gst-libs/gst/video/gstbasevideocodec.c | 4 + gst-libs/gst/video/gstbasevideodecoder.c | 4 + gst-libs/gst/video/gstbasevideoencoder.c | 4 + gst/aiff/aiffparse.c | 5 + gst/audiovisualizers/gstbaseaudiovisualizer.c | 5 + gst/camerabin/gstcamerabin.c | 5 + gst/camerabin/gstinputselector.c | 1 + gst/camerabin2/gstcamerabin2.c | 1 + gst/camerabin2/gstwrappercamerabinsrc.c | 4 + gst/cdxaparse/gstcdxaparse.c | 5 + gst/coloreffects/gstchromahold.c | 4 + gst/dvbsuboverlay/gstdvbsuboverlay.c | 4 +- gst/dvdspu/gstdvdspu.c | 4 + gst/hls/Makefile.am | 2 +- gst/hls/gsthlsdemux.c | 4 + gst/hls/m3u8.c | 1 + gst/inter/Makefile.am | 4 +- gst/inter/gstintersurface.c | 1 + gst/inter/gstintertest.c | 3 + gst/liveadder/Makefile.am | 2 +- gst/liveadder/liveadder.c | 1 + gst/mpegdemux/gstmpegdemux.c | 4 + gst/mpegtsdemux/mpegtsbase.c | 7 +- gst/mpegtsmux/mpegtsmux.c | 4 + gst/mve/Makefile.am | 2 +- gst/mve/gstmvemux.c | 1 + gst/mxf/mxfdemux.c | 4 + gst/rawparse/gstrawparse.c | 4 + gst/sdp/gstsdpdemux.c | 4 + gst/tta/gstttaparse.c | 4 + sys/decklink/Makefile.am | 1 + sys/decklink/capture.cpp | 2 + sys/decklink/gstdecklinksink.cpp | 2 +- sys/decklink/gstdecklinksrc.cpp | 5 + sys/dvb/gstdvbsrc.c | 1 + sys/shm/Makefile.am | 2 +- sys/shm/gstshmsink.c | 1 + tests/examples/camerabin/gst-camera-perf.c | 2 + tests/examples/camerabin/gst-camerabin-test.c | 2 + .../examples/camerabin2/gst-camerabin2-test.c | 2 + tests/examples/mxf/mxfdemux-structure.c | 2 + tests/examples/scaletempo/Makefile.am | 2 +- tests/examples/scaletempo/demo-gui.c | 1 + tests/examples/scaletempo/demo-main.c | 2 + 71 files changed, 297 insertions(+), 16 deletions(-) create mode 100644 gst-libs/gst/glib-compat-private.h diff --git a/ext/cog/Makefile.am b/ext/cog/Makefile.am index 81e0f15e1c..595dab7d98 100644 --- a/ext/cog/Makefile.am +++ b/ext/cog/Makefile.am @@ -7,6 +7,7 @@ libgstcog_la_CFLAGS = \ -DCOG_ENABLE_UNSTABLE_API \ -I$(srcdir)/.. \ $(GST_PLUGINS_BASE_CFLAGS) \ + $(GST_PLUGINS_BAD_CFLAGS) \ $(GST_CFLAGS) \ $(ORC_CFLAGS) \ $(COG_CFLAGS) diff --git a/ext/cog/gstcogmse.c b/ext/cog/gstcogmse.c index f85c873c8b..af29087f31 100644 --- a/ext/cog/gstcogmse.c +++ b/ext/cog/gstcogmse.c @@ -23,6 +23,7 @@ #endif #include +#include #include #include #include diff --git a/ext/curl/Makefile.am b/ext/curl/Makefile.am index 77b237385a..4fc6868a78 100644 --- a/ext/curl/Makefile.am +++ b/ext/curl/Makefile.am @@ -3,6 +3,7 @@ plugin_LTLIBRARIES = libgstcurl.la libgstcurl_la_SOURCES = gstcurl.c gstcurlsink.c libgstcurl_la_CFLAGS = \ $(GST_BASE_CFLAGS) \ + $(GST_PLUGINS_BAD_CFLAGS) \ $(GST_CFLAGS) \ $(CURL_CFLAGS) libgstcurl_la_LIBADD = \ diff --git a/ext/curl/gstcurlsink.c b/ext/curl/gstcurlsink.c index 75b459c550..4306de43b8 100644 --- a/ext/curl/gstcurlsink.c +++ b/ext/curl/gstcurlsink.c @@ -57,6 +57,8 @@ #include "gstcurlsink.h" +#include "gst/glib-compat-private.h" + /* Default values */ #define GST_CAT_DEFAULT gst_curl_sink_debug #define DEFAULT_URL "localhost:5555" diff --git a/ext/gsettings/Makefile.am b/ext/gsettings/Makefile.am index 64801df9ba..2c3abb114e 100644 --- a/ext/gsettings/Makefile.am +++ b/ext/gsettings/Makefile.am @@ -18,7 +18,7 @@ libgstgsettingselements_la_SOURCES = \ gstswitchsrc.c \ plugin.c -libgstgsettingselements_la_CFLAGS = $(GST_CFLAGS) $(GSETTINGS_CFLAGS) $(DIR_CFLAGS) \ +libgstgsettingselements_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GSETTINGS_CFLAGS) $(DIR_CFLAGS) \ -DGstSwitchSrc=GstGSettingsSwitchSrc \ -DGstSwitchSrcClass=GstGSettingsSwitchSrcClass \ -DGstSwitchSink=GstGSettingsSwitchSink \ diff --git a/ext/gsettings/gstgsettingsaudiosink.c b/ext/gsettings/gstgsettingsaudiosink.c index 7e115c9de0..f4155b3bcf 100644 --- a/ext/gsettings/gstgsettingsaudiosink.c +++ b/ext/gsettings/gstgsettingsaudiosink.c @@ -35,6 +35,7 @@ #endif #include +#include #include #include "gstgsettingsaudiosink.h" diff --git a/ext/gsettings/gstgsettingsaudiosrc.c b/ext/gsettings/gstgsettingsaudiosrc.c index 844c8eba44..7b9bd1f18b 100644 --- a/ext/gsettings/gstgsettingsaudiosrc.c +++ b/ext/gsettings/gstgsettingsaudiosrc.c @@ -35,6 +35,7 @@ #endif #include +#include #include #include "gstgsettingsaudiosrc.h" diff --git a/ext/gsettings/gstgsettingsvideosink.c b/ext/gsettings/gstgsettingsvideosink.c index 2444c7c5d5..f04e8054ce 100644 --- a/ext/gsettings/gstgsettingsvideosink.c +++ b/ext/gsettings/gstgsettingsvideosink.c @@ -35,6 +35,7 @@ #endif #include +#include #include #include "gstgsettingsvideosink.h" diff --git a/ext/gsettings/gstgsettingsvideosrc.c b/ext/gsettings/gstgsettingsvideosrc.c index 42ee5fef53..877656814f 100644 --- a/ext/gsettings/gstgsettingsvideosrc.c +++ b/ext/gsettings/gstgsettingsvideosrc.c @@ -35,6 +35,7 @@ #endif #include +#include #include #include "gstgsettingsvideosrc.h" diff --git a/ext/kate/Makefile.am b/ext/kate/Makefile.am index fd7d6ced4d..d732ffa654 100644 --- a/ext/kate/Makefile.am +++ b/ext/kate/Makefile.am @@ -9,7 +9,7 @@ libgstkate_la_SOURCES += gstkatetiger.c endif # flags used to compile this plugin -libgstkate_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(TIGER_CFLAGS) $(KATE_CFLAGS) +libgstkate_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(TIGER_CFLAGS) $(KATE_CFLAGS) libgstkate_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) -lgsttag-$(GST_MAJORMINOR) $(GST_LIBS) $(TIGER_LIBS) $(KATE_LIBS) libgstkate_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstkate_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/ext/kate/gstkatetiger.c b/ext/kate/gstkatetiger.c index c82be32a0c..602192ffdb 100644 --- a/ext/kate/gstkatetiger.c +++ b/ext/kate/gstkatetiger.c @@ -80,6 +80,7 @@ #include #include +#include #include #include "gstkate.h" diff --git a/ext/modplug/gstmodplug.cc b/ext/modplug/gstmodplug.cc index 09836a9102..9344cf9c02 100644 --- a/ext/modplug/gstmodplug.cc +++ b/ext/modplug/gstmodplug.cc @@ -43,6 +43,10 @@ #include "config.h" #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + /* Required to not get an undefined warning * https://bugzilla.gnome.org/show_bug.cgi?id=613795 */ diff --git a/ext/mpeg2enc/Makefile.am b/ext/mpeg2enc/Makefile.am index 1e3d944032..32e00c8ae1 100644 --- a/ext/mpeg2enc/Makefile.am +++ b/ext/mpeg2enc/Makefile.am @@ -8,7 +8,7 @@ libgstmpeg2enc_la_SOURCES = \ gstmpeg2encpicturereader.cc libgstmpeg2enc_la_CXXFLAGS = \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) $(MPEG2ENC_CFLAGS) + $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GST_CXXFLAGS) $(MPEG2ENC_CFLAGS) libgstmpeg2enc_la_LIBADD = \ $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) $(MPEG2ENC_LIBS) libgstmpeg2enc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) diff --git a/ext/mpeg2enc/gstmpeg2enc.cc b/ext/mpeg2enc/gstmpeg2enc.cc index 1987103e22..e437b34dfd 100644 --- a/ext/mpeg2enc/gstmpeg2enc.cc +++ b/ext/mpeg2enc/gstmpeg2enc.cc @@ -57,6 +57,7 @@ #include "config.h" #endif +#include #include "gstmpeg2enc.hh" GST_DEBUG_CATEGORY (mpeg2enc_debug); diff --git a/ext/mplex/Makefile.am b/ext/mplex/Makefile.am index 86ff2f2158..4155d7048d 100644 --- a/ext/mplex/Makefile.am +++ b/ext/mplex/Makefile.am @@ -7,7 +7,7 @@ libgstmplex_la_SOURCES = \ gstmplexoutputstream.cc libgstmplex_la_CXXFLAGS = \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) $(MPLEX_CFLAGS) + $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GST_CXXFLAGS) $(MPLEX_CFLAGS) libgstmplex_la_LIBADD = \ $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(MPLEX_LIBS) libgstmplex_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(MPLEX_LDFLAGS) diff --git a/ext/mplex/gstmplex.cc b/ext/mplex/gstmplex.cc index ac94e7c290..31de91e5a5 100644 --- a/ext/mplex/gstmplex.cc +++ b/ext/mplex/gstmplex.cc @@ -53,6 +53,7 @@ #include +#include #include "gstmplex.hh" #include "gstmplexoutputstream.hh" #include "gstmplexibitstream.hh" diff --git a/ext/opus/Makefile.am b/ext/opus/Makefile.am index cdf3c30ac1..1aaed79247 100644 --- a/ext/opus/Makefile.am +++ b/ext/opus/Makefile.am @@ -4,6 +4,7 @@ libgstopus_la_SOURCES = gstopus.c gstopusdec.c gstopusenc.c gstopusparse.c gstop libgstopus_la_CFLAGS = \ -DGST_USE_UNSTABLE_API \ $(GST_PLUGINS_BASE_CFLAGS) \ + $(GST_PLUGINS_BAD_CFLAGS) \ $(GST_CFLAGS) \ $(OPUS_CFLAGS) libgstopus_la_LIBADD = \ diff --git a/ext/opus/gstopusenc.c b/ext/opus/gstopusenc.c index 9b475cf8c7..29b254ee23 100644 --- a/ext/opus/gstopusenc.c +++ b/ext/opus/gstopusenc.c @@ -48,6 +48,7 @@ #include #include +#include #include "gstopusheader.h" #include "gstopuscommon.h" #include "gstopusenc.h" diff --git a/ext/resindvd/resindvdbin.c b/ext/resindvd/resindvdbin.c index c1a29eb3e0..c8102e82e0 100644 --- a/ext/resindvd/resindvdbin.c +++ b/ext/resindvd/resindvdbin.c @@ -24,6 +24,7 @@ #include #include +#include #include #include "resindvdbin.h" diff --git a/ext/resindvd/resindvdsrc.c b/ext/resindvd/resindvdsrc.c index 75cefe8134..2a52fcd8ad 100644 --- a/ext/resindvd/resindvdsrc.c +++ b/ext/resindvd/resindvdsrc.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/ext/resindvd/rsnparsetter.c b/ext/resindvd/rsnparsetter.c index baaea2b440..ffa5ab50ec 100644 --- a/ext/resindvd/rsnparsetter.c +++ b/ext/resindvd/rsnparsetter.c @@ -7,6 +7,7 @@ #endif #include +#include #include #include diff --git a/ext/sdl/Makefile.am b/ext/sdl/Makefile.am index 7f29981060..ce027dd2fc 100644 --- a/ext/sdl/Makefile.am +++ b/ext/sdl/Makefile.am @@ -5,7 +5,7 @@ libgstsdl_la_SOURCES = \ sdlvideosink.c \ sdlaudiosink.c -libgstsdl_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(SDL_CFLAGS) +libgstsdl_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GST_CFLAGS) $(SDL_CFLAGS) libgstsdl_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ -lgstvideo-$(GST_MAJORMINOR) \ -lgstaudio-$(GST_MAJORMINOR) \ diff --git a/ext/sdl/sdlaudiosink.c b/ext/sdl/sdlaudiosink.c index 98f5bb709f..62c975c4b7 100644 --- a/ext/sdl/sdlaudiosink.c +++ b/ext/sdl/sdlaudiosink.c @@ -23,6 +23,8 @@ #include +#include + GST_DEBUG_CATEGORY_EXTERN (sdl_debug); #define GST_CAT_DEFAULT sdl_debug diff --git a/ext/sdl/sdlvideosink.c b/ext/sdl/sdlvideosink.c index fe155a45e7..0b89805aca 100644 --- a/ext/sdl/sdlvideosink.c +++ b/ext/sdl/sdlvideosink.c @@ -30,6 +30,7 @@ #endif #include +#include #include #include diff --git a/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c b/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c index 09995b8236..99838ad0a8 100644 --- a/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c +++ b/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c @@ -54,6 +54,7 @@ # include #endif +#include #include "gstbasecamerasrc.h" enum diff --git a/gst-libs/gst/basecamerabinsrc/gstcamerabinpreview.c b/gst-libs/gst/basecamerabinsrc/gstcamerabinpreview.c index 4273c71096..b1ab9c7f7f 100644 --- a/gst-libs/gst/basecamerabinsrc/gstcamerabinpreview.c +++ b/gst-libs/gst/basecamerabinsrc/gstcamerabinpreview.c @@ -28,6 +28,7 @@ */ #include #include +#include #include "gstcamerabinpreview.h" #include "gstbasecamerasrc.h" diff --git a/gst-libs/gst/glib-compat-private.h b/gst-libs/gst/glib-compat-private.h new file mode 100644 index 0000000000..9d54e92fa7 --- /dev/null +++ b/gst-libs/gst/glib-compat-private.h @@ -0,0 +1,148 @@ +/* + * glib-compat.c + * Functions copied from glib 2.10 + * + * Copyright 2005 David Schleef + * + * 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 __GLIB_COMPAT_PRIVATE_H__ +#define __GLIB_COMPAT_PRIVATE_H__ + +#include + +G_BEGIN_DECLS + +#if !GLIB_CHECK_VERSION(2,25,0) + +#if defined (_MSC_VER) && !defined(_WIN64) +typedef struct _stat32 GStatBuf; +#else +typedef struct stat GStatBuf; +#endif + +#endif + +#if GLIB_CHECK_VERSION(2,26,0) +#define GLIB_HAS_GDATETIME +#endif + +/* See bug #651514 */ +#if GLIB_CHECK_VERSION(2,29,5) +#define G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE(a,b,c) \ + g_atomic_pointer_compare_and_exchange ((a),(b),(c)) +#define G_ATOMIC_INT_COMPARE_AND_EXCHANGE(a,b,c) \ + g_atomic_int_compare_and_exchange ((a),(b),(c)) +#else +#define G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE(a,b,c) \ + g_atomic_pointer_compare_and_exchange ((volatile gpointer *)(a),(b),(c)) +#define G_ATOMIC_INT_COMPARE_AND_EXCHANGE(a,b,c) \ + g_atomic_int_compare_and_exchange ((volatile int *)(a),(b),(c)) +#endif + +/* See bug #651514 */ +#if GLIB_CHECK_VERSION(2,29,5) +#define G_ATOMIC_INT_ADD(a,b) g_atomic_int_add ((a),(b)) +#else +#define G_ATOMIC_INT_ADD(a,b) g_atomic_int_exchange_and_add ((a),(b)) +#endif + +/* copies */ + +#if GLIB_CHECK_VERSION (2, 31, 0) +#define g_mutex_new gst_g_mutex_new +static inline GMutex * +gst_g_mutex_new (void) +{ + GMutex *mutex = g_slice_new (GMutex); + g_mutex_init (mutex); + return mutex; +} +#define g_mutex_free gst_g_mutex_free +static inline void +gst_g_mutex_free (GMutex *mutex) +{ + g_mutex_clear (mutex); + g_slice_free (GMutex, mutex); +} +#define g_static_rec_mutex_init gst_g_static_rec_mutex_init +static inline void +gst_g_static_rec_mutex_init (GStaticRecMutex *mutex) +{ + static const GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT; + + *mutex = init_mutex; +} +#define g_cond_new gst_g_cond_new +static inline GCond * +gst_g_cond_new (void) +{ + GCond *cond = g_slice_new (GCond); + g_cond_init (cond); + return cond; +} +#define g_cond_free gst_g_cond_free +static inline void +gst_g_cond_free (GCond *cond) +{ + g_cond_clear (cond); + g_slice_free (GCond, cond); +} +#define g_cond_timed_wait gst_g_cond_timed_wait +static inline gboolean +gst_g_cond_timed_wait (GCond *cond, GMutex *mutex, GTimeVal *abs_time) +{ + gint64 end_time; + + if (abs_time == NULL) { + g_cond_wait (cond, mutex); + return TRUE; + } + + end_time = abs_time->tv_sec; + end_time *= 1000000; + end_time += abs_time->tv_usec; + + /* would be nice if we had clock_rtoffset, but that didn't seem to + * make it into the kernel yet... + */ + /* if CLOCK_MONOTONIC is not defined then g_get_montonic_time() and + * g_get_real_time() are returning the same clock and we'd add ~0 + */ + end_time += g_get_monotonic_time () - g_get_real_time (); + return g_cond_wait_until (cond, mutex, end_time); +} +#endif /* GLIB_CHECK_VERSION (2, 31, 0) */ + +#if GLIB_CHECK_VERSION (2, 31, 0) +#define g_thread_create gst_g_thread_create +static inline GThread * +gst_g_thread_create (GThreadFunc func, gpointer data, gboolean joinable, + GError **error) +{ + GThread *thread = g_thread_try_new ("gst-check", func, data, error); + if (!joinable) + g_thread_unref (thread); + return thread; +} +#endif /* GLIB_CHECK_VERSION (2, 31, 0) */ + +/* adaptations */ + +G_END_DECLS + +#endif diff --git a/gst-libs/gst/video/gstbasevideocodec.c b/gst-libs/gst/video/gstbasevideocodec.c index 9c130ed5e3..9bdee5936f 100644 --- a/gst-libs/gst/video/gstbasevideocodec.c +++ b/gst-libs/gst/video/gstbasevideocodec.c @@ -21,6 +21,10 @@ #include "config.h" #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include "gstbasevideocodec.h" #include diff --git a/gst-libs/gst/video/gstbasevideodecoder.c b/gst-libs/gst/video/gstbasevideodecoder.c index 83255f4141..dab7ae898a 100644 --- a/gst-libs/gst/video/gstbasevideodecoder.c +++ b/gst-libs/gst/video/gstbasevideodecoder.c @@ -127,6 +127,10 @@ #include "config.h" #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include "gstbasevideodecoder.h" #include "gstbasevideoutils.h" diff --git a/gst-libs/gst/video/gstbasevideoencoder.c b/gst-libs/gst/video/gstbasevideoencoder.c index e2c730e799..d643e72790 100644 --- a/gst-libs/gst/video/gstbasevideoencoder.c +++ b/gst-libs/gst/video/gstbasevideoencoder.c @@ -105,6 +105,10 @@ #include "config.h" #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include "gstbasevideoencoder.h" #include "gstbasevideoutils.h" diff --git a/gst/aiff/aiffparse.c b/gst/aiff/aiffparse.c index 6dbee68682..176c679606 100644 --- a/gst/aiff/aiffparse.c +++ b/gst/aiff/aiffparse.c @@ -52,6 +52,11 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif + +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include diff --git a/gst/audiovisualizers/gstbaseaudiovisualizer.c b/gst/audiovisualizers/gstbaseaudiovisualizer.c index 6d42b7dc58..6613e3ae12 100644 --- a/gst/audiovisualizers/gstbaseaudiovisualizer.c +++ b/gst/audiovisualizers/gstbaseaudiovisualizer.c @@ -32,6 +32,11 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif + +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index c9f342bedc..605780e40c 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -151,11 +151,16 @@ # include #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include #include #include +#include /* FIXME: include #include and use _(" ") */ #include "gstcamerabin.h" diff --git a/gst/camerabin/gstinputselector.c b/gst/camerabin/gstinputselector.c index 62ee380442..2f0c817e04 100644 --- a/gst/camerabin/gstinputselector.c +++ b/gst/camerabin/gstinputselector.c @@ -35,6 +35,7 @@ #include +#include #include "gstinputselector.h" #include "gstcamerabin-marshal.h" diff --git a/gst/camerabin2/gstcamerabin2.c b/gst/camerabin2/gstcamerabin2.c index 7d5f8f4c78..54cffc86fd 100644 --- a/gst/camerabin2/gstcamerabin2.c +++ b/gst/camerabin2/gstcamerabin2.c @@ -165,6 +165,7 @@ #include "gstcamerabin2.h" #include #include +#include #if GLIB_CHECK_VERSION(2,29,6) #define gst_camerabin2_atomic_int_add g_atomic_int_add diff --git a/gst/camerabin2/gstwrappercamerabinsrc.c b/gst/camerabin2/gstwrappercamerabinsrc.c index 1fc71c0b27..2b45342550 100644 --- a/gst/camerabin2/gstwrappercamerabinsrc.c +++ b/gst/camerabin2/gstwrappercamerabinsrc.c @@ -31,6 +31,10 @@ # include #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include "gstwrappercamerabinsrc.h" diff --git a/gst/cdxaparse/gstcdxaparse.c b/gst/cdxaparse/gstcdxaparse.c index 1f997b7bb4..7620fdab8a 100644 --- a/gst/cdxaparse/gstcdxaparse.c +++ b/gst/cdxaparse/gstcdxaparse.c @@ -22,6 +22,11 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif + +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include "gstcdxaparse.h" diff --git a/gst/coloreffects/gstchromahold.c b/gst/coloreffects/gstchromahold.c index e6e7c4028b..9a6a6954bf 100644 --- a/gst/coloreffects/gstchromahold.c +++ b/gst/coloreffects/gstchromahold.c @@ -40,6 +40,10 @@ #include "config.h" #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include "gstchromahold.h" #include diff --git a/gst/dvbsuboverlay/gstdvbsuboverlay.c b/gst/dvbsuboverlay/gstdvbsuboverlay.c index 3c2cab3e42..5cd7a7fb8d 100644 --- a/gst/dvbsuboverlay/gstdvbsuboverlay.c +++ b/gst/dvbsuboverlay/gstdvbsuboverlay.c @@ -38,6 +38,7 @@ # include #endif +#include #include "gstdvbsuboverlay.h" #include @@ -123,8 +124,7 @@ gst_dvbsub_overlay_base_init (gpointer gclass) gst_element_class_add_static_pad_template (element_class, &src_factory); gst_element_class_add_static_pad_template (element_class, &video_sink_factory); - gst_element_class_add_static_pad_template (element_class, - &text_sink_factory); + gst_element_class_add_static_pad_template (element_class, &text_sink_factory); gst_element_class_set_details_simple (element_class, "DVB Subtitles Overlay", diff --git a/gst/dvdspu/gstdvdspu.c b/gst/dvdspu/gstdvdspu.c index f57d3c20b3..94e69be869 100644 --- a/gst/dvdspu/gstdvdspu.c +++ b/gst/dvdspu/gstdvdspu.c @@ -32,6 +32,10 @@ # include #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include diff --git a/gst/hls/Makefile.am b/gst/hls/Makefile.am index 687b568e02..19fd6211f0 100644 --- a/gst/hls/Makefile.am +++ b/gst/hls/Makefile.am @@ -6,7 +6,7 @@ libgstfragmented_la_SOURCES = \ gsthlsdemux.c \ gstfragmentedplugin.c -libgstfragmented_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(SOUP_CFLAGS) +libgstfragmented_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(SOUP_CFLAGS) libgstfragmented_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(SOUP_LIBS) libgstfragmented_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -no-undefined libgstfragmented_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/gst/hls/gsthlsdemux.c b/gst/hls/gsthlsdemux.c index d840ae028d..d0f77a39ac 100644 --- a/gst/hls/gsthlsdemux.c +++ b/gst/hls/gsthlsdemux.c @@ -41,9 +41,13 @@ # include "config.h" #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS #include #include +#include #include "gsthlsdemux.h" static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src%d", diff --git a/gst/hls/m3u8.c b/gst/hls/m3u8.c index 449b63ee9d..c27f159b59 100644 --- a/gst/hls/m3u8.c +++ b/gst/hls/m3u8.c @@ -23,6 +23,7 @@ #include #include +#include #include "gstfragmented.h" #include "m3u8.h" diff --git a/gst/inter/Makefile.am b/gst/inter/Makefile.am index 7728de9915..d6749a5ef0 100644 --- a/gst/inter/Makefile.am +++ b/gst/inter/Makefile.am @@ -24,6 +24,7 @@ noinst_HEADERS = \ libgstinter_la_CFLAGS = \ $(GST_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ + $(GST_PLUGINS_BAD_CFLAGS) \ $(GST_BASE_CFLAGS) libgstinter_la_LIBADD = \ @@ -40,7 +41,8 @@ gstintertest_SOURCES = \ gstintertest_CFLAGS = \ $(GST_CFLAGS) \ - $(GST_PLUGINS_BASE_CFLAGS) + $(GST_PLUGINS_BASE_CFLAGS) \ + $(GST_PLUGINS_BAD_CFLAGS) gstintertest_LDADD = \ $(GST_LIBS) \ diff --git a/gst/inter/gstintersurface.c b/gst/inter/gstintersurface.c index 1d23e5de15..0fc1c84cc5 100644 --- a/gst/inter/gstintersurface.c +++ b/gst/inter/gstintersurface.c @@ -23,6 +23,7 @@ #include +#include #include "gstintersurface.h" static GList *list; diff --git a/gst/inter/gstintertest.c b/gst/inter/gstintertest.c index cb7b08c668..ff4c65f474 100644 --- a/gst/inter/gstintertest.c +++ b/gst/inter/gstintertest.c @@ -29,6 +29,7 @@ #endif #include +#include #include //#define GETTEXT_PACKAGE "intertest" @@ -80,8 +81,10 @@ main (int argc, char *argv[]) GstInterTest *intertest2; GMainLoop *main_loop; +#if !GLIB_CHECK_VERSION (2, 31, 0) if (!g_thread_supported ()) g_thread_init (NULL); +#endif context = g_option_context_new ("- FIXME"); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); diff --git a/gst/liveadder/Makefile.am b/gst/liveadder/Makefile.am index 4fe8e29592..14f490da75 100644 --- a/gst/liveadder/Makefile.am +++ b/gst/liveadder/Makefile.am @@ -1,7 +1,7 @@ plugin_LTLIBRARIES = libgstliveadder.la libgstliveadder_la_SOURCES = liveadder.c -libgstliveadder_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) +libgstliveadder_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GST_CFLAGS) libgstliveadder_la_LIBADD = \ $(GST_PLUGINS_BASE_LIBS) -lgstaudio-@GST_MAJORMINOR@ \ $(GST_BASE_LIBS) $(GST_LIBS) diff --git a/gst/liveadder/liveadder.c b/gst/liveadder/liveadder.c index 205bd020dc..f9a39e7c7e 100644 --- a/gst/liveadder/liveadder.c +++ b/gst/liveadder/liveadder.c @@ -44,6 +44,7 @@ #include "liveadder.h" +#include #include #include diff --git a/gst/mpegdemux/gstmpegdemux.c b/gst/mpegdemux/gstmpegdemux.c index ef29208dee..0da3e0c777 100644 --- a/gst/mpegdemux/gstmpegdemux.c +++ b/gst/mpegdemux/gstmpegdemux.c @@ -46,6 +46,10 @@ #include "config.h" #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include "gstmpegdefs.h" diff --git a/gst/mpegtsdemux/mpegtsbase.c b/gst/mpegtsdemux/mpegtsbase.c index c63170e1e1..99b5ea7bf2 100644 --- a/gst/mpegtsdemux/mpegtsbase.c +++ b/gst/mpegtsdemux/mpegtsbase.c @@ -32,6 +32,10 @@ #include "config.h" #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include @@ -169,8 +173,7 @@ mpegts_base_base_init (gpointer klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); - gst_element_class_add_static_pad_template (element_class, - &sink_template); + gst_element_class_add_static_pad_template (element_class, &sink_template); } static void diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c index f4b375ea91..4de290f2e8 100644 --- a/gst/mpegtsmux/mpegtsmux.c +++ b/gst/mpegtsmux/mpegtsmux.c @@ -88,6 +88,10 @@ #include #include +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include "mpegtsmux.h" diff --git a/gst/mve/Makefile.am b/gst/mve/Makefile.am index 272b918578..2c3104f64d 100644 --- a/gst/mve/Makefile.am +++ b/gst/mve/Makefile.am @@ -1,6 +1,6 @@ plugin_LTLIBRARIES = libgstmve.la -libgstmve_la_CFLAGS = $(GST_BASE_CFLAGS) $(GST_CFLAGS) +libgstmve_la_CFLAGS = $(GST_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GST_CFLAGS) libgstmve_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM) libgstmve_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstmve_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/gst/mve/gstmvemux.c b/gst/mve/gstmvemux.c index fad163b82e..0b1a24ce8b 100644 --- a/gst/mve/gstmvemux.c +++ b/gst/mve/gstmvemux.c @@ -31,6 +31,7 @@ gst-launch-0.10 filesrc location=movie.mve ! mvedemux name=d ! #include #include +#include #include "gstmvemux.h" #include "mve.h" diff --git a/gst/mxf/mxfdemux.c b/gst/mxf/mxfdemux.c index 13ab13b600..d5ce5f23b8 100644 --- a/gst/mxf/mxfdemux.c +++ b/gst/mxf/mxfdemux.c @@ -54,6 +54,10 @@ #include "config.h" #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include "mxfdemux.h" #include "mxfessence.h" diff --git a/gst/rawparse/gstrawparse.c b/gst/rawparse/gstrawparse.c index cf0f5d0098..b49ddd053a 100644 --- a/gst/rawparse/gstrawparse.c +++ b/gst/rawparse/gstrawparse.c @@ -29,6 +29,10 @@ #include +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include #include diff --git a/gst/sdp/gstsdpdemux.c b/gst/sdp/gstsdpdemux.c index 9254dbcf1d..9b65b18bb1 100644 --- a/gst/sdp/gstsdpdemux.c +++ b/gst/sdp/gstsdpdemux.c @@ -47,6 +47,10 @@ #include "config.h" #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_UNISTD_H #include #endif diff --git a/gst/tta/gstttaparse.c b/gst/tta/gstttaparse.c index 52cd8e474b..12269ac3b0 100644 --- a/gst/tta/gstttaparse.c +++ b/gst/tta/gstttaparse.c @@ -19,6 +19,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include #include diff --git a/sys/decklink/Makefile.am b/sys/decklink/Makefile.am index cb13a8aceb..94dbb09efd 100644 --- a/sys/decklink/Makefile.am +++ b/sys/decklink/Makefile.am @@ -2,6 +2,7 @@ plugin_LTLIBRARIES = libgstdecklink.la libgstdecklink_la_CPPFLAGS = \ $(GST_BASE_CFLAGS) \ + $(GST_PLUGINS_BAD_CFLAGS) \ $(GST_CXXFLAGS) \ $(DECKLINK_CXXFLAGS) libgstdecklink_la_LIBADD = \ diff --git a/sys/decklink/capture.cpp b/sys/decklink/capture.cpp index bc3d9e0875..39ee6c449a 100644 --- a/sys/decklink/capture.cpp +++ b/sys/decklink/capture.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include "gstdecklinksrc.h" #include "capture.h" diff --git a/sys/decklink/gstdecklinksink.cpp b/sys/decklink/gstdecklinksink.cpp index bc24cfefe7..62cdff1ff7 100644 --- a/sys/decklink/gstdecklinksink.cpp +++ b/sys/decklink/gstdecklinksink.cpp @@ -35,7 +35,7 @@ #endif #include -#include +#include #include "gstdecklink.h" #include "gstdecklinksink.h" #include diff --git a/sys/decklink/gstdecklinksrc.cpp b/sys/decklink/gstdecklinksrc.cpp index b2e2c51278..6b088e8caa 100644 --- a/sys/decklink/gstdecklinksrc.cpp +++ b/sys/decklink/gstdecklinksrc.cpp @@ -35,7 +35,12 @@ #include "config.h" #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include +#include #include "gstdecklink.h" #include "gstdecklinksrc.h" #include "capture.h" diff --git a/sys/dvb/gstdvbsrc.c b/sys/dvb/gstdvbsrc.c index 7eb2a2302f..0fa673325b 100644 --- a/sys/dvb/gstdvbsrc.c +++ b/sys/dvb/gstdvbsrc.c @@ -42,6 +42,7 @@ #include "gstdvbsrc.h" #include +#include #include #include #include diff --git a/sys/shm/Makefile.am b/sys/shm/Makefile.am index bfe7b49feb..59a1e3b79c 100644 --- a/sys/shm/Makefile.am +++ b/sys/shm/Makefile.am @@ -5,7 +5,7 @@ include $(top_srcdir)/common/glib-gen.mak plugin_LTLIBRARIES = libgstshm.la libgstshm_la_SOURCES = shmpipe.c shmalloc.c gstshm.c gstshmsrc.c gstshmsink.c -libgstshm_la_CFLAGS = $(GST_CFLAGS) -DSHM_PIPE_USE_GLIB +libgstshm_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) -DSHM_PIPE_USE_GLIB libgstshm_la_LIBADD = -lrt libgstshm_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) libgstshm_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/sys/shm/gstshmsink.c b/sys/shm/gstshmsink.c index 903760be1c..111fbbf0f5 100644 --- a/sys/shm/gstshmsink.c +++ b/sys/shm/gstshmsink.c @@ -27,6 +27,7 @@ #include "gstshmsink.h" #include +#include #include diff --git a/tests/examples/camerabin/gst-camera-perf.c b/tests/examples/camerabin/gst-camera-perf.c index c5554a0e3b..0c56ee6e5a 100644 --- a/tests/examples/camerabin/gst-camera-perf.c +++ b/tests/examples/camerabin/gst-camera-perf.c @@ -979,8 +979,10 @@ main (int argc, char *argv[]) GOptionContext *ctx; GError *err = NULL; +#if !GLIB_CHECK_VERSION (2, 31, 0) if (!g_thread_supported ()) g_thread_init (NULL); +#endif ctx = g_option_context_new (NULL); g_option_context_add_main_entries (ctx, options, NULL); diff --git a/tests/examples/camerabin/gst-camerabin-test.c b/tests/examples/camerabin/gst-camerabin-test.c index 27037fad3f..3f16a7fe5a 100644 --- a/tests/examples/camerabin/gst-camerabin-test.c +++ b/tests/examples/camerabin/gst-camerabin-test.c @@ -786,8 +786,10 @@ main (int argc, char *argv[]) GOptionContext *ctx; GError *err = NULL; +#if !GLIB_CHECK_VERSION (2, 31, 0) if (!g_thread_supported ()) g_thread_init (NULL); +#endif ctx = g_option_context_new ("\n\ncamerabin command line test application."); g_option_context_add_main_entries (ctx, options, NULL); diff --git a/tests/examples/camerabin2/gst-camerabin2-test.c b/tests/examples/camerabin2/gst-camerabin2-test.c index f112dbcb34..cb4b00872c 100644 --- a/tests/examples/camerabin2/gst-camerabin2-test.c +++ b/tests/examples/camerabin2/gst-camerabin2-test.c @@ -1257,8 +1257,10 @@ main (int argc, char *argv[]) GOptionContext *ctx; GError *err = NULL; +#if !GLIB_CHECK_VERSION (2, 31, 0) if (!g_thread_supported ()) g_thread_init (NULL); +#endif ctx = g_option_context_new ("\n\ncamerabin command line test application."); g_option_context_add_main_entries (ctx, options, NULL); diff --git a/tests/examples/mxf/mxfdemux-structure.c b/tests/examples/mxf/mxfdemux-structure.c index 6f735c4da3..8a6c1b6679 100644 --- a/tests/examples/mxf/mxfdemux-structure.c +++ b/tests/examples/mxf/mxfdemux-structure.c @@ -184,8 +184,10 @@ main (gint argc, gchar ** argv) return -1; } +#if !GLIB_CHECK_VERSION (2, 31, 0) if (!g_thread_supported ()) g_thread_init (NULL); +#endif gst_init (NULL, NULL); gtk_init (NULL, NULL); diff --git a/tests/examples/scaletempo/Makefile.am b/tests/examples/scaletempo/Makefile.am index 5cdf3c7f0d..500e511239 100644 --- a/tests/examples/scaletempo/Makefile.am +++ b/tests/examples/scaletempo/Makefile.am @@ -1,7 +1,7 @@ noinst_PROGRAMS = scaletempo-demo scaletempo_demo_SOURCES = demo-main.c demo-player.c demo-gui.c -scaletempo_demo_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GTK_CFLAGS) +scaletempo_demo_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GTK_CFLAGS) scaletempo_demo_LDFLAGS = $(GST_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GTK_LIBS) -lgstinterfaces-@GST_MAJORMINOR@ noinst_HEADERS = demo-player.h demo-gui.h diff --git a/tests/examples/scaletempo/demo-gui.c b/tests/examples/scaletempo/demo-gui.c index c31c2bf199..61a5a66eb6 100644 --- a/tests/examples/scaletempo/demo-gui.c +++ b/tests/examples/scaletempo/demo-gui.c @@ -19,6 +19,7 @@ #include "config.h" #endif +#include #include #include #include diff --git a/tests/examples/scaletempo/demo-main.c b/tests/examples/scaletempo/demo-main.c index 6ddcde71dc..d2ed0df118 100644 --- a/tests/examples/scaletempo/demo-main.c +++ b/tests/examples/scaletempo/demo-main.c @@ -60,8 +60,10 @@ main (int argc, char *argv[]) {NULL,} }; +#if !GLIB_CHECK_VERSION (2, 31, 0) if (!g_thread_supported ()) g_thread_init (NULL); +#endif ctx = g_option_context_new ("uri ..."); g_option_context_add_group (ctx, gst_init_get_option_group ()); From e0b0604119fd7cfb2242605dcff10405ff0a1285 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Sat, 28 Jan 2012 12:32:46 +0000 Subject: [PATCH 04/37] kateenc: remove 'flush every packet' hack This is a bad hack which does not work with Matroska, and is now obsolete as similar code is not included in oggmux/oggstream. --- ext/kate/gstkateenc.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ext/kate/gstkateenc.c b/ext/kate/gstkateenc.c index 8b782c6a17..1f5afdfd09 100644 --- a/ext/kate/gstkateenc.c +++ b/ext/kate/gstkateenc.c @@ -426,10 +426,6 @@ gst_kate_enc_create_buffer (GstKateEnc * ke, kate_packet * kp, GST_BUFFER_TIMESTAMP (buffer) = timestamp; GST_BUFFER_DURATION (buffer) = duration; - /* data packets are each on their own page */ -// if (!header) -// GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT); - return buffer; } @@ -445,9 +441,6 @@ gst_kate_enc_push_buffer (GstKateEnc * ke, GstBuffer * buffer) GST_BUFFER_TIMESTAMP (buffer) + GST_BUFFER_DURATION (buffer); } - /* Hack to flush each packet on its own page - taken off the CMML encoder element */ - GST_BUFFER_DURATION (buffer) = G_MAXINT64; - flow = gst_pad_push (ke->srcpad, buffer); if (G_UNLIKELY (flow != GST_FLOW_OK)) { GST_WARNING_OBJECT (ke->srcpad, "push flow: %s", gst_flow_get_name (flow)); From 5dc80902e2a3196d89b693429ba4a7c719e3294a Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Sat, 28 Jan 2012 20:01:19 +0100 Subject: [PATCH 05/37] voaacenc: init debug category --- ext/voaacenc/gstvoaacenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/voaacenc/gstvoaacenc.c b/ext/voaacenc/gstvoaacenc.c index a0bd9dae51..c3f33637ca 100644 --- a/ext/voaacenc/gstvoaacenc.c +++ b/ext/voaacenc/gstvoaacenc.c @@ -175,6 +175,8 @@ gst_voaacenc_class_init (GstVoAacEncClass * klass) "Target Audio Bitrate", 0, G_MAXINT, VOAAC_ENC_DEFAULT_BITRATE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + GST_DEBUG_CATEGORY_INIT (gst_voaacenc_debug, "voaacenc", 0, "voaac encoder"); } static void From dcc13e3eba17c59efb7c72870cef259ed93d61b5 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Sat, 28 Jan 2012 20:01:35 +0100 Subject: [PATCH 06/37] voamrwbenc: init debug category --- ext/voamrwbenc/gstvoamrwbenc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/voamrwbenc/gstvoamrwbenc.c b/ext/voamrwbenc/gstvoamrwbenc.c index 2b37802398..f29e71ecb1 100644 --- a/ext/voamrwbenc/gstvoamrwbenc.c +++ b/ext/voamrwbenc/gstvoamrwbenc.c @@ -189,6 +189,9 @@ gst_voamrwbenc_class_init (GstVoAmrWbEncClass * klass) "Encoding Band Mode (Kbps)", GST_VOAMRWBENC_BANDMODE_TYPE, BANDMODE_DEFAULT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS)); + + GST_DEBUG_CATEGORY_INIT (gst_voamrwbenc_debug, "voamrwbenc", 0, + "voamrwb encoder"); } static void From 4964db6a1cdf6f391943a2d69856b904ef001c29 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 25 Jan 2012 13:57:57 +0100 Subject: [PATCH 07/37] codecparsers: h264: fix parsing of VUI parameters. max_dec_frame_buffering was mis-parsed because log2_max_mv_length_vertical was parsed twice. https://bugzilla.gnome.org/show_bug.cgi?id=668660 --- gst-libs/gst/codecparsers/gsth264parser.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gst-libs/gst/codecparsers/gsth264parser.c b/gst-libs/gst/codecparsers/gsth264parser.c index b969650919..2f18ffd383 100644 --- a/gst-libs/gst/codecparsers/gsth264parser.c +++ b/gst-libs/gst/codecparsers/gsth264parser.c @@ -623,7 +623,6 @@ gst_h264_parse_vui_parameters (GstH264SPS * sps, NalReader * nr) READ_UE_ALLOWED (nr, vui->max_bits_per_mb_denom, 0, 16); READ_UE_ALLOWED (nr, vui->log2_max_mv_length_horizontal, 0, 16); READ_UE_ALLOWED (nr, vui->log2_max_mv_length_vertical, 0, 16); - READ_UE_ALLOWED (nr, vui->log2_max_mv_length_vertical, 0, 16); READ_UE (nr, vui->num_reorder_frames); READ_UE (nr, vui->max_dec_frame_buffering); } From f547336fdc8a34738c3e6fac9f1e124f59169fd7 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Tue, 31 Jan 2012 08:44:04 +0100 Subject: [PATCH 08/37] mpegtsmux: update after collectpads2 changes --- gst/mpegtsmux/mpegtsmux.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c index 4de290f2e8..bab4a873de 100644 --- a/gst/mpegtsmux/mpegtsmux.c +++ b/gst/mpegtsmux/mpegtsmux.c @@ -663,27 +663,6 @@ mpegtsmux_choose_best_stream (MpegTsMux * mux) #define COLLECT_DATA_PAD(collect_data) (((GstCollectData2 *)(collect_data))->pad) -static MpegTsPadData * -find_pad_data (MpegTsMux * mux, GstPad * pad) -{ - GSList *walk; - MpegTsPadData *ts_data = NULL; - - GST_COLLECT_PADS2_STREAM_LOCK (mux->collect); - walk = mux->collect->pad_list; - while (walk) { - if (((GstCollectData2 *) walk->data)->pad == pad) { - ts_data = (MpegTsPadData *) walk->data; - break; - } - - walk = g_slist_next (walk); - } - GST_COLLECT_PADS2_STREAM_UNLOCK (mux->collect); - - return ts_data; -} - static gboolean mpegtsmux_sink_event (GstPad * pad, GstEvent * event) { @@ -692,7 +671,7 @@ mpegtsmux_sink_event (GstPad * pad, GstEvent * event) gboolean res = TRUE; gboolean forward = TRUE; - ts_data = find_pad_data (mux, pad); + ts_data = (MpegTsPadData *) gst_pad_get_element_private (pad); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_CUSTOM_DOWNSTREAM: From 521e8b199bc3c88b8cd902e236bf37d5485d6624 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Mon, 26 Dec 2011 21:57:48 -0600 Subject: [PATCH 09/37] videoparsers: set interlaced field in caps for mpeg2 https://bugzilla.gnome.org/show_bug.cgi?id=667218 --- gst/videoparsers/gstmpegvideoparse.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gst/videoparsers/gstmpegvideoparse.c b/gst/videoparsers/gstmpegvideoparse.c index 4170996aea..8d19046e7a 100644 --- a/gst/videoparsers/gstmpegvideoparse.c +++ b/gst/videoparsers/gstmpegvideoparse.c @@ -673,6 +673,9 @@ gst_mpegv_parse_update_src_caps (GstMpegvParse * mpvparse) gst_caps_set_simple (caps, "level", G_TYPE_STRING, level, NULL); else GST_DEBUG_OBJECT (mpvparse, "Invalid level - %u", level_c); + + gst_caps_set_simple (caps, "interlaced", + G_TYPE_BOOLEAN, !mpvparse->sequenceext.progressive, NULL); } gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (mpvparse), caps); From 73a8c272c0d3a61aab75b9aa653fba7aa51b772f Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Wed, 1 Feb 2012 02:13:48 +0100 Subject: [PATCH 10/37] schro: Fix compilation with 1.0.10 --- ext/schroedinger/gstschrodec.c | 4 ++++ ext/schroedinger/gstschroenc.c | 10 ++++++++++ ext/schroedinger/gstschroutils.c | 3 +-- ext/schroedinger/gstschroutils.h | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ext/schroedinger/gstschrodec.c b/ext/schroedinger/gstschrodec.c index 030298e40c..782788aa47 100644 --- a/ext/schroedinger/gstschrodec.c +++ b/ext/schroedinger/gstschrodec.c @@ -313,11 +313,13 @@ parse_sequence_header (GstSchroDec * schro_dec, guint8 * data, int size) ret = schro_parse_decode_sequence_header (data + 13, size - 13, &video_format); if (ret) { +#if SCHRO_CHECK_VERSION(1,0,11) int bit_depth; bit_depth = schro_video_format_get_bit_depth (&video_format); if (bit_depth == 8) { +#endif if (video_format.chroma_format == SCHRO_CHROMA_444) { state->format = GST_VIDEO_FORMAT_AYUV; } else if (video_format.chroma_format == SCHRO_CHROMA_422) { @@ -325,6 +327,7 @@ parse_sequence_header (GstSchroDec * schro_dec, guint8 * data, int size) } else if (video_format.chroma_format == SCHRO_CHROMA_420) { state->format = GST_VIDEO_FORMAT_I420; } +#if SCHRO_CHECK_VERSION(1,0,11) } else if (bit_depth <= 10) { state->format = GST_VIDEO_FORMAT_v210; } else if (bit_depth <= 16) { @@ -333,6 +336,7 @@ parse_sequence_header (GstSchroDec * schro_dec, guint8 * data, int size) GST_ERROR ("bit depth too large (%d > 16)", bit_depth); state->format = GST_VIDEO_FORMAT_AYUV64; } +#endif state->fps_n = video_format.frame_rate_numerator; state->fps_d = video_format.frame_rate_denominator; GST_DEBUG_OBJECT (schro_dec, "Frame rate is %d/%d", state->fps_n, diff --git a/ext/schroedinger/gstschroenc.c b/ext/schroedinger/gstschroenc.c index 7ed96b3b74..9c00177628 100644 --- a/ext/schroedinger/gstschroenc.c +++ b/ext/schroedinger/gstschroenc.c @@ -271,18 +271,24 @@ gst_schro_enc_set_format (GstBaseVideoEncoder * base_video_encoder, switch (state->format) { case GST_VIDEO_FORMAT_I420: case GST_VIDEO_FORMAT_YV12: +#if SCHRO_CHECK_VERSION(1,0,11) case GST_VIDEO_FORMAT_Y42B: +#endif schro_enc->video_format->chroma_format = SCHRO_CHROMA_420; break; case GST_VIDEO_FORMAT_YUY2: case GST_VIDEO_FORMAT_UYVY: +#if SCHRO_CHECK_VERSION(1,0,11) case GST_VIDEO_FORMAT_v216: case GST_VIDEO_FORMAT_v210: +#endif schro_enc->video_format->chroma_format = SCHRO_CHROMA_422; break; case GST_VIDEO_FORMAT_AYUV: +#if SCHRO_CHECK_VERSION(1,0,11) case GST_VIDEO_FORMAT_Y444: case GST_VIDEO_FORMAT_AYUV64: +#endif schro_enc->video_format->chroma_format = SCHRO_CHROMA_444; break; case GST_VIDEO_FORMAT_ARGB: @@ -305,10 +311,13 @@ gst_schro_enc_set_format (GstBaseVideoEncoder * base_video_encoder, schro_enc->video_format->aspect_ratio_numerator = state->par_n; schro_enc->video_format->aspect_ratio_denominator = state->par_d; +#if SCHRO_CHECK_VERSION(1,0,11) switch (state->format) { default: +#endif schro_video_format_set_std_signal_range (schro_enc->video_format, SCHRO_SIGNAL_RANGE_8BIT_VIDEO); +#if SCHRO_CHECK_VERSION(1,0,11) break; case GST_VIDEO_FORMAT_v210: schro_video_format_set_std_signal_range (schro_enc->video_format, @@ -322,6 +331,7 @@ gst_schro_enc_set_format (GstBaseVideoEncoder * base_video_encoder, schro_enc->video_format->chroma_excursion = 224 << 8; break; } +#endif schro_video_format_set_std_colour_spec (schro_enc->video_format, SCHRO_COLOUR_SPEC_HDTV); diff --git a/ext/schroedinger/gstschroutils.c b/ext/schroedinger/gstschroutils.c index 99a22c8a4b..5ee2317f03 100644 --- a/ext/schroedinger/gstschroutils.c +++ b/ext/schroedinger/gstschroutils.c @@ -72,6 +72,7 @@ gst_schro_buffer_wrap (GstBuffer * buf, GstVideoFormat format, int width, frame = schro_frame_new_from_data_AYUV (GST_BUFFER_DATA (buf), width, height); break; +#if SCHRO_CHECK_VERSION(1,0,11) case GST_VIDEO_FORMAT_Y42B: frame = schro_frame_new_from_data_Y42B (GST_BUFFER_DATA (buf), width, height); @@ -88,8 +89,6 @@ gst_schro_buffer_wrap (GstBuffer * buf, GstVideoFormat format, int width, frame = schro_frame_new_from_data_v216 (GST_BUFFER_DATA (buf), width, height); break; -#ifdef SCHRO_FRAME_FORMAT_AY64 - /* Added in 1.0.11 */ case GST_VIDEO_FORMAT_AYUV64: frame = schro_frame_new_from_data_AY64 (GST_BUFFER_DATA (buf), width, height); diff --git a/ext/schroedinger/gstschroutils.h b/ext/schroedinger/gstschroutils.h index a9924a6331..c1d06c5038 100644 --- a/ext/schroedinger/gstschroutils.h +++ b/ext/schroedinger/gstschroutils.h @@ -24,10 +24,10 @@ #include #include -#ifdef SCHRO_FRAME_FORMAT_AY64 +#if SCHRO_CHECK_VERSION(1,0,11) #define GST_SCHRO_YUV_LIST "{ I420, YV12, YUY2, UYVY, AYUV, Y42B, Y444, v216, v210, AY64 }" #else -#define GST_SCHRO_YUV_LIST "{ I420, YV12, YUY2, UYVY, AYUV, Y42B, Y444 }" +#define GST_SCHRO_YUV_LIST "{ I420, YV12, YUY2, UYVY, AYUV }" #endif SchroFrame * From 7a9fff74c6b6a3bc9559d624af3e8d71f8771db8 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Mon, 30 Jan 2012 18:46:07 +0000 Subject: [PATCH 11/37] resindvd: fix wedge in preroll when playbin2 deinterlacing is enabled When deinterlacing is enabled, an extra colorspace element is added. Colorspace is a basetransform, and is then the only basetransform element on the video path. A while ago, basetransform started delaying events till caps were set on its source pad. These things conspired to end up sending the DVD highlight events onto a blocked pad on subtitleoverlay. Ensuring these highlight events are only sent once we're in playing mode fixes the issue. https://bugzilla.gnome.org/show_bug.cgi?id=668762 --- ext/resindvd/resindvdsrc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ext/resindvd/resindvdsrc.c b/ext/resindvd/resindvdsrc.c index 2a52fcd8ad..53320752bd 100644 --- a/ext/resindvd/resindvdsrc.c +++ b/ext/resindvd/resindvdsrc.c @@ -1120,7 +1120,7 @@ rsn_dvdsrc_step (resinDvdSrc * src, gboolean have_dvd_lock) break; } - if (src->highlight_event && have_dvd_lock) { + if (src->highlight_event && have_dvd_lock && src->in_playing) { GstEvent *hl_event = src->highlight_event; src->highlight_event = NULL; @@ -1411,8 +1411,12 @@ rsn_dvdsrc_create (GstBaseSrc * bsrc, guint64 offset, } } - highlight_event = src->highlight_event; - src->highlight_event = NULL; + if (src->in_playing) { + highlight_event = src->highlight_event; + src->highlight_event = NULL; + } else { + highlight_event = NULL; + } /* Schedule a clock callback for the any pending nav packet */ rsn_dvdsrc_check_nav_blocks (src); From 8ba11fe2ff8a9d372a994fa5431573df6b55600f Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Wed, 14 Dec 2011 19:27:53 +0000 Subject: [PATCH 12/37] tiger: use the new premultiplied support in gstvideo --- ext/kate/gstkatetiger.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/ext/kate/gstkatetiger.c b/ext/kate/gstkatetiger.c index 602192ffdb..dfeff65e66 100644 --- a/ext/kate/gstkatetiger.c +++ b/ext/kate/gstkatetiger.c @@ -776,7 +776,7 @@ gst_kate_tiger_set_composition (GstKateTiger * tiger) rectangle = gst_video_overlay_rectangle_new_argb (tiger->render_buffer, tiger->video_width, tiger->video_height, 4 * tiger->video_width, 0, 0, tiger->video_width, tiger->video_height, - GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE); + GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA); if (tiger->composition) gst_video_overlay_composition_unref (tiger->composition); @@ -789,23 +789,6 @@ gst_kate_tiger_set_composition (GstKateTiger * tiger) } } -static inline void -gst_kate_tiger_unpremultiply (GstKateTiger * tiger) -{ - guint i, j; - guint8 *pimage, *text_image = GST_BUFFER_DATA (tiger->render_buffer); - - for (i = 0; i < tiger->video_height; i++) { - pimage = text_image + 4 * (i * tiger->video_width); - for (j = 0; j < tiger->video_width; j++) { - TIGER_UNPREMULTIPLY (pimage[TIGER_ARGB_A], pimage[TIGER_ARGB_R], - pimage[TIGER_ARGB_G], pimage[TIGER_ARGB_B]); - - pimage += 4; - } - } -} - static GstFlowReturn gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf) { @@ -895,9 +878,6 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf) } if (gst_video_format_is_yuv (tiger->video_format)) { - /* As the GstVideoOverlayComposition supports only unpremultiply ARGB, - * we need to unpermultiply it */ - gst_kate_tiger_unpremultiply (tiger); gst_kate_tiger_set_composition (tiger); if (tiger->composition) gst_video_overlay_composition_blend (tiger->composition, buf); From 136f42974da30f421384d2b263255f0f812d7f45 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 1 Feb 2012 12:03:04 +0100 Subject: [PATCH 13/37] h264parse: unbreak optimized packetized NALU collection processing ... in that it was so optimized it did not consider grouping NALU into AU altogether. Fixes #668627. --- gst/videoparsers/gsth264parse.c | 33 ++++++++++++++++++++++++--------- gst/videoparsers/gsth264parse.h | 1 + 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 2e4da486ad..d5e3473589 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -575,10 +575,6 @@ gst_h264_parse_collect_nal (GstH264Parse * h264parse, const guint8 * data, GstH264NalUnitType nal_type = nalu->type; GstH264NalUnit nnalu; - if (h264parse->align == GST_H264_PARSE_ALIGN_NAL) { - return TRUE; - } - GST_DEBUG_OBJECT (h264parse, "parsing collected nal"); parse_res = gst_h264_parser_identify_nalu (h264parse->nalparser, data, nalu->offset + nalu->size, size, &nnalu); @@ -657,6 +653,8 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, nalu = h264parse->nalu; current_off = h264parse->current_off; + g_assert (current_off < size); + GST_DEBUG_OBJECT (h264parse, "last parse position %u", current_off); while (TRUE) { GstH264ParserResult pres; @@ -691,6 +689,10 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, current_off = nalu.sc_offset; goto more; } + } else if (h264parse->packetized) { + /* normal next nal based collection not possible, + * _chain will have to tell us whether this was last one for AU */ + drain = h264parse->packetized_last; } break; case GST_H264_PARSER_BROKEN_LINK: @@ -752,14 +754,24 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, data, nalu.offset, nalu.size); gst_h264_parse_process_nal (h264parse, &nalu); + + /* simulate no next nal if none needed */ + drain = drain || (h264parse->align == GST_H264_PARSE_ALIGN_NAL); + + /* In packetized mode we know there's only on NALU in each input packet, + * but we may not have seen the whole AU already, possibly need more */ + if (h264parse->packetized) { + if (drain) + break; + /* next NALU expected at end of current data */ + current_off = size; + goto more; + } + /* if no next nal, we know it's complete here */ if (drain || gst_h264_parse_collect_nal (h264parse, data, size, &nalu)) break; - /* In packetized mode we know there's only on NALU in each input packet */ - if (h264parse->packetized) - break; - GST_DEBUG_OBJECT (h264parse, "Looking for more"); } @@ -1834,7 +1846,10 @@ gst_h264_parse_chain (GstPad * pad, GstBuffer * buffer) nalu.data + nalu.offset, nalu.size); /* at least this should make sense */ GST_BUFFER_TIMESTAMP (sub) = GST_BUFFER_TIMESTAMP (buffer); - GST_LOG_OBJECT (h264parse, "pushing NAL of size %d", nalu.size); + h264parse->packetized_last = + (nalu.offset + nalu.size + nl >= GST_BUFFER_SIZE (buffer)); + GST_LOG_OBJECT (h264parse, "pushing NAL of size %d, last = %d", + nalu.size, h264parse->packetized_last); ret = h264parse->parse_chain (pad, sub); } else { /* pass-through: no looking for frames (and nal processing), diff --git a/gst/videoparsers/gsth264parse.h b/gst/videoparsers/gsth264parse.h index 1064ff8bba..a97dfcb15f 100644 --- a/gst/videoparsers/gsth264parse.h +++ b/gst/videoparsers/gsth264parse.h @@ -71,6 +71,7 @@ struct _GstH264Parse guint align; guint format; guint current_off; + gboolean packetized_last; GstClockTime last_report; gboolean push_codec; From 283f97cb79bb834b8caaaaf361bd84671ae945ba Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 1 Feb 2012 12:23:23 +0100 Subject: [PATCH 14/37] h264parse: also mind SEI position for config data insertion Fixes #668627. --- gst/videoparsers/gsth264parse.c | 16 ++++++++++++++++ gst/videoparsers/gsth264parse.h | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index d5e3473589..182b00e929 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -186,6 +186,7 @@ gst_h264_parse_reset_frame (GstH264Parse * h264parse) h264parse->picture_start = FALSE; h264parse->update_caps = FALSE; h264parse->idr_pos = -1; + h264parse->sei_pos = -1; h264parse->keyframe = FALSE; h264parse->frame_start = FALSE; gst_adapter_clear (h264parse->frame_out); @@ -504,6 +505,15 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu) GST_TIME_ARGS (h264parse->ts_trn_nb)); break; } + /* mark SEI pos */ + if (h264parse->sei_pos == -1) { + if (h264parse->format == GST_H264_PARSE_FORMAT_AVC) + h264parse->sei_pos = gst_adapter_available (h264parse->frame_out); + else + h264parse->sei_pos = nalu->offset - 4; + GST_DEBUG_OBJECT (h264parse, "marking SEI in frame at offset %d", + h264parse->sei_pos); + } break; case GST_H264_NAL_SLICE: @@ -547,6 +557,12 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu) GST_DEBUG_OBJECT (h264parse, "marking IDR in frame at offset %d", h264parse->idr_pos); } + /* if SEI preceeds (faked) IDR, then we have to insert config there */ + if (h264parse->sei_pos >= 0 && h264parse->idr_pos > h264parse->sei_pos) { + h264parse->idr_pos = h264parse->sei_pos; + GST_DEBUG_OBJECT (h264parse, "moved IDR mark to SEI position %d", + h264parse->idr_pos); + } break; default: gst_h264_parser_parse_nal (nalparser, nalu); diff --git a/gst/videoparsers/gsth264parse.h b/gst/videoparsers/gsth264parse.h index a97dfcb15f..812ac4fb88 100644 --- a/gst/videoparsers/gsth264parse.h +++ b/gst/videoparsers/gsth264parse.h @@ -98,7 +98,7 @@ struct _GstH264Parse /* frame parsing */ /*guint last_nal_pos;*/ /*guint next_sc_pos;*/ - gint idr_pos; + gint idr_pos, sei_pos; gboolean update_caps; GstAdapter *frame_out; gboolean keyframe; From da89903f81849fa61e0224d50c214ff3140cd9fc Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 1 Feb 2012 12:47:56 +0100 Subject: [PATCH 15/37] h264parse: disable optimized packetized processing for reverse playback ... as baseparse then provides whole chunks of data (as it should) at once to be parsed, and so the assumptions used to optimize are no longer valid. Fixes #667560. --- gst/videoparsers/gsth264parse.c | 16 ++++++++++++---- gst/videoparsers/gsth264parse.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 182b00e929..230fd85c64 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -675,7 +675,7 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, while (TRUE) { GstH264ParserResult pres; - if (h264parse->packetized) + if (h264parse->packetized_chunked) pres = gst_h264_parser_identify_nalu_unchecked (nalparser, data, current_off, size, &nalu); @@ -697,7 +697,8 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, h264parse->nalu = nalu; /* need 2 bytes of next nal */ - if (!h264parse->packetized && (nalu.offset + nalu.size + 4 + 2 > size)) { + if (!h264parse->packetized_chunked && + (nalu.offset + nalu.size + 4 + 2 > size)) { if (GST_BASE_PARSE_DRAINING (parse)) { drain = TRUE; } else { @@ -705,7 +706,7 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, current_off = nalu.sc_offset; goto more; } - } else if (h264parse->packetized) { + } else if (h264parse->packetized_chunked) { /* normal next nal based collection not possible, * _chain will have to tell us whether this was last one for AU */ drain = h264parse->packetized_last; @@ -776,7 +777,7 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, /* In packetized mode we know there's only on NALU in each input packet, * but we may not have seen the whole AU already, possibly need more */ - if (h264parse->packetized) { + if (h264parse->packetized_chunked) { if (drain) break; /* next NALU expected at end of current data */ @@ -1862,6 +1863,13 @@ gst_h264_parse_chain (GstPad * pad, GstBuffer * buffer) nalu.data + nalu.offset, nalu.size); /* at least this should make sense */ GST_BUFFER_TIMESTAMP (sub) = GST_BUFFER_TIMESTAMP (buffer); + /* transfer flags (e.g. DISCONT) for first fragment */ + if (nalu.offset <= nl) + gst_buffer_copy_metadata (sub, buffer, GST_BUFFER_COPY_FLAGS); + /* in reverse playback, baseparse gathers buffers, so we cannot + * guarantee a buffer to contain a single whole NALU */ + h264parse->packetized_chunked = + (GST_BASE_PARSE (h264parse)->segment.rate > 0.0); h264parse->packetized_last = (nalu.offset + nalu.size + nl >= GST_BUFFER_SIZE (buffer)); GST_LOG_OBJECT (h264parse, "pushing NAL of size %d, last = %d", diff --git a/gst/videoparsers/gsth264parse.h b/gst/videoparsers/gsth264parse.h index 812ac4fb88..ff6eb59f01 100644 --- a/gst/videoparsers/gsth264parse.h +++ b/gst/videoparsers/gsth264parse.h @@ -72,6 +72,7 @@ struct _GstH264Parse guint format; guint current_off; gboolean packetized_last; + gboolean packetized_chunked; GstClockTime last_report; gboolean push_codec; From fac39bae51008b00f5b03990ccfca0007ca653d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 1 Feb 2012 19:38:59 +0000 Subject: [PATCH 16/37] chromaprint: fix parent structure in boilerplate macro --- ext/chromaprint/gstchromaprint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/chromaprint/gstchromaprint.c b/ext/chromaprint/gstchromaprint.c index c0a129301c..66347d9741 100644 --- a/ext/chromaprint/gstchromaprint.c +++ b/ext/chromaprint/gstchromaprint.c @@ -64,7 +64,7 @@ enum }; -GST_BOILERPLATE (GstChromaprint, gst_chromaprint, GstElement, +GST_BOILERPLATE (GstChromaprint, gst_chromaprint, GstAudioFilter, GST_TYPE_AUDIO_FILTER); static void gst_chromaprint_finalize (GObject * object); From ea28347bb6df1b6eb022c75b0c8243e8e4cea4af Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Thu, 2 Feb 2012 10:59:53 +0000 Subject: [PATCH 17/37] kate: better error/debug reporting Include text messages instead of error codes. --- ext/kate/gstkateenc.c | 53 ++++++++++++++++++++++++-------------- ext/kate/gstkateparse.c | 3 ++- ext/kate/gstkatetiger.c | 22 ++++++++++------ ext/kate/gstkateutil.c | 57 ++++++++++++++++++++++++++++++++++++++--- ext/kate/gstkateutil.h | 2 ++ 5 files changed, 106 insertions(+), 31 deletions(-) diff --git a/ext/kate/gstkateenc.c b/ext/kate/gstkateenc.c index 1f5afdfd09..ff7aff2185 100644 --- a/ext/kate/gstkateenc.c +++ b/ext/kate/gstkateenc.c @@ -618,7 +618,8 @@ gst_kate_enc_send_headers (GstKateEnc * ke) break; } else { GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), - ("kate_encode_headers: %d", ret)); + ("Failed encoding headers: %s", + gst_kate_util_get_error_message (ret))); rflow = GST_FLOW_ERROR; break; } @@ -676,7 +677,8 @@ gst_kate_enc_flush_headers (GstKateEnc * ke) ke->headers_sent = TRUE; GST_INFO_OBJECT (ke, "headers flushed"); } else { - GST_WARNING_OBJECT (ke, "Failed to flush headers: %d", rflow); + GST_WARNING_OBJECT (ke, "Failed to flush headers: %s", + gst_flow_get_name (rflow)); } } return rflow; @@ -714,7 +716,8 @@ gst_kate_enc_generate_keepalive (GstKateEnc * ke, GstClockTime timestamp) GST_DEBUG_OBJECT (ke, "keepalive at %f", t); ret = kate_encode_keepalive (&ke->k, t, &kp); if (ret < 0) { - GST_WARNING_OBJECT (ke, "Failed to encode keepalive packet: %d", ret); + GST_WARNING_OBJECT (ke, "Failed to encode keepalive packet: %s", + gst_kate_util_get_error_message (ret)); } else { kate_int64_t granpos = kate_encode_get_granule (&ke->k); GST_LOG_OBJECT (ke, "Keepalive packet encoded"); @@ -744,7 +747,8 @@ gst_kate_enc_flush_waiting (GstKateEnc * ke, GstClockTime now) ret = kate_encode_text (&ke->k, t0, t1, "", 0, &kp); if (G_UNLIKELY (ret < 0)) { GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), - ("kate_encode_text: %d", ret)); + ("Failed to encode text packet: %s", + gst_kate_util_get_error_message (ret))); rflow = GST_FLOW_ERROR; } else { rflow = @@ -755,7 +759,8 @@ gst_kate_enc_flush_waiting (GstKateEnc * ke, GstClockTime now) if (rflow == GST_FLOW_OK) { GST_DEBUG_OBJECT (ke, "delayed SPU packet flushed"); } else { - GST_WARNING_OBJECT (ke, "Failed to flush delayed SPU packet: %d", rflow); + GST_WARNING_OBJECT (ke, "Failed to flush delayed SPU packet: %s", + gst_flow_get_name (rflow)); } /* forget it even if we couldn't flush it */ @@ -865,19 +870,21 @@ gst_kate_enc_chain_spu (GstKateEnc * ke, GstBuffer * buf) ret = kate_encode_set_region (&ke->k, kregion); if (G_UNLIKELY (ret < 0)) { GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), - ("kate_encode_set_region: %d", ret)); + ("Failed to set region: %s", gst_kate_util_get_error_message (ret))); rflow = GST_FLOW_ERROR; } else { ret = kate_encode_set_palette (&ke->k, kpalette); if (G_UNLIKELY (ret < 0)) { GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), - ("kate_encode_set_palette: %d", ret)); + ("Failed to set palette: %s", + gst_kate_util_get_error_message (ret))); rflow = GST_FLOW_ERROR; } else { ret = kate_encode_set_bitmap (&ke->k, kbitmap); if (G_UNLIKELY (ret < 0)) { GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), - ("kate_encode_set_bitmap: %d", ret)); + ("Failed to set bitmap: %s", + gst_kate_util_get_error_message (ret))); rflow = GST_FLOW_ERROR; } else { /* Some SPUs have no hide time - so I'm going to delay the encoding of the packet @@ -899,7 +906,8 @@ gst_kate_enc_chain_spu (GstKateEnc * ke, GstBuffer * buf) ret = kate_encode_text (&ke->k, t0, t1, "", 0, &kp); if (G_UNLIKELY (ret < 0)) { GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), - ("Failed to encode empty text for SPU buffer: %d", ret)); + ("Failed to encode empty text for SPU buffer: %s", + gst_kate_util_get_error_message (ret))); rflow = GST_FLOW_ERROR; } else { rflow = @@ -941,7 +949,8 @@ gst_kate_enc_chain_text (GstKateEnc * ke, GstBuffer * buf, if (G_UNLIKELY (ret < 0)) { GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), - ("kate_encode_set_markup_type: %d", ret)); + ("Failed to set markup type: %s", + gst_kate_util_get_error_message (ret))); rflow = GST_FLOW_ERROR; } else { const char *text = (const char *) GST_BUFFER_DATA (buf); @@ -960,7 +969,7 @@ gst_kate_enc_chain_text (GstKateEnc * ke, GstBuffer * buf, ret = kate_encode_text (&ke->k, t0, t1, text, text_len, &kp); if (G_UNLIKELY (ret < 0)) { GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), - ("Failed to encode text: %d", ret)); + ("Failed to encode text: %s", gst_kate_util_get_error_message (ret))); rflow = GST_FLOW_ERROR; } else { rflow = gst_kate_enc_chain_push_packet (ke, &kp, start, stop - start + 1); @@ -1044,21 +1053,23 @@ gst_kate_enc_change_state (GstElement * element, GstStateChange transition) GST_DEBUG_OBJECT (ke, "READY -> PAUSED, initializing kate state"); ret = kate_info_init (&ke->ki); if (ret < 0) { - GST_WARNING_OBJECT (ke, "failed to initialize kate info structure: %d", - ret); + GST_WARNING_OBJECT (ke, "failed to initialize kate info structure: %s", + gst_kate_util_get_error_message (ret)); break; } if (ke->language) { ret = kate_info_set_language (&ke->ki, ke->language); if (ret < 0) { - GST_WARNING_OBJECT (ke, "failed to set stream language: %d", ret); + GST_WARNING_OBJECT (ke, "failed to set stream language: %s", + gst_kate_util_get_error_message (ret)); break; } } if (ke->category) { ret = kate_info_set_category (&ke->ki, ke->category); if (ret < 0) { - GST_WARNING_OBJECT (ke, "failed to set stream category: %d", ret); + GST_WARNING_OBJECT (ke, "failed to set stream category: %s", + gst_kate_util_get_error_message (ret)); break; } } @@ -1066,18 +1077,21 @@ gst_kate_enc_change_state (GstElement * element, GstStateChange transition) kate_info_set_original_canvas_size (&ke->ki, ke->original_canvas_width, ke->original_canvas_height); if (ret < 0) { - GST_WARNING_OBJECT (ke, "failed to set original canvas size: %d", ret); + GST_WARNING_OBJECT (ke, "failed to set original canvas size: %s", + gst_kate_util_get_error_message (ret)); break; } ret = kate_comment_init (&ke->kc); if (ret < 0) { GST_WARNING_OBJECT (ke, - "failed to initialize kate comment structure: %d", ret); + "failed to initialize kate comment structure: %s", + gst_kate_util_get_error_message (ret)); break; } ret = kate_encode_init (&ke->k, &ke->ki); if (ret < 0) { - GST_WARNING_OBJECT (ke, "failed to initialize kate state: %d", ret); + GST_WARNING_OBJECT (ke, "failed to initialize kate state: %s", + gst_kate_util_get_error_message (ret)); break; } ke->headers_sent = FALSE; @@ -1381,7 +1395,8 @@ gst_kate_enc_sink_event (GstPad * pad, GstEvent * event) ret = kate_encode_finish (&ke->k, -1, &kp); if (ret < 0) { - GST_WARNING_OBJECT (ke, "Failed to encode EOS packet: %d", ret); + GST_WARNING_OBJECT (ke, "Failed to encode EOS packet: %s", + gst_kate_util_get_error_message (ret)); } else { kate_int64_t granpos = kate_encode_get_granule (&ke->k); GST_LOG_OBJECT (ke, "EOS packet encoded"); diff --git a/ext/kate/gstkateparse.c b/ext/kate/gstkateparse.c index fff1208b35..dfb3f31bab 100644 --- a/ext/kate/gstkateparse.c +++ b/ext/kate/gstkateparse.c @@ -189,7 +189,8 @@ gst_kate_parse_push_headers (GstKateParse * parse) GST_BUFFER_DATA (outbuf)); ret = kate_decode_headerin (&parse->ki, &parse->kc, &packet); if (G_UNLIKELY (ret < 0)) { - GST_WARNING_OBJECT (parse, "kate_decode_headerin returned %d", ret); + GST_WARNING_OBJECT (parse, "Failed to decode header: %s", + gst_kate_util_get_error_message (ret)); } /* takes ownership of outbuf, which was previously in parse->streamheader */ outbuf_list = g_list_append (outbuf_list, outbuf); diff --git a/ext/kate/gstkatetiger.c b/ext/kate/gstkatetiger.c index dfeff65e66..d6e25a9c44 100644 --- a/ext/kate/gstkatetiger.c +++ b/ext/kate/gstkatetiger.c @@ -682,7 +682,8 @@ gst_kate_tiger_kate_chain (GstPad * pad, GstBuffer * buf) ev->ki, ev->start_time, ev->end_time, ev->bitmap, ev->text); if (G_UNLIKELY (ret < 0)) { GST_WARNING_OBJECT (tiger, - "failed to add Kate event to Tiger renderer: %d", ret); + "failed to add Kate event to Tiger renderer: %s", + gst_kate_util_get_error_message (ret)); } } } @@ -824,7 +825,8 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf) tiger->video_height, tiger->video_width * 4, tiger->swap_rgb); if (G_UNLIKELY (ret < 0)) { GST_WARNING_OBJECT (tiger, - "Tiger renderer failed to set buffer to video frame: %d", ret); + "Tiger renderer failed to set buffer to video frame: %s", + gst_kate_util_get_error_message (ret)); goto pass; } @@ -834,7 +836,8 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf) (long) tiger->video_segment.last_stop, t); ret = tiger_renderer_update (tiger->tr, t, 1); if (G_UNLIKELY (ret < 0)) { - GST_WARNING_OBJECT (tiger, "Tiger renderer failed to update: %d", ret); + GST_WARNING_OBJECT (tiger, "Tiger renderer failed to update: %s", + gst_kate_util_get_error_message (ret)); goto pass; } @@ -866,13 +869,15 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf) tiger->video_height, tiger->video_width * 4, tiger->swap_rgb); if (G_UNLIKELY (ret < 0)) { GST_WARNING_OBJECT (tiger, - "Tiger renderer failed to set buffer to video frame: %d", ret); + "Tiger renderer failed to set buffer to video frame: %s", + gst_kate_util_get_error_message (ret)); goto pass; } ret = tiger_renderer_render (tiger->tr); if (G_UNLIKELY (ret < 0)) { GST_WARNING_OBJECT (tiger, - "Tiger renderer failed to render to video frame: %d", ret); + "Tiger renderer failed to render to video frame: %s", + gst_kate_util_get_error_message (ret)); } else { GST_LOG_OBJECT (tiger, "Tiger renderer rendered on video frame at %f", t); } @@ -928,15 +933,16 @@ gst_kate_tiger_change_state (GstElement * element, GstStateChange transition) if (tiger->decoder.initialized) { int ret = tiger_renderer_create (&tiger->tr); if (ret < 0) { - GST_WARNING_OBJECT (tiger, "failed to create tiger renderer: %d", - ret); + GST_WARNING_OBJECT (tiger, "failed to create tiger renderer: %s", + gst_kate_util_get_error_message (ret)); } else { ret = tiger_renderer_set_default_font_description (tiger->tr, tiger->default_font_desc); if (ret < 0) { GST_WARNING_OBJECT (tiger, - "failed to set tiger default font description: %d", ret); + "failed to set tiger default font description: %s", + gst_kate_util_get_error_message (ret)); } gst_kate_tiger_update_default_font_color (tiger); gst_kate_tiger_update_default_background_color (tiger); diff --git a/ext/kate/gstkateutil.c b/ext/kate/gstkateutil.c index 3062d5cd80..d369205bbc 100644 --- a/ext/kate/gstkateutil.c +++ b/ext/kate/gstkateutil.c @@ -24,6 +24,9 @@ #endif #include +#ifdef HAVE_TIGER +#include +#endif #include #include "gstkate.h" #include "gstkateutil.h" @@ -266,7 +269,8 @@ gst_kate_util_decoder_base_chain_kate_packet (GstKateDecoderBase * decoder, ret = kate_high_decode_packetin (&decoder->k, &kp, ev); if (G_UNLIKELY (ret < 0)) { GST_ELEMENT_ERROR (element, STREAM, DECODE, (NULL), - ("Failed to decode Kate packet: %d", ret)); + ("Failed to decode Kate packet: %s", + gst_kate_util_get_error_message (ret))); return GST_FLOW_ERROR; } @@ -436,8 +440,8 @@ gst_kate_decoder_base_change_state (GstKateDecoderBase * decoder, GST_DEBUG_OBJECT (element, "READY -> PAUSED, initializing kate state"); ret = kate_high_decode_init (&decoder->k); if (ret < 0) { - GST_WARNING_OBJECT (element, "failed to initialize kate state: %d", - ret); + GST_WARNING_OBJECT (element, "failed to initialize kate state: %s", + gst_kate_util_get_error_message (ret)); } gst_segment_init (&decoder->kate_segment, GST_FORMAT_UNDEFINED); decoder->kate_flushing = FALSE; @@ -635,3 +639,50 @@ gst_kate_decoder_base_sink_query (GstKateDecoderBase * decoder, return gst_pad_query_default (pad, query); } } + +const char * +gst_kate_util_get_error_message (int ret) +{ + switch (ret) { + case KATE_E_NOT_FOUND: + return "value not found"; + case KATE_E_INVALID_PARAMETER: + return "invalid parameter"; + case KATE_E_OUT_OF_MEMORY: + return "out of memory"; + case KATE_E_BAD_GRANULE: + return "bad granule"; + case KATE_E_INIT: + return "initialization error"; + case KATE_E_BAD_PACKET: + return "bad packet"; + case KATE_E_TEXT: + return "invalid/truncated text"; + case KATE_E_LIMIT: + return "a limit was exceeded"; + case KATE_E_VERSION: + return "unsupported bitstream version"; + case KATE_E_NOT_KATE: + return "not a kate bitstream"; + case KATE_E_BAD_TAG: + return "bad tag"; + case KATE_E_IMPL: + return "not implemented"; + +#ifdef HAVE_TIGER + case TIGER_E_NOT_FOUND: + return "value not found"; + case TIGER_E_INVALID_PARAMETER: + return "invalid parameter"; + case TIGER_E_OUT_OF_MEMORY: + return "out of memory"; + case TIGER_E_CAIRO_ERROR: + return "Cairo error"; + case TIGER_E_BAD_SURFACE_TYPE: + return "bad surface type"; +#endif + + default: + return "unknown error"; + } +} diff --git a/ext/kate/gstkateutil.h b/ext/kate/gstkateutil.h index 27b6f70f31..ffa49b4838 100644 --- a/ext/kate/gstkateutil.h +++ b/ext/kate/gstkateutil.h @@ -98,6 +98,8 @@ extern gboolean gst_kate_decoder_base_sink_query (GstKateDecoderBase * decoder, GstElement * element, GstPad * pad, GstQuery * query); extern gboolean gst_kate_util_decoder_base_queue_event (GstKateDecoderBase * decoder, GstEvent * event, gboolean (*handler)(GstPad *, GstEvent *), GstPad * pad); +extern const char * +gst_kate_util_get_error_message (int ret); G_END_DECLS #endif /* __GST_KATE_UTIL_H__ */ From 5c8ca4e1d03620223a0dce72a1515199bfb1d872 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Thu, 2 Feb 2012 11:20:38 +0000 Subject: [PATCH 18/37] mpegdemux: include specific AAC stream-format types in template caps https://bugzilla.gnome.org/show_bug.cgi?id=665394 --- gst/mpegdemux/gstmpegdemux.c | 4 ++-- gst/mpegdemux/gstmpegtsdemux.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gst/mpegdemux/gstmpegdemux.c b/gst/mpegdemux/gstmpegdemux.c index 0da3e0c777..7e9fb14c65 100644 --- a/gst/mpegdemux/gstmpegdemux.c +++ b/gst/mpegdemux/gstmpegdemux.c @@ -118,8 +118,8 @@ static GstStaticPadTemplate audio_template = GST_STATIC_PAD_TEMPLATE ("audio_%02x", GST_PAD_SRC, GST_PAD_SOMETIMES, - GST_STATIC_CAPS ("audio/mpeg, " - "mpegversion = (int) { 1, 4 };" + GST_STATIC_CAPS ("audio/mpeg, mpegversion = (int) 1;" + "audio/mpeg, mpegversion = (int) 4, stream-format = (string) { adts, loas };" "audio/x-private1-lpcm; " "audio/x-private1-ac3;" "audio/x-private1-dts;" "audio/ac3") ); diff --git a/gst/mpegdemux/gstmpegtsdemux.c b/gst/mpegdemux/gstmpegtsdemux.c index 2c6db7da39..a7c3a17b97 100644 --- a/gst/mpegdemux/gstmpegtsdemux.c +++ b/gst/mpegdemux/gstmpegtsdemux.c @@ -125,7 +125,10 @@ enum #define AUDIO_CAPS \ GST_STATIC_CAPS ( \ "audio/mpeg, " \ - "mpegversion = (int) { 1, 4 };" \ + "mpegversion = (int) 1;" \ + "audio/mpeg, " \ + "mpegversion = (int) 4, " \ + "stream-format = (string) { adts, loas };" \ "audio/x-lpcm, " \ "width = (int) { 16, 20, 24 }, " \ "rate = (int) { 48000, 96000 }, " \ From 27f21d31ac3f4c5f856b21cc780031bb3cf9e7a7 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Thu, 2 Feb 2012 11:27:33 +0000 Subject: [PATCH 19/37] mpegtsmux: specify in template caps we only take raw/adts AAC format This appears to be what this element supports. https://bugzilla.gnome.org/show_bug.cgi?id=665394 --- gst/mpegtsmux/mpegtsmux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c index bab4a873de..9eede8125a 100644 --- a/gst/mpegtsmux/mpegtsmux.c +++ b/gst/mpegtsmux/mpegtsmux.c @@ -121,7 +121,9 @@ static GstStaticPadTemplate mpegtsmux_sink_factory = "video/x-dirac;" "video/x-h264,stream-format=(string)byte-stream;" "audio/mpeg, " - "mpegversion = (int) { 1, 2, 4 };" + "mpegversion = (int) { 1, 2 };" + "audio/mpeg, " + "mpegversion = (int) 4, stream-format = (string) { raw, adts };" "audio/x-lpcm, " "width = (int) { 16, 20, 24 }, " "rate = (int) { 48000, 96000 }, " From b131ad9563a67288e80c6795b21ac749506c571b Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Thu, 2 Feb 2012 11:31:32 +0000 Subject: [PATCH 20/37] faad: include specific support AAC stream formats in template caps https://bugzilla.gnome.org/show_bug.cgi?id=665394 --- ext/faad/gstfaad.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/faad/gstfaad.c b/ext/faad/gstfaad.c index 838df31bca..4dd73eba8d 100644 --- a/ext/faad/gstfaad.c +++ b/ext/faad/gstfaad.c @@ -92,7 +92,8 @@ GST_DEBUG_CATEGORY_STATIC (faad_debug); static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/mpeg, " "mpegversion = (int) { 2, 4 }") + GST_STATIC_CAPS ("audio/mpeg, " "mpegversion = (int) 2; " + "audio/mpeg, mpegversion = (int) 4, stream-format = (string) { raw, adts }") ); #define STATIC_INT_CAPS(bpp) \ From 2dec0950cfd32bf4c50a78a1f03acba3bd7029aa Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Thu, 2 Feb 2012 11:37:55 +0000 Subject: [PATCH 21/37] tsdemux: add explicit supported AAC stream-format in template caps https://bugzilla.gnome.org/show_bug.cgi?id=665394 --- gst/mpegtsdemux/tsdemux.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index 0162ab9aee..166089ba5b 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -146,7 +146,10 @@ struct _TSDemuxStream #define AUDIO_CAPS \ GST_STATIC_CAPS ( \ "audio/mpeg, " \ - "mpegversion = (int) { 1, 4 };" \ + "mpegversion = (int) 1;" \ + "audio/mpeg, " \ + "mpegversion = (int) 4, " \ + "stream-format = (string) adts; " \ "audio/x-lpcm, " \ "width = (int) { 16, 20, 24 }, " \ "rate = (int) { 48000, 96000 }, " \ @@ -1077,11 +1080,12 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream, case ST_DSMCC_D: MPEGTS_BIT_UNSET (base->is_pes, bstream->pid); break; - case ST_AUDIO_AAC: + case ST_AUDIO_AAC: /* ADTS */ template = gst_static_pad_template_get (&audio_template); name = g_strdup_printf ("audio_%04x", bstream->pid); caps = gst_caps_new_simple ("audio/mpeg", - "mpegversion", G_TYPE_INT, 4, NULL); + "mpegversion", G_TYPE_INT, 4, + "stream-format", G_TYPE_STRING, "adts", NULL); break; case ST_VIDEO_MPEG4: template = gst_static_pad_template_get (&video_template); From 0d1c9624ea568456c23845c0673bf7bee8ebace3 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Thu, 2 Feb 2012 11:41:15 +0000 Subject: [PATCH 22/37] mpegpsmux: include specific AAC stream-format in template caps This elements seems to support raw and adts AAC. https://bugzilla.gnome.org/show_bug.cgi?id=665394 --- gst/mpegpsmux/mpegpsmux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gst/mpegpsmux/mpegpsmux.c b/gst/mpegpsmux/mpegpsmux.c index 218f4fb0e9..947bdb8dad 100644 --- a/gst/mpegpsmux/mpegpsmux.c +++ b/gst/mpegpsmux/mpegpsmux.c @@ -69,7 +69,9 @@ static GstStaticPadTemplate mpegpsmux_sink_factory = "video/x-dirac;" "video/x-h264;" "audio/mpeg, " - "mpegversion = (int) { 1, 2, 4 };" + "mpegversion = (int) { 1, 2 };" + "audio/mpeg, " + "mpegversion = (int) 4, stream-format = (string) { raw, adts }; " "audio/x-lpcm, " "width = (int) { 16, 20, 24 }, " "rate = (int) { 48000, 96000 }, " From f8f462045184086e610079c872b80e745b7d8474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 3 Feb 2012 00:50:33 +0000 Subject: [PATCH 23/37] build: fix CFLAGS order and LIBS order _BAD_CFLAGS should always come first, then GST_PLUGINS_BASE_CFLAGS, then GST_BASE_CFLAGS then GST_CFLAGS. Same for libs: first plugins base libs, then GST_BASE_LIB then GST_LIBS. --- ext/cog/Makefile.am | 2 +- ext/curl/Makefile.am | 2 +- ext/gsettings/Makefile.am | 2 +- ext/kate/Makefile.am | 2 +- ext/mpeg2enc/Makefile.am | 2 +- ext/mplex/Makefile.am | 2 +- ext/opus/Makefile.am | 7 +++---- ext/sdl/Makefile.am | 2 +- gst/hls/Makefile.am | 4 ++-- gst/inter/Makefile.am | 16 ++++++++-------- gst/liveadder/Makefile.am | 2 +- gst/mve/Makefile.am | 2 +- sys/decklink/Makefile.am | 2 +- sys/shm/Makefile.am | 4 ++-- tests/examples/scaletempo/Makefile.am | 4 ++-- 15 files changed, 27 insertions(+), 28 deletions(-) diff --git a/ext/cog/Makefile.am b/ext/cog/Makefile.am index 595dab7d98..bbed6fe0e3 100644 --- a/ext/cog/Makefile.am +++ b/ext/cog/Makefile.am @@ -5,9 +5,9 @@ include $(top_srcdir)/common/orc.mak libgstcog_la_CFLAGS = \ -DCOG_ENABLE_UNSTABLE_API \ + $(GST_PLUGINS_BAD_CFLAGS) \ -I$(srcdir)/.. \ $(GST_PLUGINS_BASE_CFLAGS) \ - $(GST_PLUGINS_BAD_CFLAGS) \ $(GST_CFLAGS) \ $(ORC_CFLAGS) \ $(COG_CFLAGS) diff --git a/ext/curl/Makefile.am b/ext/curl/Makefile.am index 4fc6868a78..42fbe31b47 100644 --- a/ext/curl/Makefile.am +++ b/ext/curl/Makefile.am @@ -2,8 +2,8 @@ plugin_LTLIBRARIES = libgstcurl.la libgstcurl_la_SOURCES = gstcurl.c gstcurlsink.c libgstcurl_la_CFLAGS = \ - $(GST_BASE_CFLAGS) \ $(GST_PLUGINS_BAD_CFLAGS) \ + $(GST_BASE_CFLAGS) \ $(GST_CFLAGS) \ $(CURL_CFLAGS) libgstcurl_la_LIBADD = \ diff --git a/ext/gsettings/Makefile.am b/ext/gsettings/Makefile.am index 2c3abb114e..6cef006a60 100644 --- a/ext/gsettings/Makefile.am +++ b/ext/gsettings/Makefile.am @@ -18,7 +18,7 @@ libgstgsettingselements_la_SOURCES = \ gstswitchsrc.c \ plugin.c -libgstgsettingselements_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GSETTINGS_CFLAGS) $(DIR_CFLAGS) \ +libgstgsettingselements_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_CFLAGS) $(GSETTINGS_CFLAGS) $(DIR_CFLAGS) \ -DGstSwitchSrc=GstGSettingsSwitchSrc \ -DGstSwitchSrcClass=GstGSettingsSwitchSrcClass \ -DGstSwitchSink=GstGSettingsSwitchSink \ diff --git a/ext/kate/Makefile.am b/ext/kate/Makefile.am index d732ffa654..4e310d92ba 100644 --- a/ext/kate/Makefile.am +++ b/ext/kate/Makefile.am @@ -9,7 +9,7 @@ libgstkate_la_SOURCES += gstkatetiger.c endif # flags used to compile this plugin -libgstkate_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(TIGER_CFLAGS) $(KATE_CFLAGS) +libgstkate_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(TIGER_CFLAGS) $(KATE_CFLAGS) libgstkate_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) -lgsttag-$(GST_MAJORMINOR) $(GST_LIBS) $(TIGER_LIBS) $(KATE_LIBS) libgstkate_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstkate_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/ext/mpeg2enc/Makefile.am b/ext/mpeg2enc/Makefile.am index 32e00c8ae1..ae78a55546 100644 --- a/ext/mpeg2enc/Makefile.am +++ b/ext/mpeg2enc/Makefile.am @@ -8,7 +8,7 @@ libgstmpeg2enc_la_SOURCES = \ gstmpeg2encpicturereader.cc libgstmpeg2enc_la_CXXFLAGS = \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GST_CXXFLAGS) $(MPEG2ENC_CFLAGS) + $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) $(MPEG2ENC_CFLAGS) libgstmpeg2enc_la_LIBADD = \ $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) $(MPEG2ENC_LIBS) libgstmpeg2enc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) diff --git a/ext/mplex/Makefile.am b/ext/mplex/Makefile.am index 4155d7048d..741b0d8934 100644 --- a/ext/mplex/Makefile.am +++ b/ext/mplex/Makefile.am @@ -7,7 +7,7 @@ libgstmplex_la_SOURCES = \ gstmplexoutputstream.cc libgstmplex_la_CXXFLAGS = \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GST_CXXFLAGS) $(MPLEX_CFLAGS) + $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) $(MPLEX_CFLAGS) libgstmplex_la_LIBADD = \ $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(MPLEX_LIBS) libgstmplex_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(MPLEX_LDFLAGS) diff --git a/ext/opus/Makefile.am b/ext/opus/Makefile.am index 1aaed79247..48a7eade40 100644 --- a/ext/opus/Makefile.am +++ b/ext/opus/Makefile.am @@ -3,14 +3,13 @@ plugin_LTLIBRARIES = libgstopus.la libgstopus_la_SOURCES = gstopus.c gstopusdec.c gstopusenc.c gstopusparse.c gstopusheader.c gstopuscommon.c gstrtpopuspay.c gstrtpopusdepay.c libgstopus_la_CFLAGS = \ -DGST_USE_UNSTABLE_API \ - $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_PLUGINS_BAD_CFLAGS) \ + $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_CFLAGS) \ $(OPUS_CFLAGS) libgstopus_la_LIBADD = \ - -lgstaudio-$(GST_MAJORMINOR) \ - $(GST_PLUGINS_BASE_LIBS) -lgsttag-$(GST_MAJORMINOR) \ - -lgstrtp-@GST_MAJORMINOR@ \ + $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) \ + -lgsttag-$(GST_MAJORMINOR) -lgstrtp-$(GST_MAJORMINOR) \ $(GST_BASE_LIBS) \ $(GST_LIBS) \ $(OPUS_LIBS) diff --git a/ext/sdl/Makefile.am b/ext/sdl/Makefile.am index ce027dd2fc..6bc4264f60 100644 --- a/ext/sdl/Makefile.am +++ b/ext/sdl/Makefile.am @@ -5,7 +5,7 @@ libgstsdl_la_SOURCES = \ sdlvideosink.c \ sdlaudiosink.c -libgstsdl_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GST_CFLAGS) $(SDL_CFLAGS) +libgstsdl_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(SDL_CFLAGS) libgstsdl_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ -lgstvideo-$(GST_MAJORMINOR) \ -lgstaudio-$(GST_MAJORMINOR) \ diff --git a/gst/hls/Makefile.am b/gst/hls/Makefile.am index 19fd6211f0..fec8eeb278 100644 --- a/gst/hls/Makefile.am +++ b/gst/hls/Makefile.am @@ -6,8 +6,8 @@ libgstfragmented_la_SOURCES = \ gsthlsdemux.c \ gstfragmentedplugin.c -libgstfragmented_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(SOUP_CFLAGS) -libgstfragmented_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(SOUP_LIBS) +libgstfragmented_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(SOUP_CFLAGS) +libgstfragmented_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(SOUP_LIBS) libgstfragmented_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -no-undefined libgstfragmented_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/gst/inter/Makefile.am b/gst/inter/Makefile.am index d6749a5ef0..e404959879 100644 --- a/gst/inter/Makefile.am +++ b/gst/inter/Makefile.am @@ -22,15 +22,15 @@ noinst_HEADERS = \ gstintersurface.h libgstinter_la_CFLAGS = \ - $(GST_CFLAGS) \ - $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_PLUGINS_BAD_CFLAGS) \ - $(GST_BASE_CFLAGS) + $(GST_PLUGINS_BASE_CFLAGS) \ + $(GST_BASE_CFLAGS) \ + $(GST_CFLAGS) libgstinter_la_LIBADD = \ - $(GST_LIBS) \ - $(GST_BASE_LIBS) \ $(GST_PLUGINS_BASE_LIBS) -lgstvideo-@GST_MAJORMINOR@ -lgstaudio-@GST_MAJORMINOR@ \ + $(GST_BASE_LIBS) \ + $(GST_LIBS) \ $(LIBM) libgstinter_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) @@ -40,13 +40,13 @@ gstintertest_SOURCES = \ gstintertest.c gstintertest_CFLAGS = \ - $(GST_CFLAGS) \ + $(GST_PLUGINS_BAD_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ - $(GST_PLUGINS_BAD_CFLAGS) + $(GST_CFLAGS) gstintertest_LDADD = \ - $(GST_LIBS) \ $(GST_PLUGINS_BASE_LIBS) \ + $(GST_LIBS) \ $(LIBM) Android.mk: Makefile.am $(BUILT_SOURCES) diff --git a/gst/liveadder/Makefile.am b/gst/liveadder/Makefile.am index 14f490da75..0bbeff90fd 100644 --- a/gst/liveadder/Makefile.am +++ b/gst/liveadder/Makefile.am @@ -1,7 +1,7 @@ plugin_LTLIBRARIES = libgstliveadder.la libgstliveadder_la_SOURCES = liveadder.c -libgstliveadder_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GST_CFLAGS) +libgstliveadder_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) libgstliveadder_la_LIBADD = \ $(GST_PLUGINS_BASE_LIBS) -lgstaudio-@GST_MAJORMINOR@ \ $(GST_BASE_LIBS) $(GST_LIBS) diff --git a/gst/mve/Makefile.am b/gst/mve/Makefile.am index 2c3104f64d..8be4517d30 100644 --- a/gst/mve/Makefile.am +++ b/gst/mve/Makefile.am @@ -1,6 +1,6 @@ plugin_LTLIBRARIES = libgstmve.la -libgstmve_la_CFLAGS = $(GST_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GST_CFLAGS) +libgstmve_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) libgstmve_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM) libgstmve_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstmve_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/sys/decklink/Makefile.am b/sys/decklink/Makefile.am index 94dbb09efd..22863edc33 100644 --- a/sys/decklink/Makefile.am +++ b/sys/decklink/Makefile.am @@ -1,8 +1,8 @@ plugin_LTLIBRARIES = libgstdecklink.la libgstdecklink_la_CPPFLAGS = \ - $(GST_BASE_CFLAGS) \ $(GST_PLUGINS_BAD_CFLAGS) \ + $(GST_BASE_CFLAGS) \ $(GST_CXXFLAGS) \ $(DECKLINK_CXXFLAGS) libgstdecklink_la_LIBADD = \ diff --git a/sys/shm/Makefile.am b/sys/shm/Makefile.am index 59a1e3b79c..f62e20e1ad 100644 --- a/sys/shm/Makefile.am +++ b/sys/shm/Makefile.am @@ -5,9 +5,9 @@ include $(top_srcdir)/common/glib-gen.mak plugin_LTLIBRARIES = libgstshm.la libgstshm_la_SOURCES = shmpipe.c shmalloc.c gstshm.c gstshmsrc.c gstshmsink.c -libgstshm_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) -DSHM_PIPE_USE_GLIB +libgstshm_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_CFLAGS) -DSHM_PIPE_USE_GLIB libgstshm_la_LIBADD = -lrt -libgstshm_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) +libgstshm_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(GST_BASE_LIBS) libgstshm_la_LIBTOOLFLAGS = --tag=disable-static noinst_HEADERS = gstshmsrc.h gstshmsink.h shmpipe.h shmalloc.h diff --git a/tests/examples/scaletempo/Makefile.am b/tests/examples/scaletempo/Makefile.am index 500e511239..aec2f29c32 100644 --- a/tests/examples/scaletempo/Makefile.am +++ b/tests/examples/scaletempo/Makefile.am @@ -1,8 +1,8 @@ noinst_PROGRAMS = scaletempo-demo scaletempo_demo_SOURCES = demo-main.c demo-player.c demo-gui.c -scaletempo_demo_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GTK_CFLAGS) -scaletempo_demo_LDFLAGS = $(GST_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GTK_LIBS) -lgstinterfaces-@GST_MAJORMINOR@ +scaletempo_demo_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(GTK_CFLAGS) +scaletempo_demo_LDFLAGS = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-@GST_MAJORMINOR@ $(GST_LIBS) $(GTK_LIBS) noinst_HEADERS = demo-player.h demo-gui.h From c36bb8b73d224ce4872e1533694577707446a527 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Fri, 3 Feb 2012 11:26:53 +0100 Subject: [PATCH 24/37] h264parse: decrease passthrough negotiation preference Also ensure parsing fixed caps when negotiating rather than failing to handle non-fixed list cases. See #668471. --- gst/videoparsers/gsth264parse.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 230fd85c64..3482d5bfe4 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -293,6 +293,9 @@ gst_h264_parse_get_string (GstH264Parse * parse, gboolean format, gint code) static void gst_h264_parse_format_from_caps (GstCaps * caps, guint * format, guint * align) { + g_return_if_fail (gst_caps_is_fixed (caps)); + + GST_DEBUG ("parsing caps: %" GST_PTR_FORMAT, caps); if (format) *format = GST_H264_PARSE_FORMAT_NONE; @@ -332,9 +335,20 @@ gst_h264_parse_negotiate (GstH264Parse * h264parse, GstCaps * in_caps) guint format = GST_H264_PARSE_FORMAT_NONE; guint align = GST_H264_PARSE_ALIGN_NONE; + g_return_if_fail ((in_caps == NULL) || gst_caps_is_fixed (in_caps)); + caps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (h264parse)); GST_DEBUG_OBJECT (h264parse, "allowed caps: %" GST_PTR_FORMAT, caps); + /* concentrate on leading structure, since decodebin2 parser + * capsfilter always includes parser template caps */ + if (caps) { + caps = gst_caps_make_writable (caps); + gst_caps_truncate (caps); + GST_DEBUG_OBJECT (h264parse, "negotiating with caps: %" GST_PTR_FORMAT, + caps); + } + if (in_caps && caps) { if (gst_caps_can_intersect (in_caps, caps)) { GST_DEBUG_OBJECT (h264parse, "downstream accepts upstream caps"); @@ -345,6 +359,8 @@ gst_h264_parse_negotiate (GstH264Parse * h264parse, GstCaps * in_caps) } if (caps) { + /* fixate to avoid ambiguity with lists when parsing */ + gst_pad_fixate_caps (GST_BASE_PARSE_SRC_PAD (h264parse), caps); gst_h264_parse_format_from_caps (caps, &format, &align); gst_caps_unref (caps); } From 2eef9828d6735572e5f1bfd0409108e40963696c Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Fri, 3 Feb 2012 11:08:48 +0000 Subject: [PATCH 25/37] mpegtsdemux: do not emit no-more-pads Doing so may fix some things, but breaks others (new streams being added in the future). https://bugzilla.gnome.org/show_bug.cgi?id=665814 --- gst/mpegdemux/gstmpegtsdemux.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gst/mpegdemux/gstmpegtsdemux.c b/gst/mpegdemux/gstmpegtsdemux.c index a7c3a17b97..012c1cc716 100644 --- a/gst/mpegdemux/gstmpegtsdemux.c +++ b/gst/mpegdemux/gstmpegtsdemux.c @@ -399,6 +399,14 @@ gst_mpegts_demux_reset (GstMpegTSDemux * demux) demux->last_buf_ts = GST_CLOCK_TIME_NONE; } +static void +gst_mpegts_demux_no_more_pads (GstElement * demux) +{ + /* We should really call no-more-pads here, but we don't as + this would preclude addition of more pads if/when new streams + are added. */ +} + #if 0 static void gst_mpegts_demux_remove_pads (GstMpegTSDemux * demux) @@ -1086,7 +1094,7 @@ gst_mpegts_demux_sync_streams (GstMpegTSDemux * demux, GstClockTime time) any pad that might be waiting for data */ if (!stream->pad && demux->pending_pads > 0) { demux->pending_pads = 0; - gst_element_no_more_pads (GST_ELEMENT (demux)); + gst_mpegts_demux_no_more_pads (GST_ELEMENT (demux)); } if (stream->pad) { @@ -1332,7 +1340,7 @@ gst_mpegts_demux_data_cb (GstPESFilter * filter, gboolean first, If not, we'll add pads as we get data for them, and will end up hitting decodebin2's overrun threshold (if using decodebin2) */ GST_DEBUG_OBJECT (demux, "All pads added, we can signal no-more-pads"); - gst_element_no_more_pads (GST_ELEMENT (demux)); + gst_mpegts_demux_no_more_pads (GST_ELEMENT (demux)); } else { GST_DEBUG_OBJECT (demux, "All pads could not be added, we will not signal no-more-pads"); @@ -1387,7 +1395,7 @@ gst_mpegts_demux_data_cb (GstPESFilter * filter, gboolean first, "Adding pad due to received data, decreasing pending pads to %d", demux->pending_pads); if (demux->pending_pads == 0) - gst_element_no_more_pads (GST_ELEMENT (demux)); + gst_mpegts_demux_no_more_pads (GST_ELEMENT (demux)); stream->discont = TRUE; @@ -1741,7 +1749,7 @@ gst_mpegts_stream_parse_pmt (GstMpegTSStream * stream, GST_DEBUG_OBJECT (demux, "Done parsing PMT, pending pads now %d", demux->pending_pads); if (demux->pending_pads == 0) - gst_element_no_more_pads (GST_ELEMENT (demux)); + gst_mpegts_demux_no_more_pads (GST_ELEMENT (demux)); return TRUE; From e84bbcbeabece21849f45d51b6e0f7b766cfa4dd Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Sat, 4 Feb 2012 22:06:12 +0000 Subject: [PATCH 26/37] rotate: fix description string to match what the element does https://bugzilla.gnome.org/show_bug.cgi?id=669365 --- gst/geometrictransform/gstrotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gst/geometrictransform/gstrotate.c b/gst/geometrictransform/gstrotate.c index 6c5ba62cbc..2c26bc3fed 100644 --- a/gst/geometrictransform/gstrotate.c +++ b/gst/geometrictransform/gstrotate.c @@ -134,7 +134,7 @@ gst_rotate_base_init (gpointer gclass) gst_element_class_set_details_simple (element_class, "rotate", "Transform/Effect/Video", - "Warps the picture into an arc shaped form", + "Rotates the picture by an arbitrary angle", "Thiago Santos"); } From ddff93320dda8460c22fbe3cc0567b40fb4a0f31 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Sat, 4 Feb 2012 22:06:57 +0000 Subject: [PATCH 27/37] rotate: angle is in radians already, do not scale it Other plugins use radians, and the angle documentation says radians. https://bugzilla.gnome.org/show_bug.cgi?id=669365 --- gst/geometrictransform/gstrotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gst/geometrictransform/gstrotate.c b/gst/geometrictransform/gstrotate.c index 2c26bc3fed..764feb56a0 100644 --- a/gst/geometrictransform/gstrotate.c +++ b/gst/geometrictransform/gstrotate.c @@ -154,7 +154,7 @@ rotate_map (GstGeometricTransform * gt, gint x, gint y, gdouble * in_x, h = gt->height; /* our parameters */ - ar = rotate->angle * G_PI / 180.0; /* angle of rotation, degrees to radians */ + ar = rotate->angle; /* angle of rotation */ /* get in and out centers */ cox = 0.5 * w; From 9bd40e92ce4b4558be90f6f5a202812267149ebe Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Thu, 2 Feb 2012 12:22:06 -0300 Subject: [PATCH 28/37] camerabin: Improve debug message about processing counter Mention on the logs how many capture operations might have been lost --- gst/camerabin/gstcamerabin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index 605780e40c..7ebb0bb906 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -3929,7 +3929,8 @@ gst_camerabin_change_state (GstElement * element, GstStateChange transition) } /* reset processing counter */ - GST_DEBUG_OBJECT (camera, "Reset processing counter to 0"); + GST_DEBUG_OBJECT (camera, "Reset processing counter from %d to 0", + camera->processing_counter); camera->processing_counter = 0; g_object_notify (G_OBJECT (camera), "idle"); g_mutex_unlock (camera->capture_mutex); From 3b549c4dbdbe1129f4bbc0be3a9caf3b1c8ca22d Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Thu, 2 Feb 2012 13:33:02 -0300 Subject: [PATCH 29/37] camerabin: prevent captures from being lost when switching resolutions When switching capture caps, camerabin1 resets its state to ready to force a new caps to be negotiated. This causes ongoing captures to be aborted. This commit adds a condition to wait for captures to finish before going to ready state. --- gst/camerabin/gstcamerabin.c | 31 ++++++++++++++++++++++++++----- gst/camerabin/gstcamerabin.h | 1 + 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index 7ebb0bb906..e3f4bf7ea3 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -242,25 +242,37 @@ static guint camerabin_signals[LAST_SIGNAL]; GST_DEBUG_OBJECT ((c), "Processing counter incremented to: %d", \ (c)->processing_counter); \ if ((c)->processing_counter == 1) \ - g_object_notify (G_OBJECT (c), "idle"); \ + g_object_notify (G_OBJECT (c), "idle"); #define CAMERABIN_PROCESSING_DEC_UNLOCKED(c) \ (c)->processing_counter -= 1; \ GST_DEBUG_OBJECT ((c), "Processing counter decremented to: %d", \ (c)->processing_counter); \ g_assert ((c)->processing_counter >= 0); \ - if ((c)->processing_counter == 0) \ - g_object_notify (G_OBJECT (c), "idle"); \ + if ((c)->processing_counter == 0) { \ + g_cond_signal ((c)->idle_cond); \ + g_object_notify (G_OBJECT (c), "idle"); \ + } #define CAMERABIN_PROCESSING_INC(c) \ g_mutex_lock ((c)->capture_mutex); \ CAMERABIN_PROCESSING_INC_UNLOCKED ((c)); \ - g_mutex_unlock ((c)->capture_mutex); \ + g_mutex_unlock ((c)->capture_mutex); #define CAMERABIN_PROCESSING_DEC(c) \ g_mutex_lock ((c)->capture_mutex); \ CAMERABIN_PROCESSING_DEC_UNLOCKED ((c)); \ - g_mutex_unlock ((c)->capture_mutex); \ + g_mutex_unlock ((c)->capture_mutex); + +#define CAMERABIN_PROCESSING_WAIT_IDLE(c) \ + g_mutex_lock ((c)->capture_mutex); \ + if ((c)->processing_counter > 0) { \ + GST_DEBUG_OBJECT ((c), "Waiting for processing operations to finish %d", \ + (c)->processing_counter); \ + g_cond_wait ((c)->idle_cond, (c)->capture_mutex); \ + GST_DEBUG_OBJECT ((c), "Processing operations finished"); \ + } \ + g_mutex_unlock ((c)->capture_mutex); /* * static helper functions declaration @@ -939,6 +951,10 @@ camerabin_dispose_elements (GstCameraBin * camera) g_cond_free (camera->cond); camera->cond = NULL; } + if (camera->idle_cond) { + g_cond_free (camera->idle_cond); + camera->idle_cond = NULL; + } if (camera->filename) { g_string_free (camera->filename, TRUE); camera->filename = NULL; @@ -1613,6 +1629,9 @@ reset_video_capture_caps (GstCameraBin * camera) /* Interrupt ongoing capture */ gst_camerabin_do_stop (camera); + /* prevent image captures from being lost */ + CAMERABIN_PROCESSING_WAIT_IDLE (camera); + gst_element_get_state (GST_ELEMENT (camera), &state, &pending, 0); if (state == GST_STATE_PAUSED || state == GST_STATE_PLAYING) { GST_INFO_OBJECT (camera, @@ -3354,6 +3373,7 @@ gst_camerabin_init (GstCameraBin * camera, GstCameraBinClass * gclass) /* concurrency control */ camera->capture_mutex = g_mutex_new (); camera->cond = g_cond_new (); + camera->idle_cond = g_cond_new (); camera->processing_counter = 0; /* pad names for output and input selectors */ @@ -3932,6 +3952,7 @@ gst_camerabin_change_state (GstElement * element, GstStateChange transition) GST_DEBUG_OBJECT (camera, "Reset processing counter from %d to 0", camera->processing_counter); camera->processing_counter = 0; + g_cond_signal (camera->idle_cond); g_object_notify (G_OBJECT (camera), "idle"); g_mutex_unlock (camera->capture_mutex); diff --git a/gst/camerabin/gstcamerabin.h b/gst/camerabin/gstcamerabin.h index 066545c94c..1c0a075f5f 100644 --- a/gst/camerabin/gstcamerabin.h +++ b/gst/camerabin/gstcamerabin.h @@ -129,6 +129,7 @@ struct _GstCameraBin /* concurrency control */ GMutex *capture_mutex; GCond *cond; + GCond *idle_cond; gboolean capturing; gboolean eos_handled; /* everytime a new capture is started this is incremented, when it is From d3b1488fa734b4aa025845feb0590bf46d0983f5 Mon Sep 17 00:00:00 2001 From: Andoni Morales Alastruey Date: Sat, 27 Aug 2011 13:07:00 +0200 Subject: [PATCH 30/37] d3dvideosink: Fix device initialization check --- sys/d3dvideosink/d3dvideosink.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/d3dvideosink/d3dvideosink.c b/sys/d3dvideosink/d3dvideosink.c index 53d5c89fff..ed4d249b6e 100644 --- a/sys/d3dvideosink/d3dvideosink.c +++ b/sys/d3dvideosink/d3dvideosink.c @@ -495,6 +495,9 @@ gst_d3dvideosink_create_shared_hidden_window (GstD3DVideoSink * sink) CloseHandle (shared.hidden_window_created_signal); + if (!shared.d3ddev) + goto failed; + GST_DEBUG ("Successfully created Direct3D hidden window, handle: %p", shared.hidden_window_handle); @@ -1356,7 +1359,8 @@ gst_d3dvideosink_change_state (GstElement * element, GstStateChange transition) switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: - gst_d3dvideosink_initialize_direct3d (sink); + if (!gst_d3dvideosink_initialize_direct3d (sink)) + return GST_STATE_CHANGE_FAILURE; break; case GST_STATE_CHANGE_READY_TO_PAUSED: break; From 12407a13a0900bf0689bb380cc40b820a9fd5317 Mon Sep 17 00:00:00 2001 From: Carsten Kroll Date: Mon, 22 Aug 2011 14:13:30 +0200 Subject: [PATCH 31/37] d3dvideosink: added NV12 + enabled RGB support --- sys/d3dvideosink/d3dvideosink.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/sys/d3dvideosink/d3dvideosink.c b/sys/d3dvideosink/d3dvideosink.c index ed4d249b6e..15d6f4b3d2 100644 --- a/sys/d3dvideosink/d3dvideosink.c +++ b/sys/d3dvideosink/d3dvideosink.c @@ -89,12 +89,11 @@ struct _IPCData GST_DEBUG_CATEGORY (d3dvideosink_debug); #define GST_CAT_DEFAULT d3dvideosink_debug -/* TODO: Support RGB! */ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ YUY2, UYVY, YV12, I420 }")) - //";" GST_VIDEO_CAPS_RGBx) + GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ YUY2, UYVY, YV12, I420, NV12 }") + ";" GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_BGRA) ); static void gst_d3dvideosink_init_interfaces (GType type); @@ -1678,6 +1677,30 @@ gst_d3dvideosink_show_frame (GstVideoSink * vsink, GstBuffer * buffer) } break; } + case GST_MAKE_FOURCC ('N', 'V', '1', '2'): + { + guint8 *dst = dest; + int component; + dststride = lr.Pitch; + for (component = 0; component < 2; component++) { + const int compHeight = + gst_video_format_get_component_height (sink->format, + component, sink->height); + guint8 *src = + source + + gst_video_format_get_component_offset (sink->format, + component, sink->width, sink->height); + srcstride = + gst_video_format_get_row_stride (sink->format, component, + sink->width); + for (i = 0; i < compHeight; i++) { + memcpy (dst + dststride * i, src + srcstride * i, + srcstride); + } + dst += dststride * compHeight; + } + break; + } default: g_assert_not_reached (); } @@ -2124,6 +2147,10 @@ gst_d3dvideosink_initialize_swap_chain (GstD3DVideoSink * sink) d3dformat = D3DFMT_X8R8G8B8; d3dfourcc = (D3DFORMAT) MAKEFOURCC ('Y', 'V', '1', '2'); break; + case GST_MAKE_FOURCC ('N', 'V', '1', '2'): + d3dformat = D3DFMT_X8R8G8B8; + d3dfourcc = (D3DFORMAT) MAKEFOURCC ('N', 'V', '1', '2'); + break; default: g_assert_not_reached (); goto error; From 56193e8f4960d870a41693d580ac390a3cbc776c Mon Sep 17 00:00:00 2001 From: Carsten Kroll Date: Mon, 22 Aug 2011 14:19:06 +0200 Subject: [PATCH 32/37] d3dvideosink: redraw last buffer when new window handle has been set. --- sys/d3dvideosink/d3dvideosink.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/d3dvideosink/d3dvideosink.c b/sys/d3dvideosink/d3dvideosink.c index 15d6f4b3d2..c864f178fa 100644 --- a/sys/d3dvideosink/d3dvideosink.c +++ b/sys/d3dvideosink/d3dvideosink.c @@ -187,7 +187,7 @@ static void gst_d3dvideosink_log_warning (const gchar * file, const gchar * function, gint line, const gchar * format, va_list args); static void gst_d3dvideosink_log_error (const gchar * file, const gchar * function, gint line, const gchar * format, va_list args); - +static void gst_d3dvideosink_set_window_for_renderer (GstD3DVideoSink * sink); static DirectXInitParams directx_init_params = { gst_d3dvideosink_log_debug, gst_d3dvideosink_log_warning, gst_d3dvideosink_log_error @@ -1057,7 +1057,8 @@ gst_d3dvideosink_set_window_handle (GstXOverlay * overlay, guintptr window_id) /* Save our window id */ sink->window_handle = hWnd; - + gst_d3dvideosink_set_window_for_renderer(sink); + if (init_swap_chain) gst_d3dvideosink_initialize_swap_chain (sink); } @@ -1066,7 +1067,9 @@ gst_d3dvideosink_set_window_handle (GstXOverlay * overlay, guintptr window_id) GST_DEBUG ("Direct3D window id successfully changed for sink %p to %p", sink, hWnd); GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return; + GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK + gst_d3dvideosink_update(sink); + return; /*error:*/ /* GST_DEBUG("Error attempting to change the window id for sink %d to %d", sink, hWnd); */ /* GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK(sink); */ From ec603dc32620edf41a13b176c3510b0b0488233d Mon Sep 17 00:00:00 2001 From: Carsten Kroll Date: Mon, 22 Aug 2011 14:30:43 +0200 Subject: [PATCH 33/37] d3dvideosink: check for hardware capabilities, when negotiating --- sys/d3dvideosink/d3dvideosink.c | 58 +++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/sys/d3dvideosink/d3dvideosink.c b/sys/d3dvideosink/d3dvideosink.c index c864f178fa..c42f6c241c 100644 --- a/sys/d3dvideosink/d3dvideosink.c +++ b/sys/d3dvideosink/d3dvideosink.c @@ -454,9 +454,52 @@ static GstCaps * gst_d3dvideosink_get_caps (GstBaseSink * basesink) { GstD3DVideoSink *sink = GST_D3DVIDEOSINK (basesink); + GstCaps *caps = gst_caps_new_empty (); + const GstCaps *tempCaps = + gst_pad_get_pad_template_caps (GST_VIDEO_SINK_PAD (sink)); - return - gst_caps_copy (gst_pad_get_pad_template_caps (GST_VIDEO_SINK_PAD (sink))); + /* restrict caps based on the hw capabilities */ + if (shared.d3d) { + D3DDISPLAYMODE d3ddm; + if (FAILED (IDirect3D9_GetAdapterDisplayMode (shared.d3d, + D3DADAPTER_DEFAULT, &d3ddm))) { + GST_WARNING ("Unable to request adapter display mode"); + gst_caps_unref (caps); + caps = gst_caps_copy (tempCaps); + } else { + gint i; + GstCaps *c = gst_caps_normalize (tempCaps); + + for (i = 0; i < gst_caps_get_size (c); i++) { + D3DFORMAT d3dfourcc = 0; + GstStructure *stru = gst_caps_get_structure (c, i); + if (!gst_structure_has_name (stru, "video/x-raw-rgb")) { + gst_structure_get_fourcc (stru, "format", &d3dfourcc); + switch (d3dfourcc) { + case GST_MAKE_FOURCC ('Y', 'V', '1', '2'): + case GST_MAKE_FOURCC ('I', '4', '2', '0'): + d3dfourcc = (D3DFORMAT) MAKEFOURCC ('Y', 'V', '1', '2'); + break; + } + if (d3dfourcc && SUCCEEDED (IDirect3D9_CheckDeviceFormat (shared.d3d, + D3DADAPTER_DEFAULT, + D3DDEVTYPE_HAL, + d3ddm.Format, 0, D3DRTYPE_SURFACE, d3dfourcc))) { + /* hw supports this format */ + gst_caps_append (caps, gst_caps_copy_nth (c, i)); + } + } else { + /* rgb formats */ + gst_caps_append (caps, gst_caps_copy_nth (c, i)); + } + } + gst_caps_unref (c); + } + } else { + gst_caps_unref (caps); + caps = gst_caps_copy (tempCaps); + } + return caps; } static void @@ -1057,8 +1100,8 @@ gst_d3dvideosink_set_window_handle (GstXOverlay * overlay, guintptr window_id) /* Save our window id */ sink->window_handle = hWnd; - gst_d3dvideosink_set_window_for_renderer(sink); - + gst_d3dvideosink_set_window_for_renderer (sink); + if (init_swap_chain) gst_d3dvideosink_initialize_swap_chain (sink); } @@ -1067,8 +1110,8 @@ gst_d3dvideosink_set_window_handle (GstXOverlay * overlay, guintptr window_id) GST_DEBUG ("Direct3D window id successfully changed for sink %p to %p", sink, hWnd); GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK - gst_d3dvideosink_update(sink); + GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK + gst_d3dvideosink_update (GST_BASE_SINK_CAST (sink)); return; /*error:*/ /* GST_DEBUG("Error attempting to change the window id for sink %d to %d", sink, hWnd); */ @@ -2166,7 +2209,8 @@ gst_d3dvideosink_initialize_swap_chain (GstD3DVideoSink * sink) goto error; } - GST_DEBUG ("Determined Direct3D format: %d", d3dfourcc); + GST_DEBUG ("Determined Direct3D format: %" GST_FOURCC_FORMAT, + GST_FOURCC_ARGS (d3dfourcc)); //Stencil/depth buffers aren't created by default when using swap chains //if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(shared.d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dformat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D32))) { From ab22a64a1331dafa9c6ca542845240ada6850b48 Mon Sep 17 00:00:00 2001 From: Carsten Kroll Date: Mon, 22 Aug 2011 14:46:48 +0200 Subject: [PATCH 34/37] d3dvideosink: flush GPU before Present added alternate wait for vsync method based on GetRasterStatus --- sys/d3dvideosink/d3dvideosink.c | 69 +++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/sys/d3dvideosink/d3dvideosink.c b/sys/d3dvideosink/d3dvideosink.c index c42f6c241c..77626b1a0c 100644 --- a/sys/d3dvideosink/d3dvideosink.c +++ b/sys/d3dvideosink/d3dvideosink.c @@ -1587,6 +1587,65 @@ gst_d3dvideosink_stop (GstBaseSink * bsink) return TRUE; } +static void +gst_d3dvideosink_flush_gpu (GstD3DVideoSink * sink) +{ + LPDIRECT3DDEVICE9 d3ddev = NULL; + LPDIRECT3DQUERY9 pEventQuery = NULL; + + if (D3D_OK == IDirect3DSwapChain9_GetDevice (sink->d3d_swap_chain, &d3ddev)) { + IDirect3DDevice9_CreateQuery (d3ddev, D3DQUERYTYPE_EVENT, &pEventQuery); + IDirect3DDevice9_Release (d3ddev); + if (pEventQuery) { + IDirect3DQuery9_Issue (pEventQuery, D3DISSUE_END); + /* Empty the command buffer and wait until the GPU is idle. */ + while (S_FALSE == IDirect3DQuery9_GetData (pEventQuery, NULL, 0, + D3DGETDATA_FLUSH)); + IDirect3DQuery9_Release (pEventQuery); + } + } +} + +static void +gst_d3dvideosink_wait_for_vsync (GstD3DVideoSink * sink) +{ + D3DPRESENT_PARAMETERS d3dpp; + ZeroMemory (&d3dpp, sizeof (d3dpp)); + + IDirect3DSwapChain9_GetPresentParameters (sink->d3d_swap_chain, &d3dpp); + + if (d3dpp.PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE) { + D3DRASTER_STATUS raster_stat; + D3DDISPLAYMODE d3ddm; + UINT lastScanline = 0; + UINT vblankStart = 0; + HANDLE thdl = GetCurrentThread (); + int prio = GetThreadPriority (thdl); + ZeroMemory (&d3ddm, sizeof (d3ddm)); + + GST_ERROR_OBJECT (sink, "USING ALT VSYNC"); + + IDirect3DSwapChain9_GetDisplayMode (sink->d3d_swap_chain, &d3ddm); + vblankStart = d3ddm.Height - 10; + SetThreadPriority (thdl, THREAD_PRIORITY_TIME_CRITICAL); + do { + if (FAILED (IDirect3DSwapChain9_GetRasterStatus (sink->d3d_swap_chain, + &raster_stat))) + break; + if (!raster_stat.InVBlank) { + if (raster_stat.ScanLine < lastScanline) { + GST_INFO_OBJECT (sink, "missed last vsync curr : %d", + raster_stat.ScanLine); + break; + } + lastScanline = raster_stat.ScanLine; + SwitchToThread (); + } + } while (raster_stat.ScanLine < vblankStart); + SetThreadPriority (thdl, prio); + } +} + static GstFlowReturn gst_d3dvideosink_show_frame (GstVideoSink * vsink, GstBuffer * buffer) { @@ -1763,10 +1822,12 @@ gst_d3dvideosink_show_frame (GstVideoSink * vsink, GstBuffer * buffer) gst_d3dvideosink_stretch (sink, backBuffer); IDirect3DDevice9_EndScene (shared.d3ddev); } + gst_d3dvideosink_flush_gpu (sink); + gst_d3dvideosink_wait_for_vsync (sink); + hr = IDirect3DSwapChain9_Present (sink->d3d_swap_chain, NULL, NULL, NULL, + NULL, 0); /* Swap back and front buffers on video card and present to the user */ - if (FAILED (hr = - IDirect3DSwapChain9_Present (sink->d3d_swap_chain, NULL, NULL, NULL, - NULL, 0))) { + if (FAILED (hr)) { switch (hr) { case D3DERR_DEVICELOST: case D3DERR_DEVICENOTRESET: @@ -2237,11 +2298,13 @@ gst_d3dvideosink_initialize_swap_chain (GstD3DVideoSink * sink) ZeroMemory (&d3dpp, sizeof (d3dpp)); d3dpp.Windowed = TRUE; + d3dpp.Flags = D3DPRESENTFLAG_VIDEO; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.hDeviceWindow = sink->window_handle; d3dpp.BackBufferFormat = d3dformat; d3dpp.BackBufferWidth = width; d3dpp.BackBufferHeight = height; + d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; /*D3DPRESENT_INTERVAL_IMMEDIATE; */ if (FAILED (IDirect3DDevice9_CreateAdditionalSwapChain (shared.d3ddev, &d3dpp, &d3dswapchain))) From 0c5037072ad18394188960a6c4d346f22609a864 Mon Sep 17 00:00:00 2001 From: Carsten Kroll Date: Mon, 22 Aug 2011 16:31:38 +0200 Subject: [PATCH 35/37] d3dvideosink: create a d3d device for each sink and use the default swap chain in connection with flushing the GPU and not recreating the swap chain this avoids tearing also use GST_xx_DEBUG macros where appropriate --- sys/d3dvideosink/d3dvideosink.c | 1132 +++++++++++++------------------ sys/d3dvideosink/d3dvideosink.h | 3 +- 2 files changed, 462 insertions(+), 673 deletions(-) diff --git a/sys/d3dvideosink/d3dvideosink.c b/sys/d3dvideosink/d3dvideosink.c index 77626b1a0c..1bca84703b 100644 --- a/sys/d3dvideosink/d3dvideosink.c +++ b/sys/d3dvideosink/d3dvideosink.c @@ -30,28 +30,20 @@ /* Provide access to data that will be shared among all instantiations of this element */ #define GST_D3DVIDEOSINK_SHARED_D3D_LOCK g_static_mutex_lock (&shared_d3d_lock); #define GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK g_static_mutex_unlock (&shared_d3d_lock); -#define GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK g_static_mutex_lock (&shared_d3d_dev_lock); -#define GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK g_static_mutex_unlock (&shared_d3d_dev_lock); #define GST_D3DVIDEOSINK_SHARED_D3D_HOOK_LOCK g_static_mutex_lock (&shared_d3d_hook_lock); #define GST_D3DVIDEOSINK_SHARED_D3D_HOOK_UNLOCK g_static_mutex_unlock (&shared_d3d_hook_lock); typedef struct _GstD3DVideoSinkShared GstD3DVideoSinkShared; struct _GstD3DVideoSinkShared { LPDIRECT3D9 d3d; - LPDIRECT3DDEVICE9 d3ddev; D3DCAPS9 d3dcaps; - D3DFORMAT d3ddmformat; - D3DFORMAT d3dformat; - D3DFORMAT d3dfourcc; - D3DFORMAT d3dstencilformat; - D3DTEXTUREFILTERTYPE d3dfiltertype; - gboolean d3dEnableAutoDepthStencil; GList *element_list; gint32 element_count; gboolean device_lost; UINT_PTR device_lost_timer; + GstD3DVideoSink *device_lost_sink; HWND hidden_window_handle; HANDLE hidden_window_created_signal; @@ -163,13 +155,13 @@ static void gst_d3dvideosink_remove_window_for_renderer (GstD3DVideoSink * sink); static gboolean gst_d3dvideosink_initialize_direct3d (GstD3DVideoSink * sink); static gboolean gst_d3dvideosink_initialize_d3d_device (GstD3DVideoSink * sink); -static gboolean gst_d3dvideosink_initialize_swap_chain (GstD3DVideoSink * sink); static gboolean gst_d3dvideosink_resize_swap_chain (GstD3DVideoSink * sink, gint width, gint height); +static gboolean gst_d3dvideosink_notify_device_init (GstD3DVideoSink * sink); static gboolean gst_d3dvideosink_notify_device_lost (GstD3DVideoSink * sink); static gboolean gst_d3dvideosink_notify_device_reset (GstD3DVideoSink * sink); +static gboolean gst_d3dvideosink_notify_device_resize (GstD3DVideoSink * sink); static gboolean gst_d3dvideosink_device_lost (GstD3DVideoSink * sink); -static gboolean gst_d3dvideosink_release_swap_chain (GstD3DVideoSink * sink); static gboolean gst_d3dvideosink_release_d3d_device (GstD3DVideoSink * sink); static gboolean gst_d3dvideosink_release_direct3d (GstD3DVideoSink * sink); static gboolean gst_d3dvideosink_window_size (GstD3DVideoSink * sink, @@ -177,6 +169,7 @@ static gboolean gst_d3dvideosink_window_size (GstD3DVideoSink * sink, static gboolean gst_d3dvideosink_direct3d_supported (GstD3DVideoSink * sink); static gboolean gst_d3dvideosink_shared_hidden_window_thread (GstD3DVideoSink * sink); +static void gst_d3dvideosink_flush_gpu (GstD3DVideoSink * sink); static void gst_d3dvideosink_hook_window_for_renderer (GstD3DVideoSink * sink); static void gst_d3dvideosink_unhook_window_for_renderer (GstD3DVideoSink * sink); @@ -474,7 +467,7 @@ gst_d3dvideosink_get_caps (GstBaseSink * basesink) D3DFORMAT d3dfourcc = 0; GstStructure *stru = gst_caps_get_structure (c, i); if (!gst_structure_has_name (stru, "video/x-raw-rgb")) { - gst_structure_get_fourcc (stru, "format", &d3dfourcc); + gst_structure_get_fourcc (stru, "format", (guint32 *) & d3dfourcc); switch (d3dfourcc) { case GST_MAKE_FOURCC ('Y', 'V', '1', '2'): case GST_MAKE_FOURCC ('I', '4', '2', '0'): @@ -590,10 +583,6 @@ gst_d3dvideosink_shared_hidden_window_thread (GstD3DVideoSink * sink) shared.hidden_window_handle = hWnd; shared.device_lost_timer = 0; - GST_DEBUG ("Initializing Direct3D"); - SendMessage (shared.hidden_window_handle, WM_DIRECTX_D3D_INIT_DEVICE, 0, 0); - GST_DEBUG ("Direct3D initialization complete"); - gst_d3dvideosink_shared_hidden_window_created (sink); GST_DEBUG ("Entering Direct3D hidden window message loop"); @@ -640,36 +629,32 @@ SharedHiddenWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { GstD3DVideoSink *sink; - if (message == WM_CREATE) { - /* lParam holds a pointer to a CREATESTRUCT instance which in turn holds the parameter used when creating the window. */ - sink = (GstD3DVideoSink *) ((LPCREATESTRUCT) lParam)->lpCreateParams; - - /* In our case, this is a pointer to the sink. So we immediately attach it for use in subsequent calls. */ - SetWindowLongPtr (hWnd, GWLP_USERDATA, (LONG_PTR) sink); - } - - sink = (GstD3DVideoSink *) GetWindowLongPtr (hWnd, GWLP_USERDATA); + /* lParam holds pointer to the sink. */ + sink = (GstD3DVideoSink *) lParam; switch (message) { case WM_DIRECTX_D3D_INIT_DEVICE: { + shared.device_lost_sink = NULL; + GST_DEBUG ("Initializing Direct3D"); gst_d3dvideosink_initialize_d3d_device (sink); + GST_DEBUG ("Direct3D initialization complete"); break; + } case WM_DIRECTX_D3D_INIT_DEVICELOST: { if (!shared.device_lost) { - //GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK - //GST_D3DVIDEOSINK_SHARED_D3D_LOCK shared.device_lost = TRUE; + shared.device_lost_sink = sink; /* Handle device lost by creating a timer and posting WM_D3D_DEVICELOST twice a second */ /* Create a timer to periodically check the d3d device and attempt to recreate it */ shared.device_lost_timer = SetTimer (hWnd, IDT_DEVICELOST, 500, NULL); /* Try it once immediately */ - SendMessage (hWnd, WM_DIRECTX_D3D_DEVICELOST, 0, 0); + SendMessage (hWnd, WM_DIRECTX_D3D_DEVICELOST, 0, (LPARAM) sink); } break; } @@ -678,15 +663,15 @@ SharedHiddenWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) /* Did we receive a message to check if the device is available again? */ if (wParam == IDT_DEVICELOST) { /* This will synchronously call SharedHiddenWndProc() because this thread is the one that created the window. */ - SendMessage (hWnd, WM_DIRECTX_D3D_DEVICELOST, 0, 0); + SendMessage (hWnd, WM_DIRECTX_D3D_DEVICELOST, 0, + (LPARAM) shared.device_lost_sink); return 0; } break; } case WM_DIRECTX_D3D_DEVICELOST: { - gst_d3dvideosink_device_lost (sink); - break; + return gst_d3dvideosink_device_lost (sink); } case WM_DIRECTX_D3D_END_DEVICELOST: { @@ -704,9 +689,8 @@ SharedHiddenWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) /* Then redraw just in case we don't have a last buffer */ gst_d3dvideosink_refresh_all (sink); - //GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK - //GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK } + shared.device_lost_sink = NULL; break; } case WM_DESTROY: @@ -714,6 +698,10 @@ SharedHiddenWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) PostQuitMessage (0); return 0; } + case WM_DIRECTX_D3D_RESIZE: + { + return gst_d3dvideosink_device_lost (sink); + } } return DefWindowProc (hWnd, message, wParam, lParam); @@ -839,17 +827,6 @@ gst_d3dvideosink_wnd_proc (GstD3DVideoSink * sink, HWND hWnd, UINT message, gst_d3dvideosink_refresh (sink); break; } - case WM_SIZE: - case WM_DIRECTX_D3D_RESIZE: - { - gint width; - gint height; - gst_d3dvideosink_window_size (sink, &width, &height); - gst_d3dvideosink_resize_swap_chain (sink, width, height); - gst_d3dvideosink_refresh (sink); - //gst_d3dvideosink_resize_swap_chain(sink, MAX(1, ABS(LOWORD(lParam))), MAX(1, ABS(HIWORD(lParam)))); - break; - } case WM_CLOSE: case WM_DESTROY: { @@ -1088,35 +1065,27 @@ gst_d3dvideosink_set_window_handle (GstXOverlay * overlay, guintptr window_id) return; } - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK (sink); - { - /* If we're already playing/paused, then we need to lock the swap chain, and recreate it with the new window. */ - gboolean init_swap_chain = sink->d3d_swap_chain != NULL; - - gst_d3dvideosink_release_swap_chain (sink); - + /* If we're already playing/paused, then we need to lock the swap chain, and recreate it with the new window. */ + if (sink->d3ddev != NULL) { /* Close our existing window if there is one */ gst_d3dvideosink_close_window (sink); - /* Save our window id */ sink->window_handle = hWnd; gst_d3dvideosink_set_window_for_renderer (sink); - - if (init_swap_chain) - gst_d3dvideosink_initialize_swap_chain (sink); + gst_d3dvideosink_notify_device_resize (sink); + } else { + sink->window_handle = hWnd; } /*success:*/ - GST_DEBUG ("Direct3D window id successfully changed for sink %p to %p", sink, + GST_DEBUG_OBJECT (sink, "Direct3D window id successfully changed to %p", hWnd); - GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK - gst_d3dvideosink_update (GST_BASE_SINK_CAST (sink)); + + gst_d3dvideosink_update (GST_BASE_SINK_CAST (sink)); return; /*error:*/ /* GST_DEBUG("Error attempting to change the window id for sink %d to %d", sink, hWnd); */ /* GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK(sink); */ -/* GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK */ /* return; */ } @@ -1324,12 +1293,13 @@ gst_d3dvideosink_unhook_all_windows (void) { /* Unhook all windows that may be currently hooked. This is mainly a precaution in case */ /* a wayward process doesn't properly set state back to NULL (which would remove the hook). */ - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK - GST_D3DVIDEOSINK_SHARED_D3D_LOCK GST_D3DVIDEOSINK_SHARED_D3D_HOOK_LOCK { + + GST_D3DVIDEOSINK_SHARED_D3D_LOCK GST_D3DVIDEOSINK_SHARED_D3D_HOOK_LOCK + { GList *item; GstD3DVideoSink *s; - GST_DEBUG ("Attempting to unhook all windows for process %lu", + GST_DEBUG ("Attempting to unhook all windows for process %lu", GetCurrentProcessId ()); for (item = g_list_first (shared.element_list); item; item = item->next) { @@ -1337,13 +1307,11 @@ gst_d3dvideosink_unhook_all_windows (void) gst_d3dvideosink_unhook_window_for_renderer (s); } } -GST_D3DVIDEOSINK_SHARED_D3D_HOOK_UNLOCK - GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK} +GST_D3DVIDEOSINK_SHARED_D3D_HOOK_UNLOCK GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK} static void gst_d3dvideosink_remove_window_for_renderer (GstD3DVideoSink * sink) { - //GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK //GST_D3DVIDEOSINK_SHARED_D3D_LOCK //GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK(sink); { @@ -1374,7 +1342,6 @@ gst_d3dvideosink_remove_window_for_renderer (GstD3DVideoSink * sink) } //GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK(sink); //GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK - //GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK } static void @@ -1392,8 +1359,7 @@ gst_d3dvideosink_prepare_window (GstD3DVideoSink * sink) } else { gst_d3dvideosink_create_default_window (sink); } - - gst_d3dvideosink_initialize_swap_chain (sink); + gst_d3dvideosink_notify_device_init (sink); } static GstStateChangeReturn @@ -1583,38 +1549,28 @@ gst_d3dvideosink_stop (GstBaseSink * bsink) { GstD3DVideoSink *sink = GST_D3DVIDEOSINK (bsink); gst_d3dvideosink_close_window (sink); - gst_d3dvideosink_release_swap_chain (sink); return TRUE; } static void gst_d3dvideosink_flush_gpu (GstD3DVideoSink * sink) { - LPDIRECT3DDEVICE9 d3ddev = NULL; LPDIRECT3DQUERY9 pEventQuery = NULL; - if (D3D_OK == IDirect3DSwapChain9_GetDevice (sink->d3d_swap_chain, &d3ddev)) { - IDirect3DDevice9_CreateQuery (d3ddev, D3DQUERYTYPE_EVENT, &pEventQuery); - IDirect3DDevice9_Release (d3ddev); - if (pEventQuery) { - IDirect3DQuery9_Issue (pEventQuery, D3DISSUE_END); - /* Empty the command buffer and wait until the GPU is idle. */ - while (S_FALSE == IDirect3DQuery9_GetData (pEventQuery, NULL, 0, - D3DGETDATA_FLUSH)); - IDirect3DQuery9_Release (pEventQuery); - } + IDirect3DDevice9_CreateQuery (sink->d3ddev, D3DQUERYTYPE_EVENT, &pEventQuery); + if (pEventQuery) { + IDirect3DQuery9_Issue (pEventQuery, D3DISSUE_END); + /* Empty the command buffer and wait until the GPU is idle. */ + while (S_FALSE == IDirect3DQuery9_GetData (pEventQuery, NULL, 0, + D3DGETDATA_FLUSH)); + IDirect3DQuery9_Release (pEventQuery); } } static void gst_d3dvideosink_wait_for_vsync (GstD3DVideoSink * sink) { - D3DPRESENT_PARAMETERS d3dpp; - ZeroMemory (&d3dpp, sizeof (d3dpp)); - - IDirect3DSwapChain9_GetPresentParameters (sink->d3d_swap_chain, &d3dpp); - - if (d3dpp.PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE) { + if (sink->d3dpp.PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE) { D3DRASTER_STATUS raster_stat; D3DDISPLAYMODE d3ddm; UINT lastScanline = 0; @@ -1623,15 +1579,15 @@ gst_d3dvideosink_wait_for_vsync (GstD3DVideoSink * sink) int prio = GetThreadPriority (thdl); ZeroMemory (&d3ddm, sizeof (d3ddm)); - GST_ERROR_OBJECT (sink, "USING ALT VSYNC"); - - IDirect3DSwapChain9_GetDisplayMode (sink->d3d_swap_chain, &d3ddm); + IDirect3DDevice9_GetDisplayMode (sink->d3ddev, 0, &d3ddm); vblankStart = d3ddm.Height - 10; SetThreadPriority (thdl, THREAD_PRIORITY_TIME_CRITICAL); do { - if (FAILED (IDirect3DSwapChain9_GetRasterStatus (sink->d3d_swap_chain, - &raster_stat))) - break; + if (FAILED (IDirect3DDevice9_GetRasterStatus (sink->d3ddev, 0, + &raster_stat))) { + GST_ERROR_OBJECT (sink, "GetRasterStatus failed"); + } + break; if (!raster_stat.InVBlank) { if (raster_stat.ScanLine < lastScanline) { GST_INFO_OBJECT (sink, "missed last vsync curr : %d", @@ -1650,220 +1606,165 @@ static GstFlowReturn gst_d3dvideosink_show_frame (GstVideoSink * vsink, GstBuffer * buffer) { GstD3DVideoSink *sink = GST_D3DVIDEOSINK (vsink); + LPDIRECT3DSURFACE9 drawSurface = NULL; - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK (sink); - { - HRESULT hr; - LPDIRECT3DSURFACE9 backBuffer; - - if (!shared.d3ddev) { - if (!shared.device_lost) { - GST_WARNING ("No Direct3D device has been created, stopping"); - goto error; - } else { - GST_WARNING - ("Direct3D device is lost. Maintaining flow until it has been reset."); - goto success; - } - } - - if (!sink->d3d_offscreen_surface) { - GST_WARNING ("No Direct3D offscreen surface has been created, stopping"); + GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK (sink); + if (!sink->d3ddev) { + if (!shared.device_lost) { + GST_ERROR_OBJECT (sink, "No Direct3D device has been created, stopping"); goto error; - } - - if (!sink->d3d_swap_chain) { - GST_WARNING ("No Direct3D swap chain has been created, stopping"); - goto error; - } - - if (sink->window_closed) { - GST_WARNING ("Window has been closed, stopping"); - goto error; - } - - if (sink->window_handle && !sink->is_new_window) { - if (shared.d3ddev) { - gint win_width = 0, win_height = 0; - D3DPRESENT_PARAMETERS d3dpp; - - ZeroMemory (&d3dpp, sizeof (d3dpp)); - - if (gst_d3dvideosink_window_size (sink, &win_width, &win_height)) { - IDirect3DSwapChain9_GetPresentParameters (sink->d3d_swap_chain, - &d3dpp); - if ((d3dpp.BackBufferWidth > 0 && d3dpp.BackBufferHeight > 0 - && win_width != d3dpp.BackBufferWidth) - || win_height != d3dpp.BackBufferHeight) - gst_d3dvideosink_resize_swap_chain (sink, win_width, win_height); - } - } - } - - /* Set the render target to our swap chain */ - IDirect3DSwapChain9_GetBackBuffer (sink->d3d_swap_chain, 0, - D3DBACKBUFFER_TYPE_MONO, &backBuffer); - IDirect3DDevice9_SetRenderTarget (shared.d3ddev, 0, backBuffer); - IDirect3DSurface9_Release (backBuffer); - - /* Clear the target */ - IDirect3DDevice9_Clear (shared.d3ddev, 0, NULL, D3DCLEAR_TARGET, - D3DCOLOR_XRGB (0, 0, 0), 1.0f, 0); - - if (SUCCEEDED (IDirect3DDevice9_BeginScene (shared.d3ddev))) { - if (GST_BUFFER_DATA (buffer)) { - D3DLOCKED_RECT lr; - guint8 *dest, *source; - int srcstride, dststride, i; - - IDirect3DSurface9_LockRect (sink->d3d_offscreen_surface, &lr, NULL, 0); - dest = (guint8 *) lr.pBits; - source = GST_BUFFER_DATA (buffer); - - if (dest) { - if (gst_video_format_is_yuv (sink->format)) { - guint32 fourcc = gst_video_format_to_fourcc (sink->format); - - switch (fourcc) { - case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'): - case GST_MAKE_FOURCC ('Y', 'U', 'Y', 'V'): - case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'): - dststride = lr.Pitch; - srcstride = GST_BUFFER_SIZE (buffer) / sink->height; - for (i = 0; i < sink->height; ++i) - memcpy (dest + dststride * i, source + srcstride * i, - srcstride); - break; - case GST_MAKE_FOURCC ('I', '4', '2', '0'): - case GST_MAKE_FOURCC ('Y', 'V', '1', '2'): - { - int srcystride, srcvstride, srcustride; - int dstystride, dstvstride, dstustride; - int rows; - guint8 *srcv, *srcu, *dstv, *dstu; - - rows = sink->height; - - /* Source y, u and v strides */ - srcystride = GST_ROUND_UP_4 (sink->width); - srcustride = GST_ROUND_UP_8 (sink->width) / 2; - srcvstride = GST_ROUND_UP_8 (srcystride) / 2; - - /* Destination y, u and v strides */ - dstystride = lr.Pitch; - dstustride = dstystride / 2; - dstvstride = dstustride; - - srcu = source + srcystride * GST_ROUND_UP_2 (rows); - srcv = srcu + srcustride * GST_ROUND_UP_2 (rows) / 2; - - if (fourcc == GST_MAKE_FOURCC ('I', '4', '2', '0')) { - /* swap u and v planes */ - dstv = dest + dstystride * rows; - dstu = dstv + dstustride * rows / 2; - } else { - dstu = dest + dstystride * rows; - dstv = dstu + dstustride * rows / 2; - } - - for (i = 0; i < rows; ++i) { - /* Copy the y plane */ - memcpy (dest + dstystride * i, source + srcystride * i, - srcystride); - } - - for (i = 0; i < rows / 2; ++i) { - /* Copy the u plane */ - memcpy (dstu + dstustride * i, srcu + srcustride * i, - srcustride); - /* Copy the v plane */ - memcpy (dstv + dstvstride * i, srcv + srcvstride * i, - srcvstride); - } - break; - } - case GST_MAKE_FOURCC ('N', 'V', '1', '2'): - { - guint8 *dst = dest; - int component; - dststride = lr.Pitch; - for (component = 0; component < 2; component++) { - const int compHeight = - gst_video_format_get_component_height (sink->format, - component, sink->height); - guint8 *src = - source + - gst_video_format_get_component_offset (sink->format, - component, sink->width, sink->height); - srcstride = - gst_video_format_get_row_stride (sink->format, component, - sink->width); - for (i = 0; i < compHeight; i++) { - memcpy (dst + dststride * i, src + srcstride * i, - srcstride); - } - dst += dststride * compHeight; - } - break; - } - default: - g_assert_not_reached (); - } - } else if (gst_video_format_is_rgb (sink->format)) { - dststride = lr.Pitch; - srcstride = GST_BUFFER_SIZE (buffer) / sink->height; - for (i = 0; i < sink->height; ++i) - memcpy (dest + dststride * i, source + srcstride * i, srcstride); - } - } - - IDirect3DSurface9_UnlockRect (sink->d3d_offscreen_surface); - } - gst_d3dvideosink_stretch (sink, backBuffer); - IDirect3DDevice9_EndScene (shared.d3ddev); - } - gst_d3dvideosink_flush_gpu (sink); - gst_d3dvideosink_wait_for_vsync (sink); - hr = IDirect3DSwapChain9_Present (sink->d3d_swap_chain, NULL, NULL, NULL, - NULL, 0); - /* Swap back and front buffers on video card and present to the user */ - if (FAILED (hr)) { - switch (hr) { - case D3DERR_DEVICELOST: - case D3DERR_DEVICENOTRESET: - gst_d3dvideosink_notify_device_lost (sink); - break; - default: - goto wrong_state; - } + } else { + GST_WARNING_OBJECT (sink, + "Direct3D device is lost. Maintaining flow until it has been reset."); + goto success; } } + if (sink->window_closed) { + GST_ERROR_OBJECT (sink, "Window has been closed, stopping"); + goto error; + } + + + drawSurface = sink->d3d_offscreen_surface; + + if (SUCCEEDED (IDirect3DDevice9_BeginScene (sink->d3ddev))) { + if (GST_BUFFER_DATA (buffer)) { + D3DLOCKED_RECT lr; + guint8 *dest, *source; + int srcstride, dststride, i; + + IDirect3DSurface9_LockRect (drawSurface, &lr, NULL, 0); + dest = (guint8 *) lr.pBits; + source = GST_BUFFER_DATA (buffer); + + if (dest) { + if (gst_video_format_is_yuv (sink->format)) { + guint32 fourcc = gst_video_format_to_fourcc (sink->format); + + switch (fourcc) { + case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'): + case GST_MAKE_FOURCC ('Y', 'U', 'Y', 'V'): + case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'): + dststride = lr.Pitch; + srcstride = GST_BUFFER_SIZE (buffer) / sink->height; + for (i = 0; i < sink->height; ++i) + memcpy (dest + dststride * i, source + srcstride * i, + srcstride); + break; + case GST_MAKE_FOURCC ('I', '4', '2', '0'): + case GST_MAKE_FOURCC ('Y', 'V', '1', '2'): + { + int srcystride, srcvstride, srcustride; + int dstystride, dstvstride, dstustride; + int rows; + guint8 *srcv, *srcu, *dstv, *dstu; + + rows = sink->height; + + /* Source y, u and v strides */ + srcystride = GST_ROUND_UP_4 (sink->width); + srcustride = GST_ROUND_UP_8 (sink->width) / 2; + srcvstride = GST_ROUND_UP_8 (srcystride) / 2; + + /* Destination y, u and v strides */ + dstystride = lr.Pitch; + dstustride = dstystride / 2; + dstvstride = dstustride; + + srcu = source + srcystride * GST_ROUND_UP_2 (rows); + srcv = srcu + srcustride * GST_ROUND_UP_2 (rows) / 2; + + if (fourcc == GST_MAKE_FOURCC ('I', '4', '2', '0')) { + /* swap u and v planes */ + dstv = dest + dstystride * rows; + dstu = dstv + dstustride * rows / 2; + } else { + dstu = dest + dstystride * rows; + dstv = dstu + dstustride * rows / 2; + } + + for (i = 0; i < rows; ++i) { + /* Copy the y plane */ + memcpy (dest + dstystride * i, source + srcystride * i, + srcystride); + } + + for (i = 0; i < rows / 2; ++i) { + /* Copy the u plane */ + memcpy (dstu + dstustride * i, srcu + srcustride * i, + srcustride); + /* Copy the v plane */ + memcpy (dstv + dstvstride * i, srcv + srcvstride * i, + srcvstride); + } + break; + } + case GST_MAKE_FOURCC ('N', 'V', '1', '2'): + { + guint8 *dst = dest; + int component; + dststride = lr.Pitch; + for (component = 0; component < 2; component++) { + const int compHeight = + gst_video_format_get_component_height (sink->format, + component, sink->height); + guint8 *src = + source + + gst_video_format_get_component_offset (sink->format, + component, sink->width, sink->height); + srcstride = + gst_video_format_get_row_stride (sink->format, component, + sink->width); + for (i = 0; i < compHeight; i++) { + memcpy (dst + dststride * i, src + srcstride * i, srcstride); + } + dst += dststride * compHeight; + } + break; + } + default: + g_assert_not_reached (); + } + } else if (gst_video_format_is_rgb (sink->format)) { + dststride = lr.Pitch; + srcstride = GST_BUFFER_SIZE (buffer) / sink->height; + for (i = 0; i < sink->height; ++i) + memcpy (dest + dststride * i, source + srcstride * i, srcstride); + } + } + IDirect3DSurface9_UnlockRect (drawSurface); + } + IDirect3DDevice9_EndScene (sink->d3ddev); + } success: GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return GST_FLOW_OK; + gst_d3dvideosink_refresh (sink); + return GST_FLOW_OK; +#if 0 wrong_state: GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return GST_FLOW_WRONG_STATE; + return GST_FLOW_WRONG_STATE; /*unexpected:*/ /* GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK(sink); */ -/* GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK */ +/* */ /* return GST_FLOW_UNEXPECTED; */ +#endif error: GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return GST_FLOW_ERROR; + return GST_FLOW_ERROR; } /* Simply redraws the last item on our offscreen surface to the window */ static gboolean gst_d3dvideosink_refresh (GstD3DVideoSink * sink) { - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK (sink); + GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK (sink); { HRESULT hr; LPDIRECT3DSURFACE9 backBuffer; - if (!shared.d3ddev) { + if (!sink->d3ddev) { if (!shared.device_lost) GST_DEBUG ("No Direct3D device has been created"); goto error; @@ -1874,35 +1775,33 @@ gst_d3dvideosink_refresh (GstD3DVideoSink * sink) goto error; } - if (!sink->d3d_swap_chain) { - GST_DEBUG ("No Direct3D swap chain has been created"); - goto error; - } - if (sink->window_closed) { GST_DEBUG ("Window has been closed"); goto error; } /* Set the render target to our swap chain */ - IDirect3DSwapChain9_GetBackBuffer (sink->d3d_swap_chain, 0, - D3DBACKBUFFER_TYPE_MONO, &backBuffer); - IDirect3DDevice9_SetRenderTarget (shared.d3ddev, 0, backBuffer); + if (FAILED (IDirect3DDevice9_GetBackBuffer (sink->d3ddev, 0, 0, + D3DBACKBUFFER_TYPE_MONO, &backBuffer))) { + GST_ERROR_OBJECT (sink, "failed to get back buffer"); + goto error; + } + IDirect3DDevice9_SetRenderTarget (sink->d3ddev, 0, backBuffer); IDirect3DSurface9_Release (backBuffer); /* Clear the target */ - IDirect3DDevice9_Clear (shared.d3ddev, 0, NULL, D3DCLEAR_TARGET, + IDirect3DDevice9_Clear (sink->d3ddev, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB (0, 0, 0), 1.0f, 0); - if (SUCCEEDED (IDirect3DDevice9_BeginScene (shared.d3ddev))) { + if (SUCCEEDED (IDirect3DDevice9_BeginScene (sink->d3ddev))) { gst_d3dvideosink_stretch (sink, backBuffer); - IDirect3DDevice9_EndScene (shared.d3ddev); + IDirect3DDevice9_EndScene (sink->d3ddev); } - + IDirect3DSurface9_Release (backBuffer); + gst_d3dvideosink_flush_gpu (sink); /* Swap back and front buffers on video card and present to the user */ if (FAILED (hr = - IDirect3DSwapChain9_Present (sink->d3d_swap_chain, NULL, NULL, NULL, - NULL, 0))) { + IDirect3DDevice9_Present (sink->d3ddev, NULL, NULL, NULL, NULL))) { switch (hr) { case D3DERR_DEVICELOST: case D3DERR_DEVICENOTRESET: @@ -1912,21 +1811,21 @@ gst_d3dvideosink_refresh (GstD3DVideoSink * sink) goto error; } } + gst_d3dvideosink_flush_gpu (sink); } /*success:*/ GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return TRUE; + return TRUE; error: GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return FALSE; + return FALSE; } static gboolean gst_d3dvideosink_update_all (GstD3DVideoSink * sink) { - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SHARED_D3D_LOCK - { + GST_D3DVIDEOSINK_SHARED_D3D_LOCK { GList *item; GstD3DVideoSink *s; for (item = g_list_first (shared.element_list); item; item = item->next) { @@ -1935,19 +1834,17 @@ gst_d3dvideosink_update_all (GstD3DVideoSink * sink) } } /*success:*/ - GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return TRUE; + GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK return TRUE; /*error:*/ /* GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK */ -/* GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK */ +/* */ /* return FALSE; */ } static gboolean gst_d3dvideosink_refresh_all (GstD3DVideoSink * sink) { - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SHARED_D3D_LOCK - { + GST_D3DVIDEOSINK_SHARED_D3D_LOCK { GList *item; GstD3DVideoSink *s; for (item = g_list_first (shared.element_list); item; item = item->next) { @@ -1956,11 +1853,9 @@ gst_d3dvideosink_refresh_all (GstD3DVideoSink * sink) } } /*success:*/ - GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return TRUE; + GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK return TRUE; /*error:*/ /* GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK */ -/* GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK */ /* return FALSE; */ } @@ -1974,26 +1869,44 @@ gst_d3dvideosink_stretch (GstD3DVideoSink * sink, LPDIRECT3DSURFACE9 backBuffer) GstVideoRectangle src; GstVideoRectangle dst; GstVideoRectangle result; + gdouble x_scale, y_scale; gst_d3dvideosink_window_size (sink, &window_width, &window_height); + src.x = 0; + src.y = 0; src.w = GST_VIDEO_SINK_WIDTH (sink); src.h = GST_VIDEO_SINK_HEIGHT (sink); + dst.x = 0; + dst.y = 0; dst.w = window_width; dst.h = window_height; + x_scale = (gdouble) src.w / (gdouble) dst.w; + y_scale = (gdouble) src.h / (gdouble) dst.h; gst_video_sink_center_rect (src, dst, &result, TRUE); + result.x = result.x * x_scale; + result.y = result.y * y_scale; + result.w = result.w * x_scale; + result.h = result.h * y_scale; + + //clip to src + gst_video_sink_center_rect (result, src, &result, FALSE); + r.left = result.x; r.top = result.y; r.right = result.x + result.w; r.bottom = result.y + result.h; - IDirect3DDevice9_StretchRect (shared.d3ddev, sink->d3d_offscreen_surface, - NULL, backBuffer, &r, sink->d3dfiltertype); + if (FAILED (IDirect3DDevice9_StretchRect (sink->d3ddev, + sink->d3d_offscreen_surface, NULL, backBuffer, &r, + sink->d3dfiltertype))) { + GST_ERROR_OBJECT (sink, "StretchRect failed"); + } } else { - IDirect3DDevice9_StretchRect (shared.d3ddev, sink->d3d_offscreen_surface, + IDirect3DDevice9_StretchRect (sink->d3ddev, sink->d3d_offscreen_surface, NULL, backBuffer, NULL, sink->d3dfiltertype); } } @@ -2001,14 +1914,8 @@ gst_d3dvideosink_stretch (GstD3DVideoSink * sink, LPDIRECT3DSURFACE9 backBuffer) static void gst_d3dvideosink_expose (GstXOverlay * overlay) { - GstD3DVideoSink *sink = GST_D3DVIDEOSINK (overlay); - GstBuffer *last_buffer; - - last_buffer = gst_base_sink_get_last_buffer (GST_BASE_SINK (sink)); - if (last_buffer) { - gst_d3dvideosink_show_frame (GST_VIDEO_SINK (sink), last_buffer); - gst_buffer_unref (last_buffer); - } + GstBaseSink *sink = GST_BASE_SINK (overlay); + gst_d3dvideosink_update (sink); } static void @@ -2045,6 +1952,9 @@ gst_d3dvideosink_unlock_stop (GstBaseSink * bsink) static gboolean gst_d3dvideosink_initialize_direct3d (GstD3DVideoSink * sink) { + DirectXAPI *api; + GstD3DVideoSinkClass *klass; + /* Let's hope this is never a problem (they have millions of d3d elements going at the same time) */ if (shared.element_count >= G_MAXINT32) { GST_ERROR @@ -2052,10 +1962,10 @@ gst_d3dvideosink_initialize_direct3d (GstD3DVideoSink * sink) return FALSE; } - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SHARED_D3D_LOCK + GST_D3DVIDEOSINK_SHARED_D3D_LOCK /* Add to our GList containing all of our elements. */ /* GLists are doubly-linked lists and calling prepend() prevents it from having to traverse the entire list just to add one item. */ - shared.element_list = g_list_prepend (shared.element_list, sink); + shared.element_list = g_list_prepend (shared.element_list, sink); /* Increment our count of the number of elements we have */ shared.element_count++; @@ -2066,39 +1976,9 @@ gst_d3dvideosink_initialize_direct3d (GstD3DVideoSink * sink) /* We'll destroy this once all elements using direct3d have been finalized. */ /* See gst_d3dvideosink_release_direct3d() for details. */ - /* We create a window that's hidden and used by the Direct3D device. The */ - /* device is shared among all d3dvideosink windows. */ - - GST_DEBUG ("Creating hidden window for Direct3D"); - if (!gst_d3dvideosink_create_shared_hidden_window (sink)) - goto error; - -success: - GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return TRUE; -error: - GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return FALSE; -} - -static gboolean -gst_d3dvideosink_initialize_d3d_device (GstD3DVideoSink * sink) -{ - HRESULT hr; - DWORD d3dcreate; - LPDIRECT3D9 d3d; - D3DCAPS9 d3dcaps; - D3DFORMAT d3ddmformat; - D3DDISPLAYMODE d3ddm; - LPDIRECT3DDEVICE9 d3ddev; - D3DPRESENT_PARAMETERS d3dpp; - D3DTEXTUREFILTERTYPE d3dfiltertype; - GstD3DVideoSinkClass *klass; - DirectXAPI *api; - if (!sink) { GST_WARNING ("Missing gobject instance."); - goto error; + return FALSE; } klass = GST_D3DVIDEOSINK_GET_CLASS (sink); @@ -2112,34 +1992,68 @@ gst_d3dvideosink_initialize_d3d_device (GstD3DVideoSink * sink) GST_WARNING ("Missing DirectX api"); goto error; } - //d3d = Direct3DCreate9(D3D_SDK_VERSION); - d3d = + + shared.d3d = (LPDIRECT3D9) DX9_D3D_COMPONENT_CALL_FUNC (DIRECTX_D3D (api), Direct3DCreate9, D3D_SDK_VERSION); - if (!d3d) { - GST_WARNING ("Unable to create Direct3D interface"); + if (!shared.d3d) { + GST_ERROR ("Unable to create Direct3D interface"); goto error; } - if (FAILED (IDirect3D9_GetAdapterDisplayMode (d3d, D3DADAPTER_DEFAULT, + /* We create a window that's hidden, so we can control the + device's from a single thread */ + + GST_DEBUG ("Creating hidden window for Direct3D"); + if (!gst_d3dvideosink_create_shared_hidden_window (sink)) + goto error; + +success: + GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK return TRUE; +error: + GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK return FALSE; +} + +static gboolean +gst_d3dvideosink_initialize_d3d_device (GstD3DVideoSink * sink) +{ + HRESULT hr; + DWORD d3dcreate; + D3DCAPS9 d3dcaps; + HWND hwnd = sink->window_handle; + D3DFORMAT d3dformat = sink->d3dformat; + D3DFORMAT d3dfourcc; + D3DDISPLAYMODE d3ddm; + D3DTEXTUREFILTERTYPE d3dfiltertype; + gint width, height; + + + + /* Get the current size of the window */ + gst_d3dvideosink_window_size (sink, &width, &height); + + + GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK (sink); + + if (!shared.d3d) { + GST_WARNING ("Direct3D object has not been initialized"); + goto error; + } + if (FAILED (IDirect3D9_GetAdapterDisplayMode (shared.d3d, D3DADAPTER_DEFAULT, &d3ddm))) { - /* Prevent memory leak */ - IDirect3D9_Release (d3d); GST_WARNING ("Unable to request adapter display mode"); goto error; } - if (FAILED (IDirect3D9_GetDeviceCaps (d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, - &d3dcaps))) { - /* Prevent memory leak */ - IDirect3D9_Release (d3d); + if (FAILED (IDirect3D9_GetDeviceCaps (shared.d3d, D3DADAPTER_DEFAULT, + D3DDEVTYPE_HAL, &d3dcaps))) { GST_WARNING ("Unable to request device caps"); goto error; } /* Ask DirectX to please not clobber the FPU state when making DirectX API calls. */ /* This can cause libraries such as cairo to misbehave in certain scenarios. */ - d3dcreate = 0 | D3DCREATE_FPU_PRESERVE; + d3dcreate = 0 | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED; /* Determine vertex processing capabilities. Some cards have issues using software vertex processing. */ /* Courtesy http://www.chadvernon.com/blog/resources/directx9/improved-direct3d-initialization/ */ @@ -2162,33 +2076,112 @@ gst_d3dvideosink_initialize_d3d_device (GstD3DVideoSink * sink) d3dfiltertype = D3DTEXF_NONE; } - /* Setup the display mode format. */ - d3ddmformat = d3ddm.Format; + if (gst_video_format_is_yuv (sink->format)) { + switch (gst_video_format_to_fourcc (sink->format)) { + case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'): + d3dformat = D3DFMT_X8R8G8B8; + d3dfourcc = (D3DFORMAT) MAKEFOURCC ('Y', 'U', 'Y', '2'); + break; + //case GST_MAKE_FOURCC ('Y', 'U', 'V', 'Y'): + // d3dformat = D3DFMT_X8R8G8B8; + // d3dfourcc = (D3DFORMAT)MAKEFOURCC('Y', 'U', 'V', 'Y'); + // break; + case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'): + d3dformat = D3DFMT_X8R8G8B8; + d3dfourcc = (D3DFORMAT) MAKEFOURCC ('U', 'Y', 'V', 'Y'); + break; + case GST_MAKE_FOURCC ('Y', 'V', '1', '2'): + case GST_MAKE_FOURCC ('I', '4', '2', '0'): + d3dformat = D3DFMT_X8R8G8B8; + d3dfourcc = (D3DFORMAT) MAKEFOURCC ('Y', 'V', '1', '2'); + break; + case GST_MAKE_FOURCC ('N', 'V', '1', '2'): + d3dformat = D3DFMT_X8R8G8B8; + d3dfourcc = (D3DFORMAT) MAKEFOURCC ('N', 'V', '1', '2'); + break; + default: + g_assert_not_reached (); + goto error; + } + } else if (gst_video_format_is_rgb (sink->format)) { + d3dformat = D3DFMT_X8R8G8B8; + d3dfourcc = D3DFMT_X8R8G8B8; + } else { + g_assert_not_reached (); + goto error; + } - ZeroMemory (&d3dpp, sizeof (d3dpp)); - //d3dpp.Flags = D3DPRESENTFLAG_VIDEO; - d3dpp.Windowed = TRUE; - d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp.BackBufferCount = 1; - d3dpp.BackBufferFormat = d3ddmformat; - d3dpp.BackBufferWidth = 1; - d3dpp.BackBufferHeight = 1; - d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; - d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; //D3DPRESENT_INTERVAL_IMMEDIATE; + GST_DEBUG ("Determined Direct3D format: %" GST_FOURCC_FORMAT, + GST_FOURCC_ARGS (d3dfourcc)); - GST_DEBUG ("Creating Direct3D device for hidden window %p", - shared.hidden_window_handle); + //Stencil/depth buffers aren't created by default when using swap chains + //if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(shared.d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dformat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D32))) { + // d3dstencilformat = D3DFMT_D32; + // d3dEnableAutoDepthStencil = TRUE; + //} else if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(shared.d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dformat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X8))) { + // d3dstencilformat = D3DFMT_D24X8; + // d3dEnableAutoDepthStencil = TRUE; + //} else if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(shared.d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dformat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16))) { + // d3dstencilformat = D3DFMT_D16; + // d3dEnableAutoDepthStencil = TRUE; + //} else { + // d3dstencilformat = D3DFMT_X8R8G8B8; + // d3dEnableAutoDepthStencil = FALSE; + //} + // + //GST_DEBUG("Determined Direct3D stencil format: %d", d3dstencilformat); - if (FAILED (hr = IDirect3D9_CreateDevice (d3d, + GST_DEBUG ("Direct3D back buffer size: %dx%d", GST_VIDEO_SINK_WIDTH (sink), + GST_VIDEO_SINK_HEIGHT (sink)); + + sink->d3dformat = d3dformat; + sink->d3dfourcc = d3dfourcc; + + + ZeroMemory (&sink->d3dpp, sizeof (sink->d3dpp)); + sink->d3dpp.Flags = D3DPRESENTFLAG_VIDEO | D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; + sink->d3dpp.Windowed = TRUE; + sink->d3dpp.hDeviceWindow = hwnd; + sink->d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + sink->d3dpp.BackBufferCount = 1; + //sink->d3dpp.BackBufferFormat = d3dformat; + sink->d3dpp.BackBufferWidth = sink->width; + sink->d3dpp.BackBufferHeight = sink->height; + sink->d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; + sink->d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; + + GST_DEBUG ("Creating Direct3D device for window %p", hwnd); + + sink->d3ddev = NULL; + + if (FAILED (hr = IDirect3D9_CreateDevice (shared.d3d, D3DADAPTER_DEFAULT, - D3DDEVTYPE_HAL, - shared.hidden_window_handle, d3dcreate, &d3dpp, &d3ddev))) { - /* Prevent memory leak */ - IDirect3D9_Release (d3d); + D3DDEVTYPE_HAL, hwnd, d3dcreate, &sink->d3dpp, &sink->d3ddev))) { GST_WARNING ("Unable to create Direct3D device. Result: %ld (0x%lx)", hr, hr); goto error; } + + if (FAILED (IDirect3DDevice9_CreateOffscreenPlainSurface (sink->d3ddev, + sink->width, sink->height, d3dfourcc, D3DPOOL_DEFAULT, + &sink->d3d_offscreen_surface, NULL))) { + goto error; + } + + + /* Determine texture filtering support. If it's supported for this format, use the filter + type determined when we created the dev and checked the dev caps. + */ + if (FAILED (IDirect3D9_CheckDeviceFormat (shared.d3d, D3DADAPTER_DEFAULT, + D3DDEVTYPE_HAL, d3dformat, D3DUSAGE_QUERY_FILTER, + D3DRTYPE_TEXTURE, d3dformat))) { + d3dfiltertype = D3DTEXF_NONE; + } + + GST_DEBUG ("Direct3D stretch rect texture filter: %d", d3dfiltertype); + + sink->d3dfiltertype = d3dfiltertype; + //if (FAILED(IDirect3DDevice9_GetDeviceCaps( // d3ddev, // &d3dcaps @@ -2199,150 +2192,14 @@ gst_d3dvideosink_initialize_d3d_device (GstD3DVideoSink * sink) // goto error; //} - shared.d3d = d3d; - shared.d3ddev = d3ddev; - shared.d3ddmformat = d3ddmformat; - shared.d3dfiltertype = d3dfiltertype; - /*success:*/ + GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); return TRUE; error: + GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); return FALSE; } -static gboolean -gst_d3dvideosink_initialize_swap_chain (GstD3DVideoSink * sink) -{ - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK (sink); - { - gint width; - gint height; - //D3DDISPLAYMODE mode; - D3DPRESENT_PARAMETERS d3dpp; - D3DFORMAT d3dformat; - D3DFORMAT d3dfourcc; - //D3DFORMAT d3dstencilformat; - LPDIRECT3DSWAPCHAIN9 d3dswapchain; - LPDIRECT3DSURFACE9 d3dsurface; - D3DTEXTUREFILTERTYPE d3dfiltertype; - //gboolean d3dEnableAutoDepthStencil; - - /* This should always work since gst_d3dvideosink_initialize_direct3d() should have always been called previously */ - if (!shared.d3ddev) { - GST_ERROR ("Direct3D device has not been initialized"); - goto error; - } - - GST_DEBUG ("Initializing Direct3D swap chain for sink %p", sink); - - if (gst_video_format_is_yuv (sink->format)) { - switch (gst_video_format_to_fourcc (sink->format)) { - case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'): - d3dformat = D3DFMT_X8R8G8B8; - d3dfourcc = (D3DFORMAT) MAKEFOURCC ('Y', 'U', 'Y', '2'); - break; - //case GST_MAKE_FOURCC ('Y', 'U', 'V', 'Y'): - // d3dformat = D3DFMT_X8R8G8B8; - // d3dfourcc = (D3DFORMAT)MAKEFOURCC('Y', 'U', 'V', 'Y'); - // break; - case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'): - d3dformat = D3DFMT_X8R8G8B8; - d3dfourcc = (D3DFORMAT) MAKEFOURCC ('U', 'Y', 'V', 'Y'); - break; - case GST_MAKE_FOURCC ('Y', 'V', '1', '2'): - case GST_MAKE_FOURCC ('I', '4', '2', '0'): - d3dformat = D3DFMT_X8R8G8B8; - d3dfourcc = (D3DFORMAT) MAKEFOURCC ('Y', 'V', '1', '2'); - break; - case GST_MAKE_FOURCC ('N', 'V', '1', '2'): - d3dformat = D3DFMT_X8R8G8B8; - d3dfourcc = (D3DFORMAT) MAKEFOURCC ('N', 'V', '1', '2'); - break; - default: - g_assert_not_reached (); - goto error; - } - } else if (gst_video_format_is_rgb (sink->format)) { - d3dformat = D3DFMT_X8R8G8B8; - d3dfourcc = D3DFMT_X8R8G8B8; - } else { - g_assert_not_reached (); - goto error; - } - - GST_DEBUG ("Determined Direct3D format: %" GST_FOURCC_FORMAT, - GST_FOURCC_ARGS (d3dfourcc)); - - //Stencil/depth buffers aren't created by default when using swap chains - //if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(shared.d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dformat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D32))) { - // d3dstencilformat = D3DFMT_D32; - // d3dEnableAutoDepthStencil = TRUE; - //} else if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(shared.d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dformat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X8))) { - // d3dstencilformat = D3DFMT_D24X8; - // d3dEnableAutoDepthStencil = TRUE; - //} else if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(shared.d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dformat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16))) { - // d3dstencilformat = D3DFMT_D16; - // d3dEnableAutoDepthStencil = TRUE; - //} else { - // d3dstencilformat = D3DFMT_X8R8G8B8; - // d3dEnableAutoDepthStencil = FALSE; - //} - // - //GST_DEBUG("Determined Direct3D stencil format: %d", d3dstencilformat); - - GST_DEBUG ("Direct3D back buffer size: %dx%d", GST_VIDEO_SINK_WIDTH (sink), - GST_VIDEO_SINK_HEIGHT (sink)); - - /* Get the current size of the window */ - gst_d3dvideosink_window_size (sink, &width, &height); - - ZeroMemory (&d3dpp, sizeof (d3dpp)); - d3dpp.Windowed = TRUE; - d3dpp.Flags = D3DPRESENTFLAG_VIDEO; - d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp.hDeviceWindow = sink->window_handle; - d3dpp.BackBufferFormat = d3dformat; - d3dpp.BackBufferWidth = width; - d3dpp.BackBufferHeight = height; - d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; /*D3DPRESENT_INTERVAL_IMMEDIATE; */ - - if (FAILED (IDirect3DDevice9_CreateAdditionalSwapChain (shared.d3ddev, - &d3dpp, &d3dswapchain))) - goto error; - - if (FAILED (IDirect3DDevice9_CreateOffscreenPlainSurface (shared.d3ddev, - sink->width, sink->height, d3dfourcc, D3DPOOL_DEFAULT, - &d3dsurface, NULL))) { - /* Ensure that we release our newly created swap chain to prevent memory leaks */ - IDirect3DSwapChain9_Release (d3dswapchain); - goto error; - } - - /* Determine texture filtering support. If it's supported for this format, use the filter type determined when we created the dev and checked the dev caps. */ - if (SUCCEEDED (IDirect3D9_CheckDeviceFormat (shared.d3d, D3DADAPTER_DEFAULT, - D3DDEVTYPE_HAL, shared.d3ddmformat, D3DUSAGE_QUERY_FILTER, - D3DRTYPE_TEXTURE, d3dformat))) { - d3dfiltertype = shared.d3dfiltertype; - } else { - d3dfiltertype = D3DTEXF_NONE; - } - - GST_DEBUG ("Direct3D stretch rect texture filter: %d", d3dfiltertype); - - sink->d3dformat = d3dformat; - sink->d3dfourcc = d3dfourcc; - sink->d3dfiltertype = d3dfiltertype; - sink->d3d_swap_chain = d3dswapchain; - sink->d3d_offscreen_surface = d3dsurface; - } - -/*success:*/ - GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return TRUE; -error: - GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return FALSE; -} static gboolean gst_d3dvideosink_resize_swap_chain (GstD3DVideoSink * sink, gint width, @@ -2353,152 +2210,81 @@ gst_d3dvideosink_resize_swap_chain (GstD3DVideoSink * sink, gint width, GST_DEBUG ("Invalid size"); return FALSE; } - - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK (sink); - { - int ref_count; - D3DPRESENT_PARAMETERS d3dpp; - LPDIRECT3DSWAPCHAIN9 d3dswapchain; - - GST_DEBUG ("Resizing Direct3D swap chain for sink %p to %dx%d", sink, width, - height); - - if (!shared.d3d || !shared.d3ddev) { - if (!shared.device_lost) - GST_WARNING ("Direct3D device has not been initialized"); - goto error; - } - - if (!sink->d3d_swap_chain) { - GST_DEBUG ("Direct3D swap chain has not been initialized"); - goto error; - } - - /* Get the parameters used to create this swap chain */ - if (FAILED (IDirect3DSwapChain9_GetPresentParameters (sink->d3d_swap_chain, - &d3dpp))) { - GST_DEBUG - ("Unable to determine Direct3D present parameters for swap chain"); - goto error; - } - - /* Release twice because IDirect3DSwapChain9_GetPresentParameters() adds a reference */ - while ((ref_count = - IDirect3DSwapChain9_Release (sink->d3d_swap_chain)) > 0); - sink->d3d_swap_chain = NULL; - GST_DEBUG ("Old Direct3D swap chain released. Reference count: %d", - ref_count); - - /* Adjust back buffer width/height */ - d3dpp.BackBufferWidth = width; - d3dpp.BackBufferHeight = height; - - if (FAILED (IDirect3DDevice9_CreateAdditionalSwapChain (shared.d3ddev, - &d3dpp, &d3dswapchain))) - goto error; - - sink->d3d_swap_chain = d3dswapchain; + if (!shared.d3d || !sink->d3ddev) { + GST_DEBUG_OBJECT (sink, "Direct3D device not initialized."); + return TRUE; } -/*success:*/ - GST_DEBUG ("Direct3D swap chain successfully resized for sink %p", sink); - GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return TRUE; + GST_LOG_OBJECT (sink, "Resizing Direct3D swap chain for sink %p to %dx%d", + sink, width, height); + /* actually recreates the device + associated surfaces + must be called from thread that created the device */ + if (!gst_d3dvideosink_notify_device_resize (sink)) + goto error; + + +/* success:*/ + GST_LOG_OBJECT (sink, "Direct3D swap chain successfully resized"); + return TRUE; error: - GST_DEBUG ("Error attempting to resize the Direct3D swap chain for sink %p", - sink); - GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return FALSE; + GST_ERROR_OBJECT (sink, "Error attempting to resize the Direct3D swap chain"); + return FALSE; } static gboolean -gst_d3dvideosink_release_swap_chain (GstD3DVideoSink * sink) +gst_d3dvideosink_notify_device_init (GstD3DVideoSink * sink) { - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK (sink); - { - GST_DEBUG ("Releasing Direct3D swap chain for sink %p", sink); - - /* This should always work since gst_d3dvideosink_initialize_direct3d() should have always been called previously */ - if (!shared.d3d || !shared.d3ddev) { - if (!shared.device_lost) - GST_ERROR ("Direct3D device has not been initialized"); - goto error; - } - - if (!sink->d3d_swap_chain && !sink->d3d_offscreen_surface) - goto success; - - if (sink->d3d_offscreen_surface) { - int ref_count; - while ((ref_count = - IDirect3DSurface9_Release (sink->d3d_offscreen_surface)) > 0); - sink->d3d_offscreen_surface = NULL; - GST_DEBUG - ("Direct3D offscreen surface released for sink %p. Reference count: %d", - sink, ref_count); - } - - if (sink->d3d_swap_chain) { - int ref_count; - while ((ref_count = - IDirect3DSwapChain9_Release (sink->d3d_swap_chain)) > 0); - sink->d3d_swap_chain = NULL; - GST_DEBUG - ("Direct3D swap chain released for sink %p. Reference count: %d", - sink, ref_count); - } + if (sink->window_handle) { + SendMessage (shared.hidden_window_handle, WM_DIRECTX_D3D_INIT_DEVICE, 0, + (LPARAM) sink); } + return TRUE; +} -success: - GST_DEBUG ("Direct3D swap chain successfully released for sink %p", sink); - GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return TRUE; -error: - GST_DEBUG ("Error attempting to release the Direct3D swap chain for sink %p", - sink); - GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return FALSE; +static gboolean +gst_d3dvideosink_notify_device_resize (GstD3DVideoSink * sink) +{ + if (sink->window_handle) { + SendMessage (shared.hidden_window_handle, WM_DIRECTX_D3D_RESIZE, 0, + (LPARAM) sink); + } + return TRUE; } static gboolean gst_d3dvideosink_notify_device_lost (GstD3DVideoSink * sink) { - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SHARED_D3D_LOCK - { - /* Send notification asynchronously */ - PostMessage (shared.hidden_window_handle, WM_DIRECTX_D3D_INIT_DEVICELOST, 0, - 0); - } + /* Send notification asynchronously */ + PostMessage (shared.hidden_window_handle, WM_DIRECTX_D3D_INIT_DEVICELOST, 0, + (LPARAM) sink); + /*success:*/ GST_DEBUG ("Successfully sent notification of device lost event for sink %p", sink); - GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK - return TRUE; + return TRUE; /*error:*/ /* GST_DEBUG("Error attempting to send notification of device lost event for sink %d", sink); */ /* GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK */ -/* GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK */ +/* */ /* return FALSE; */ } static gboolean gst_d3dvideosink_notify_device_reset (GstD3DVideoSink * sink) { - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SHARED_D3D_LOCK { /* Send notification synchronously -- let's ensure the timer's been killed before returning */ SendMessage (shared.hidden_window_handle, WM_DIRECTX_D3D_END_DEVICELOST, 0, - 0); + (LPARAM) sink); } /*success:*/ GST_DEBUG ("Successfully sent notification of device reset event for sink %p", sink); - GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK - return TRUE; + return TRUE; /*error:*/ /* GST_DEBUG("Error attempting to send notification of reset lost event for sink %d", sink); */ /* GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK */ -/* GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK */ +/* */ /* return FALSE; */ } @@ -2507,38 +2293,33 @@ gst_d3dvideosink_device_lost (GstD3DVideoSink * sink) { /* Must be called from hidden window's message loop! */ - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SHARED_D3D_LOCK + GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK (sink); { - GST_DEBUG ("Direct3D device lost. Resetting the device."); + if (shared.device_lost) + GST_DEBUG ("Direct3D device lost"); - if (g_thread_self () != shared.hidden_window_thread) - { + GST_DEBUG_OBJECT (sink, ". Resetting the device."); + + if (g_thread_self () != shared.hidden_window_thread) { GST_ERROR ("Direct3D device can only be reset by the thread that created it."); goto error; } - if (!shared.device_lost && (!shared.d3d || !shared.d3ddev)) - { + if (!shared.d3d) { GST_ERROR ("Direct3D device has not been initialized"); goto error; } { - GList *item; - GstD3DVideoSink *s; + //GList *item; + //GstD3DVideoSink *s; /* This is technically a bit different from the normal. We don't call reset(), instead */ /* we recreate everything from scratch. */ - /* Release all swap chains, surfaces, buffers, etc. */ - for (item = g_list_first (shared.element_list); item; item = item->next) { - s = (GstD3DVideoSink *) item->data; - gst_d3dvideosink_release_swap_chain (s); - } - /* Release the device */ - if (!gst_d3dvideosink_release_d3d_device (NULL)) + if (!gst_d3dvideosink_release_d3d_device (sink)) goto error; /* Recreate device */ @@ -2546,10 +2327,12 @@ gst_d3dvideosink_device_lost (GstD3DVideoSink * sink) goto error; /* Reinitialize all swap chains, surfaces, buffers, etc. */ - for (item = g_list_first (shared.element_list); item; item = item->next) { - s = (GstD3DVideoSink *) item->data; - gst_d3dvideosink_initialize_swap_chain (s); - } + /* + for (item = g_list_first (shared.element_list); item; item = item->next) { + s = (GstD3DVideoSink *) item->data; + gst_d3dvideosink_initialize_swap_chain (s); + } + */ } /* Let the hidden window know that it's okay to kill the timer */ @@ -2558,42 +2341,43 @@ gst_d3dvideosink_device_lost (GstD3DVideoSink * sink) /*success:*/ GST_DEBUG ("Direct3D device has successfully been reset."); - GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return TRUE; + GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); + return TRUE; error: GST_DEBUG ("Unable to successfully reset the Direct3D device."); - GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return FALSE; + GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); + return FALSE; } static gboolean gst_d3dvideosink_release_d3d_device (GstD3DVideoSink * sink) { - GST_DEBUG ("Cleaning all Direct3D objects"); - - if (shared.d3ddev) { + GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK (sink); + if (sink->d3ddev) { int ref_count; - ref_count = IDirect3DDevice9_Release (shared.d3ddev); - shared.d3ddev = NULL; - GST_DEBUG ("Direct3D device released. Reference count: %d", ref_count); + ref_count = IDirect3DDevice9_Release (sink->d3ddev); + sink->d3ddev = NULL; + GST_DEBUG_OBJECT (sink, "Direct3D device released. Reference count: %d", + ref_count); } - - if (shared.d3d) { + if (sink->d3d_offscreen_surface) { int ref_count; - ref_count = IDirect3D9_Release (shared.d3d); - shared.d3d = NULL; - GST_DEBUG ("Direct3D object released. Reference count: %d", ref_count); + ref_count = IDirect3DSurface9_Release (sink->d3d_offscreen_surface); + sink->d3d_offscreen_surface = NULL; + GST_DEBUG_OBJECT (sink, + "Direct3D offscreen surface released. Reference count: %d", ref_count); } - + GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK (sink); return TRUE; } static gboolean gst_d3dvideosink_release_direct3d (GstD3DVideoSink * sink) { - GST_D3DVIDEOSINK_SHARED_D3D_DEV_LOCK GST_D3DVIDEOSINK_SHARED_D3D_LOCK + GST_DEBUG ("Cleaning all Direct3D objects"); + GST_D3DVIDEOSINK_SHARED_D3D_LOCK /* Be absolutely sure that we've released this sink's hook (if any). */ - gst_d3dvideosink_unhook_window_for_renderer (sink); + gst_d3dvideosink_unhook_window_for_renderer (sink); /* Remove item from the list */ shared.element_list = g_list_remove (shared.element_list, sink); @@ -2606,16 +2390,20 @@ gst_d3dvideosink_release_direct3d (GstD3DVideoSink * sink) goto success; gst_d3dvideosink_release_d3d_device (sink); + if (shared.d3d) { + int ref_count; + ref_count = IDirect3D9_Release (shared.d3d); + shared.d3d = NULL; + GST_DEBUG ("Direct3D object released. Reference count: %d", ref_count); + } GST_DEBUG ("Closing hidden Direct3D window"); gst_d3dvideosink_close_shared_hidden_window (sink); success: - GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK - GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK return TRUE; + GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK return TRUE; /*error:*/ /* GST_D3DVIDEOSINK_SHARED_D3D_UNLOCK */ -/* GST_D3DVIDEOSINK_SHARED_D3D_DEV_UNLOCK */ /* return FALSE; */ } diff --git a/sys/d3dvideosink/d3dvideosink.h b/sys/d3dvideosink/d3dvideosink.h index e067dd3f16..14b52fd001 100644 --- a/sys/d3dvideosink/d3dvideosink.h +++ b/sys/d3dvideosink/d3dvideosink.h @@ -83,8 +83,9 @@ struct _GstD3DVideoSink gboolean is_hooked; GMutex *d3d_swap_chain_lock; - LPDIRECT3DSWAPCHAIN9 d3d_swap_chain; LPDIRECT3DSURFACE9 d3d_offscreen_surface; + LPDIRECT3DDEVICE9 d3ddev; + D3DPRESENT_PARAMETERS d3dpp; D3DFORMAT d3dformat; D3DFORMAT d3dfourcc; From c83532553663218d7e89590afa574429bc1a3fe3 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Wed, 8 Feb 2012 21:21:47 +0000 Subject: [PATCH 36/37] shmsink: fix indefinite wait after adding a new fd to the poll set If the second call to _wait blocks, we will not signal the condition variable, so ensure that second call is not blocking. See rationale and information in the linked bug: https://bugzilla.gnome.org/show_bug.cgi?id=669697 --- sys/shm/gstshmsink.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/shm/gstshmsink.c b/sys/shm/gstshmsink.c index 111fbbf0f5..fd7ffb4edf 100644 --- a/sys/shm/gstshmsink.c +++ b/sys/shm/gstshmsink.c @@ -512,12 +512,15 @@ pollthread_func (gpointer data) { GstShmSink *self = GST_SHM_SINK (data); GList *item; + GstClockTime timeout = GST_CLOCK_TIME_NONE; while (!self->stop) { - if (gst_poll_wait (self->poll, GST_CLOCK_TIME_NONE) < 0) + if (gst_poll_wait (self->poll, timeout) < 0) return NULL; + timeout = GST_CLOCK_TIME_NONE; + if (self->stop) return NULL; @@ -561,6 +564,7 @@ pollthread_func (gpointer data) functions on that new descriptor, so restart the loop, so _wait will have been called on all elements of self->poll, whether they have just been added or not. */ + timeout = 0; continue; } From 1cbd755a2cd45531076c7b19ef194b77d5575cb0 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Fri, 10 Feb 2012 14:46:00 +0100 Subject: [PATCH 37/37] h264parse: unobfuscate frame parsing code --- gst/videoparsers/gsth264parse.c | 208 ++++++++++++++++---------------- gst/videoparsers/gsth264parse.h | 3 +- 2 files changed, 102 insertions(+), 109 deletions(-) diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 3482d5bfe4..545a08dbae 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -177,11 +177,7 @@ gst_h264_parse_reset_frame (GstH264Parse * h264parse) GST_DEBUG_OBJECT (h264parse, "reset frame"); /* done parsing; reset state */ - h264parse->nalu.valid = FALSE; - h264parse->nalu.offset = 0; - h264parse->nalu.sc_offset = 0; - h264parse->nalu.size = 0; - h264parse->current_off = 0; + h264parse->current_off = -1; h264parse->picture_start = FALSE; h264parse->update_caps = FALSE; @@ -656,10 +652,12 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, GstH264Parse *h264parse = GST_H264_PARSE (parse); GstBuffer *buffer = frame->buffer; guint8 *data; - guint size, current_off = 0; - gboolean drain; + guint size; + gint current_off = 0; + gboolean drain, nonext; GstH264NalParser *nalparser = h264parse->nalparser; GstH264NalUnit nalu; + GstH264ParserResult pres; /* expect at least 3 bytes startcode == sc, and 2 bytes NALU payload */ if (G_UNLIKELY (GST_BUFFER_SIZE (buffer) < 5)) @@ -681,16 +679,38 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, data = GST_BUFFER_DATA (buffer); size = GST_BUFFER_SIZE (buffer); - drain = FALSE; - nalu = h264parse->nalu; + drain = GST_BASE_PARSE_DRAINING (parse); + nonext = FALSE; + current_off = h264parse->current_off; - + if (current_off < 0) + current_off = 0; g_assert (current_off < size); + GST_DEBUG_OBJECT (h264parse, "last parse position %d", current_off); + + /* check for initial skip */ + if (h264parse->current_off == -1) { + pres = + gst_h264_parser_identify_nalu_unchecked (nalparser, data, current_off, + size, &nalu); + switch (pres) { + case GST_H264_PARSER_OK: + if (nalu.sc_offset > 0) { + *skipsize = nalu.sc_offset; + goto skip; + } + break; + case GST_H264_PARSER_NO_NAL: + *skipsize = size - 3; + goto skip; + break; + default: + g_assert_not_reached (); + break; + } + } - GST_DEBUG_OBJECT (h264parse, "last parse position %u", current_off); while (TRUE) { - GstH264ParserResult pres; - if (h264parse->packetized_chunked) pres = gst_h264_parser_identify_nalu_unchecked (nalparser, data, current_off, @@ -702,99 +722,85 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, switch (pres) { case GST_H264_PARSER_OK: - GST_DEBUG_OBJECT (h264parse, "complete nal found. " - "current offset: %u, Nal offset: %u, Nal Size: %u", - current_off, nalu.offset, nalu.size); - - GST_DEBUG_OBJECT (h264parse, "current off. %u", - nalu.offset + nalu.size); - - if (!h264parse->nalu.size && !h264parse->nalu.valid) - h264parse->nalu = nalu; - - /* need 2 bytes of next nal */ - if (!h264parse->packetized_chunked && - (nalu.offset + nalu.size + 4 + 2 > size)) { - if (GST_BASE_PARSE_DRAINING (parse)) { - drain = TRUE; - } else { - GST_DEBUG_OBJECT (h264parse, "need more bytes of next nal"); - current_off = nalu.sc_offset; - goto more; - } - } else if (h264parse->packetized_chunked) { - /* normal next nal based collection not possible, - * _chain will have to tell us whether this was last one for AU */ - drain = h264parse->packetized_last; - } + GST_DEBUG_OBJECT (h264parse, "complete nal (offset, size): (%u, %u) ", + nalu.offset, nalu.size); break; - case GST_H264_PARSER_BROKEN_LINK: - return FALSE; - case GST_H264_PARSER_ERROR: - current_off = size - 3; - goto parsing_error; - case GST_H264_PARSER_NO_NAL: - /* don't expect to have found any NAL so far */ - g_assert (h264parse->nalu.size == 0); - current_off = h264parse->nalu.sc_offset = size - 3; - goto more; - case GST_H264_PARSER_BROKEN_DATA: - GST_WARNING_OBJECT (h264parse, "input stream is corrupt; " - "it contains a NAL unit of length %d", nalu.size); - - /* broken nal at start -> arrange to skip it, - * otherwise have it terminate current au - * (and so it will be skipped on next frame round) */ - if (nalu.sc_offset == h264parse->nalu.sc_offset) { - *skipsize = nalu.offset; - - GST_DEBUG_OBJECT (h264parse, "skipping broken nal"); - goto invalid; - } else { - nalu.size = 0; - goto end; - } case GST_H264_PARSER_NO_NAL_END: GST_DEBUG_OBJECT (h264parse, "not a complete nal found at offset %u", nalu.offset); - - current_off = nalu.sc_offset; - /* We keep the reference to this nal so we start over the parsing - * here */ - if (!h264parse->nalu.size && !h264parse->nalu.valid) - h264parse->nalu = nalu; - - if (GST_BASE_PARSE_DRAINING (parse)) { - drain = TRUE; - GST_DEBUG_OBJECT (h264parse, "draining NAL %u %u %u", size, - h264parse->nalu.offset, h264parse->nalu.size); - /* Can't parse the nalu */ - if (size - h264parse->nalu.offset < 2) { - *skipsize = nalu.offset; - goto invalid; - } - - /* We parse it anyway */ + /* if draining, accept it as complete nal */ + if (drain) { + nonext = TRUE; nalu.size = size - nalu.offset; + GST_DEBUG_OBJECT (h264parse, "draining, accepting with size %u", + nalu.size); + /* if it's not too short at least */ + if (nalu.size < 2) + goto broken; break; } + /* otherwise need more */ goto more; + case GST_H264_PARSER_BROKEN_LINK: + g_assert_not_reached (); + break; + case GST_H264_PARSER_ERROR: + /* should not really occur either */ + GST_DEBUG_OBJECT (h264parse, "error parsing Nal Unit"); + /* fall-through */ + case GST_H264_PARSER_NO_NAL: + g_assert_not_reached (); + break; + case GST_H264_PARSER_BROKEN_DATA: + GST_WARNING_OBJECT (h264parse, "input stream is corrupt; " + "it contains a NAL unit of length %u", nalu.size); + broken: + /* broken nal at start -> arrange to skip it, + * otherwise have it terminate current au + * (and so it will be skipped on next frame round) */ + if (current_off == 0) { + GST_DEBUG_OBJECT (h264parse, "skipping broken nal"); + *skipsize = nalu.offset; + goto skip; + } else { + GST_DEBUG_OBJECT (h264parse, "terminating au"); + nalu.size = 0; + nalu.offset = nalu.sc_offset; + goto end; + } + break; + default: + g_assert_not_reached (); + break; } - current_off = nalu.offset + nalu.size; - GST_DEBUG_OBJECT (h264parse, "%p complete nal found. Off: %u, Size: %u", data, nalu.offset, nalu.size); + /* simulate no next nal if none needed */ + nonext = nonext || (h264parse->align == GST_H264_PARSE_ALIGN_NAL); + + if (!nonext && !h264parse->packetized_chunked) { + if (nalu.offset + nalu.size + 4 + 2 > size) { + GST_DEBUG_OBJECT (h264parse, "not enough data for next NALU"); + if (drain) { + GST_DEBUG_OBJECT (h264parse, "but draining anyway"); + nonext = TRUE; + } else { + goto more; + } + } + } + gst_h264_parse_process_nal (h264parse, &nalu); - /* simulate no next nal if none needed */ - drain = drain || (h264parse->align == GST_H264_PARSE_ALIGN_NAL); + if (nonext) + break; /* In packetized mode we know there's only on NALU in each input packet, * but we may not have seen the whole AU already, possibly need more */ if (h264parse->packetized_chunked) { - if (drain) + if (h264parse->packetized_last) break; /* next NALU expected at end of current data */ current_off = size; @@ -802,42 +808,30 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, } /* if no next nal, we know it's complete here */ - if (drain || gst_h264_parse_collect_nal (h264parse, data, size, &nalu)) + if (gst_h264_parse_collect_nal (h264parse, data, size, &nalu)) break; GST_DEBUG_OBJECT (h264parse, "Looking for more"); + current_off = nalu.offset + nalu.size; } end: - *skipsize = h264parse->nalu.sc_offset; - *framesize = nalu.offset + nalu.size - h264parse->nalu.sc_offset; - h264parse->current_off = current_off; - + *framesize = nalu.offset + nalu.size; return TRUE; -parsing_error: - GST_DEBUG_OBJECT (h264parse, "error parsing Nal Unit"); - more: /* ask for best next available */ *framesize = G_MAXUINT; - if (!h264parse->nalu.size) { - /* skip up to initial startcode */ - *skipsize = h264parse->nalu.sc_offset; - /* but mind some stuff will have been skipped */ - g_assert (current_off >= *skipsize); - current_off -= *skipsize; - h264parse->nalu.sc_offset = 0; - } else { - *skipsize = 0; - } + *skipsize = 0; /* Restart parsing from here next time */ - h264parse->current_off = current_off; + if (current_off > 0) + h264parse->current_off = current_off; return FALSE; -invalid: +skip: + GST_DEBUG_OBJECT (h264parse, "skipping %d", *skipsize); gst_h264_parse_reset_frame (h264parse); return FALSE; } diff --git a/gst/videoparsers/gsth264parse.h b/gst/videoparsers/gsth264parse.h index ff6eb59f01..61afe93878 100644 --- a/gst/videoparsers/gsth264parse.h +++ b/gst/videoparsers/gsth264parse.h @@ -67,10 +67,9 @@ struct _GstH264Parse /* state */ GstH264NalParser *nalparser; - GstH264NalUnit nalu; guint align; guint format; - guint current_off; + gint current_off; gboolean packetized_last; gboolean packetized_chunked;