Merge branch 'master' into 0.11

Conflicts:
	ext/flac/gstflacenc.c
	ext/jack/gstjackaudioclient.c
	ext/jack/gstjackaudiosink.c
	ext/jack/gstjackaudiosrc.c
	ext/pulse/plugin.c
	ext/shout2/gstshout2.c
	gst/matroska/matroska-mux.c
	gst/rtp/gstrtph264pay.c
This commit is contained in:
Wim Taymans 2012-02-10 16:23:14 +01:00
commit 225e98d623
19 changed files with 255 additions and 233 deletions

View file

@ -36,8 +36,8 @@ libgstcairo_la_CFLAGS = \
$(GST_BASE_CFLAGS) \
$(GST_CFLAGS) $(CAIRO_CFLAGS) $(CAIRO_GOBJECT_CFLAGS)
libgstcairo_la_LIBADD = \
$(GST_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) \
$(GST_LIBS) $(CAIRO_LIBS) $(CAIRO_GOBJECT_LIBS) $(LIBM)
$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) \
$(GST_BASE_LIBS) $(GST_LIBS) $(CAIRO_LIBS) $(CAIRO_GOBJECT_LIBS) $(LIBM)
libgstcairo_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstcairo_la_LIBTOOLFLAGS = --tag=disable-static

View file

@ -839,7 +839,6 @@ gst_flac_enc_seek_callback (const FLAC__StreamEncoder * encoder,
FLAC__uint64 absolute_byte_offset, void *client_data)
{
GstFlacEnc *flacenc;
GstEvent *event;
GstPad *peerpad;
GstSegment seg;
@ -848,15 +847,17 @@ gst_flac_enc_seek_callback (const FLAC__StreamEncoder * encoder,
if (flacenc->stopped)
return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
gst_segment_init (&seg, GST_FORMAT_BYTES);
seg.start = absolute_byte_offset;
seg.stop = GST_BUFFER_OFFSET_NONE;
seg.time = 0;
event = gst_event_new_segment (&seg);
if ((peerpad = gst_pad_get_peer (GST_AUDIO_ENCODER_SRC_PAD (flacenc)))) {
gboolean ret = gst_pad_send_event (peerpad, event);
GstEvent *event;
gboolean ret;
gst_segment_init (&seg, GST_FORMAT_BYTES);
seg.start = absolute_byte_offset;
seg.stop = GST_BUFFER_OFFSET_NONE;
seg.time = 0;
event = gst_event_new_segment (&seg);
ret = gst_pad_send_event (peerpad, event);
gst_object_unref (peerpad);
if (ret) {

View file

@ -22,6 +22,7 @@
#include <string.h>
#include "gstjackaudioclient.h"
#include "gstjack.h"
#include <gst/glib-compat-private.h>
@ -77,14 +78,29 @@ struct _GstJackAudioClient
gpointer user_data;
};
typedef jack_default_audio_sample_t sample_t;
typedef struct
{
jack_nframes_t nframes;
gpointer user_data;
} JackCB;
static gboolean
jack_handle_transport_change (GstJackAudioClient * client, GstState state)
{
GstObject *obj = GST_OBJECT_PARENT (client->user_data);
GstJackTransport mode;
g_object_get (obj, "transport", &mode, NULL);
if ((mode == GST_JACK_TRANSPORT_SLAVE) && (GST_STATE (obj) != state)) {
GST_INFO_OBJECT (obj, "requesting state change: %s",
gst_element_state_get_name (state));
gst_element_post_message (GST_ELEMENT (obj),
gst_message_new_request_state (obj, state));
return TRUE;
}
return FALSE;
}
static int
jack_process_cb (jack_nframes_t nframes, void *arg)
{
@ -111,6 +127,8 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
default:
break;
}
GST_DEBUG ("num of clients: src=%d, sink=%d",
g_list_length (conn->src_clients), g_list_length (conn->sink_clients));
}
g_mutex_lock (&conn->lock);
@ -141,7 +159,29 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
}
}
}
/* handle transport state requisition, do sinks first, stop after the first
* element that handled it */
if (conn->transport_state != GST_STATE_VOID_PENDING) {
for (walk = conn->sink_clients; walk; walk = g_list_next (walk)) {
if (jack_handle_transport_change ((GstJackAudioClient *) walk->data,
conn->transport_state)) {
conn->transport_state = GST_STATE_VOID_PENDING;
break;
}
}
}
if (conn->transport_state != GST_STATE_VOID_PENDING) {
for (walk = conn->src_clients; walk; walk = g_list_next (walk)) {
if (jack_handle_transport_change ((GstJackAudioClient *) walk->data,
conn->transport_state)) {
conn->transport_state = GST_STATE_VOID_PENDING;
break;
}
}
}
g_mutex_unlock (&conn->lock);
return res;
}
@ -259,6 +299,7 @@ gst_jack_audio_make_connection (const gchar * id, const gchar * server,
jack_on_shutdown (jclient, jack_shutdown_cb, conn);
/* all callbacks are set, activate the client */
GST_INFO ("activate jack_client %p", jclient);
if ((res = jack_activate (jclient)))
goto could_not_activate;
@ -353,6 +394,7 @@ gst_jack_audio_unref_connection (GstJackAudioConnection * conn)
* waiting for the JACK thread, and can thus cause deadlock in
* jack_process_cb()
*/
GST_INFO ("deactivate jack_client %p", conn->client);
if ((res = jack_deactivate (conn->client))) {
/* we only warn, this means the server is probably shut down and the client
* is gone anyway. */

View file

@ -197,18 +197,6 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
channels = GST_AUDIO_INFO_CHANNELS (&buf->spec.info);
/* handle transport state requisitions */
if (sink->transport == GST_JACK_TRANSPORT_SLAVE) {
GstState state = gst_jack_audio_client_get_transport_state (sink->client);
if ((state != GST_STATE_VOID_PENDING) && (GST_STATE (sink) != state)) {
GST_DEBUG_OBJECT (sink, "requesting state change: %s",
gst_element_state_get_name (state));
gst_element_post_message (GST_ELEMENT (sink),
gst_message_new_request_state (GST_OBJECT (sink), state));
}
}
/* get target buffers */
for (i = 0; i < channels; i++) {
sink->buffers[i] =

View file

@ -217,18 +217,6 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
channels = GST_AUDIO_INFO_CHANNELS (&buf->spec.info);
/* handle transport state requisitions */
if (src->transport == GST_JACK_TRANSPORT_SLAVE) {
GstState state = gst_jack_audio_client_get_transport_state (src->client);
if ((state != GST_STATE_VOID_PENDING) && (GST_STATE (src) != state)) {
GST_DEBUG_OBJECT (src, "requesting state change: %s",
gst_element_state_get_name (state));
gst_element_post_message (GST_ELEMENT (src),
gst_message_new_request_state (GST_OBJECT (src), state));
}
}
/* get input buffers */
for (i = 0; i < channels; i++)
src->buffers[i] =

View file

@ -1,6 +1,7 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2006> Tim-Philipp Müller <tim centricular net>
* Copyright (C) <2012> Ralph Giles <giles@mozilla.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -70,12 +71,17 @@ enum
static GstElementClass *parent_class = NULL;
#ifdef SHOUT_FORMAT_WEBM
#define WEBM_CAPS "; video/webm"
#else
#define WEBM_CAPS ""
#endif
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/ogg; "
"audio/mpeg, mpegversion = (int) 1, layer = (int) [ 1, 3 ]")
);
"audio/mpeg, mpegversion = (int) 1, layer = (int) [ 1, 3 ]" WEBM_CAPS));
static void gst_shout2send_class_init (GstShout2sendClass * klass);
static void gst_shout2send_base_init (GstShout2sendClass * klass);
static void gst_shout2send_init (GstShout2send * shout2send);
@ -162,6 +168,7 @@ gst_shout2send_base_init (GstShout2sendClass * klass)
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template));
gst_element_class_set_details_simple (element_class, "Icecast network sink",
"Sink/Network", "Sends data to an icecast server",
"Wim Taymans <wim.taymans@chello.be>, "
@ -538,9 +545,14 @@ set_failed:
static gboolean
gst_shout2send_connect (GstShout2send * sink)
{
GST_DEBUG_OBJECT (sink, "Connection format is: %s",
const char *format =
(sink->audio_format == SHOUT_FORMAT_VORBIS) ? "vorbis" :
((sink->audio_format == SHOUT_FORMAT_MP3) ? "mp3" : "unknown"));
((sink->audio_format == SHOUT_FORMAT_MP3) ? "mp3" : "unknown");
#ifdef SHOUT_FORMAT_WEBM
if (sink->audio_format == SHOUT_FORMAT_WEBM)
format = "webm";
#endif
GST_DEBUG_OBJECT (sink, "Connection format is: %s", format);
if (shout_set_format (sink->conn, sink->audio_format) != SHOUTERR_SUCCESS)
goto could_not_set_format;
@ -810,6 +822,10 @@ gst_shout2send_setcaps (GstPad * pad, GstCaps * caps)
shout2send->audio_format = SHOUT_FORMAT_MP3;
} else if (!strcmp (mimetype, "application/ogg")) {
shout2send->audio_format = SHOUT_FORMAT_VORBIS;
#ifdef SHOUT_FORMAT_WEBM
} else if (!strcmp (mimetype, "video/webm")) {
shout2send->audio_format = SHOUT_FORMAT_WEBM;
#endif
} else {
ret = FALSE;
}

View file

@ -63,7 +63,7 @@ static GstStaticPadTemplate audio_src_template =
GST_STATIC_CAPS
("audio/x-adpcm, layout = (string) swf, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "
"audio/mpeg, mpegversion = (int) 1, layer = (int) 3, channels = (int) { 1, 2 }, rate = (int) { 5512, 8000, 11025, 22050, 44100 }, parsed = (boolean) TRUE; "
"audio/mpeg, mpegversion = (int) 4, framed = (boolean) TRUE; "
"audio/mpeg, mpegversion = (int) 4, stream-format = (string) raw, framed = (boolean) TRUE; "
"audio/x-nellymoser, channels = (int) { 1, 2 }, rate = (int) { 5512, 8000, 11025, 16000, 22050, 44100 }; "
"audio/x-raw, format = (string) { U8, S16LE }, layout = (string) interleaved, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "
"audio/x-alaw, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "

View file

@ -76,7 +76,8 @@ static GstStaticPadTemplate audiosink_templ = GST_STATIC_PAD_TEMPLATE ("audio",
GST_STATIC_CAPS
("audio/x-adpcm, layout = (string) swf, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "
"audio/mpeg, mpegversion = (int) 1, layer = (int) 3, channels = (int) { 1, 2 }, rate = (int) { 5512, 8000, 11025, 22050, 44100 }, parsed = (boolean) TRUE; "
"audio/mpeg, mpegversion = (int) { 2, 4 }, framed = (boolean) TRUE; "
"audio/mpeg, mpegversion = (int) 2, framed = (boolean) TRUE; "
"audio/mpeg, mpegversion = (int) 4, stream-format = (string) raw, framed = (boolean) TRUE; "
"audio/x-nellymoser, channels = (int) { 1, 2 }, rate = (int) { 5512, 8000, 11025, 16000, 22050, 44100 }; "
"audio/x-raw, format = (string) { U8, S16LE}, layout = (string) interleaved, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "
"audio/x-alaw, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "

View file

@ -3549,10 +3549,12 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
demux->common.segment.duration =
last_stop_end - demux->stream_start_time;
GST_OBJECT_UNLOCK (demux);
gst_element_post_message (GST_ELEMENT_CAST (demux),
gst_message_new_duration (GST_OBJECT_CAST (demux),
GST_FORMAT_TIME, GST_CLOCK_TIME_NONE));
demux->invalid_duration = TRUE;
if (!demux->invalid_duration) {
gst_element_post_message (GST_ELEMENT_CAST (demux),
gst_message_new_duration (GST_OBJECT_CAST (demux),
GST_FORMAT_TIME, GST_CLOCK_TIME_NONE));
demux->invalid_duration = TRUE;
}
} else {
GST_OBJECT_UNLOCK (demux);
}

View file

@ -1955,7 +1955,6 @@ gst_matroska_mux_subtitle_pad_setcaps (GstPad * pad, GstCaps * caps)
GstStructure *structure;
const GValue *value = NULL;
GstBuffer *buf = NULL;
gchar *id = NULL;
gboolean ret = TRUE;
mux = GST_MATROSKA_MUX (GST_PAD_PARENT (pad));
@ -1971,9 +1970,6 @@ gst_matroska_mux_subtitle_pad_setcaps (GstPad * pad, GstCaps * caps)
structure = gst_caps_get_structure (caps, 0);
mimetype = gst_structure_get_name (structure);
/* keep track of default set in request_pad */
id = context->codec_id;
/* general setup */
scontext->check_utf8 = 1;
scontext->invalid_utf8 = 0;
@ -2007,7 +2003,6 @@ gst_matroska_mux_subtitle_pad_setcaps (GstPad * pad, GstCaps * caps)
gst_matroska_mux_set_codec_id (context,
GST_MATROSKA_CODEC_ID_SUBTITLE_VOBSUB);
} else {
id = NULL;
ret = FALSE;
goto exit;
}
@ -2043,9 +2038,6 @@ gst_matroska_mux_subtitle_pad_setcaps (GstPad * pad, GstCaps * caps)
GST_STR_NULL (context->codec_id), context->codec_priv_size);
exit:
/* free default if modified */
if (id)
g_free (id);
return ret;
}

View file

@ -46,10 +46,13 @@ enum
static const guint8 sync_bytes[] = { 0, 0, 0, 1 };
static GstStaticPadTemplate gst_rtp_h264_depay_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-h264")
GST_STATIC_CAPS ("video/x-h264, "
"stream-format = (string) avc, alignment = (string) au; "
"video/x-h264, "
"stream-format = (string) byte-stream, alignment = (string) { nal, au }")
);
static GstStaticPadTemplate gst_rtp_h264_depay_sink_template =
@ -735,8 +738,9 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
*/
nalu_size = (payload[0] << 8) | payload[1];
if (nalu_size > payload_len)
nalu_size = payload_len;
/* dont include nalu_size */
if (nalu_size > (payload_len - 2))
nalu_size = payload_len - 2;
outsize = nalu_size + sizeof (sync_bytes);
outbuf = gst_buffer_new_and_alloc (outsize);

View file

@ -45,10 +45,13 @@ GST_DEBUG_CATEGORY_STATIC (rtph264pay_debug);
*/
static GstStaticPadTemplate gst_rtp_h264_pay_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-h264")
GST_STATIC_CAPS ("video/x-h264, "
"stream-format = (string) byte-stream, alignment = (string) { nal, au };"
"video/x-h264, "
"stream-format = (string) avc, alignment = (string) au")
);
static GstStaticPadTemplate gst_rtp_h264_pay_src_template =
@ -267,98 +270,110 @@ static GstCaps *
gst_rtp_h264_pay_getcaps (GstRTPBasePayload * payload, GstPad * pad,
GstCaps * filter)
{
GstCaps *template_caps;
GstCaps *allowed_caps;
GstCaps *caps, *icaps;
guint i;
allowed_caps =
gst_pad_peer_query_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload), filter);
if (allowed_caps) {
GstCaps *caps = NULL;
guint i;
if (allowed_caps == NULL)
return NULL;
if (gst_caps_is_any (allowed_caps)) {
gst_caps_unref (allowed_caps);
goto any;
}
template_caps =
gst_static_pad_template_get_caps (&gst_rtp_h264_pay_sink_template);
if (gst_caps_is_empty (allowed_caps))
return allowed_caps;
caps = gst_caps_new_empty ();
for (i = 0; i < gst_caps_get_size (allowed_caps); i++) {
GstStructure *s = gst_caps_get_structure (allowed_caps, i);
GstStructure *new_s = gst_structure_new_empty ("video/x-h264");
const gchar *profile_level_id;
profile_level_id = gst_structure_get_string (s, "profile-level-id");
if (profile_level_id && strlen (profile_level_id) == 6) {
const gchar *profile;
const gchar *level;
long int spsint;
guint8 sps[3];
spsint = strtol (profile_level_id, NULL, 16);
sps[0] = spsint >> 16;
sps[1] = spsint >> 8;
sps[2] = spsint;
profile = gst_codec_utils_h264_get_profile (sps, 3);
level = gst_codec_utils_h264_get_level (sps, 3);
if (profile && level) {
GST_LOG_OBJECT (payload, "In caps, have profile %s and level %s",
profile, level);
if (!strcmp (profile, "constrained-baseline"))
gst_structure_set (new_s, "profile", G_TYPE_STRING, profile, NULL);
else {
GValue val = { 0, };
GValue profiles = { 0, };
g_value_init (&profiles, GST_TYPE_LIST);
g_value_init (&val, G_TYPE_STRING);
g_value_set_static_string (&val, profile);
gst_value_list_append_value (&profiles, &val);
g_value_set_static_string (&val, "constrained-baseline");
gst_value_list_append_value (&profiles, &val);
gst_structure_take_value (new_s, "profile", &profiles);
}
if (!strcmp (level, "1"))
gst_structure_set (new_s, "level", G_TYPE_STRING, level, NULL);
else {
GValue levels = { 0, };
GValue val = { 0, };
int j;
g_value_init (&levels, GST_TYPE_LIST);
g_value_init (&val, G_TYPE_STRING);
for (j = 0; all_levels[j]; j++) {
g_value_set_static_string (&val, all_levels[j]);
gst_value_list_prepend_value (&levels, &val);
if (!strcmp (level, all_levels[j]))
break;
}
gst_structure_take_value (new_s, "level", &levels);
}
}
}
gst_caps_merge_structure (caps, new_s);
}
gst_caps_unref (allowed_caps);
return caps;
if (gst_caps_is_any (allowed_caps)) {
caps = gst_caps_ref (template_caps);
goto done;
}
any:
return gst_caps_new_empty_simple ("video/x-h264");
if (gst_caps_is_empty (allowed_caps)) {
caps = gst_caps_ref (allowed_caps);
goto done;
}
caps = gst_caps_new_empty ();
for (i = 0; i < gst_caps_get_size (allowed_caps); i++) {
GstStructure *s = gst_caps_get_structure (allowed_caps, i);
GstStructure *new_s = gst_structure_new_empty ("video/x-h264");
const gchar *profile_level_id;
profile_level_id = gst_structure_get_string (s, "profile-level-id");
if (profile_level_id && strlen (profile_level_id) == 6) {
const gchar *profile;
const gchar *level;
long int spsint;
guint8 sps[3];
spsint = strtol (profile_level_id, NULL, 16);
sps[0] = spsint >> 16;
sps[1] = spsint >> 8;
sps[2] = spsint;
profile = gst_codec_utils_h264_get_profile (sps, 3);
level = gst_codec_utils_h264_get_level (sps, 3);
if (profile && level) {
GST_LOG_OBJECT (payload, "In caps, have profile %s and level %s",
profile, level);
if (!strcmp (profile, "constrained-baseline"))
gst_structure_set (new_s, "profile", G_TYPE_STRING, profile, NULL);
else {
GValue val = { 0, };
GValue profiles = { 0, };
g_value_init (&profiles, GST_TYPE_LIST);
g_value_init (&val, G_TYPE_STRING);
g_value_set_static_string (&val, profile);
gst_value_list_append_value (&profiles, &val);
g_value_set_static_string (&val, "constrained-baseline");
gst_value_list_append_value (&profiles, &val);
gst_structure_take_value (new_s, "profile", &profiles);
}
if (!strcmp (level, "1"))
gst_structure_set (new_s, "level", G_TYPE_STRING, level, NULL);
else {
GValue levels = { 0, };
GValue val = { 0, };
int j;
g_value_init (&levels, GST_TYPE_LIST);
g_value_init (&val, G_TYPE_STRING);
for (j = 0; all_levels[j]; j++) {
g_value_set_static_string (&val, all_levels[j]);
gst_value_list_prepend_value (&levels, &val);
if (!strcmp (level, all_levels[j]))
break;
}
gst_structure_take_value (new_s, "level", &levels);
}
}
}
gst_caps_merge_structure (caps, new_s);
}
icaps = gst_caps_intersect (caps, template_caps);
gst_caps_unref (caps);
caps = icaps;
done:
gst_caps_unref (template_caps);
gst_caps_unref (allowed_caps);
GST_LOG_OBJECT (payload, "returning caps %" GST_PTR_FORMAT, caps);
return caps;
}
/* take the currently configured SPS and PPS lists and set them on the caps as

View file

@ -124,6 +124,8 @@ gst_rtp_mp2t_pay_flush (GstRTPMP2TPay * rtpmp2tpay)
GstRTPBuffer rtp = { NULL };
avail = gst_adapter_available (rtpmp2tpay->adapter);
if (avail == 0)
return GST_FLOW_OK;
outbuf = gst_rtp_buffer_new_allocate (avail, 0, 0);
/* get payload */

View file

@ -1901,7 +1901,7 @@ gst_rtp_bin_init (GstRtpBin * rtpbin)
rtpbin->use_pipeline_clock = DEFAULT_USE_PIPELINE_CLOCK;
/* some default SDES entries */
cname = g_strdup_printf ("user%u@x-%u.net", g_random_int (), g_random_int ());
cname = g_strdup_printf ("user%u@host-%x", g_random_int (), g_random_int ());
rtpbin->sdes = gst_structure_new ("application/x-rtp-source-sdes",
"cname", G_TYPE_STRING, cname, "tool", G_TYPE_STRING, "GStreamer", NULL);
g_free (cname);

View file

@ -488,7 +488,7 @@ rtp_session_init (RTPSession * sess)
/* some default SDES entries */
/* we do not want to leak details like the username or hostname here */
str = g_strdup_printf ("user%u@x-%u.net", g_random_int (), g_random_int ());
str = g_strdup_printf ("user%u@host-%x", g_random_int (), g_random_int ());
rtp_source_set_sdes_string (sess->source, GST_RTCP_SDES_CNAME, str);
g_free (str);

View file

@ -240,7 +240,7 @@ gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BYTES_SERVED,
g_param_spec_uint64 ("bytes-served", "Bytes served",
"Total number of bytes send to all clients", 0, G_MAXUINT64, 0,
"Total number of bytes sent to all clients", 0, G_MAXUINT64, 0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_SOCKET,
g_param_spec_object ("socket", "Socket Handle",

View file

@ -3270,8 +3270,8 @@ static void
gst_video_box_process (GstVideoBox * video_box, const guint8 * src,
guint8 * dest)
{
guint b_alpha = CLAMP (video_box->border_alpha * 256, 0, 256);
guint i_alpha = CLAMP (video_box->alpha * 256, 0, 256);
guint b_alpha = CLAMP (video_box->border_alpha * 256, 0, 255);
guint i_alpha = CLAMP (video_box->alpha * 256, 0, 255);
GstVideoBoxFill fill_type = video_box->fill_type;
gint br, bl, bt, bb, crop_w, crop_h;

View file

@ -41,8 +41,6 @@ GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS (SRC_CAPS_TMPL)
);
const gchar *factory = "aacparse";
/* some data */
static guint8 mp3_frame[384] = {
0xff, 0xfb, 0x94, 0xc4, 0xff, 0x83, 0xc0, 0x00,

View file

@ -31,13 +31,11 @@
typedef struct
{
GstElement *pipeline;
GstElement *fdsrc;
GstElement *capsfilter;
GstElement *appsrc;
GstElement *rtppay;
GstElement *rtpdepay;
GstElement *fakesink;
int fd[2];
const char *frame_data;
const guint8 *frame_data;
int frame_data_size;
int frame_count;
} rtp_pipeline;
@ -134,13 +132,11 @@ rtp_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
* The user must free the RTP pipeline when it's not used anymore.
*/
static rtp_pipeline *
rtp_pipeline_create (const char *frame_data, int frame_data_size,
rtp_pipeline_create (const guint8 * frame_data, int frame_data_size,
int frame_count, const char *filtercaps, const char *pay, const char *depay)
{
gchar *pipeline_name;
rtp_pipeline *p;
GstCaps *caps;
/* Check parameters. */
@ -159,60 +155,39 @@ rtp_pipeline_create (const char *frame_data, int frame_data_size,
pipeline_name = g_strdup_printf ("%s-%s-pipeline", pay, depay);
p->pipeline = gst_pipeline_new (pipeline_name);
g_free (pipeline_name);
p->fdsrc = gst_element_factory_make ("fdsrc", NULL);
p->capsfilter = gst_element_factory_make ("capsfilter", NULL);
p->appsrc = gst_element_factory_make ("appsrc", NULL);
p->rtppay = gst_element_factory_make (pay, NULL);
p->rtpdepay = gst_element_factory_make (depay, NULL);
p->fakesink = gst_element_factory_make ("fakesink", NULL);
/* One or more elements are not created successfully or failed to create p? */
if (!p->pipeline || !p->fdsrc || !p->capsfilter || !p->rtppay || !p->rtpdepay
|| !p->fakesink || pipe (p->fd) == -1) {
if (!p->pipeline || !p->appsrc || !p->rtppay || !p->rtpdepay || !p->fakesink) {
/* Release created elements. */
RELEASE_ELEMENT (p->pipeline);
RELEASE_ELEMENT (p->fdsrc);
RELEASE_ELEMENT (p->capsfilter);
RELEASE_ELEMENT (p->appsrc);
RELEASE_ELEMENT (p->rtppay);
RELEASE_ELEMENT (p->rtpdepay);
RELEASE_ELEMENT (p->fakesink);
/* Close pipe. */
if (p->fd[0]) {
close (p->fd[0]);
}
if (p->fd[1]) {
close (p->fd[1]);
}
/* Release allocated memory. */
free (p);
return NULL;
}
/* Set fdsrc properties. */
g_object_set (p->fdsrc, "fd", p->fd[0], NULL);
g_object_set (p->fdsrc, "do-timestamp", TRUE, NULL);
g_object_set (p->fdsrc, "blocksize", p->frame_data_size, NULL);
g_object_set (p->fdsrc, "num-buffers", p->frame_count * LOOP_COUNT, NULL);
/* Set caps filters. */
/* Set src properties. */
caps = gst_caps_from_string (filtercaps);
g_object_set (p->capsfilter, "caps", caps, NULL);
g_object_set (p->appsrc, "do-timestamp", TRUE, "caps", caps, NULL);
gst_caps_unref (caps);
/* Add elements to the pipeline. */
gst_bin_add (GST_BIN (p->pipeline), p->fdsrc);
gst_bin_add (GST_BIN (p->pipeline), p->capsfilter);
gst_bin_add (GST_BIN (p->pipeline), p->appsrc);
gst_bin_add (GST_BIN (p->pipeline), p->rtppay);
gst_bin_add (GST_BIN (p->pipeline), p->rtpdepay);
gst_bin_add (GST_BIN (p->pipeline), p->fakesink);
/* Link elements. */
gst_element_link (p->fdsrc, p->capsfilter);
gst_element_link (p->capsfilter, p->rtppay);
gst_element_link (p->appsrc, p->rtppay);
gst_element_link (p->rtppay, p->rtpdepay);
gst_element_link (p->rtpdepay, p->fakesink);
@ -234,15 +209,6 @@ rtp_pipeline_destroy (rtp_pipeline * p)
/* Release pipeline. */
RELEASE_ELEMENT (p->pipeline);
/* Close pipe. */
if (p->fd[0]) {
close (p->fd[0]);
}
if (p->fd[1]) {
close (p->fd[1]);
}
/* Release allocated memory. */
free (p);
}
@ -254,11 +220,10 @@ rtp_pipeline_destroy (rtp_pipeline * p)
static void
rtp_pipeline_run (rtp_pipeline * p)
{
GstFlowReturn flow_ret;
GMainLoop *mainloop = NULL;
GstBus *bus;
gint i;
gint i, j;
/* Check parameters. */
if (p == NULL) {
@ -280,22 +245,27 @@ rtp_pipeline_run (rtp_pipeline * p)
/* Set pipeline to PLAYING. */
gst_element_set_state (p->pipeline, GST_STATE_PLAYING);
/* TODO: Writing may need some changes... */
/* Push data into the pipeline */
for (i = 0; i < LOOP_COUNT; i++) {
const char *frame_data_pointer = p->frame_data;
int res;
int frame_count = p->frame_count;
const guint8 *data = p->frame_data;
/* Write in to the pipe. */
while (frame_count > 0) {
res = write (p->fd[1], frame_data_pointer, p->frame_data_size);
fail_unless_equals_int (res, p->frame_data_size);
frame_data_pointer += p->frame_data_size;
frame_count--;
for (j = 0; j < p->frame_count; j++) {
GstBuffer *buf;
buf =
gst_buffer_new_wrapped_full ((guint8 *) data, NULL, 0,
p->frame_data_size);
g_signal_emit_by_name (p->appsrc, "push-buffer", buf, &flow_ret);
fail_unless_equals_int (flow_ret, GST_FLOW_OK);
data += p->frame_data_size;
gst_buffer_unref (buf);
}
}
g_signal_emit_by_name (p->appsrc, "end-of-stream", &flow_ret);
/* Run mainloop. */
g_main_loop_run (mainloop);
@ -344,8 +314,8 @@ rtp_pipeline_enable_lists (rtp_pipeline * p, guint mtu_size)
* @use_lists enable buffer lists
*/
static void
rtp_pipeline_test (const char *frame_data, int frame_data_size, int frame_count,
const char *filtercaps, const char *pay, const char *depay,
rtp_pipeline_test (const guint8 * frame_data, int frame_data_size,
int frame_count, const char *filtercaps, const char *pay, const char *depay,
guint bytes_sent, guint mtu_size, gboolean use_lists)
{
/* Create RTP pipeline. */
@ -374,7 +344,7 @@ rtp_pipeline_test (const char *frame_data, int frame_data_size, int frame_count,
}
}
static char rtp_ilbc_frame_data[] =
static const guint8 rtp_ilbc_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -391,7 +361,7 @@ GST_START_TEST (rtp_ilbc)
}
GST_END_TEST;
static char rtp_gsm_frame_data[] =
static const guint8 rtp_gsm_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -408,7 +378,7 @@ GST_START_TEST (rtp_gsm)
}
GST_END_TEST;
static char rtp_amr_frame_data[] =
static const guint8 rtp_amr_frame_data[] =
{ 0x3c, 0x24, 0x03, 0xb3, 0x48, 0x10, 0x68, 0x46, 0x6c, 0xec, 0x03,
0x7a, 0x37, 0x16, 0x41, 0x41, 0xc0, 0x00, 0x0d, 0xcd, 0x12, 0xed,
0xad, 0x80, 0x00, 0x00, 0x11, 0x31, 0x00, 0x00, 0x0d, 0xa0
@ -426,7 +396,7 @@ GST_START_TEST (rtp_amr)
}
GST_END_TEST;
static char rtp_pcma_frame_data[] =
static const guint8 rtp_pcma_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -443,7 +413,7 @@ GST_START_TEST (rtp_pcma)
}
GST_END_TEST;
static char rtp_pcmu_frame_data[] =
static const guint8 rtp_pcmu_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -460,7 +430,7 @@ GST_START_TEST (rtp_pcmu)
}
GST_END_TEST;
static char rtp_mpa_frame_data[] =
static const guint8 rtp_mpa_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -477,7 +447,7 @@ GST_START_TEST (rtp_mpa)
}
GST_END_TEST;
static char rtp_h263_frame_data[] =
static const guint8 rtp_h263_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -489,12 +459,12 @@ static int rtp_h263_frame_count = 1;
GST_START_TEST (rtp_h263)
{
rtp_pipeline_test (rtp_h263_frame_data, rtp_h263_frame_data_size,
rtp_h263_frame_count, "video/x-h263,variant=itu,h263version=h263",
rtp_h263_frame_count, "video/x-h263,variant=(string)itu,h263version=h263",
"rtph263pay", "rtph263depay", 0, 0, FALSE);
}
GST_END_TEST;
static char rtp_h263p_frame_data[] =
static const guint8 rtp_h263p_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -506,12 +476,12 @@ static int rtp_h263p_frame_count = 1;
GST_START_TEST (rtp_h263p)
{
rtp_pipeline_test (rtp_h263p_frame_data, rtp_h263p_frame_data_size,
rtp_h263p_frame_count, "video/x-h263,variant=itu", "rtph263ppay",
rtp_h263p_frame_count, "video/x-h263,variant=(string)itu", "rtph263ppay",
"rtph263pdepay", 0, 0, FALSE);
}
GST_END_TEST;
static char rtp_h264_frame_data[] =
static const guint8 rtp_h264_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -522,13 +492,14 @@ static int rtp_h264_frame_count = 1;
GST_START_TEST (rtp_h264)
{
/* FIXME 0.11: fully specify h264 caps (and make payloader check) */
rtp_pipeline_test (rtp_h264_frame_data, rtp_h264_frame_data_size,
rtp_h264_frame_count, "video/x-h264", "rtph264pay", "rtph264depay",
0, 0, FALSE);
}
GST_END_TEST;
static char rtp_h264_list_lt_mtu_frame_data[] =
static const guint8 rtp_h264_list_lt_mtu_frame_data[] =
/* not packetized, next NAL starts with 0001 */
{ 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
@ -546,6 +517,7 @@ static int rtp_h264_list_lt_mtu_mtu_size = 1024;
GST_START_TEST (rtp_h264_list_lt_mtu)
{
/* FIXME 0.11: fully specify h264 caps (and make payloader check) */
rtp_pipeline_test (rtp_h264_list_lt_mtu_frame_data,
rtp_h264_list_lt_mtu_frame_data_size, rtp_h264_list_lt_mtu_frame_count,
"video/x-h264", "rtph264pay", "rtph264depay",
@ -553,7 +525,7 @@ GST_START_TEST (rtp_h264_list_lt_mtu)
}
GST_END_TEST;
static char rtp_h264_list_gt_mtu_frame_data[] =
static const guint8 rtp_h264_list_gt_mtu_frame_data[] =
/* not packetized, next NAL starts with 0001 */
{ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -574,6 +546,7 @@ static int rtp_h264_list_gt_mtu_mty_size = 28;
GST_START_TEST (rtp_h264_list_gt_mtu)
{
/* FIXME 0.11: fully specify h264 caps (and make payloader check) */
rtp_pipeline_test (rtp_h264_list_gt_mtu_frame_data,
rtp_h264_list_gt_mtu_frame_data_size, rtp_h264_list_gt_mtu_frame_count,
"video/x-h264", "rtph264pay", "rtph264depay",
@ -581,7 +554,7 @@ GST_START_TEST (rtp_h264_list_gt_mtu)
}
GST_END_TEST;
static char rtp_L16_frame_data[] =
static const guint8 rtp_L16_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -599,7 +572,7 @@ GST_START_TEST (rtp_L16)
}
GST_END_TEST;
static char rtp_mp2t_frame_data[] =
static const guint8 rtp_mp2t_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -616,7 +589,7 @@ GST_START_TEST (rtp_mp2t)
}
GST_END_TEST;
static char rtp_mp4v_frame_data[] =
static const guint8 rtp_mp4v_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -633,7 +606,7 @@ GST_START_TEST (rtp_mp4v)
}
GST_END_TEST;
static char rtp_mp4v_list_frame_data[] =
static const guint8 rtp_mp4v_list_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -653,7 +626,7 @@ GST_START_TEST (rtp_mp4v_list)
}
GST_END_TEST;
static char rtp_mp4g_frame_data[] =
static const guint8 rtp_mp4g_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -671,7 +644,7 @@ GST_START_TEST (rtp_mp4g)
}
GST_END_TEST;
static char rtp_theora_frame_data[] =
static const guint8 rtp_theora_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -688,7 +661,7 @@ GST_START_TEST (rtp_theora)
}
GST_END_TEST;
static char rtp_vorbis_frame_data[] =
static const guint8 rtp_vorbis_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -705,7 +678,7 @@ GST_START_TEST (rtp_vorbis)
}
GST_END_TEST;
static char rtp_jpeg_frame_data[] =
static const guint8 rtp_jpeg_frame_data[] =
{ /* SOF */ 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0x08, 0x00, 0x08,
0x03, 0x00, 0x21, 0x08, 0x01, 0x11, 0x08, 0x02, 0x11, 0x08,
/* DQT */ 0xFF, 0xDB, 0x00, 0x43, 0x08,
@ -732,7 +705,7 @@ GST_START_TEST (rtp_jpeg)
}
GST_END_TEST;
static char rtp_jpeg_list_frame_data[] =
static const guint8 rtp_jpeg_list_frame_data[] =
{ /* SOF */ 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0x08, 0x00, 0x08,
0x03, 0x00, 0x21, 0x08, 0x01, 0x11, 0x08, 0x02, 0x11, 0x08,
/* DQT */ 0xFF, 0xDB, 0x00, 0x43, 0x08,
@ -761,7 +734,7 @@ GST_START_TEST (rtp_jpeg_list)
}
GST_END_TEST;
static char rtp_g729_frame_data[] =
static const guint8 rtp_g729_frame_data[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};