2013-05-29 08:37:55 +00:00
|
|
|
/* GStreamer unit tests for playbin complex stream support
|
2011-03-15 10:41:14 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
|
|
|
|
* Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2011-03-15 10:41:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
#include <gst/base/gstpushsrc.h>
|
|
|
|
#include <gst/base/gstbasesink.h>
|
2014-10-24 12:09:42 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2013-06-10 11:43:35 +00:00
|
|
|
#include <gst/video/gstvideodecoder.h>
|
2011-03-15 10:41:14 +00:00
|
|
|
|
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
|
|
|
|
|
|
|
#define NBUFFERS 100
|
|
|
|
|
|
|
|
static GType gst_caps_src_get_type (void);
|
|
|
|
static GType gst_codec_demuxer_get_type (void);
|
|
|
|
static GType gst_codec_sink_get_type (void);
|
|
|
|
static GType gst_audio_codec_sink_get_type (void);
|
|
|
|
static GType gst_video_codec_sink_get_type (void);
|
2013-06-10 11:43:35 +00:00
|
|
|
static GType gst_video_decoder1_get_type (void);
|
|
|
|
static GType gst_video_decoder2_get_type (void);
|
|
|
|
static GType gst_video_sink1_get_type (void);
|
|
|
|
static GType gst_video_sink2_get_type (void);
|
2011-03-15 10:41:14 +00:00
|
|
|
|
|
|
|
typedef struct _GstCapsSrc GstCapsSrc;
|
|
|
|
typedef GstPushSrcClass GstCapsSrcClass;
|
|
|
|
|
|
|
|
struct _GstCapsSrc
|
|
|
|
{
|
|
|
|
GstPushSrc parent;
|
|
|
|
|
|
|
|
GstCaps *caps;
|
|
|
|
gchar *uri;
|
|
|
|
gint nbuffers;
|
|
|
|
};
|
|
|
|
|
|
|
|
static GstURIType
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_caps_src_uri_get_type (GType type)
|
2011-03-15 10:41:14 +00:00
|
|
|
{
|
|
|
|
return GST_URI_SRC;
|
|
|
|
}
|
|
|
|
|
2011-11-13 23:44:23 +00:00
|
|
|
static const gchar *const *
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_caps_src_uri_get_protocols (GType type)
|
2011-03-15 10:41:14 +00:00
|
|
|
{
|
2011-11-13 23:44:23 +00:00
|
|
|
static const gchar *protocols[] = { "caps", NULL };
|
2011-03-15 10:41:14 +00:00
|
|
|
|
|
|
|
return protocols;
|
|
|
|
}
|
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
static gchar *
|
2011-03-15 10:41:14 +00:00
|
|
|
gst_caps_src_uri_get_uri (GstURIHandler * handler)
|
|
|
|
{
|
|
|
|
GstCapsSrc *src = (GstCapsSrc *) handler;
|
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
return g_strdup (src->uri);
|
2011-03-15 10:41:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_caps_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
|
|
|
|
GError ** error)
|
2011-03-15 10:41:14 +00:00
|
|
|
{
|
|
|
|
GstCapsSrc *src = (GstCapsSrc *) handler;
|
|
|
|
|
|
|
|
if (uri == NULL || !g_str_has_prefix (uri, "caps:"))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
g_free (src->uri);
|
|
|
|
src->uri = g_strdup (uri);
|
|
|
|
|
|
|
|
if (src->caps)
|
|
|
|
gst_caps_unref (src->caps);
|
|
|
|
src->caps = NULL;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_caps_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
|
|
|
|
{
|
|
|
|
GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
|
|
|
|
|
|
|
|
iface->get_type = gst_caps_src_uri_get_type;
|
|
|
|
iface->get_protocols = gst_caps_src_uri_get_protocols;
|
|
|
|
iface->get_uri = gst_caps_src_uri_get_uri;
|
|
|
|
iface->set_uri = gst_caps_src_uri_set_uri;
|
|
|
|
}
|
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstCapsSrc, gst_caps_src, GST_TYPE_PUSH_SRC,
|
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
|
|
|
|
gst_caps_src_uri_handler_init));
|
2011-03-15 10:41:14 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_caps_src_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstCapsSrc *src = (GstCapsSrc *) object;
|
|
|
|
|
|
|
|
if (src->caps)
|
|
|
|
gst_caps_unref (src->caps);
|
|
|
|
src->caps = NULL;
|
|
|
|
g_free (src->uri);
|
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
G_OBJECT_CLASS (gst_caps_src_parent_class)->finalize (object);
|
2011-03-15 10:41:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_caps_src_create (GstPushSrc * psrc, GstBuffer ** p_buf)
|
|
|
|
{
|
|
|
|
GstCapsSrc *src = (GstCapsSrc *) psrc;
|
|
|
|
GstBuffer *buf;
|
|
|
|
|
|
|
|
if (src->nbuffers >= NBUFFERS) {
|
2012-01-04 15:41:53 +00:00
|
|
|
return GST_FLOW_EOS;
|
2011-03-15 10:41:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!src->caps) {
|
|
|
|
if (!src->uri) {
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
src->caps = gst_caps_from_string (src->uri + sizeof ("caps"));
|
|
|
|
if (!src->caps) {
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-31 15:56:03 +00:00
|
|
|
if (src->nbuffers == 0) {
|
2013-05-09 16:02:57 +00:00
|
|
|
gst_pad_push_event (GST_BASE_SRC_PAD (psrc),
|
|
|
|
gst_event_new_stream_start ("test"));
|
2012-01-31 15:56:03 +00:00
|
|
|
gst_pad_set_caps (GST_BASE_SRC_PAD (psrc), src->caps);
|
|
|
|
}
|
|
|
|
|
2013-05-28 16:59:22 +00:00
|
|
|
buf = gst_buffer_new_wrapped (g_malloc0 (4), 4);
|
2011-03-15 10:41:14 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (buf) =
|
|
|
|
gst_util_uint64_scale (src->nbuffers, GST_SECOND, 25);
|
|
|
|
src->nbuffers++;
|
|
|
|
|
|
|
|
*p_buf = buf;
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_caps_src_class_init (GstCapsSrcClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
2012-01-04 15:41:53 +00:00
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
2011-03-15 10:41:14 +00:00
|
|
|
GstPushSrcClass *pushsrc_class = (GstPushSrcClass *) klass;
|
2012-01-04 15:41:53 +00:00
|
|
|
static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC, GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
2016-03-03 07:46:24 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class, &src_templ);
|
2012-09-14 15:02:53 +00:00
|
|
|
gst_element_class_set_metadata (element_class,
|
2012-01-04 15:41:53 +00:00
|
|
|
"CapsSource", "Source/Generic", "yep", "me");
|
2011-03-15 10:41:14 +00:00
|
|
|
|
|
|
|
gobject_class->finalize = gst_caps_src_finalize;
|
|
|
|
pushsrc_class->create = gst_caps_src_create;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_caps_src_init (GstCapsSrc * src)
|
2011-03-15 10:41:14 +00:00
|
|
|
{
|
|
|
|
gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct _GstCodecSink GstCodecSink;
|
|
|
|
typedef GstBaseSinkClass GstCodecSinkClass;
|
|
|
|
|
|
|
|
struct _GstCodecSink
|
|
|
|
{
|
|
|
|
GstBaseSink parent;
|
|
|
|
|
|
|
|
gboolean audio;
|
|
|
|
gboolean raw;
|
|
|
|
gint n_raw, n_compressed;
|
|
|
|
};
|
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
G_DEFINE_TYPE (GstCodecSink, gst_codec_sink, GST_TYPE_BASE_SINK);
|
2011-03-15 10:41:14 +00:00
|
|
|
|
2011-03-29 17:15:27 +00:00
|
|
|
static gboolean
|
|
|
|
gst_codec_sink_start (GstBaseSink * bsink)
|
|
|
|
{
|
|
|
|
GstCodecSink *sink = (GstCodecSink *) bsink;
|
|
|
|
|
|
|
|
sink->n_raw = 0;
|
|
|
|
sink->n_compressed = 0;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-03-15 10:41:14 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_codec_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstCodecSink *sink = (GstCodecSink *) bsink;
|
|
|
|
|
|
|
|
if (sink->raw)
|
|
|
|
sink->n_raw++;
|
|
|
|
else
|
|
|
|
sink->n_compressed++;
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_codec_sink_class_init (GstCodecSinkClass * klass)
|
|
|
|
{
|
|
|
|
GstBaseSinkClass *basesink_class = (GstBaseSinkClass *) klass;
|
|
|
|
|
2011-03-29 17:15:27 +00:00
|
|
|
basesink_class->start = gst_codec_sink_start;
|
2011-03-15 10:41:14 +00:00
|
|
|
basesink_class->render = gst_codec_sink_render;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_codec_sink_init (GstCodecSink * sink)
|
2011-03-15 10:41:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef GstCodecSink GstAudioCodecSink;
|
|
|
|
typedef GstCodecSinkClass GstAudioCodecSinkClass;
|
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstAudioCodecSink, gst_audio_codec_sink,
|
|
|
|
gst_codec_sink_get_type (),
|
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_STREAM_VOLUME, NULL));
|
2011-03-15 10:41:14 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_audio_codec_sink_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
switch (prop_id) {
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_audio_codec_sink_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case 1:
|
|
|
|
g_value_set_double (value, 1.0);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
g_value_set_boolean (value, FALSE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_audio_codec_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *sink = (GstAudioCodecSink *) bsink;
|
|
|
|
GstStructure *s;
|
|
|
|
|
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
|
2011-09-29 11:46:36 +00:00
|
|
|
if (gst_structure_has_name (s, "audio/x-raw")) {
|
2011-03-15 10:41:14 +00:00
|
|
|
sink->raw = TRUE;
|
|
|
|
} else if (gst_structure_has_name (s, "audio/x-compressed")) {
|
|
|
|
sink->raw = FALSE;
|
|
|
|
} else {
|
2011-09-29 11:46:36 +00:00
|
|
|
fail_unless (gst_structure_has_name (s, "audio/x-raw")
|
2011-03-15 10:41:14 +00:00
|
|
|
|| gst_structure_has_name (s, "audio/x-compressed"));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_audio_codec_sink_class_init (GstAudioCodecSinkClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
2012-01-04 15:41:53 +00:00
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
2011-03-15 10:41:14 +00:00
|
|
|
GstBaseSinkClass *basesink_class = (GstBaseSinkClass *) klass;
|
2012-01-04 15:41:53 +00:00
|
|
|
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK, GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-raw; audio/x-compressed")
|
|
|
|
);
|
2011-03-15 10:41:14 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_audio_codec_sink_set_property;
|
|
|
|
gobject_class->get_property = gst_audio_codec_sink_get_property;
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
1,
|
|
|
|
g_param_spec_double ("volume", "Volume",
|
|
|
|
"Linear volume of this stream, 1.0=100%", 0.0, 10.0,
|
|
|
|
1.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
2,
|
|
|
|
g_param_spec_boolean ("mute", "Mute",
|
|
|
|
"Mute", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2016-03-03 07:46:24 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class, &sink_templ);
|
2012-09-14 15:02:53 +00:00
|
|
|
gst_element_class_set_metadata (element_class,
|
2012-01-04 15:41:53 +00:00
|
|
|
"AudioCodecSink", "Sink/Audio", "yep", "me");
|
|
|
|
|
2011-03-15 10:41:14 +00:00
|
|
|
basesink_class->set_caps = gst_audio_codec_sink_set_caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_audio_codec_sink_init (GstAudioCodecSink * sink)
|
2011-03-15 10:41:14 +00:00
|
|
|
{
|
|
|
|
sink->audio = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef GstCodecSink GstVideoCodecSink;
|
|
|
|
typedef GstCodecSinkClass GstVideoCodecSinkClass;
|
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
G_DEFINE_TYPE (GstVideoCodecSink, gst_video_codec_sink,
|
2011-03-15 10:41:14 +00:00
|
|
|
gst_codec_sink_get_type ());
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_video_codec_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *sink = (GstVideoCodecSink *) bsink;
|
|
|
|
GstStructure *s;
|
|
|
|
|
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
|
2011-06-16 11:41:25 +00:00
|
|
|
if (gst_structure_has_name (s, "video/x-raw")) {
|
2011-03-15 10:41:14 +00:00
|
|
|
sink->raw = TRUE;
|
|
|
|
} else if (gst_structure_has_name (s, "video/x-compressed")) {
|
|
|
|
sink->raw = FALSE;
|
|
|
|
} else {
|
2011-06-16 11:41:25 +00:00
|
|
|
fail_unless (gst_structure_has_name (s, "video/x-raw")
|
2011-03-15 10:41:14 +00:00
|
|
|
|| gst_structure_has_name (s, "video/x-compressed"));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_video_codec_sink_class_init (GstVideoCodecSinkClass * klass)
|
|
|
|
{
|
|
|
|
GstBaseSinkClass *basesink_class = (GstBaseSinkClass *) klass;
|
2012-01-04 15:41:53 +00:00
|
|
|
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK, GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/x-raw; video/x-compressed")
|
|
|
|
);
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
2016-03-03 07:46:24 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class, &sink_templ);
|
2012-09-14 15:02:53 +00:00
|
|
|
gst_element_class_set_metadata (element_class,
|
2012-01-04 15:41:53 +00:00
|
|
|
"VideoCodecSink", "Sink/Video", "yep", "me");
|
2011-03-15 10:41:14 +00:00
|
|
|
|
|
|
|
basesink_class->set_caps = gst_video_codec_sink_set_caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_video_codec_sink_init (GstVideoCodecSink * sink)
|
2011-03-15 10:41:14 +00:00
|
|
|
{
|
|
|
|
sink->audio = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct _GstCodecDemuxer GstCodecDemuxer;
|
|
|
|
typedef GstElementClass GstCodecDemuxerClass;
|
|
|
|
|
|
|
|
struct _GstCodecDemuxer
|
|
|
|
{
|
|
|
|
GstElement parent;
|
|
|
|
|
|
|
|
GstPad *sinkpad;
|
|
|
|
GstPad *srcpad0, *srcpad1;
|
|
|
|
|
|
|
|
GstEvent *newseg_event;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define STREAM_TYPES "{ " \
|
|
|
|
"none, " \
|
|
|
|
"raw-audio, " \
|
|
|
|
"compressed-audio, " \
|
|
|
|
"raw-video, " \
|
|
|
|
"compressed-video " \
|
|
|
|
"}"
|
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
static GstStaticPadTemplate cd_sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK, GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("application/x-container,"
|
|
|
|
" stream0 = (string)" STREAM_TYPES " ,"
|
|
|
|
" stream1 = (string)" STREAM_TYPES)
|
|
|
|
);
|
2014-07-10 14:26:08 +00:00
|
|
|
static GstStaticPadTemplate cd_src_templ = GST_STATIC_PAD_TEMPLATE ("src_%u",
|
2012-01-04 15:41:53 +00:00
|
|
|
GST_PAD_SRC, GST_PAD_SOMETIMES,
|
|
|
|
GST_STATIC_CAPS ("audio/x-raw; audio/x-compressed; "
|
|
|
|
"video/x-raw; video/x-compressed")
|
|
|
|
);
|
2011-03-15 10:41:14 +00:00
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
G_DEFINE_TYPE (GstCodecDemuxer, gst_codec_demuxer, GST_TYPE_ELEMENT);
|
2011-03-15 10:41:14 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_codec_demuxer_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstCodecDemuxer *demux = (GstCodecDemuxer *) object;
|
|
|
|
|
|
|
|
if (demux->newseg_event)
|
|
|
|
gst_event_unref (demux->newseg_event);
|
|
|
|
demux->newseg_event = NULL;
|
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
G_OBJECT_CLASS (gst_codec_demuxer_parent_class)->finalize (object);
|
2011-03-15 10:41:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_codec_demuxer_class_init (GstCodecDemuxerClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
2012-01-04 15:41:53 +00:00
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
2011-03-15 10:41:14 +00:00
|
|
|
|
|
|
|
gobject_class->finalize = gst_codec_demuxer_finalize;
|
2012-01-04 15:41:53 +00:00
|
|
|
|
2016-03-03 07:46:24 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class, &cd_sink_templ);
|
|
|
|
gst_element_class_add_static_pad_template (element_class, &cd_src_templ);
|
2012-09-14 15:02:53 +00:00
|
|
|
gst_element_class_set_metadata (element_class,
|
2012-01-04 15:41:53 +00:00
|
|
|
"CodecDemuxer", "Codec/Demuxer", "yep", "me");
|
2011-03-15 10:41:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_codec_demuxer_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
2011-03-15 10:41:14 +00:00
|
|
|
{
|
2012-01-04 15:41:53 +00:00
|
|
|
GstCodecDemuxer *demux = (GstCodecDemuxer *) parent;
|
2011-03-15 10:41:14 +00:00
|
|
|
GstFlowReturn ret0 = GST_FLOW_OK, ret1 = GST_FLOW_OK;
|
|
|
|
|
2013-05-09 16:02:57 +00:00
|
|
|
if (demux->newseg_event) {
|
|
|
|
if (demux->srcpad0)
|
|
|
|
gst_pad_push_event (demux->srcpad0, gst_event_ref (demux->newseg_event));
|
|
|
|
if (demux->srcpad1)
|
|
|
|
gst_pad_push_event (demux->srcpad1, gst_event_ref (demux->newseg_event));
|
|
|
|
gst_event_unref (demux->newseg_event);
|
|
|
|
demux->newseg_event = NULL;
|
|
|
|
}
|
|
|
|
|
2011-03-15 10:41:14 +00:00
|
|
|
if (demux->srcpad0) {
|
2013-05-28 16:59:22 +00:00
|
|
|
GstBuffer *outbuf = gst_buffer_copy (buf);
|
2011-03-15 10:41:14 +00:00
|
|
|
ret0 = gst_pad_push (demux->srcpad0, outbuf);
|
|
|
|
}
|
|
|
|
if (demux->srcpad1) {
|
2013-05-28 16:59:22 +00:00
|
|
|
GstBuffer *outbuf = gst_buffer_copy (buf);
|
2011-03-15 10:41:14 +00:00
|
|
|
ret1 = gst_pad_push (demux->srcpad1, outbuf);
|
|
|
|
}
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
if (ret0 == GST_FLOW_NOT_LINKED && ret1 == GST_FLOW_NOT_LINKED)
|
|
|
|
return GST_FLOW_NOT_LINKED;
|
|
|
|
if (ret0 == GST_FLOW_OK && ret1 == GST_FLOW_OK)
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
|
|
|
|
return MIN (ret0, ret1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_codec_demuxer_setup_pad (GstCodecDemuxer * demux, GstPad ** pad,
|
|
|
|
const gchar * streaminfo)
|
|
|
|
{
|
|
|
|
if (g_str_equal (streaminfo, "none")) {
|
|
|
|
if (*pad) {
|
|
|
|
gst_pad_set_active (*pad, FALSE);
|
|
|
|
gst_element_remove_pad (GST_ELEMENT (demux), *pad);
|
|
|
|
*pad = NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
if (!*pad) {
|
|
|
|
GstPadTemplate *templ;
|
|
|
|
|
|
|
|
templ =
|
|
|
|
gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (demux),
|
2014-07-10 14:26:08 +00:00
|
|
|
"src_%u");
|
2011-03-15 10:41:14 +00:00
|
|
|
if (pad == &demux->srcpad0)
|
|
|
|
*pad = gst_pad_new_from_template (templ, "src_0");
|
|
|
|
else
|
|
|
|
*pad = gst_pad_new_from_template (templ, "src_1");
|
|
|
|
gst_pad_set_active (*pad, TRUE);
|
|
|
|
gst_pad_use_fixed_caps (*pad);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (demux), *pad);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_str_equal (streaminfo, "raw-video")) {
|
2011-06-16 11:41:25 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-raw",
|
2012-01-04 15:41:53 +00:00
|
|
|
"format", G_TYPE_STRING, "I420",
|
2011-03-15 10:41:14 +00:00
|
|
|
"width", G_TYPE_INT, 320,
|
|
|
|
"height", G_TYPE_INT, 240,
|
|
|
|
"framerate", GST_TYPE_FRACTION, 25, 1,
|
|
|
|
"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
|
|
|
|
} else if (g_str_equal (streaminfo, "compressed-video")) {
|
2012-01-04 15:41:53 +00:00
|
|
|
caps = gst_caps_new_empty_simple ("video/x-compressed");
|
2011-03-15 10:41:14 +00:00
|
|
|
} else if (g_str_equal (streaminfo, "raw-audio")) {
|
2011-09-29 11:46:36 +00:00
|
|
|
caps = gst_caps_new_simple ("audio/x-raw",
|
2014-10-24 12:09:42 +00:00
|
|
|
"format", G_TYPE_STRING, GST_AUDIO_NE (S16),
|
2012-04-03 16:30:38 +00:00
|
|
|
"layout", G_TYPE_STRING, "interleaved",
|
2011-09-29 11:46:36 +00:00
|
|
|
"rate", G_TYPE_INT, 48000, "channels", G_TYPE_INT, 2, NULL);
|
2011-03-15 10:41:14 +00:00
|
|
|
} else {
|
2012-01-04 15:41:53 +00:00
|
|
|
caps = gst_caps_new_empty_simple ("audio/x-compressed");
|
2011-03-15 10:41:14 +00:00
|
|
|
}
|
2013-05-09 16:02:57 +00:00
|
|
|
|
|
|
|
gst_pad_push_event (*pad, gst_event_new_stream_start ("test"));
|
|
|
|
|
2011-03-15 10:41:14 +00:00
|
|
|
gst_pad_set_caps (*pad, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_codec_demuxer_setcaps (GstPad * pad, GstObject * parent, GstCaps * caps)
|
2011-03-15 10:41:14 +00:00
|
|
|
{
|
2012-01-04 15:41:53 +00:00
|
|
|
GstCodecDemuxer *demux = (GstCodecDemuxer *) parent;
|
2011-03-15 10:41:14 +00:00
|
|
|
GstStructure *s;
|
|
|
|
const gchar *streaminfo;
|
|
|
|
|
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
streaminfo = gst_structure_get_string (s, "stream0");
|
|
|
|
gst_codec_demuxer_setup_pad (demux, &demux->srcpad0, streaminfo);
|
|
|
|
|
|
|
|
streaminfo = gst_structure_get_string (s, "stream1");
|
|
|
|
gst_codec_demuxer_setup_pad (demux, &demux->srcpad1, streaminfo);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
static gboolean
|
|
|
|
gst_codec_demuxer_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
2011-03-15 10:41:14 +00:00
|
|
|
{
|
2012-01-04 15:41:53 +00:00
|
|
|
GstCodecDemuxer *demux = (GstCodecDemuxer *) parent;
|
|
|
|
gboolean ret = TRUE;
|
2011-03-15 10:41:14 +00:00
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
/* The single newsegment event is pushed when the pads are created */
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_CAPS:
|
|
|
|
{
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
gst_event_parse_caps (event, &caps);
|
|
|
|
ret = gst_codec_demuxer_setcaps (pad, parent, caps);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_EVENT_SEGMENT:
|
|
|
|
gst_event_replace (&demux->newseg_event, event);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (demux->srcpad0)
|
|
|
|
ret = ret && gst_pad_push_event (demux->srcpad0, gst_event_ref (event));
|
|
|
|
if (demux->srcpad1)
|
|
|
|
ret = ret && gst_pad_push_event (demux->srcpad1, gst_event_ref (event));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_event_unref (event);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_codec_demuxer_init (GstCodecDemuxer * demux)
|
|
|
|
{
|
|
|
|
demux->sinkpad = gst_pad_new_from_static_template (&cd_sink_templ, "sink");
|
2011-03-15 10:41:14 +00:00
|
|
|
gst_pad_set_chain_function (demux->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_codec_demuxer_chain));
|
|
|
|
gst_pad_set_event_function (demux->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_codec_demuxer_event));
|
|
|
|
gst_element_add_pad (GST_ELEMENT (demux), demux->sinkpad);
|
|
|
|
}
|
|
|
|
|
2013-06-10 11:43:35 +00:00
|
|
|
typedef struct _GstVideoDecoder1 GstVideoDecoder1;
|
|
|
|
typedef GstVideoDecoderClass GstVideoDecoder1Class;
|
|
|
|
|
|
|
|
typedef struct _GstVideoDecoder2 GstVideoDecoder2;
|
|
|
|
typedef GstVideoDecoderClass GstVideoDecoder2Class;
|
|
|
|
|
|
|
|
typedef struct _GstVideoSink1 GstVideoSink1;
|
|
|
|
typedef GstBaseSinkClass GstVideoSink1Class;
|
|
|
|
|
|
|
|
typedef struct _GstVideoSink2 GstVideoSink2;
|
|
|
|
typedef GstBaseSinkClass GstVideoSink2Class;
|
|
|
|
|
|
|
|
struct _GstVideoDecoder1
|
|
|
|
{
|
|
|
|
GstVideoDecoder parent;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstVideoDecoder2
|
|
|
|
{
|
|
|
|
GstVideoDecoder parent;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstVideoSink1
|
|
|
|
{
|
|
|
|
GstBaseSink parent;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstVideoSink2
|
|
|
|
{
|
|
|
|
GstBaseSink parent;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GST_CAPS_FEATURE_MEMORY_FAKE "memory:FakeMem"
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GstVideoDecoder1, gst_video_decoder1, GST_TYPE_VIDEO_DECODER);
|
|
|
|
G_DEFINE_TYPE (GstVideoDecoder2, gst_video_decoder2, GST_TYPE_VIDEO_DECODER);
|
|
|
|
G_DEFINE_TYPE (GstVideoSink1, gst_video_sink1, GST_TYPE_BASE_SINK);
|
|
|
|
G_DEFINE_TYPE (GstVideoSink2, gst_video_sink2, GST_TYPE_BASE_SINK);
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_video_sink1_class_init (GstVideoSink1Class * klass)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK, GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
|
|
|
(GST_CAPS_FEATURE_MEMORY_FAKE,
|
|
|
|
GST_VIDEO_FORMATS_ALL) ";"
|
|
|
|
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL))
|
|
|
|
);
|
|
|
|
|
2016-03-03 07:46:24 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class, &sink_templ);
|
2013-06-10 11:43:35 +00:00
|
|
|
|
|
|
|
gst_element_class_set_static_metadata (element_class,
|
|
|
|
"Fake Video Sink1", "Sink/Video",
|
|
|
|
"fake sink1", "Sreerenj Balachandran <sreerenj.balachandran@intel.com>");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_video_sink1_init (GstVideoSink1 * sink)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_video_sink2_class_init (GstVideoSink2Class * klass)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK, GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL)));
|
|
|
|
|
2016-03-03 07:46:24 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class, &sink_templ);
|
2013-06-10 11:43:35 +00:00
|
|
|
|
|
|
|
gst_element_class_set_static_metadata (element_class,
|
|
|
|
"Fake Video Sink2", "Sink/Video",
|
|
|
|
"fake sink2", "Sreerenj Balachandran <sreerenj.balachandran@intel.com>");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_video_sink2_init (GstVideoSink2 * sink)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
fake_theora_dec_handle_frame (GstVideoDecoder * bdec,
|
|
|
|
GstVideoCodecFrame * frame)
|
|
|
|
{
|
|
|
|
/* the width and height are hard-coded for ../../files/theora-vorbis.ogg */
|
|
|
|
gst_video_codec_state_unref (gst_video_decoder_set_output_state (bdec,
|
|
|
|
GST_VIDEO_FORMAT_NV12, 320, 240, NULL));
|
|
|
|
gst_video_decoder_allocate_output_frame (bdec, frame);
|
|
|
|
return gst_video_decoder_finish_frame (bdec, frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_video_decoder1_class_init (GstVideoDecoder1Class * klass)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
GstVideoDecoderClass *vd_class = GST_VIDEO_DECODER_CLASS (klass);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK, GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/x-theora"));
|
|
|
|
|
|
|
|
static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC, GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
|
|
|
(GST_CAPS_FEATURE_MEMORY_FAKE,
|
|
|
|
GST_VIDEO_FORMATS_ALL) ";"
|
|
|
|
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL)));
|
|
|
|
|
2016-03-03 07:46:24 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class, &sink_templ);
|
|
|
|
gst_element_class_add_static_pad_template (element_class, &src_templ);
|
2013-06-10 11:43:35 +00:00
|
|
|
gst_element_class_set_static_metadata (element_class,
|
|
|
|
"Fake theora video decoder1", "Codec/Decoder/Video",
|
|
|
|
"decode theora stream",
|
|
|
|
"Sreerenj Balachandran <sreerenj.balachandran@intel.com>");
|
|
|
|
|
|
|
|
vd_class->handle_frame = fake_theora_dec_handle_frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_video_decoder1_init (GstVideoDecoder1 * dec1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_video_decoder2_class_init (GstVideoDecoder2Class * klass)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
GstVideoDecoderClass *vd_class = GST_VIDEO_DECODER_CLASS (klass);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK, GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/x-theora"));
|
|
|
|
|
|
|
|
static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC, GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL)));
|
|
|
|
|
2016-03-03 07:46:24 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class, &sink_templ);
|
|
|
|
gst_element_class_add_static_pad_template (element_class, &src_templ);
|
2013-06-10 11:43:35 +00:00
|
|
|
gst_element_class_set_static_metadata (element_class,
|
|
|
|
"Fake theora video decoder2", "Codec/Decoder/Video",
|
|
|
|
"decode theora stream",
|
|
|
|
"Sreerenj Balachandran <sreerenj.balachandran@intel.com>");
|
|
|
|
|
|
|
|
vd_class->handle_frame = fake_theora_dec_handle_frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_video_decoder2_init (GstVideoDecoder2 * dec2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-15 10:41:14 +00:00
|
|
|
/****
|
|
|
|
* Start of the tests
|
|
|
|
***/
|
|
|
|
|
2013-06-10 11:43:35 +00:00
|
|
|
static void
|
|
|
|
pipeline_deep_notify_caps_cb (GstObject * pipeline,
|
|
|
|
GstObject * object, GParamSpec * pspec, GstElement ** dec)
|
|
|
|
{
|
|
|
|
GstObject *pad_parent;
|
|
|
|
|
|
|
|
if (!GST_IS_PAD (object))
|
|
|
|
return;
|
|
|
|
|
|
|
|
pad_parent = gst_object_get_parent (object);
|
|
|
|
|
|
|
|
if (GST_IS_ELEMENT (pad_parent) && *dec == NULL) {
|
|
|
|
GstElementFactory *factory;
|
|
|
|
GstElement *element;
|
|
|
|
const gchar *klass;
|
|
|
|
|
|
|
|
element = GST_ELEMENT_CAST (pad_parent);
|
|
|
|
if ((factory = gst_element_get_factory (element)) &&
|
|
|
|
(klass =
|
|
|
|
gst_element_factory_get_metadata (factory,
|
|
|
|
GST_ELEMENT_METADATA_KLASS)) && strstr (klass, "Video")
|
|
|
|
&& strstr (klass, "Decoder")) {
|
|
|
|
*dec = gst_object_ref (element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pad_parent)
|
|
|
|
gst_object_unref (pad_parent);
|
|
|
|
}
|
|
|
|
|
2011-03-15 10:41:14 +00:00
|
|
|
static GstElement *
|
|
|
|
create_playbin (const gchar * uri, gboolean set_sink)
|
|
|
|
{
|
|
|
|
GstElement *playbin, *sink;
|
|
|
|
|
2011-06-14 23:35:58 +00:00
|
|
|
playbin = gst_element_factory_make ("playbin", "playbin");
|
2011-03-15 10:41:14 +00:00
|
|
|
fail_unless (playbin != NULL, "Failed to create playbin element");
|
|
|
|
|
|
|
|
if (set_sink) {
|
|
|
|
sink = gst_element_factory_make ("videocodecsink", NULL);
|
|
|
|
fail_unless (sink != NULL, "Failed to create videocodecsink element");
|
|
|
|
|
|
|
|
/* Set sync to FALSE to prevent buffers from being dropped because
|
|
|
|
* they're too late */
|
|
|
|
g_object_set (sink, "sync", FALSE, NULL);
|
|
|
|
|
|
|
|
g_object_set (playbin, "video-sink", sink, NULL);
|
|
|
|
|
|
|
|
sink = gst_element_factory_make ("audiocodecsink", NULL);
|
|
|
|
fail_unless (sink != NULL, "Failed to create audiocodecsink");
|
|
|
|
|
|
|
|
/* Set sync to FALSE to prevent buffers from being dropped because
|
|
|
|
* they're too late */
|
|
|
|
g_object_set (sink, "sync", FALSE, NULL);
|
|
|
|
|
|
|
|
g_object_set (playbin, "audio-sink", sink, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_set (playbin, "uri", uri, NULL);
|
|
|
|
|
|
|
|
return playbin;
|
|
|
|
}
|
|
|
|
|
2013-06-10 11:43:35 +00:00
|
|
|
GST_START_TEST (test_autoplug_decoder_sink_combination)
|
|
|
|
{
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *decoder = NULL;
|
2013-08-13 11:43:32 +00:00
|
|
|
GstElement *sink, *asink;
|
2013-06-10 11:43:35 +00:00
|
|
|
gchar *path, *uri;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "faketheoradec1",
|
|
|
|
GST_RANK_PRIMARY + 1, gst_video_decoder1_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "faketheoradec2",
|
|
|
|
GST_RANK_PRIMARY + 1, gst_video_decoder2_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "fakevideosink1",
|
|
|
|
GST_RANK_PRIMARY + 1, gst_video_sink1_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "fakevideosink2",
|
|
|
|
GST_RANK_PRIMARY + 1, gst_video_sink2_get_type ()));
|
|
|
|
|
|
|
|
path = g_build_filename (GST_TEST_FILES_PATH, "theora-vorbis.ogg", NULL);
|
|
|
|
uri = gst_filename_to_uri (path, NULL);
|
|
|
|
g_free (path);
|
|
|
|
|
|
|
|
playbin = create_playbin (uri, FALSE);
|
2014-02-10 15:33:35 +00:00
|
|
|
g_free (uri);
|
2013-06-10 11:43:35 +00:00
|
|
|
|
2013-08-13 11:43:32 +00:00
|
|
|
asink = gst_element_factory_make ("fakesink", NULL);
|
|
|
|
g_object_set (asink, "sync", TRUE, NULL);
|
|
|
|
g_object_set (playbin, "audio-sink", asink, NULL);
|
|
|
|
|
2013-06-10 11:43:35 +00:00
|
|
|
g_signal_connect (playbin, "deep-notify::caps",
|
|
|
|
G_CALLBACK (pipeline_deep_notify_caps_cb), &decoder);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
fail_unless_equals_int (gst_element_get_state (playbin, NULL, NULL, -1),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
/* there shouldn't be any errors */
|
|
|
|
fail_if (gst_bus_poll (GST_ELEMENT_BUS (playbin), GST_MESSAGE_ERROR,
|
|
|
|
0) != NULL);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) == gst_video_sink1_get_type ());
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
fail_unless (decoder != NULL);
|
|
|
|
{
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (decoder) ==
|
|
|
|
gst_video_decoder1_get_type ());
|
|
|
|
gst_object_unref (decoder);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2011-03-15 10:41:14 +00:00
|
|
|
GST_START_TEST (test_raw_single_video_stream_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin =
|
|
|
|
create_playbin
|
2011-06-16 11:41:25 +00:00
|
|
|
("caps:video/x-raw, "
|
|
|
|
"format=(string)I420, "
|
2011-03-15 10:41:14 +00:00
|
|
|
"width=(int)320, "
|
|
|
|
"height=(int)240, "
|
|
|
|
"framerate=(fraction)0/1, " "pixel-aspect-ratio=(fraction)1/1", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->raw == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, NBUFFERS);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_compressed_single_video_stream_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:video/x-compressed", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, NBUFFERS);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_raw_single_video_stream_demuxer_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)raw-video, " "stream1=(string)none", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->raw == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, NBUFFERS);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_compressed_single_video_stream_demuxer_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)compressed-video, " "stream1=(string)none", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, NBUFFERS);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_raw_single_audio_stream_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin =
|
|
|
|
create_playbin
|
2011-09-29 11:46:36 +00:00
|
|
|
("caps:audio/x-raw,"
|
2014-10-24 12:09:42 +00:00
|
|
|
" format=(string)" GST_AUDIO_NE (S16) ", " "layout=(string)interleaved, "
|
2012-04-03 16:30:38 +00:00
|
|
|
" rate=(int)48000, " " channels=(int)2", TRUE);
|
2011-03-15 10:41:14 +00:00
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->raw == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, NBUFFERS);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_compressed_single_audio_stream_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:audio/x-compressed", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, NBUFFERS);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_raw_single_audio_stream_demuxer_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)raw-audio, " "stream1=(string)none", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->raw == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, NBUFFERS);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_compressed_single_audio_stream_demuxer_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)compressed-audio, " "stream1=(string)none", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, NBUFFERS);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_raw_audio_video_stream_demuxer_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)raw-audio, " "stream1=(string)raw-video", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->raw == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, NBUFFERS);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->raw == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, NBUFFERS);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_compressed_audio_video_stream_demuxer_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)compressed-audio, " "stream1=(string)compressed-video",
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, NBUFFERS);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->raw == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, NBUFFERS);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_raw_compressed_video_stream_demuxer_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)raw-video, " "stream1=(string)compressed-video", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw + csink->n_compressed, NBUFFERS);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_raw_compressed_audio_stream_demuxer_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)raw-audio, " "stream1=(string)compressed-audio", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw + csink->n_compressed, NBUFFERS);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2013-05-28 16:59:22 +00:00
|
|
|
GST_START_TEST (test_raw_raw_audio_stream_adder_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *adder;
|
|
|
|
GstElement *playbin_combiner;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean adder_used = FALSE;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)raw-audio, " "stream1=(string)raw-audio", TRUE);
|
|
|
|
|
|
|
|
/* before playback starts, and with no custom combiner, these should all be NULL */
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-stream-combiner", &playbin_combiner,
|
|
|
|
NULL);
|
|
|
|
fail_unless (playbin_combiner == NULL);
|
|
|
|
g_object_get (G_OBJECT (playbin), "text-stream-combiner", &playbin_combiner,
|
|
|
|
NULL);
|
|
|
|
fail_unless (playbin_combiner == NULL);
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-stream-combiner", &playbin_combiner,
|
|
|
|
NULL);
|
|
|
|
fail_unless (playbin_combiner == NULL);
|
|
|
|
|
|
|
|
/* set audio combiner */
|
|
|
|
adder = gst_element_factory_make ("adder", NULL);
|
|
|
|
fail_unless (adder != NULL);
|
|
|
|
g_object_set (G_OBJECT (playbin), "audio-stream-combiner", adder, NULL);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
/* audio combiner should still be there */
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-stream-combiner", &playbin_combiner,
|
|
|
|
NULL);
|
|
|
|
fail_unless (playbin_combiner == adder);
|
2013-05-29 08:35:11 +00:00
|
|
|
gst_object_unref (playbin_combiner);
|
2013-05-28 16:59:22 +00:00
|
|
|
|
|
|
|
/* text and video combiners should still be NULL */
|
|
|
|
g_object_get (G_OBJECT (playbin), "text-stream-combiner", &playbin_combiner,
|
|
|
|
NULL);
|
|
|
|
fail_unless (playbin_combiner == NULL);
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-stream-combiner", &playbin_combiner,
|
|
|
|
NULL);
|
|
|
|
fail_unless (playbin_combiner == NULL);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_STATE_CHANGED:
|
|
|
|
if (GST_MESSAGE_SRC (msg) == GST_OBJECT (adder)) {
|
|
|
|
GstState state;
|
|
|
|
gst_message_parse_state_changed (msg, &state, NULL, NULL);
|
|
|
|
if (state == GST_STATE_PAUSED)
|
|
|
|
adder_used = TRUE;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
fail_unless (adder_used);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, NBUFFERS);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2011-05-09 10:50:06 +00:00
|
|
|
#if 0
|
2011-03-15 10:41:14 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
} SwitchBufferProbeCtx;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
switch_video_buffer_probe (GstPad * pad, GstBuffer * buffer,
|
|
|
|
SwitchBufferProbeCtx * ctx)
|
|
|
|
{
|
|
|
|
GstElement *playbin = ctx->playbin;
|
|
|
|
GstVideoCodecSink *sink = (GstVideoCodecSink *) ctx->sink;
|
|
|
|
|
|
|
|
if (sink->n_raw + sink->n_compressed == NBUFFERS / 2) {
|
|
|
|
gint cur_video;
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "current-video", &cur_video, NULL);
|
|
|
|
cur_video = (cur_video == 0) ? 1 : 0;
|
|
|
|
g_object_set (G_OBJECT (playbin), "current-video", cur_video, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_raw_compressed_video_stream_demuxer_switch_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
GstPad *pad;
|
|
|
|
SwitchBufferProbeCtx switch_ctx;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)raw-video, " "stream1=(string)compressed-video", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
pad = gst_element_get_static_pad (sink, "sink");
|
|
|
|
fail_unless (pad != NULL);
|
|
|
|
switch_ctx.playbin = playbin;
|
|
|
|
switch_ctx.sink = sink;
|
|
|
|
gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_video_buffer_probe),
|
|
|
|
&switch_ctx);
|
|
|
|
gst_object_unref (pad);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->n_raw > 0);
|
|
|
|
fail_unless (csink->n_compressed > 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_compressed_raw_video_stream_demuxer_switch_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
GstPad *pad;
|
|
|
|
SwitchBufferProbeCtx switch_ctx;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)compressed-video, " "stream1=(string)raw-video", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
pad = gst_element_get_static_pad (sink, "sink");
|
|
|
|
fail_unless (pad != NULL);
|
|
|
|
switch_ctx.playbin = playbin;
|
|
|
|
switch_ctx.sink = sink;
|
|
|
|
gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_video_buffer_probe),
|
|
|
|
&switch_ctx);
|
|
|
|
gst_object_unref (pad);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->n_raw > 0);
|
|
|
|
fail_unless (csink->n_compressed > 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_raw_raw_video_stream_demuxer_switch_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
GstPad *pad;
|
|
|
|
SwitchBufferProbeCtx switch_ctx;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)raw-video, " "stream1=(string)raw-video", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
pad = gst_element_get_static_pad (sink, "sink");
|
|
|
|
fail_unless (pad != NULL);
|
|
|
|
switch_ctx.playbin = playbin;
|
|
|
|
switch_ctx.sink = sink;
|
|
|
|
gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_video_buffer_probe),
|
|
|
|
&switch_ctx);
|
|
|
|
gst_object_unref (pad);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless (csink->n_raw > 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST
|
|
|
|
(test_compressed_compressed_video_stream_demuxer_switch_manual_sink) {
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
GstPad *pad;
|
|
|
|
SwitchBufferProbeCtx switch_ctx;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)compressed-video, " "stream1=(string)compressed-video",
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
pad = gst_element_get_static_pad (sink, "sink");
|
|
|
|
fail_unless (pad != NULL);
|
|
|
|
switch_ctx.playbin = playbin;
|
|
|
|
switch_ctx.sink = sink;
|
|
|
|
gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_video_buffer_probe),
|
|
|
|
&switch_ctx);
|
|
|
|
gst_object_unref (pad);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless (csink->n_compressed > 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
switch_audio_buffer_probe (GstPad * pad, GstBuffer * buffer,
|
|
|
|
SwitchBufferProbeCtx * ctx)
|
|
|
|
{
|
|
|
|
GstElement *playbin = ctx->playbin;
|
|
|
|
GstAudioCodecSink *sink = (GstAudioCodecSink *) ctx->sink;
|
|
|
|
|
|
|
|
if (sink->n_raw + sink->n_compressed == NBUFFERS / 3) {
|
|
|
|
gint cur_audio;
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "current-audio", &cur_audio, NULL);
|
|
|
|
cur_audio = (cur_audio == 0) ? 1 : 0;
|
|
|
|
g_object_set (G_OBJECT (playbin), "current-audio", cur_audio, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_raw_compressed_audio_stream_demuxer_switch_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
GstPad *pad;
|
|
|
|
SwitchBufferProbeCtx switch_ctx;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)raw-audio, " "stream1=(string)compressed-audio", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
pad = gst_element_get_static_pad (sink, "sink");
|
|
|
|
fail_unless (pad != NULL);
|
|
|
|
switch_ctx.playbin = playbin;
|
|
|
|
switch_ctx.sink = sink;
|
|
|
|
gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_audio_buffer_probe),
|
|
|
|
&switch_ctx);
|
|
|
|
gst_object_unref (pad);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->n_raw > 0);
|
|
|
|
fail_unless (csink->n_compressed > 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_compressed_raw_audio_stream_demuxer_switch_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
GstPad *pad;
|
|
|
|
SwitchBufferProbeCtx switch_ctx;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)compressed-audio, " "stream1=(string)raw-audio", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
pad = gst_element_get_static_pad (sink, "sink");
|
|
|
|
fail_unless (pad != NULL);
|
|
|
|
switch_ctx.playbin = playbin;
|
|
|
|
switch_ctx.sink = sink;
|
|
|
|
gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_audio_buffer_probe),
|
|
|
|
&switch_ctx);
|
|
|
|
gst_object_unref (pad);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->n_raw > 0);
|
|
|
|
fail_unless (csink->n_compressed > 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_raw_raw_audio_stream_demuxer_switch_manual_sink)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
GstPad *pad;
|
|
|
|
SwitchBufferProbeCtx switch_ctx;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)raw-audio, " "stream1=(string)raw-audio", TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
pad = gst_element_get_static_pad (sink, "sink");
|
|
|
|
fail_unless (pad != NULL);
|
|
|
|
switch_ctx.playbin = playbin;
|
|
|
|
switch_ctx.sink = sink;
|
|
|
|
gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_audio_buffer_probe),
|
|
|
|
&switch_ctx);
|
|
|
|
gst_object_unref (pad);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless (csink->n_raw > 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST
|
|
|
|
(test_compressed_compressed_audio_stream_demuxer_switch_manual_sink) {
|
|
|
|
GstMessage *msg;
|
|
|
|
GstElement *playbin;
|
|
|
|
GstElement *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
GstPad *pad;
|
|
|
|
SwitchBufferProbeCtx switch_ctx;
|
|
|
|
|
|
|
|
fail_unless (gst_element_register (NULL, "capssrc", GST_RANK_PRIMARY,
|
|
|
|
gst_caps_src_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "codecdemuxer",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_codec_demuxer_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "audiocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_audio_codec_sink_get_type ()));
|
|
|
|
fail_unless (gst_element_register (NULL, "videocodecsink",
|
|
|
|
GST_RANK_PRIMARY + 100, gst_video_codec_sink_get_type ()));
|
|
|
|
|
|
|
|
playbin = create_playbin ("caps:application/x-container, "
|
|
|
|
"stream0=(string)compressed-audio, " "stream1=(string)compressed-audio",
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
pad = gst_element_get_static_pad (sink, "sink");
|
|
|
|
fail_unless (pad != NULL);
|
|
|
|
switch_ctx.playbin = playbin;
|
|
|
|
switch_ctx.sink = sink;
|
|
|
|
gst_pad_add_buffer_probe (pad, G_CALLBACK (switch_audio_buffer_probe),
|
|
|
|
&switch_ctx);
|
|
|
|
gst_object_unref (pad);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (playbin);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_message_unref (msg);
|
|
|
|
}
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "video-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstVideoCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_video_codec_sink_get_type ());
|
|
|
|
csink = (GstVideoCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == FALSE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless_equals_int (csink->n_compressed, 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (playbin), "audio-sink", &sink, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
{
|
|
|
|
GstAudioCodecSink *csink;
|
|
|
|
|
|
|
|
fail_unless (G_TYPE_FROM_INSTANCE (sink) ==
|
|
|
|
gst_audio_codec_sink_get_type ());
|
|
|
|
csink = (GstAudioCodecSink *) sink;
|
|
|
|
fail_unless (csink->audio == TRUE);
|
|
|
|
fail_unless_equals_int (csink->n_raw, 0);
|
|
|
|
fail_unless (csink->n_compressed > 0);
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (playbin, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2011-05-09 10:50:06 +00:00
|
|
|
#endif
|
2011-03-15 10:41:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static Suite *
|
2013-05-29 08:37:55 +00:00
|
|
|
playbin_complex_suite (void)
|
2011-03-15 10:41:14 +00:00
|
|
|
{
|
2013-05-29 08:37:55 +00:00
|
|
|
Suite *s = suite_create ("playbin_complex");
|
2011-03-15 10:41:14 +00:00
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
|
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
|
|
|
tcase_add_test (tc_chain, test_raw_single_video_stream_manual_sink);
|
|
|
|
tcase_add_test (tc_chain, test_raw_single_audio_stream_manual_sink);
|
|
|
|
tcase_add_test (tc_chain, test_compressed_single_video_stream_manual_sink);
|
|
|
|
tcase_add_test (tc_chain, test_compressed_single_audio_stream_manual_sink);
|
|
|
|
|
|
|
|
tcase_add_test (tc_chain, test_raw_single_video_stream_demuxer_manual_sink);
|
|
|
|
tcase_add_test (tc_chain, test_raw_single_audio_stream_demuxer_manual_sink);
|
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_compressed_single_video_stream_demuxer_manual_sink);
|
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_compressed_single_audio_stream_demuxer_manual_sink);
|
|
|
|
|
|
|
|
tcase_add_test (tc_chain, test_raw_audio_video_stream_demuxer_manual_sink);
|
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_compressed_audio_video_stream_demuxer_manual_sink);
|
|
|
|
|
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_raw_compressed_audio_stream_demuxer_manual_sink);
|
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_raw_compressed_video_stream_demuxer_manual_sink);
|
|
|
|
|
2013-05-28 16:59:22 +00:00
|
|
|
tcase_add_test (tc_chain, test_raw_raw_audio_stream_adder_manual_sink);
|
|
|
|
|
2017-09-10 15:32:31 +00:00
|
|
|
if (gst_registry_check_feature_version (gst_registry_get (),
|
|
|
|
"oggdemux", GST_VERSION_MAJOR, GST_VERSION_MINOR, 0)) {
|
|
|
|
tcase_add_test (tc_chain, test_autoplug_decoder_sink_combination);
|
|
|
|
}
|
2011-05-09 10:50:06 +00:00
|
|
|
/* These tests need something like the stream-activate event
|
|
|
|
* and are racy otherwise */
|
|
|
|
#if 0
|
2011-03-15 10:41:14 +00:00
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_raw_raw_audio_stream_demuxer_switch_manual_sink);
|
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_raw_compressed_audio_stream_demuxer_switch_manual_sink);
|
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_compressed_raw_audio_stream_demuxer_switch_manual_sink);
|
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_compressed_compressed_audio_stream_demuxer_switch_manual_sink);
|
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_raw_raw_video_stream_demuxer_switch_manual_sink);
|
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_raw_compressed_video_stream_demuxer_switch_manual_sink);
|
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_compressed_raw_video_stream_demuxer_switch_manual_sink);
|
|
|
|
tcase_add_test (tc_chain,
|
|
|
|
test_compressed_compressed_video_stream_demuxer_switch_manual_sink);
|
2011-05-09 10:50:06 +00:00
|
|
|
#endif
|
2011-03-15 10:41:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2013-05-29 08:37:55 +00:00
|
|
|
GST_CHECK_MAIN (playbin_complex);
|