FLAC__uint64 absolute_byte_offset, void *client_data)
{
GstFlacEnc *flacenc;
- GstEvent *event;
GstPad *peerpad;
+ GstSegment seg;
flacenc = GST_FLAC_ENC (client_data);
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)))) {
- GstEvent *event = gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES,
- absolute_byte_offset, GST_BUFFER_OFFSET_NONE, 0);
-- 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) {
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);
+ g_mutex_lock (&conn->lock);
/* call sources first, then sinks. Sources will either push data into the
* ringbuffer of the sinks, which will then pull the data out of it, or
* sinks will pull the data from the sources. */
}
}
}
- g_mutex_unlock (conn->lock);
+
+ /* 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;
}
gint i, j, flen, channels;
sample_t *data;
- buf = GST_RING_BUFFER_CAST (arg);
+ buf = GST_AUDIO_RING_BUFFER_CAST (arg);
sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
- channels = buf->spec.channels;
+ 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] =
gint channels, i, j, flen;
sample_t *data;
- buf = GST_RING_BUFFER_CAST (arg);
+ buf = GST_AUDIO_RING_BUFFER_CAST (arg);
src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
- channels = buf->spec.channels;
+ 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] =
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class, &sink_template);
+ 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>, "
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-int, endianness = (int) LITTLE_ENDIAN, channels = (int) { 1, 2 }, width = (int) 8, depth = (int) 8, rate = (int) { 5512, 11025, 22050, 44100 }, signed = (boolean) FALSE; "
- "audio/x-raw-int, endianness = (int) LITTLE_ENDIAN, channels = (int) { 1, 2 }, width = (int) 16, depth = (int) 16, rate = (int) { 5512, 11025, 22050, 44100 }, signed = (boolean) TRUE; "
+ "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 }; "
"audio/x-mulaw, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "
"audio/x-speex, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 };")
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-int, endianness = (int) LITTLE_ENDIAN, channels = (int) { 1, 2 }, width = (int) 8, depth = (int) 8, rate = (int) { 5512, 11025, 22050, 44100 }, signed = (boolean) FALSE; "
- "audio/x-raw-int, endianness = (int) LITTLE_ENDIAN, channels = (int) { 1, 2 }, width = (int) 16, depth = (int) 16, rate = (int) { 5512, 11025, 22050, 44100 }, signed = (boolean) TRUE; "
+ "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 }; "
"audio/x-mulaw, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "
"audio/x-speex, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 };")
if (demux->common.segment.duration == -1 ||
demux->stream_start_time + demux->common.segment.duration <
last_stop_end) {
- gst_segment_set_duration (&demux->common.segment, GST_FORMAT_TIME,
- last_stop_end - demux->stream_start_time);
+ 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);
}
const gchar *mimetype;
GstStructure *structure;
const GValue *value = NULL;
- const GstBuffer *buf = NULL;
+ GstBuffer *buf = NULL;
- gchar *id = NULL;
gboolean ret = TRUE;
mux = GST_MATROSKA_MUX (GST_PAD_PARENT (pad));
};
static GstCaps *
-gst_rtp_h264_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad)
+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_get_caps_reffed (GST_BASE_RTP_PAYLOAD_SRCPAD (payload));
+ 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;
+ if (gst_caps_is_any (allowed_caps)) {
+ caps = gst_caps_ref (template_caps);
+ goto done;
+ }
- caps = gst_caps_new_empty ();
+ if (gst_caps_is_empty (allowed_caps)) {
+ caps = gst_caps_ref (allowed_caps);
+ goto done;
+ }
- 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;
+ caps = gst_caps_new_empty ();
- profile_level_id = gst_structure_get_string (s, "profile-level-id");
+ 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 ("video/x-h264", NULL);
++ GstStructure *new_s = gst_structure_new_empty ("video/x-h264");
+ const gchar *profile_level_id;
- if (profile_level_id && strlen (profile_level_id) == 6) {
- const gchar *profile;
- const gchar *level;
- long int spsint;
- guint8 sps[3];
+ profile_level_id = gst_structure_get_string (s, "profile-level-id");
- spsint = strtol (profile_level_id, NULL, 16);
- sps[0] = spsint >> 16;
- sps[1] = spsint >> 8;
- sps[2] = spsint;
+ if (profile_level_id && strlen (profile_level_id) == 6) {
+ const gchar *profile;
+ const gchar *level;
+ long int spsint;
+ guint8 sps[3];
- profile = gst_codec_utils_h264_get_profile (sps, 3);
- level = gst_codec_utils_h264_get_level (sps, 3);
+ spsint = strtol (profile_level_id, NULL, 16);
+ sps[0] = spsint >> 16;
+ sps[1] = spsint >> 8;
+ sps[2] = spsint;
- if (profile && level) {
- GST_LOG_OBJECT (payload, "In caps, have profile %s and level %s",
- profile, level);
+ profile = gst_codec_utils_h264_get_profile (sps, 3);
+ level = gst_codec_utils_h264_get_level (sps, 3);
- if (!strcmp (profile, "constrained-baseline"))
- gst_structure_set (new_s, "profile", G_TYPE_STRING, profile, NULL);
- else {
- GValue val = { 0, };
- GValue profiles = { 0, };
+ if (profile && level) {
+ GST_LOG_OBJECT (payload, "In caps, have profile %s and level %s",
+ profile, level);
- g_value_init (&profiles, GST_TYPE_LIST);
- g_value_init (&val, G_TYPE_STRING);
+ 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_set_static_string (&val, profile);
- gst_value_list_append_value (&profiles, &val);
+ g_value_init (&profiles, GST_TYPE_LIST);
+ g_value_init (&val, G_TYPE_STRING);
- g_value_set_static_string (&val, "constrained-baseline");
- gst_value_list_append_value (&profiles, &val);
+ g_value_set_static_string (&val, profile);
+ gst_value_list_append_value (&profiles, &val);
- gst_structure_take_value (new_s, "profile", &profiles);
- }
+ 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);
+ 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;
+ gst_caps_merge_structure (caps, new_s);
}
- any:
- return gst_caps_new_empty_simple ("video/x-h264");
+ 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
guint8 *payload;
GstFlowReturn ret;
GstBuffer *outbuf;
+ 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 */
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_SOCKFD,
- g_param_spec_int ("sockfd", "Socket Handle",
- "Socket to use for UDP sending. (-1 == allocate)",
- -1, G_MAXINT, DEFAULT_SOCKFD,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_CLOSEFD,
- g_param_spec_boolean ("closefd", "Close sockfd",
- "Close sockfd if passed as property on state change",
- DEFAULT_CLOSEFD, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_SOCK,
- g_param_spec_int ("sock", "Socket Handle",
- "Socket currently in use for UDP sending. (-1 == no socket)",
- -1, G_MAXINT, DEFAULT_SOCK,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_SOCKET,
+ g_param_spec_object ("socket", "Socket Handle",
+ "Socket to use for UDP sending. (NULL == allocate)",
+ G_TYPE_SOCKET, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_CLOSE_SOCKET,
+ g_param_spec_boolean ("close-socket", "Close socket",
+ "Close socket if passed as property on state change",
+ DEFAULT_CLOSE_SOCKET, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_USED_SOCKET,
+ g_param_spec_object ("used-socket", "Used Socket Handle",
+ "Socket currently in use for UDP sending. (NULL == no socket)",
+ G_TYPE_SOCKET, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_CLIENTS,
g_param_spec_string ("clients", "Clients",
"A comma separated list of host:port pairs with destinations",
/* 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;
-
- /* 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--;
+ const guint8 *data = p->frame_data;
+
+ for (j = 0; j < p->frame_count; j++) {
+ GstBuffer *buf;
+
- buf = gst_buffer_new ();
- GST_BUFFER_DATA (buf) = (guint8 *) data;
- GST_BUFFER_SIZE (buf) = p->frame_data_size;
- GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);
++ 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);
}
}