1 /* GStreamer unit tests for playbin2 compressed stream support
3 * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
4 * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
26 #include <gst/check/gstcheck.h>
27 #include <gst/base/gstpushsrc.h>
28 #include <gst/base/gstbasesink.h>
29 #include <gst/interfaces/streamvolume.h>
31 #ifndef GST_DISABLE_REGISTRY
35 static GType gst_caps_src_get_type (void);
36 static GType gst_codec_demuxer_get_type (void);
37 static GType gst_codec_sink_get_type (void);
38 static GType gst_audio_codec_sink_get_type (void);
39 static GType gst_video_codec_sink_get_type (void);
42 #define parent_class caps_src_parent_class
43 typedef struct _GstCapsSrc GstCapsSrc;
44 typedef GstPushSrcClass GstCapsSrcClass;
56 gst_caps_src_uri_get_type (void)
62 gst_caps_src_uri_get_protocols (void)
64 static gchar *protocols[] = { (char *) "caps", NULL };
70 gst_caps_src_uri_get_uri (GstURIHandler * handler)
72 GstCapsSrc *src = (GstCapsSrc *) handler;
78 gst_caps_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
80 GstCapsSrc *src = (GstCapsSrc *) handler;
82 if (uri == NULL || !g_str_has_prefix (uri, "caps:"))
86 src->uri = g_strdup (uri);
89 gst_caps_unref (src->caps);
96 gst_caps_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
98 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
100 iface->get_type = gst_caps_src_uri_get_type;
101 iface->get_protocols = gst_caps_src_uri_get_protocols;
102 iface->get_uri = gst_caps_src_uri_get_uri;
103 iface->set_uri = gst_caps_src_uri_set_uri;
107 gst_caps_src_init_type (GType type)
109 static const GInterfaceInfo uri_hdlr_info = {
110 gst_caps_src_uri_handler_init, NULL, NULL
113 g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &uri_hdlr_info);
116 GST_BOILERPLATE_FULL (GstCapsSrc, gst_caps_src, GstPushSrc,
117 GST_TYPE_PUSH_SRC, gst_caps_src_init_type);
120 gst_caps_src_base_init (gpointer klass)
122 static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
123 GST_PAD_SRC, GST_PAD_ALWAYS,
124 GST_STATIC_CAPS_ANY);
125 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
127 gst_element_class_add_static_pad_template (element_class, &src_templ);
128 gst_element_class_set_details_simple (element_class,
129 "CapsSource", "Source/Generic", "yep", "me");
133 gst_caps_src_finalize (GObject * object)
135 GstCapsSrc *src = (GstCapsSrc *) object;
138 gst_caps_unref (src->caps);
142 G_OBJECT_CLASS (parent_class)->finalize (object);
146 gst_caps_src_create (GstPushSrc * psrc, GstBuffer ** p_buf)
148 GstCapsSrc *src = (GstCapsSrc *) psrc;
151 if (src->nbuffers >= NBUFFERS) {
152 return GST_FLOW_UNEXPECTED;
157 return GST_FLOW_ERROR;
160 src->caps = gst_caps_from_string (src->uri + sizeof ("caps"));
162 return GST_FLOW_ERROR;
166 buf = gst_buffer_new ();
167 gst_buffer_set_caps (buf, src->caps);
168 GST_BUFFER_TIMESTAMP (buf) =
169 gst_util_uint64_scale (src->nbuffers, GST_SECOND, 25);
177 gst_caps_src_class_init (GstCapsSrcClass * klass)
179 GObjectClass *gobject_class = (GObjectClass *) klass;
180 GstPushSrcClass *pushsrc_class = (GstPushSrcClass *) klass;
182 gobject_class->finalize = gst_caps_src_finalize;
183 pushsrc_class->create = gst_caps_src_create;
187 gst_caps_src_init (GstCapsSrc * src, GstCapsSrcClass * klass)
189 gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
193 #define parent_class codec_sink_parent_class
195 typedef struct _GstCodecSink GstCodecSink;
196 typedef GstBaseSinkClass GstCodecSinkClass;
204 gint n_raw, n_compressed;
207 GST_BOILERPLATE (GstCodecSink, gst_codec_sink, GstBaseSink, GST_TYPE_BASE_SINK);
210 gst_codec_sink_base_init (gpointer klass)
215 gst_codec_sink_start (GstBaseSink * bsink)
217 GstCodecSink *sink = (GstCodecSink *) bsink;
220 sink->n_compressed = 0;
226 gst_codec_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
228 GstCodecSink *sink = (GstCodecSink *) bsink;
233 sink->n_compressed++;
239 gst_codec_sink_class_init (GstCodecSinkClass * klass)
241 GstBaseSinkClass *basesink_class = (GstBaseSinkClass *) klass;
243 basesink_class->start = gst_codec_sink_start;
244 basesink_class->render = gst_codec_sink_render;
248 gst_codec_sink_init (GstCodecSink * sink, GstCodecSinkClass * klass)
253 #define parent_class audio_codec_sink_parent_class
255 typedef GstCodecSink GstAudioCodecSink;
256 typedef GstCodecSinkClass GstAudioCodecSinkClass;
259 gst_audio_codec_sink_init_type (GType type)
261 static const GInterfaceInfo svol_iface_info = {
265 g_type_add_interface_static (type, GST_TYPE_STREAM_VOLUME, &svol_iface_info);
268 GST_BOILERPLATE_FULL (GstAudioCodecSink, gst_audio_codec_sink, GstBaseSink,
269 gst_codec_sink_get_type (), gst_audio_codec_sink_init_type);
272 gst_audio_codec_sink_base_init (gpointer klass)
274 static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
275 GST_PAD_SINK, GST_PAD_ALWAYS,
276 GST_STATIC_CAPS ("audio/x-raw-int; audio/x-compressed")
278 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
280 gst_element_class_add_static_pad_template (element_class, &sink_templ);
281 gst_element_class_set_details_simple (element_class,
282 "AudioCodecSink", "Sink/Audio", "yep", "me");
286 gst_audio_codec_sink_set_property (GObject * object,
287 guint prop_id, const GValue * value, GParamSpec * pspec)
294 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
300 gst_audio_codec_sink_get_property (GObject * object,
301 guint prop_id, GValue * value, GParamSpec * pspec)
306 g_value_set_double (value, 1.0);
309 g_value_set_boolean (value, FALSE);
312 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
318 gst_audio_codec_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
320 GstAudioCodecSink *sink = (GstAudioCodecSink *) bsink;
323 s = gst_caps_get_structure (caps, 0);
325 if (gst_structure_has_name (s, "audio/x-raw-int")) {
327 } else if (gst_structure_has_name (s, "audio/x-compressed")) {
330 fail_unless (gst_structure_has_name (s, "audio/x-raw-int")
331 || gst_structure_has_name (s, "audio/x-compressed"));
339 gst_audio_codec_sink_class_init (GstAudioCodecSinkClass * klass)
341 GObjectClass *gobject_class = (GObjectClass *) klass;
342 GstBaseSinkClass *basesink_class = (GstBaseSinkClass *) klass;
344 gobject_class->set_property = gst_audio_codec_sink_set_property;
345 gobject_class->get_property = gst_audio_codec_sink_get_property;
347 g_object_class_install_property (gobject_class,
349 g_param_spec_double ("volume", "Volume",
350 "Linear volume of this stream, 1.0=100%", 0.0, 10.0,
351 1.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
352 g_object_class_install_property (gobject_class,
354 g_param_spec_boolean ("mute", "Mute",
355 "Mute", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
357 basesink_class->set_caps = gst_audio_codec_sink_set_caps;
361 gst_audio_codec_sink_init (GstAudioCodecSink * sink,
362 GstAudioCodecSinkClass * klass)
368 #define parent_class video_codec_sink_parent_class
370 typedef GstCodecSink GstVideoCodecSink;
371 typedef GstCodecSinkClass GstVideoCodecSinkClass;
373 GST_BOILERPLATE (GstVideoCodecSink, gst_video_codec_sink, GstBaseSink,
374 gst_codec_sink_get_type ());
377 gst_video_codec_sink_base_init (gpointer klass)
379 static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
380 GST_PAD_SINK, GST_PAD_ALWAYS,
381 GST_STATIC_CAPS ("video/x-raw-yuv; video/x-compressed")
383 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
385 gst_element_class_add_static_pad_template (element_class, &sink_templ);
386 gst_element_class_set_details_simple (element_class,
387 "VideoCodecSink", "Sink/Video", "yep", "me");
391 gst_video_codec_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
393 GstVideoCodecSink *sink = (GstVideoCodecSink *) bsink;
396 s = gst_caps_get_structure (caps, 0);
398 if (gst_structure_has_name (s, "video/x-raw-yuv")) {
400 } else if (gst_structure_has_name (s, "video/x-compressed")) {
403 fail_unless (gst_structure_has_name (s, "video/x-raw-yuv")
404 || gst_structure_has_name (s, "video/x-compressed"));
412 gst_video_codec_sink_class_init (GstVideoCodecSinkClass * klass)
414 GstBaseSinkClass *basesink_class = (GstBaseSinkClass *) klass;
416 basesink_class->set_caps = gst_video_codec_sink_set_caps;
420 gst_video_codec_sink_init (GstVideoCodecSink * sink,
421 GstVideoCodecSinkClass * klass)
427 #define parent_class codec_demuxer_parent_class
428 typedef struct _GstCodecDemuxer GstCodecDemuxer;
429 typedef GstElementClass GstCodecDemuxerClass;
431 struct _GstCodecDemuxer
436 GstPad *srcpad0, *srcpad1;
438 GstEvent *newseg_event;
441 GST_BOILERPLATE (GstCodecDemuxer, gst_codec_demuxer, GstElement,
444 #define STREAM_TYPES "{ " \
447 "compressed-audio, " \
449 "compressed-video " \
453 gst_codec_demuxer_base_init (gpointer klass)
455 static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
456 GST_PAD_SINK, GST_PAD_ALWAYS,
457 GST_STATIC_CAPS ("application/x-container,"
458 " stream0 = (string)" STREAM_TYPES " ,"
459 " stream1 = (string)" STREAM_TYPES)
461 static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src_%d",
462 GST_PAD_SRC, GST_PAD_SOMETIMES,
463 GST_STATIC_CAPS ("audio/x-raw-int; audio/x-compressed; "
464 "video/x-raw-yuv; video/x-compressed")
466 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
468 gst_element_class_add_static_pad_template (element_class, &sink_templ);
469 gst_element_class_add_static_pad_template (element_class, &src_templ);
470 gst_element_class_set_details_simple (element_class,
471 "CodecDemuxer", "Codec/Demuxer", "yep", "me");
475 gst_codec_demuxer_finalize (GObject * object)
477 GstCodecDemuxer *demux = (GstCodecDemuxer *) object;
479 if (demux->newseg_event)
480 gst_event_unref (demux->newseg_event);
481 demux->newseg_event = NULL;
483 G_OBJECT_CLASS (parent_class)->finalize (object);
487 gst_codec_demuxer_class_init (GstCodecDemuxerClass * klass)
489 GObjectClass *gobject_class = (GObjectClass *) klass;
491 gobject_class->finalize = gst_codec_demuxer_finalize;
495 gst_codec_demuxer_chain (GstPad * pad, GstBuffer * buf)
497 GstCodecDemuxer *demux = (GstCodecDemuxer *) GST_PAD_PARENT (pad);
498 GstFlowReturn ret0 = GST_FLOW_OK, ret1 = GST_FLOW_OK;
500 if (demux->srcpad0) {
501 GstBuffer *outbuf = gst_buffer_new ();
503 GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
504 gst_buffer_set_caps (outbuf, GST_PAD_CAPS (demux->srcpad0));
505 ret0 = gst_pad_push (demux->srcpad0, outbuf);
507 if (demux->srcpad1) {
508 GstBuffer *outbuf = gst_buffer_new ();
510 GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
511 gst_buffer_set_caps (outbuf, GST_PAD_CAPS (demux->srcpad1));
512 ret1 = gst_pad_push (demux->srcpad1, outbuf);
514 gst_buffer_unref (buf);
516 if (ret0 == GST_FLOW_NOT_LINKED && ret1 == GST_FLOW_NOT_LINKED)
517 return GST_FLOW_NOT_LINKED;
518 if (ret0 == GST_FLOW_OK && ret1 == GST_FLOW_OK)
521 return MIN (ret0, ret1);
525 gst_codec_demuxer_event (GstPad * pad, GstEvent * event)
527 GstCodecDemuxer *demux = (GstCodecDemuxer *) gst_pad_get_parent (pad);
530 /* The single newsegment event is pushed when the pads are created */
531 if (GST_EVENT_TYPE (event) != GST_EVENT_NEWSEGMENT) {
533 ret = ret && gst_pad_push_event (demux->srcpad0, gst_event_ref (event));
535 ret = ret && gst_pad_push_event (demux->srcpad1, gst_event_ref (event));
537 gst_event_replace (&demux->newseg_event, event);
540 gst_event_unref (event);
542 gst_object_unref (demux);
547 gst_codec_demuxer_setup_pad (GstCodecDemuxer * demux, GstPad ** pad,
548 const gchar * streaminfo)
550 if (g_str_equal (streaminfo, "none")) {
552 gst_pad_set_active (*pad, FALSE);
553 gst_element_remove_pad (GST_ELEMENT (demux), *pad);
560 GstPadTemplate *templ;
563 gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (demux),
565 if (pad == &demux->srcpad0)
566 *pad = gst_pad_new_from_template (templ, "src_0");
568 *pad = gst_pad_new_from_template (templ, "src_1");
569 gst_pad_set_active (*pad, TRUE);
570 gst_pad_use_fixed_caps (*pad);
571 gst_element_add_pad (GST_ELEMENT (demux), *pad);
574 if (g_str_equal (streaminfo, "raw-video")) {
575 caps = gst_caps_new_simple ("video/x-raw-yuv",
576 "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
577 "width", G_TYPE_INT, 320,
578 "height", G_TYPE_INT, 240,
579 "framerate", GST_TYPE_FRACTION, 25, 1,
580 "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
581 } else if (g_str_equal (streaminfo, "compressed-video")) {
582 caps = gst_caps_new_simple ("video/x-compressed", NULL);
583 } else if (g_str_equal (streaminfo, "raw-audio")) {
584 caps = gst_caps_new_simple ("audio/x-raw-int",
585 "rate", G_TYPE_INT, 48000,
586 "channels", G_TYPE_INT, 2,
587 "endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
588 "width", G_TYPE_INT, 16,
589 "depth", G_TYPE_INT, 16, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
591 caps = gst_caps_new_simple ("audio/x-compressed", NULL);
593 gst_pad_set_caps (*pad, caps);
594 gst_caps_unref (caps);
596 if (demux->newseg_event)
597 gst_pad_push_event (*pad, gst_event_ref (demux->newseg_event));
602 gst_codec_demuxer_setcaps (GstPad * pad, GstCaps * caps)
604 GstCodecDemuxer *demux = (GstCodecDemuxer *) gst_pad_get_parent (pad);
606 const gchar *streaminfo;
608 s = gst_caps_get_structure (caps, 0);
610 streaminfo = gst_structure_get_string (s, "stream0");
611 gst_codec_demuxer_setup_pad (demux, &demux->srcpad0, streaminfo);
613 streaminfo = gst_structure_get_string (s, "stream1");
614 gst_codec_demuxer_setup_pad (demux, &demux->srcpad1, streaminfo);
616 gst_object_unref (demux);
621 gst_codec_demuxer_init (GstCodecDemuxer * demux, GstCodecDemuxerClass * klass)
623 GstPadTemplate *templ;
625 templ = gst_element_class_get_pad_template (klass, "sink");
626 demux->sinkpad = gst_pad_new_from_template (templ, "sink");
627 gst_pad_set_setcaps_function (demux->sinkpad,
628 GST_DEBUG_FUNCPTR (gst_codec_demuxer_setcaps));
629 gst_pad_set_chain_function (demux->sinkpad,
630 GST_DEBUG_FUNCPTR (gst_codec_demuxer_chain));
631 gst_pad_set_event_function (demux->sinkpad,
632 GST_DEBUG_FUNCPTR (gst_codec_demuxer_event));
633 gst_element_add_pad (GST_ELEMENT (demux), demux->sinkpad);
641 create_playbin (const gchar * uri, gboolean set_sink)
643 GstElement *playbin, *sink;
645 playbin = gst_element_factory_make ("playbin2", "playbin2");
646 fail_unless (playbin != NULL, "Failed to create playbin element");
649 sink = gst_element_factory_make ("videocodecsink", NULL);
650 fail_unless (sink != NULL, "Failed to create videocodecsink element");
652 /* Set sync to FALSE to prevent buffers from being dropped because
653 * they're too late */
654 g_object_set (sink, "sync", FALSE, NULL);
656 g_object_set (playbin, "video-sink", sink, NULL);
658 sink = gst_element_factory_make ("audiocodecsink", NULL);
659 fail_unless (sink != NULL, "Failed to create audiocodecsink");
661 /* Set sync to FALSE to prevent buffers from being dropped because
662 * they're too late */
663 g_object_set (sink, "sync", FALSE, NULL);
665 g_object_set (playbin, "audio-sink", sink, NULL);
668 g_object_set (playbin, "uri", uri, NULL);
673 GST_START_TEST (test_raw_single_video_stream_manual_sink)
679 gboolean done = FALSE;
681 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
682 gst_caps_src_get_type ()));
683 fail_unless (gst_element_register (NULL, "audiocodecsink",
684 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
685 fail_unless (gst_element_register (NULL, "videocodecsink",
686 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
690 ("caps:video/x-raw-yuv, "
691 "format=(fourcc)I420, "
694 "framerate=(fraction)0/1, " "pixel-aspect-ratio=(fraction)1/1", TRUE);
696 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
697 GST_STATE_CHANGE_SUCCESS);
698 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
699 GST_STATE_CHANGE_ASYNC);
701 bus = gst_element_get_bus (playbin);
704 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
706 switch (GST_MESSAGE_TYPE (msg)) {
707 case GST_MESSAGE_EOS:
710 case GST_MESSAGE_ERROR:
711 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
713 case GST_MESSAGE_WARNING:
714 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
719 gst_message_unref (msg);
721 gst_object_unref (bus);
723 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
724 fail_unless (sink != NULL);
726 GstVideoCodecSink *csink;
728 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
729 gst_video_codec_sink_get_type ());
730 csink = (GstVideoCodecSink *) sink;
731 fail_unless (csink->audio == FALSE);
732 fail_unless (csink->raw == TRUE);
733 fail_unless_equals_int (csink->n_raw, NBUFFERS);
734 fail_unless_equals_int (csink->n_compressed, 0);
735 gst_object_unref (sink);
738 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
739 fail_unless (sink != NULL);
741 GstAudioCodecSink *csink;
743 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
744 gst_audio_codec_sink_get_type ());
745 csink = (GstAudioCodecSink *) sink;
746 fail_unless (csink->audio == TRUE);
747 fail_unless (csink->raw == FALSE);
748 fail_unless_equals_int (csink->n_raw, 0);
749 fail_unless_equals_int (csink->n_compressed, 0);
750 gst_object_unref (sink);
753 gst_element_set_state (playbin, GST_STATE_NULL);
754 gst_object_unref (playbin);
759 GST_START_TEST (test_compressed_single_video_stream_manual_sink)
765 gboolean done = FALSE;
767 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
768 gst_caps_src_get_type ()));
769 fail_unless (gst_element_register (NULL, "audiocodecsink",
770 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
771 fail_unless (gst_element_register (NULL, "videocodecsink",
772 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
774 playbin = create_playbin ("caps:video/x-compressed", TRUE);
776 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
777 GST_STATE_CHANGE_SUCCESS);
778 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
779 GST_STATE_CHANGE_ASYNC);
781 bus = gst_element_get_bus (playbin);
784 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
786 switch (GST_MESSAGE_TYPE (msg)) {
787 case GST_MESSAGE_EOS:
790 case GST_MESSAGE_ERROR:
791 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
793 case GST_MESSAGE_WARNING:
794 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
799 gst_message_unref (msg);
801 gst_object_unref (bus);
803 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
804 fail_unless (sink != NULL);
806 GstVideoCodecSink *csink;
808 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
809 gst_video_codec_sink_get_type ());
810 csink = (GstVideoCodecSink *) sink;
811 fail_unless (csink->audio == FALSE);
812 fail_unless (csink->raw == FALSE);
813 fail_unless_equals_int (csink->n_raw, 0);
814 fail_unless_equals_int (csink->n_compressed, NBUFFERS);
815 gst_object_unref (sink);
818 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
819 fail_unless (sink != NULL);
821 GstAudioCodecSink *csink;
823 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
824 gst_audio_codec_sink_get_type ());
825 csink = (GstAudioCodecSink *) sink;
826 fail_unless (csink->audio == TRUE);
827 fail_unless (csink->raw == FALSE);
828 fail_unless_equals_int (csink->n_raw, 0);
829 fail_unless_equals_int (csink->n_compressed, 0);
830 gst_object_unref (sink);
833 gst_element_set_state (playbin, GST_STATE_NULL);
834 gst_object_unref (playbin);
839 GST_START_TEST (test_raw_single_video_stream_demuxer_manual_sink)
845 gboolean done = FALSE;
847 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
848 gst_caps_src_get_type ()));
849 fail_unless (gst_element_register (NULL, "codecdemuxer",
850 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
851 fail_unless (gst_element_register (NULL, "audiocodecsink",
852 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
853 fail_unless (gst_element_register (NULL, "videocodecsink",
854 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
856 playbin = create_playbin ("caps:application/x-container, "
857 "stream0=(string)raw-video, " "stream1=(string)none", TRUE);
859 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
860 GST_STATE_CHANGE_SUCCESS);
861 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
862 GST_STATE_CHANGE_ASYNC);
864 bus = gst_element_get_bus (playbin);
867 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
869 switch (GST_MESSAGE_TYPE (msg)) {
870 case GST_MESSAGE_EOS:
873 case GST_MESSAGE_ERROR:
874 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
876 case GST_MESSAGE_WARNING:
877 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
882 gst_message_unref (msg);
884 gst_object_unref (bus);
886 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
887 fail_unless (sink != NULL);
889 GstVideoCodecSink *csink;
891 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
892 gst_video_codec_sink_get_type ());
893 csink = (GstVideoCodecSink *) sink;
894 fail_unless (csink->audio == FALSE);
895 fail_unless (csink->raw == TRUE);
896 fail_unless_equals_int (csink->n_raw, NBUFFERS);
897 fail_unless_equals_int (csink->n_compressed, 0);
898 gst_object_unref (sink);
901 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
902 fail_unless (sink != NULL);
904 GstAudioCodecSink *csink;
906 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
907 gst_audio_codec_sink_get_type ());
908 csink = (GstAudioCodecSink *) sink;
909 fail_unless (csink->audio == TRUE);
910 fail_unless (csink->raw == FALSE);
911 fail_unless_equals_int (csink->n_raw, 0);
912 fail_unless_equals_int (csink->n_compressed, 0);
913 gst_object_unref (sink);
916 gst_element_set_state (playbin, GST_STATE_NULL);
917 gst_object_unref (playbin);
922 GST_START_TEST (test_compressed_single_video_stream_demuxer_manual_sink)
928 gboolean done = FALSE;
930 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
931 gst_caps_src_get_type ()));
932 fail_unless (gst_element_register (NULL, "codecdemuxer",
933 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
934 fail_unless (gst_element_register (NULL, "audiocodecsink",
935 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
936 fail_unless (gst_element_register (NULL, "videocodecsink",
937 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
939 playbin = create_playbin ("caps:application/x-container, "
940 "stream0=(string)compressed-video, " "stream1=(string)none", TRUE);
942 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
943 GST_STATE_CHANGE_SUCCESS);
944 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
945 GST_STATE_CHANGE_ASYNC);
947 bus = gst_element_get_bus (playbin);
950 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
952 switch (GST_MESSAGE_TYPE (msg)) {
953 case GST_MESSAGE_EOS:
956 case GST_MESSAGE_ERROR:
957 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
959 case GST_MESSAGE_WARNING:
960 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
965 gst_message_unref (msg);
967 gst_object_unref (bus);
969 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
970 fail_unless (sink != NULL);
972 GstVideoCodecSink *csink;
974 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
975 gst_video_codec_sink_get_type ());
976 csink = (GstVideoCodecSink *) sink;
977 fail_unless (csink->audio == FALSE);
978 fail_unless (csink->raw == FALSE);
979 fail_unless_equals_int (csink->n_raw, 0);
980 fail_unless_equals_int (csink->n_compressed, NBUFFERS);
981 gst_object_unref (sink);
984 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
985 fail_unless (sink != NULL);
987 GstAudioCodecSink *csink;
989 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
990 gst_audio_codec_sink_get_type ());
991 csink = (GstAudioCodecSink *) sink;
992 fail_unless (csink->audio == TRUE);
993 fail_unless (csink->raw == FALSE);
994 fail_unless_equals_int (csink->n_raw, 0);
995 fail_unless_equals_int (csink->n_compressed, 0);
996 gst_object_unref (sink);
999 gst_element_set_state (playbin, GST_STATE_NULL);
1000 gst_object_unref (playbin);
1005 GST_START_TEST (test_raw_single_audio_stream_manual_sink)
1008 GstElement *playbin;
1011 gboolean done = FALSE;
1013 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
1014 gst_caps_src_get_type ()));
1015 fail_unless (gst_element_register (NULL, "audiocodecsink",
1016 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
1017 fail_unless (gst_element_register (NULL, "videocodecsink",
1018 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
1022 ("caps:audio/x-raw-int,"
1023 " rate=(int)48000, "
1024 " channels=(int)2, "
1025 " endianness=(int)LITTLE_ENDIAN, "
1026 " width=(int)16, " " depth=(int)16, " " signed=(bool)TRUE", TRUE);
1028 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
1029 GST_STATE_CHANGE_SUCCESS);
1030 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
1031 GST_STATE_CHANGE_ASYNC);
1033 bus = gst_element_get_bus (playbin);
1036 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
1038 switch (GST_MESSAGE_TYPE (msg)) {
1039 case GST_MESSAGE_EOS:
1042 case GST_MESSAGE_ERROR:
1043 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
1045 case GST_MESSAGE_WARNING:
1046 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
1051 gst_message_unref (msg);
1053 gst_object_unref (bus);
1055 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1056 fail_unless (sink != NULL);
1058 GstVideoCodecSink *csink;
1060 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1061 gst_video_codec_sink_get_type ());
1062 csink = (GstVideoCodecSink *) sink;
1063 fail_unless (csink->audio == FALSE);
1064 fail_unless (csink->raw == FALSE);
1065 fail_unless_equals_int (csink->n_raw, 0);
1066 fail_unless_equals_int (csink->n_compressed, 0);
1067 gst_object_unref (sink);
1070 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
1071 fail_unless (sink != NULL);
1073 GstAudioCodecSink *csink;
1075 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1076 gst_audio_codec_sink_get_type ());
1077 csink = (GstAudioCodecSink *) sink;
1078 fail_unless (csink->audio == TRUE);
1079 fail_unless (csink->raw == TRUE);
1080 fail_unless_equals_int (csink->n_raw, NBUFFERS);
1081 fail_unless_equals_int (csink->n_compressed, 0);
1082 gst_object_unref (sink);
1085 gst_element_set_state (playbin, GST_STATE_NULL);
1086 gst_object_unref (playbin);
1091 GST_START_TEST (test_compressed_single_audio_stream_manual_sink)
1094 GstElement *playbin;
1097 gboolean done = FALSE;
1099 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
1100 gst_caps_src_get_type ()));
1101 fail_unless (gst_element_register (NULL, "audiocodecsink",
1102 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
1103 fail_unless (gst_element_register (NULL, "videocodecsink",
1104 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
1106 playbin = create_playbin ("caps:audio/x-compressed", TRUE);
1108 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
1109 GST_STATE_CHANGE_SUCCESS);
1110 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
1111 GST_STATE_CHANGE_ASYNC);
1113 bus = gst_element_get_bus (playbin);
1116 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
1118 switch (GST_MESSAGE_TYPE (msg)) {
1119 case GST_MESSAGE_EOS:
1122 case GST_MESSAGE_ERROR:
1123 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
1125 case GST_MESSAGE_WARNING:
1126 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
1131 gst_message_unref (msg);
1133 gst_object_unref (bus);
1135 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1136 fail_unless (sink != NULL);
1138 GstVideoCodecSink *csink;
1140 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1141 gst_video_codec_sink_get_type ());
1142 csink = (GstVideoCodecSink *) sink;
1143 fail_unless (csink->audio == FALSE);
1144 fail_unless (csink->raw == FALSE);
1145 fail_unless_equals_int (csink->n_raw, 0);
1146 fail_unless_equals_int (csink->n_compressed, 0);
1147 gst_object_unref (sink);
1150 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
1151 fail_unless (sink != NULL);
1153 GstAudioCodecSink *csink;
1155 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1156 gst_audio_codec_sink_get_type ());
1157 csink = (GstAudioCodecSink *) sink;
1158 fail_unless (csink->audio == TRUE);
1159 fail_unless (csink->raw == FALSE);
1160 fail_unless_equals_int (csink->n_raw, 0);
1161 fail_unless_equals_int (csink->n_compressed, NBUFFERS);
1162 gst_object_unref (sink);
1165 gst_element_set_state (playbin, GST_STATE_NULL);
1166 gst_object_unref (playbin);
1171 GST_START_TEST (test_raw_single_audio_stream_demuxer_manual_sink)
1174 GstElement *playbin;
1177 gboolean done = FALSE;
1179 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
1180 gst_caps_src_get_type ()));
1181 fail_unless (gst_element_register (NULL, "codecdemuxer",
1182 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
1183 fail_unless (gst_element_register (NULL, "audiocodecsink",
1184 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
1185 fail_unless (gst_element_register (NULL, "videocodecsink",
1186 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
1188 playbin = create_playbin ("caps:application/x-container, "
1189 "stream0=(string)raw-audio, " "stream1=(string)none", TRUE);
1191 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
1192 GST_STATE_CHANGE_SUCCESS);
1193 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
1194 GST_STATE_CHANGE_ASYNC);
1196 bus = gst_element_get_bus (playbin);
1199 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
1201 switch (GST_MESSAGE_TYPE (msg)) {
1202 case GST_MESSAGE_EOS:
1205 case GST_MESSAGE_ERROR:
1206 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
1208 case GST_MESSAGE_WARNING:
1209 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
1214 gst_message_unref (msg);
1216 gst_object_unref (bus);
1218 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1219 fail_unless (sink != NULL);
1221 GstVideoCodecSink *csink;
1223 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1224 gst_video_codec_sink_get_type ());
1225 csink = (GstVideoCodecSink *) sink;
1226 fail_unless (csink->audio == FALSE);
1227 fail_unless (csink->raw == FALSE);
1228 fail_unless_equals_int (csink->n_raw, 0);
1229 fail_unless_equals_int (csink->n_compressed, 0);
1230 gst_object_unref (sink);
1233 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
1234 fail_unless (sink != NULL);
1236 GstAudioCodecSink *csink;
1238 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1239 gst_audio_codec_sink_get_type ());
1240 csink = (GstAudioCodecSink *) sink;
1241 fail_unless (csink->audio == TRUE);
1242 fail_unless (csink->raw == TRUE);
1243 fail_unless_equals_int (csink->n_raw, NBUFFERS);
1244 fail_unless_equals_int (csink->n_compressed, 0);
1245 gst_object_unref (sink);
1248 gst_element_set_state (playbin, GST_STATE_NULL);
1249 gst_object_unref (playbin);
1254 GST_START_TEST (test_compressed_single_audio_stream_demuxer_manual_sink)
1257 GstElement *playbin;
1260 gboolean done = FALSE;
1262 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
1263 gst_caps_src_get_type ()));
1264 fail_unless (gst_element_register (NULL, "codecdemuxer",
1265 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
1266 fail_unless (gst_element_register (NULL, "audiocodecsink",
1267 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
1268 fail_unless (gst_element_register (NULL, "videocodecsink",
1269 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
1271 playbin = create_playbin ("caps:application/x-container, "
1272 "stream0=(string)compressed-audio, " "stream1=(string)none", TRUE);
1274 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
1275 GST_STATE_CHANGE_SUCCESS);
1276 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
1277 GST_STATE_CHANGE_ASYNC);
1279 bus = gst_element_get_bus (playbin);
1282 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
1284 switch (GST_MESSAGE_TYPE (msg)) {
1285 case GST_MESSAGE_EOS:
1288 case GST_MESSAGE_ERROR:
1289 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
1291 case GST_MESSAGE_WARNING:
1292 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
1297 gst_message_unref (msg);
1299 gst_object_unref (bus);
1301 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1302 fail_unless (sink != NULL);
1304 GstVideoCodecSink *csink;
1306 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1307 gst_video_codec_sink_get_type ());
1308 csink = (GstVideoCodecSink *) sink;
1309 fail_unless (csink->audio == FALSE);
1310 fail_unless (csink->raw == FALSE);
1311 fail_unless_equals_int (csink->n_raw, 0);
1312 fail_unless_equals_int (csink->n_compressed, 0);
1313 gst_object_unref (sink);
1316 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
1317 fail_unless (sink != NULL);
1319 GstAudioCodecSink *csink;
1321 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1322 gst_audio_codec_sink_get_type ());
1323 csink = (GstAudioCodecSink *) sink;
1324 fail_unless (csink->audio == TRUE);
1325 fail_unless (csink->raw == FALSE);
1326 fail_unless_equals_int (csink->n_raw, 0);
1327 fail_unless_equals_int (csink->n_compressed, NBUFFERS);
1328 gst_object_unref (sink);
1331 gst_element_set_state (playbin, GST_STATE_NULL);
1332 gst_object_unref (playbin);
1337 GST_START_TEST (test_raw_audio_video_stream_demuxer_manual_sink)
1340 GstElement *playbin;
1343 gboolean done = FALSE;
1345 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
1346 gst_caps_src_get_type ()));
1347 fail_unless (gst_element_register (NULL, "codecdemuxer",
1348 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
1349 fail_unless (gst_element_register (NULL, "audiocodecsink",
1350 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
1351 fail_unless (gst_element_register (NULL, "videocodecsink",
1352 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
1354 playbin = create_playbin ("caps:application/x-container, "
1355 "stream0=(string)raw-audio, " "stream1=(string)raw-video", TRUE);
1357 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
1358 GST_STATE_CHANGE_SUCCESS);
1359 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
1360 GST_STATE_CHANGE_ASYNC);
1362 bus = gst_element_get_bus (playbin);
1365 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
1367 switch (GST_MESSAGE_TYPE (msg)) {
1368 case GST_MESSAGE_EOS:
1371 case GST_MESSAGE_ERROR:
1372 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
1374 case GST_MESSAGE_WARNING:
1375 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
1380 gst_message_unref (msg);
1382 gst_object_unref (bus);
1384 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1385 fail_unless (sink != NULL);
1387 GstVideoCodecSink *csink;
1389 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1390 gst_video_codec_sink_get_type ());
1391 csink = (GstVideoCodecSink *) sink;
1392 fail_unless (csink->audio == FALSE);
1393 fail_unless (csink->raw == TRUE);
1394 fail_unless_equals_int (csink->n_raw, NBUFFERS);
1395 fail_unless_equals_int (csink->n_compressed, 0);
1396 gst_object_unref (sink);
1399 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
1400 fail_unless (sink != NULL);
1402 GstAudioCodecSink *csink;
1404 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1405 gst_audio_codec_sink_get_type ());
1406 csink = (GstAudioCodecSink *) sink;
1407 fail_unless (csink->audio == TRUE);
1408 fail_unless (csink->raw == TRUE);
1409 fail_unless_equals_int (csink->n_raw, NBUFFERS);
1410 fail_unless_equals_int (csink->n_compressed, 0);
1411 gst_object_unref (sink);
1414 gst_element_set_state (playbin, GST_STATE_NULL);
1415 gst_object_unref (playbin);
1420 GST_START_TEST (test_compressed_audio_video_stream_demuxer_manual_sink)
1423 GstElement *playbin;
1426 gboolean done = FALSE;
1428 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
1429 gst_caps_src_get_type ()));
1430 fail_unless (gst_element_register (NULL, "codecdemuxer",
1431 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
1432 fail_unless (gst_element_register (NULL, "audiocodecsink",
1433 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
1434 fail_unless (gst_element_register (NULL, "videocodecsink",
1435 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
1437 playbin = create_playbin ("caps:application/x-container, "
1438 "stream0=(string)compressed-audio, " "stream1=(string)compressed-video",
1441 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
1442 GST_STATE_CHANGE_SUCCESS);
1443 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
1444 GST_STATE_CHANGE_ASYNC);
1446 bus = gst_element_get_bus (playbin);
1449 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
1451 switch (GST_MESSAGE_TYPE (msg)) {
1452 case GST_MESSAGE_EOS:
1455 case GST_MESSAGE_ERROR:
1456 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
1458 case GST_MESSAGE_WARNING:
1459 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
1464 gst_message_unref (msg);
1466 gst_object_unref (bus);
1468 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1469 fail_unless (sink != NULL);
1471 GstVideoCodecSink *csink;
1473 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1474 gst_video_codec_sink_get_type ());
1475 csink = (GstVideoCodecSink *) sink;
1476 fail_unless (csink->audio == FALSE);
1477 fail_unless (csink->raw == FALSE);
1478 fail_unless_equals_int (csink->n_raw, 0);
1479 fail_unless_equals_int (csink->n_compressed, NBUFFERS);
1480 gst_object_unref (sink);
1483 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
1484 fail_unless (sink != NULL);
1486 GstAudioCodecSink *csink;
1488 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1489 gst_audio_codec_sink_get_type ());
1490 csink = (GstAudioCodecSink *) sink;
1491 fail_unless (csink->audio == TRUE);
1492 fail_unless (csink->raw == FALSE);
1493 fail_unless_equals_int (csink->n_raw, 0);
1494 fail_unless_equals_int (csink->n_compressed, NBUFFERS);
1495 gst_object_unref (sink);
1498 gst_element_set_state (playbin, GST_STATE_NULL);
1499 gst_object_unref (playbin);
1504 GST_START_TEST (test_raw_compressed_video_stream_demuxer_manual_sink)
1507 GstElement *playbin;
1510 gboolean done = FALSE;
1512 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
1513 gst_caps_src_get_type ()));
1514 fail_unless (gst_element_register (NULL, "codecdemuxer",
1515 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
1516 fail_unless (gst_element_register (NULL, "audiocodecsink",
1517 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
1518 fail_unless (gst_element_register (NULL, "videocodecsink",
1519 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
1521 playbin = create_playbin ("caps:application/x-container, "
1522 "stream0=(string)raw-video, " "stream1=(string)compressed-video", TRUE);
1524 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
1525 GST_STATE_CHANGE_SUCCESS);
1526 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
1527 GST_STATE_CHANGE_ASYNC);
1529 bus = gst_element_get_bus (playbin);
1532 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
1534 switch (GST_MESSAGE_TYPE (msg)) {
1535 case GST_MESSAGE_EOS:
1538 case GST_MESSAGE_ERROR:
1539 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
1541 case GST_MESSAGE_WARNING:
1542 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
1547 gst_message_unref (msg);
1549 gst_object_unref (bus);
1551 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1552 fail_unless (sink != NULL);
1554 GstVideoCodecSink *csink;
1556 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1557 gst_video_codec_sink_get_type ());
1558 csink = (GstVideoCodecSink *) sink;
1559 fail_unless (csink->audio == FALSE);
1560 fail_unless_equals_int (csink->n_raw + csink->n_compressed, NBUFFERS);
1561 gst_object_unref (sink);
1564 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
1565 fail_unless (sink != NULL);
1567 GstAudioCodecSink *csink;
1569 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1570 gst_audio_codec_sink_get_type ());
1571 csink = (GstAudioCodecSink *) sink;
1572 fail_unless (csink->audio == TRUE);
1573 fail_unless_equals_int (csink->n_raw, 0);
1574 fail_unless_equals_int (csink->n_compressed, 0);
1575 gst_object_unref (sink);
1578 gst_element_set_state (playbin, GST_STATE_NULL);
1579 gst_object_unref (playbin);
1584 GST_START_TEST (test_raw_compressed_audio_stream_demuxer_manual_sink)
1587 GstElement *playbin;
1590 gboolean done = FALSE;
1592 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
1593 gst_caps_src_get_type ()));
1594 fail_unless (gst_element_register (NULL, "codecdemuxer",
1595 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
1596 fail_unless (gst_element_register (NULL, "audiocodecsink",
1597 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
1598 fail_unless (gst_element_register (NULL, "videocodecsink",
1599 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
1601 playbin = create_playbin ("caps:application/x-container, "
1602 "stream0=(string)raw-audio, " "stream1=(string)compressed-audio", TRUE);
1604 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
1605 GST_STATE_CHANGE_SUCCESS);
1606 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
1607 GST_STATE_CHANGE_ASYNC);
1609 bus = gst_element_get_bus (playbin);
1612 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
1614 switch (GST_MESSAGE_TYPE (msg)) {
1615 case GST_MESSAGE_EOS:
1618 case GST_MESSAGE_ERROR:
1619 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
1621 case GST_MESSAGE_WARNING:
1622 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
1627 gst_message_unref (msg);
1629 gst_object_unref (bus);
1631 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1632 fail_unless (sink != NULL);
1634 GstVideoCodecSink *csink;
1636 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1637 gst_video_codec_sink_get_type ());
1638 csink = (GstVideoCodecSink *) sink;
1639 fail_unless (csink->audio == FALSE);
1640 fail_unless_equals_int (csink->n_raw, 0);
1641 fail_unless_equals_int (csink->n_compressed, 0);
1642 gst_object_unref (sink);
1645 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
1646 fail_unless (sink != NULL);
1648 GstAudioCodecSink *csink;
1650 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1651 gst_audio_codec_sink_get_type ());
1652 csink = (GstAudioCodecSink *) sink;
1653 fail_unless (csink->audio == TRUE);
1654 fail_unless_equals_int (csink->n_raw + csink->n_compressed, NBUFFERS);
1655 gst_object_unref (sink);
1658 gst_element_set_state (playbin, GST_STATE_NULL);
1659 gst_object_unref (playbin);
1667 GstElement *playbin;
1669 } SwitchBufferProbeCtx;
1672 switch_video_buffer_probe (GstPad * pad, GstBuffer * buffer,
1673 SwitchBufferProbeCtx * ctx)
1675 GstElement *playbin = ctx->playbin;
1676 GstVideoCodecSink *sink = (GstVideoCodecSink *) ctx->sink;
1678 if (sink->n_raw + sink->n_compressed == NBUFFERS / 2) {
1681 g_object_get (G_OBJECT (playbin), "current-video", &cur_video, NULL);
1682 cur_video = (cur_video == 0) ? 1 : 0;
1683 g_object_set (G_OBJECT (playbin), "current-video", cur_video, NULL);
1689 GST_START_TEST (test_raw_compressed_video_stream_demuxer_switch_manual_sink)
1692 GstElement *playbin;
1695 gboolean done = FALSE;
1697 SwitchBufferProbeCtx switch_ctx;
1699 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
1700 gst_caps_src_get_type ()));
1701 fail_unless (gst_element_register (NULL, "codecdemuxer",
1702 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
1703 fail_unless (gst_element_register (NULL, "audiocodecsink",
1704 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
1705 fail_unless (gst_element_register (NULL, "videocodecsink",
1706 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
1708 playbin = create_playbin ("caps:application/x-container, "
1709 "stream0=(string)raw-video, " "stream1=(string)compressed-video", TRUE);
1711 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
1712 GST_STATE_CHANGE_SUCCESS);
1714 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1715 fail_unless (sink != NULL);
1716 pad = gst_element_get_static_pad (sink, "sink");
1717 fail_unless (pad != NULL);
1718 switch_ctx.playbin = playbin;
1719 switch_ctx.sink = sink;
1720 gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_video_buffer_probe),
1722 gst_object_unref (pad);
1723 gst_object_unref (sink);
1725 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
1726 GST_STATE_CHANGE_ASYNC);
1728 bus = gst_element_get_bus (playbin);
1731 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
1733 switch (GST_MESSAGE_TYPE (msg)) {
1734 case GST_MESSAGE_EOS:
1737 case GST_MESSAGE_ERROR:
1738 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
1740 case GST_MESSAGE_WARNING:
1741 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
1746 gst_message_unref (msg);
1748 gst_object_unref (bus);
1750 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1751 fail_unless (sink != NULL);
1753 GstVideoCodecSink *csink;
1755 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1756 gst_video_codec_sink_get_type ());
1757 csink = (GstVideoCodecSink *) sink;
1758 fail_unless (csink->audio == FALSE);
1759 fail_unless (csink->n_raw > 0);
1760 fail_unless (csink->n_compressed > 0);
1761 gst_object_unref (sink);
1764 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
1765 fail_unless (sink != NULL);
1767 GstAudioCodecSink *csink;
1769 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1770 gst_audio_codec_sink_get_type ());
1771 csink = (GstAudioCodecSink *) sink;
1772 fail_unless (csink->audio == TRUE);
1773 fail_unless_equals_int (csink->n_raw, 0);
1774 fail_unless_equals_int (csink->n_compressed, 0);
1775 gst_object_unref (sink);
1778 gst_element_set_state (playbin, GST_STATE_NULL);
1779 gst_object_unref (playbin);
1784 GST_START_TEST (test_compressed_raw_video_stream_demuxer_switch_manual_sink)
1787 GstElement *playbin;
1790 gboolean done = FALSE;
1792 SwitchBufferProbeCtx switch_ctx;
1794 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
1795 gst_caps_src_get_type ()));
1796 fail_unless (gst_element_register (NULL, "codecdemuxer",
1797 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
1798 fail_unless (gst_element_register (NULL, "audiocodecsink",
1799 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
1800 fail_unless (gst_element_register (NULL, "videocodecsink",
1801 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
1803 playbin = create_playbin ("caps:application/x-container, "
1804 "stream0=(string)compressed-video, " "stream1=(string)raw-video", TRUE);
1806 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
1807 GST_STATE_CHANGE_SUCCESS);
1809 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1810 fail_unless (sink != NULL);
1811 pad = gst_element_get_static_pad (sink, "sink");
1812 fail_unless (pad != NULL);
1813 switch_ctx.playbin = playbin;
1814 switch_ctx.sink = sink;
1815 gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_video_buffer_probe),
1817 gst_object_unref (pad);
1818 gst_object_unref (sink);
1820 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
1821 GST_STATE_CHANGE_ASYNC);
1823 bus = gst_element_get_bus (playbin);
1826 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
1828 switch (GST_MESSAGE_TYPE (msg)) {
1829 case GST_MESSAGE_EOS:
1832 case GST_MESSAGE_ERROR:
1833 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
1835 case GST_MESSAGE_WARNING:
1836 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
1841 gst_message_unref (msg);
1843 gst_object_unref (bus);
1845 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1846 fail_unless (sink != NULL);
1848 GstVideoCodecSink *csink;
1850 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1851 gst_video_codec_sink_get_type ());
1852 csink = (GstVideoCodecSink *) sink;
1853 fail_unless (csink->audio == FALSE);
1854 fail_unless (csink->n_raw > 0);
1855 fail_unless (csink->n_compressed > 0);
1856 gst_object_unref (sink);
1859 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
1860 fail_unless (sink != NULL);
1862 GstAudioCodecSink *csink;
1864 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1865 gst_audio_codec_sink_get_type ());
1866 csink = (GstAudioCodecSink *) sink;
1867 fail_unless (csink->audio == TRUE);
1868 fail_unless_equals_int (csink->n_raw, 0);
1869 fail_unless_equals_int (csink->n_compressed, 0);
1870 gst_object_unref (sink);
1873 gst_element_set_state (playbin, GST_STATE_NULL);
1874 gst_object_unref (playbin);
1879 GST_START_TEST (test_raw_raw_video_stream_demuxer_switch_manual_sink)
1882 GstElement *playbin;
1885 gboolean done = FALSE;
1887 SwitchBufferProbeCtx switch_ctx;
1889 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
1890 gst_caps_src_get_type ()));
1891 fail_unless (gst_element_register (NULL, "codecdemuxer",
1892 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
1893 fail_unless (gst_element_register (NULL, "audiocodecsink",
1894 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
1895 fail_unless (gst_element_register (NULL, "videocodecsink",
1896 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
1898 playbin = create_playbin ("caps:application/x-container, "
1899 "stream0=(string)raw-video, " "stream1=(string)raw-video", TRUE);
1901 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
1902 GST_STATE_CHANGE_SUCCESS);
1904 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1905 fail_unless (sink != NULL);
1906 pad = gst_element_get_static_pad (sink, "sink");
1907 fail_unless (pad != NULL);
1908 switch_ctx.playbin = playbin;
1909 switch_ctx.sink = sink;
1910 gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_video_buffer_probe),
1912 gst_object_unref (pad);
1913 gst_object_unref (sink);
1915 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
1916 GST_STATE_CHANGE_ASYNC);
1918 bus = gst_element_get_bus (playbin);
1921 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
1923 switch (GST_MESSAGE_TYPE (msg)) {
1924 case GST_MESSAGE_EOS:
1927 case GST_MESSAGE_ERROR:
1928 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
1930 case GST_MESSAGE_WARNING:
1931 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
1936 gst_message_unref (msg);
1938 gst_object_unref (bus);
1940 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
1941 fail_unless (sink != NULL);
1943 GstVideoCodecSink *csink;
1945 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1946 gst_video_codec_sink_get_type ());
1947 csink = (GstVideoCodecSink *) sink;
1948 fail_unless (csink->audio == FALSE);
1949 fail_unless (csink->n_raw > 0);
1950 fail_unless_equals_int (csink->n_compressed, 0);
1951 gst_object_unref (sink);
1954 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
1955 fail_unless (sink != NULL);
1957 GstAudioCodecSink *csink;
1959 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
1960 gst_audio_codec_sink_get_type ());
1961 csink = (GstAudioCodecSink *) sink;
1962 fail_unless (csink->audio == TRUE);
1963 fail_unless_equals_int (csink->n_raw, 0);
1964 fail_unless_equals_int (csink->n_compressed, 0);
1965 gst_object_unref (sink);
1968 gst_element_set_state (playbin, GST_STATE_NULL);
1969 gst_object_unref (playbin);
1975 (test_compressed_compressed_video_stream_demuxer_switch_manual_sink) {
1977 GstElement *playbin;
1980 gboolean done = FALSE;
1982 SwitchBufferProbeCtx switch_ctx;
1984 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
1985 gst_caps_src_get_type ()));
1986 fail_unless (gst_element_register (NULL, "codecdemuxer",
1987 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
1988 fail_unless (gst_element_register (NULL, "audiocodecsink",
1989 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
1990 fail_unless (gst_element_register (NULL, "videocodecsink",
1991 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
1993 playbin = create_playbin ("caps:application/x-container, "
1994 "stream0=(string)compressed-video, " "stream1=(string)compressed-video",
1997 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
1998 GST_STATE_CHANGE_SUCCESS);
2000 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
2001 fail_unless (sink != NULL);
2002 pad = gst_element_get_static_pad (sink, "sink");
2003 fail_unless (pad != NULL);
2004 switch_ctx.playbin = playbin;
2005 switch_ctx.sink = sink;
2006 gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_video_buffer_probe),
2008 gst_object_unref (pad);
2009 gst_object_unref (sink);
2011 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
2012 GST_STATE_CHANGE_ASYNC);
2014 bus = gst_element_get_bus (playbin);
2017 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
2019 switch (GST_MESSAGE_TYPE (msg)) {
2020 case GST_MESSAGE_EOS:
2023 case GST_MESSAGE_ERROR:
2024 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
2026 case GST_MESSAGE_WARNING:
2027 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
2032 gst_message_unref (msg);
2034 gst_object_unref (bus);
2036 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
2037 fail_unless (sink != NULL);
2039 GstVideoCodecSink *csink;
2041 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
2042 gst_video_codec_sink_get_type ());
2043 csink = (GstVideoCodecSink *) sink;
2044 fail_unless (csink->audio == FALSE);
2045 fail_unless_equals_int (csink->n_raw, 0);
2046 fail_unless (csink->n_compressed > 0);
2047 gst_object_unref (sink);
2050 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
2051 fail_unless (sink != NULL);
2053 GstAudioCodecSink *csink;
2055 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
2056 gst_audio_codec_sink_get_type ());
2057 csink = (GstAudioCodecSink *) sink;
2058 fail_unless (csink->audio == TRUE);
2059 fail_unless_equals_int (csink->n_raw, 0);
2060 fail_unless_equals_int (csink->n_compressed, 0);
2061 gst_object_unref (sink);
2064 gst_element_set_state (playbin, GST_STATE_NULL);
2065 gst_object_unref (playbin);
2071 switch_audio_buffer_probe (GstPad * pad, GstBuffer * buffer,
2072 SwitchBufferProbeCtx * ctx)
2074 GstElement *playbin = ctx->playbin;
2075 GstAudioCodecSink *sink = (GstAudioCodecSink *) ctx->sink;
2077 if (sink->n_raw + sink->n_compressed == NBUFFERS / 3) {
2080 g_object_get (G_OBJECT (playbin), "current-audio", &cur_audio, NULL);
2081 cur_audio = (cur_audio == 0) ? 1 : 0;
2082 g_object_set (G_OBJECT (playbin), "current-audio", cur_audio, NULL);
2088 GST_START_TEST (test_raw_compressed_audio_stream_demuxer_switch_manual_sink)
2091 GstElement *playbin;
2094 gboolean done = FALSE;
2096 SwitchBufferProbeCtx switch_ctx;
2098 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
2099 gst_caps_src_get_type ()));
2100 fail_unless (gst_element_register (NULL, "codecdemuxer",
2101 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
2102 fail_unless (gst_element_register (NULL, "audiocodecsink",
2103 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
2104 fail_unless (gst_element_register (NULL, "videocodecsink",
2105 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
2107 playbin = create_playbin ("caps:application/x-container, "
2108 "stream0=(string)raw-audio, " "stream1=(string)compressed-audio", TRUE);
2110 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
2111 GST_STATE_CHANGE_SUCCESS);
2113 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
2114 fail_unless (sink != NULL);
2115 pad = gst_element_get_static_pad (sink, "sink");
2116 fail_unless (pad != NULL);
2117 switch_ctx.playbin = playbin;
2118 switch_ctx.sink = sink;
2119 gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_audio_buffer_probe),
2121 gst_object_unref (pad);
2122 gst_object_unref (sink);
2124 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
2125 GST_STATE_CHANGE_ASYNC);
2127 bus = gst_element_get_bus (playbin);
2130 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
2132 switch (GST_MESSAGE_TYPE (msg)) {
2133 case GST_MESSAGE_EOS:
2136 case GST_MESSAGE_ERROR:
2137 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
2139 case GST_MESSAGE_WARNING:
2140 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
2145 gst_message_unref (msg);
2147 gst_object_unref (bus);
2149 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
2150 fail_unless (sink != NULL);
2152 GstVideoCodecSink *csink;
2154 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
2155 gst_video_codec_sink_get_type ());
2156 csink = (GstVideoCodecSink *) sink;
2157 fail_unless (csink->audio == FALSE);
2158 fail_unless_equals_int (csink->n_raw, 0);
2159 fail_unless_equals_int (csink->n_compressed, 0);
2160 gst_object_unref (sink);
2163 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
2164 fail_unless (sink != NULL);
2166 GstAudioCodecSink *csink;
2168 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
2169 gst_audio_codec_sink_get_type ());
2170 csink = (GstAudioCodecSink *) sink;
2171 fail_unless (csink->audio == TRUE);
2172 fail_unless (csink->n_raw > 0);
2173 fail_unless (csink->n_compressed > 0);
2174 gst_object_unref (sink);
2177 gst_element_set_state (playbin, GST_STATE_NULL);
2178 gst_object_unref (playbin);
2183 GST_START_TEST (test_compressed_raw_audio_stream_demuxer_switch_manual_sink)
2186 GstElement *playbin;
2189 gboolean done = FALSE;
2191 SwitchBufferProbeCtx switch_ctx;
2193 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
2194 gst_caps_src_get_type ()));
2195 fail_unless (gst_element_register (NULL, "codecdemuxer",
2196 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
2197 fail_unless (gst_element_register (NULL, "audiocodecsink",
2198 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
2199 fail_unless (gst_element_register (NULL, "videocodecsink",
2200 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
2202 playbin = create_playbin ("caps:application/x-container, "
2203 "stream0=(string)compressed-audio, " "stream1=(string)raw-audio", TRUE);
2205 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
2206 GST_STATE_CHANGE_SUCCESS);
2208 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
2209 fail_unless (sink != NULL);
2210 pad = gst_element_get_static_pad (sink, "sink");
2211 fail_unless (pad != NULL);
2212 switch_ctx.playbin = playbin;
2213 switch_ctx.sink = sink;
2214 gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_audio_buffer_probe),
2216 gst_object_unref (pad);
2217 gst_object_unref (sink);
2219 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
2220 GST_STATE_CHANGE_ASYNC);
2222 bus = gst_element_get_bus (playbin);
2225 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
2227 switch (GST_MESSAGE_TYPE (msg)) {
2228 case GST_MESSAGE_EOS:
2231 case GST_MESSAGE_ERROR:
2232 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
2234 case GST_MESSAGE_WARNING:
2235 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
2240 gst_message_unref (msg);
2242 gst_object_unref (bus);
2244 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
2245 fail_unless (sink != NULL);
2247 GstVideoCodecSink *csink;
2249 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
2250 gst_video_codec_sink_get_type ());
2251 csink = (GstVideoCodecSink *) sink;
2252 fail_unless (csink->audio == FALSE);
2253 fail_unless_equals_int (csink->n_raw, 0);
2254 fail_unless_equals_int (csink->n_compressed, 0);
2255 gst_object_unref (sink);
2258 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
2259 fail_unless (sink != NULL);
2261 GstAudioCodecSink *csink;
2263 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
2264 gst_audio_codec_sink_get_type ());
2265 csink = (GstAudioCodecSink *) sink;
2266 fail_unless (csink->audio == TRUE);
2267 fail_unless (csink->n_raw > 0);
2268 fail_unless (csink->n_compressed > 0);
2269 gst_object_unref (sink);
2272 gst_element_set_state (playbin, GST_STATE_NULL);
2273 gst_object_unref (playbin);
2278 GST_START_TEST (test_raw_raw_audio_stream_demuxer_switch_manual_sink)
2281 GstElement *playbin;
2284 gboolean done = FALSE;
2286 SwitchBufferProbeCtx switch_ctx;
2288 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
2289 gst_caps_src_get_type ()));
2290 fail_unless (gst_element_register (NULL, "codecdemuxer",
2291 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
2292 fail_unless (gst_element_register (NULL, "audiocodecsink",
2293 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
2294 fail_unless (gst_element_register (NULL, "videocodecsink",
2295 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
2297 playbin = create_playbin ("caps:application/x-container, "
2298 "stream0=(string)raw-audio, " "stream1=(string)raw-audio", TRUE);
2300 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
2301 GST_STATE_CHANGE_SUCCESS);
2303 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
2304 fail_unless (sink != NULL);
2305 pad = gst_element_get_static_pad (sink, "sink");
2306 fail_unless (pad != NULL);
2307 switch_ctx.playbin = playbin;
2308 switch_ctx.sink = sink;
2309 gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_audio_buffer_probe),
2311 gst_object_unref (pad);
2312 gst_object_unref (sink);
2314 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
2315 GST_STATE_CHANGE_ASYNC);
2317 bus = gst_element_get_bus (playbin);
2320 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
2322 switch (GST_MESSAGE_TYPE (msg)) {
2323 case GST_MESSAGE_EOS:
2326 case GST_MESSAGE_ERROR:
2327 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
2329 case GST_MESSAGE_WARNING:
2330 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
2335 gst_message_unref (msg);
2337 gst_object_unref (bus);
2339 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
2340 fail_unless (sink != NULL);
2342 GstVideoCodecSink *csink;
2344 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
2345 gst_video_codec_sink_get_type ());
2346 csink = (GstVideoCodecSink *) sink;
2347 fail_unless (csink->audio == FALSE);
2348 fail_unless_equals_int (csink->n_raw, 0);
2349 fail_unless_equals_int (csink->n_compressed, 0);
2350 gst_object_unref (sink);
2353 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
2354 fail_unless (sink != NULL);
2356 GstAudioCodecSink *csink;
2358 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
2359 gst_audio_codec_sink_get_type ());
2360 csink = (GstAudioCodecSink *) sink;
2361 fail_unless (csink->audio == TRUE);
2362 fail_unless (csink->n_raw > 0);
2363 fail_unless_equals_int (csink->n_compressed, 0);
2364 gst_object_unref (sink);
2367 gst_element_set_state (playbin, GST_STATE_NULL);
2368 gst_object_unref (playbin);
2374 (test_compressed_compressed_audio_stream_demuxer_switch_manual_sink) {
2376 GstElement *playbin;
2379 gboolean done = FALSE;
2381 SwitchBufferProbeCtx switch_ctx;
2383 fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
2384 gst_caps_src_get_type ()));
2385 fail_unless (gst_element_register (NULL, "codecdemuxer",
2386 GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
2387 fail_unless (gst_element_register (NULL, "audiocodecsink",
2388 GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
2389 fail_unless (gst_element_register (NULL, "videocodecsink",
2390 GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
2392 playbin = create_playbin ("caps:application/x-container, "
2393 "stream0=(string)compressed-audio, " "stream1=(string)compressed-audio",
2396 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
2397 GST_STATE_CHANGE_SUCCESS);
2399 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
2400 fail_unless (sink != NULL);
2401 pad = gst_element_get_static_pad (sink, "sink");
2402 fail_unless (pad != NULL);
2403 switch_ctx.playbin = playbin;
2404 switch_ctx.sink = sink;
2405 gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_audio_buffer_probe),
2407 gst_object_unref (pad);
2408 gst_object_unref (sink);
2410 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
2411 GST_STATE_CHANGE_ASYNC);
2413 bus = gst_element_get_bus (playbin);
2416 msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
2418 switch (GST_MESSAGE_TYPE (msg)) {
2419 case GST_MESSAGE_EOS:
2422 case GST_MESSAGE_ERROR:
2423 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
2425 case GST_MESSAGE_WARNING:
2426 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_WARNING);
2431 gst_message_unref (msg);
2433 gst_object_unref (bus);
2435 g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
2436 fail_unless (sink != NULL);
2438 GstVideoCodecSink *csink;
2440 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
2441 gst_video_codec_sink_get_type ());
2442 csink = (GstVideoCodecSink *) sink;
2443 fail_unless (csink->audio == FALSE);
2444 fail_unless_equals_int (csink->n_raw, 0);
2445 fail_unless_equals_int (csink->n_compressed, 0);
2446 gst_object_unref (sink);
2449 g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
2450 fail_unless (sink != NULL);
2452 GstAudioCodecSink *csink;
2454 fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
2455 gst_audio_codec_sink_get_type ());
2456 csink = (GstAudioCodecSink *) sink;
2457 fail_unless (csink->audio == TRUE);
2458 fail_unless_equals_int (csink->n_raw, 0);
2459 fail_unless (csink->n_compressed > 0);
2460 gst_object_unref (sink);
2463 gst_element_set_state (playbin, GST_STATE_NULL);
2464 gst_object_unref (playbin);
2472 playbin2_compressed_suite (void)
2474 Suite *s = suite_create ("playbin2-compressed");
2475 TCase *tc_chain = tcase_create ("general");
2477 suite_add_tcase (s, tc_chain);
2479 #ifndef GST_DISABLE_REGISTRY
2480 tcase_add_test (tc_chain, test_raw_single_video_stream_manual_sink);
2481 tcase_add_test (tc_chain, test_raw_single_audio_stream_manual_sink);
2482 tcase_add_test (tc_chain, test_compressed_single_video_stream_manual_sink);
2483 tcase_add_test (tc_chain, test_compressed_single_audio_stream_manual_sink);
2485 tcase_add_test (tc_chain, test_raw_single_video_stream_demuxer_manual_sink);
2486 tcase_add_test (tc_chain, test_raw_single_audio_stream_demuxer_manual_sink);
2487 tcase_add_test (tc_chain,
2488 test_compressed_single_video_stream_demuxer_manual_sink);
2489 tcase_add_test (tc_chain,
2490 test_compressed_single_audio_stream_demuxer_manual_sink);
2492 tcase_add_test (tc_chain, test_raw_audio_video_stream_demuxer_manual_sink);
2493 tcase_add_test (tc_chain,
2494 test_compressed_audio_video_stream_demuxer_manual_sink);
2496 tcase_add_test (tc_chain,
2497 test_raw_compressed_audio_stream_demuxer_manual_sink);
2498 tcase_add_test (tc_chain,
2499 test_raw_compressed_video_stream_demuxer_manual_sink);
2501 /* These tests need something like the stream-activate event
2502 * and are racy otherwise */
2504 tcase_add_test (tc_chain,
2505 test_raw_raw_audio_stream_demuxer_switch_manual_sink);
2506 tcase_add_test (tc_chain,
2507 test_raw_compressed_audio_stream_demuxer_switch_manual_sink);
2508 tcase_add_test (tc_chain,
2509 test_compressed_raw_audio_stream_demuxer_switch_manual_sink);
2510 tcase_add_test (tc_chain,
2511 test_compressed_compressed_audio_stream_demuxer_switch_manual_sink);
2512 tcase_add_test (tc_chain,
2513 test_raw_raw_video_stream_demuxer_switch_manual_sink);
2514 tcase_add_test (tc_chain,
2515 test_raw_compressed_video_stream_demuxer_switch_manual_sink);
2516 tcase_add_test (tc_chain,
2517 test_compressed_raw_video_stream_demuxer_switch_manual_sink);
2518 tcase_add_test (tc_chain,
2519 test_compressed_compressed_video_stream_demuxer_switch_manual_sink);
2526 GST_CHECK_MAIN (playbin2_compressed);