Send a stream-start whenever we send tags

This is to make sure tags are cleared on the client if the
stream-start was previously lost, otherwise, the client may end
up with a merged taglist of multiple songs
This commit is contained in:
Youness Alaoui 2013-08-07 09:47:35 -04:00 committed by Wim Taymans
parent 05bcfee5a3
commit 62a6f58697
2 changed files with 24 additions and 2 deletions

View file

@ -167,6 +167,9 @@ gst_rtp_gst_pay_finalize (GObject * obj)
if (rtpgstpay->taglist)
gst_tag_list_unref (rtpgstpay->taglist);
rtpgstpay->taglist = NULL;
if (rtpgstpay->stream_id)
g_free (rtpgstpay->stream_id);
rtpgstpay->stream_id = NULL;
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@ -474,12 +477,22 @@ gst_rtp_gst_pay_sink_event (GstRTPBasePayload * payload, GstEvent * event)
case GST_EVENT_CUSTOM_BOTH:
etype = 3;
break;
case GST_EVENT_STREAM_START:
etype = 4;
case GST_EVENT_STREAM_START:{
const gchar *stream_id = NULL;
if (rtpgstpay->taglist)
gst_tag_list_unref (rtpgstpay->taglist);
rtpgstpay->taglist = NULL;
gst_event_parse_stream_start (event, &stream_id);
if (stream_id) {
if (rtpgstpay->stream_id)
g_free (rtpgstpay->stream_id);
rtpgstpay->stream_id = g_strdup (stream_id);
}
etype = 4;
break;
}
default:
etype = 0;
GST_LOG_OBJECT (rtpgstpay, "no event for %s",
@ -509,12 +522,20 @@ gst_rtp_gst_pay_send_config (GstRtpGSTPay * rtpgstpay, GstClockTime timestamp)
GstPad *pad = GST_RTP_BASE_PAYLOAD_SINKPAD (rtpgstpay);
GstCaps *caps = NULL;
GstEvent *tag = NULL;
GstEvent *stream_start = NULL;
GST_DEBUG_OBJECT (rtpgstpay, "time to send config");
/* Send tags */
if (rtpgstpay->taglist && !gst_tag_list_is_empty (rtpgstpay->taglist))
tag = gst_event_new_tag (gst_tag_list_ref (rtpgstpay->taglist));
if (tag) {
/* Send start-stream to clear tags */
if (rtpgstpay->stream_id)
stream_start = gst_event_new_stream_start (rtpgstpay->stream_id);
if (stream_start) {
gst_rtp_gst_pay_send_event (rtpgstpay, 4, stream_start);
gst_event_unref (stream_start);
}
gst_rtp_gst_pay_send_event (rtpgstpay, 1, tag);
gst_event_unref (tag);
}

View file

@ -52,6 +52,7 @@ struct _GstRtpGSTPay
guint8 current_CV; /* CV field of incoming caps*/
guint8 next_CV;
gchar *stream_id;
GstTagList *taglist;
guint config_interval;
GstClockTime last_config;