diff --git a/ext/cog/Makefile.am b/ext/cog/Makefile.am index 81e0f15e1c..bbed6fe0e3 100644 --- a/ext/cog/Makefile.am +++ b/ext/cog/Makefile.am @@ -5,6 +5,7 @@ include $(top_srcdir)/common/orc.mak libgstcog_la_CFLAGS = \ -DCOG_ENABLE_UNSTABLE_API \ + $(GST_PLUGINS_BAD_CFLAGS) \ -I$(srcdir)/.. \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_CFLAGS) \ diff --git a/ext/cog/gstcogmse.c b/ext/cog/gstcogmse.c index f4ac3fb58f..f73a3b8d43 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..42fbe31b47 100644 --- a/ext/curl/Makefile.am +++ b/ext/curl/Makefile.am @@ -2,6 +2,7 @@ plugin_LTLIBRARIES = libgstcurl.la libgstcurl_la_SOURCES = gstcurl.c gstcurlsink.c libgstcurl_la_CFLAGS = \ + $(GST_PLUGINS_BAD_CFLAGS) \ $(GST_BASE_CFLAGS) \ $(GST_CFLAGS) \ $(CURL_CFLAGS) diff --git a/ext/curl/gstcurlsink.c b/ext/curl/gstcurlsink.c index 2a448f436c..a068435225 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/faad/gstfaad.c b/ext/faad/gstfaad.c index 8fa3447248..94ac0a781d 100644 --- a/ext/faad/gstfaad.c +++ b/ext/faad/gstfaad.c @@ -91,7 +91,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_RAW_CAPS(format) \ diff --git a/ext/gsettings/Makefile.am b/ext/gsettings/Makefile.am index 64801df9ba..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) $(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/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..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) $(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/kate/gstkateenc.c b/ext/kate/gstkateenc.c index 450e8e61e2..db365691c2 100644 --- a/ext/kate/gstkateenc.c +++ b/ext/kate/gstkateenc.c @@ -409,10 +409,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; } @@ -428,9 +424,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)); @@ -608,7 +601,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; } @@ -656,7 +650,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; @@ -694,7 +689,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"); @@ -724,7 +720,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 = @@ -735,7 +732,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 */ @@ -845,19 +843,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 @@ -879,7 +879,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 = @@ -921,7 +922,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; @@ -943,7 +945,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); @@ -1030,21 +1032,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; } } @@ -1052,18 +1056,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; @@ -1375,7 +1382,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 80c7ca41b3..67821d8c16 100644 --- a/ext/kate/gstkateparse.c +++ b/ext/kate/gstkateparse.c @@ -189,7 +189,8 @@ gst_kate_parse_push_headers (GstKateParse * parse) kate_packet_wrap (&packet, size, data); 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)); } gst_buffer_unmap (outbuf, data, size); /* takes ownership of outbuf, which was previously in parse->streamheader */ diff --git a/ext/kate/gstkatetiger.c b/ext/kate/gstkatetiger.c index 67783dcfa5..fda3f7c12f 100644 --- a/ext/kate/gstkatetiger.c +++ b/ext/kate/gstkatetiger.c @@ -80,6 +80,7 @@ #include #include +#include #include #include "gstkate.h" @@ -683,7 +684,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)); } } } @@ -777,7 +779,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); @@ -790,23 +792,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) { @@ -842,7 +827,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; } @@ -852,7 +838,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; } @@ -884,21 +871,20 @@ 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); } 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); @@ -949,15 +935,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 787bc3e10e..d281587589 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" @@ -273,7 +276,8 @@ gst_kate_util_decoder_base_chain_kate_packet (GstKateDecoderBase * decoder, 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; } @@ -443,8 +447,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; @@ -627,3 +631,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 a837369dba..85a86d2add 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__ */ diff --git a/ext/modplug/gstmodplug.cc b/ext/modplug/gstmodplug.cc index 8c9f6064aa..05d8278537 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 719a161b7e..9b79185ff6 100644 --- a/ext/mpeg2enc/Makefile.am +++ b/ext/mpeg2enc/Makefile.am @@ -8,8 +8,7 @@ libgstmpeg2enc_la_SOURCES = \ gstmpeg2encpicturereader.cc libgstmpeg2enc_la_CXXFLAGS = \ - $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \ - $(GST_CXXFLAGS) $(MPEG2ENC_CFLAGS) + $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) $(MPEG2ENC_CFLAGS) libgstmpeg2enc_la_LIBADD = \ $(GST_PLUGINS_BASE_LIBS) -lgstvideo-@GST_MAJORMINOR@ \ $(GST_LIBS) $(MPEG2ENC_LIBS) diff --git a/ext/mpeg2enc/gstmpeg2enc.cc b/ext/mpeg2enc/gstmpeg2enc.cc index e8f16aa215..4e8eaaccdb 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..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_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/mplex/gstmplex.cc b/ext/mplex/gstmplex.cc index 4a492976b0..2c9328d177 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..48a7eade40 100644 --- a/ext/opus/Makefile.am +++ b/ext/opus/Makefile.am @@ -3,13 +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_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/opus/gstopusenc.c b/ext/opus/gstopusenc.c index fd2f0ad625..167d195ffc 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 8c2d94fd60..a83656d1e2 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 21282a6203..8ce39a1b26 100644 --- a/ext/resindvd/resindvdsrc.c +++ b/ext/resindvd/resindvdsrc.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -1120,7 +1121,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 +1412,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); diff --git a/ext/resindvd/rsnparsetter.c b/ext/resindvd/rsnparsetter.c index a69366f9d5..f2f328c25a 100644 --- a/ext/resindvd/rsnparsetter.c +++ b/ext/resindvd/rsnparsetter.c @@ -7,6 +7,7 @@ #endif #include +#include #include #include diff --git a/ext/schroedinger/gstschrodec.c b/ext/schroedinger/gstschrodec.c index c8fa8336e8..7508b3885d 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 1fb75f98e5..933a92102f 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 * diff --git a/ext/sdl/Makefile.am b/ext/sdl/Makefile.am index 7f29981060..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_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/ext/sdl/sdlaudiosink.c b/ext/sdl/sdlaudiosink.c index 707459fc7b..77f885a9d7 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 fa05ace1ad..ebf756f175 100644 --- a/ext/sdl/sdlvideosink.c +++ b/ext/sdl/sdlvideosink.c @@ -30,6 +30,7 @@ #endif #include +#include #include #include diff --git a/ext/voaacenc/gstvoaacenc.c b/ext/voaacenc/gstvoaacenc.c index f6fb6517fe..dd4b7ed9e9 100644 --- a/ext/voaacenc/gstvoaacenc.c +++ b/ext/voaacenc/gstvoaacenc.c @@ -166,6 +166,8 @@ gst_voaacenc_class_init (GstVoAacEncClass * klass) gst_element_class_set_details_simple (element_class, "AAC audio encoder", "Codec/Encoder/Audio", "AAC audio encoder", "Kan Hu "); + + GST_DEBUG_CATEGORY_INIT (gst_voaacenc_debug, "voaacenc", 0, "voaac encoder"); } static void diff --git a/ext/voamrwbenc/gstvoamrwbenc.c b/ext/voamrwbenc/gstvoamrwbenc.c index 2c2e253cb0..0f40fb3c2f 100644 --- a/ext/voamrwbenc/gstvoamrwbenc.c +++ b/ext/voamrwbenc/gstvoamrwbenc.c @@ -182,6 +182,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 diff --git a/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c b/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c index d6ad8d517b..c342216713 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 426df21cbc..ee08c6b2f1 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/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); } 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 70d8d12e48..a175962c46 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 8b0ad8eedf..b1ae65bae6 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 5482e67c10..3f38c298b4 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 575b309b5a..4fe5f64e46 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 da0482adec..27c605f2ff 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 "gstbaseaudiovisualizer.h" diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index 39cd2b91b3..1a3e2a0f38 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" @@ -210,9 +215,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 @@ -236,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 @@ -933,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; @@ -1607,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, @@ -3348,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 */ @@ -3923,8 +3949,10 @@ 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_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 diff --git a/gst/camerabin/gstinputselector.c b/gst/camerabin/gstinputselector.c index 750d6ce87a..6af1918a57 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 8bf1e2799a..aeb38974b2 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 @@ -817,15 +818,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, diff --git a/gst/camerabin2/gstwrappercamerabinsrc.c b/gst/camerabin2/gstwrappercamerabinsrc.c index 9c9d1ba8c5..3bc047108d 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 efcda21174..dc9f949f84 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 1c5524af49..4f6a7d4346 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 aa26cdaad9..235f86a241 100644 --- a/gst/dvbsuboverlay/gstdvbsuboverlay.c +++ b/gst/dvbsuboverlay/gstdvbsuboverlay.c @@ -38,6 +38,7 @@ # include #endif +#include #include "gstdvbsuboverlay.h" #include diff --git a/gst/dvdspu/gstdvdspu.c b/gst/dvdspu/gstdvdspu.c index 488b46625e..ea348fe22e 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/geometrictransform/gstrotate.c b/gst/geometrictransform/gstrotate.c index 6c5ba62cbc..764feb56a0 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"); } @@ -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; diff --git a/gst/hls/Makefile.am b/gst/hls/Makefile.am index 687b568e02..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) $(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/hls/gsthlsdemux.c b/gst/hls/gsthlsdemux.c index 7a7d5f6698..f0f4b522dc 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_%u", 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..e404959879 100644 --- a/gst/inter/Makefile.am +++ b/gst/inter/Makefile.am @@ -22,14 +22,15 @@ noinst_HEADERS = \ gstintersurface.h libgstinter_la_CFLAGS = \ - $(GST_CFLAGS) \ + $(GST_PLUGINS_BAD_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ - $(GST_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) @@ -39,12 +40,13 @@ gstintertest_SOURCES = \ gstintertest.c gstintertest_CFLAGS = \ - $(GST_CFLAGS) \ - $(GST_PLUGINS_BASE_CFLAGS) + $(GST_PLUGINS_BAD_CFLAGS) \ + $(GST_PLUGINS_BASE_CFLAGS) \ + $(GST_CFLAGS) gstintertest_LDADD = \ - $(GST_LIBS) \ $(GST_PLUGINS_BASE_LIBS) \ + $(GST_LIBS) \ $(LIBM) Android.mk: Makefile.am $(BUILT_SOURCES) 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..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_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/liveadder/liveadder.c b/gst/liveadder/liveadder.c index fc3154ce93..d22bcb7d9d 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 4bf6235460..8e7bd23108 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" @@ -114,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..012c1cc716 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 }, " \ @@ -396,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) @@ -1083,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) { @@ -1329,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"); @@ -1384,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; @@ -1738,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; diff --git a/gst/mpegpsmux/mpegpsmux.c b/gst/mpegpsmux/mpegpsmux.c index 3fff4be51e..b9e40fbe5f 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 }, " diff --git a/gst/mpegtsdemux/mpegtsbase.c b/gst/mpegtsdemux/mpegtsbase.c index bdf4caddb6..bb200df743 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 @@ -174,6 +178,7 @@ mpegts_base_class_init (MpegTSBaseClass * klass) element_class = GST_ELEMENT_CLASS (klass); element_class->change_state = mpegts_base_change_state; + gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sink_template)); diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index 6261ff908a..70b464a640 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -144,7 +144,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 }, " \ @@ -1082,11 +1085,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); diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c index 3e3b3f9e11..6abfc9380e 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" @@ -117,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 }, " @@ -659,27 +665,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) { @@ -688,7 +673,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: diff --git a/gst/mve/Makefile.am b/gst/mve/Makefile.am index 272b918578..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_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/gst/mve/gstmvemux.c b/gst/mve/gstmvemux.c index 3bf07b01e0..fdec7f0961 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 47042103d1..f56c4f3869 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 59a3093f82..2148ca7f61 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 0eb46a0450..30e98fd094 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 + #include "gstsdpdemux.h" #include diff --git a/gst/tta/gstttaparse.c b/gst/tta/gstttaparse.c index e7c131ba9a..80f93b7b98 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/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index bb9a93c9d6..2ba6af0ae1 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -176,15 +176,12 @@ 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; h264parse->idr_pos = -1; + h264parse->sei_pos = -1; h264parse->keyframe = FALSE; h264parse->frame_start = FALSE; gst_adapter_clear (h264parse->frame_out); @@ -291,6 +288,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; @@ -330,9 +330,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"); @@ -343,6 +354,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); } @@ -504,6 +517,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 +569,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); @@ -575,10 +603,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); @@ -631,9 +655,10 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, guint8 *data; gsize size; guint current_off = 0; - gboolean drain; + gboolean drain, nonext; GstH264NalParser *nalparser = h264parse->nalparser; GstH264NalUnit nalu; + GstH264ParserResult pres; gst_buffer_map (buffer, &map, GST_MAP_READ); data = map.data; @@ -658,15 +683,39 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse, GST_LOG_OBJECT (h264parse, "resuming frame parsing"); } - 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) + if (h264parse->packetized_chunked) pres = gst_h264_parser_identify_nalu_unchecked (nalparser, data, current_off, size, &nalu); @@ -677,131 +726,121 @@ 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 && (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; - } - } + GST_DEBUG_OBJECT (h264parse, "complete nal (offset, size): (%u, %u) ", + nalu.offset, nalu.size); break; - case GST_H264_PARSER_BROKEN_LINK: - goto out; - 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 %" G_GSIZE_FORMAT " %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); - /* if no next nal, we know it's complete here */ - if (drain || gst_h264_parse_collect_nal (h264parse, data, size, &nalu)) + + if (nonext) break; - /* In packetized mode we know there's only on NALU in each input packet */ - if (h264parse->packetized) + /* 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 (h264parse->packetized_last) + 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 (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; gst_buffer_unmap (buffer, &map); 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; /* Fall-through. */ out: gst_buffer_unmap (buffer, &map); return FALSE; -invalid: +skip: + GST_DEBUG_OBJECT (h264parse, "skipping %d", *skipsize); gst_h264_parse_reset_frame (h264parse); goto out; } @@ -1873,7 +1912,17 @@ gst_h264_parse_chain (GstPad * pad, GstObject * parent, 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); + /* 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", + nalu.size, h264parse->packetized_last); ret = h264parse->parse_chain (pad, parent, 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..61afe93878 100644 --- a/gst/videoparsers/gsth264parse.h +++ b/gst/videoparsers/gsth264parse.h @@ -67,10 +67,11 @@ struct _GstH264Parse /* state */ GstH264NalParser *nalparser; - GstH264NalUnit nalu; guint align; guint format; - guint current_off; + gint current_off; + gboolean packetized_last; + gboolean packetized_chunked; GstClockTime last_report; gboolean push_codec; @@ -97,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; diff --git a/gst/videoparsers/gstmpegvideoparse.c b/gst/videoparsers/gstmpegvideoparse.c index 974fecc569..37a13cc63c 100644 --- a/gst/videoparsers/gstmpegvideoparse.c +++ b/gst/videoparsers/gstmpegvideoparse.c @@ -691,6 +691,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); diff --git a/sys/d3dvideosink/d3dvideosink.c b/sys/d3dvideosink/d3dvideosink.c index 6c757b4b9e..a327802881 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; @@ -89,12 +81,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); @@ -164,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, @@ -178,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); @@ -188,7 +180,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 @@ -455,9 +447,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", (guint32 *) & 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 @@ -495,6 +530,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); @@ -545,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"); @@ -595,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; } @@ -633,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: { @@ -659,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: @@ -669,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); @@ -794,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: { @@ -1043,32 +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; - - if (init_swap_chain) - gst_d3dvideosink_initialize_swap_chain (sink); + gst_d3dvideosink_set_window_for_renderer (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 return; + + 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; */ } @@ -1276,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) { @@ -1289,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); { @@ -1326,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 @@ -1344,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 @@ -1356,7 +1370,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; @@ -1534,202 +1549,222 @@ 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) +{ + LPDIRECT3DQUERY9 pEventQuery = NULL; + + 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) +{ + if (sink->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)); + + IDirect3DDevice9_GetDisplayMode (sink->d3ddev, 0, &d3ddm); + vblankStart = d3ddm.Height - 10; + SetThreadPriority (thdl, THREAD_PRIORITY_TIME_CRITICAL); + do { + 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", + 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) { 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; - } - 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); - } - /* 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))) { - 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_FLUSHING; + return GST_FLOW_FLUSHING; /*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; @@ -1740,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: @@ -1778,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) { @@ -1801,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) { @@ -1822,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; */ } @@ -1840,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); } } @@ -1867,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 @@ -1911,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 @@ -1918,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++; @@ -1932,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); @@ -1978,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/ */ @@ -2028,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 @@ -2065,143 +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; - 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: %d", 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.SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp.hDeviceWindow = sink->window_handle; - d3dpp.BackBufferFormat = d3dformat; - d3dpp.BackBufferWidth = width; - d3dpp.BackBufferHeight = height; - - 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, @@ -2212,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; */ } @@ -2366,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 */ @@ -2405,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 */ @@ -2417,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); @@ -2465,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; diff --git a/sys/decklink/Makefile.am b/sys/decklink/Makefile.am index cb13a8aceb..22863edc33 100644 --- a/sys/decklink/Makefile.am +++ b/sys/decklink/Makefile.am @@ -1,6 +1,7 @@ plugin_LTLIBRARIES = libgstdecklink.la libgstdecklink_la_CPPFLAGS = \ + $(GST_PLUGINS_BAD_CFLAGS) \ $(GST_BASE_CFLAGS) \ $(GST_CXXFLAGS) \ $(DECKLINK_CXXFLAGS) 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 8ccb880545..9fd9b0ced2 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 61b546ede0..755cb3dfc9 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 6096f6ca3d..5f2ddd9962 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..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) -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/sys/shm/gstshmsink.c b/sys/shm/gstshmsink.c index 64490cf921..a4d7056355 100644 --- a/sys/shm/gstshmsink.c +++ b/sys/shm/gstshmsink.c @@ -27,6 +27,7 @@ #include "gstshmsink.h" #include +#include #include @@ -512,12 +513,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 +565,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; } diff --git a/tests/examples/scaletempo/Makefile.am b/tests/examples/scaletempo/Makefile.am index 33e6bc92e6..245084c294 100644 --- a/tests/examples/scaletempo/Makefile.am +++ b/tests/examples/scaletempo/Makefile.am @@ -4,8 +4,8 @@ noinst_PROGRAMS = scaletempo-demo ERROR_CFLAGS= 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_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 diff --git a/tests/examples/scaletempo/demo-gui.c b/tests/examples/scaletempo/demo-gui.c index b4e5683310..9af311308c 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