From c4cb38f3949b395b34258cd3aebe0bd8dcd9ed34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 10 Dec 2011 20:08:20 +0000 Subject: [PATCH] mpegpsmux: remember primary video stream --- gst/mpegpsmux/mpegpsmux.c | 11 +++++++++++ gst/mpegpsmux/mpegpsmux.h | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gst/mpegpsmux/mpegpsmux.c b/gst/mpegpsmux/mpegpsmux.c index d0e31bb863..19e23d93dd 100644 --- a/gst/mpegpsmux/mpegpsmux.c +++ b/gst/mpegpsmux/mpegpsmux.c @@ -217,6 +217,7 @@ mpegpsmux_create_stream (MpegPsMux * mux, MpegPsPadData * ps_data, GstPad * pad) GstFlowReturn ret = GST_FLOW_ERROR; GstCaps *caps = gst_pad_get_negotiated_caps (pad); GstStructure *s; + gboolean is_video = FALSE; if (caps == NULL) { GST_DEBUG_OBJECT (pad, "Sink pad caps were not set before pushing"); @@ -229,6 +230,7 @@ mpegpsmux_create_stream (MpegPsMux * mux, MpegPsPadData * ps_data, GstPad * pad) if (gst_structure_has_name (s, "video/x-dirac")) { GST_DEBUG_OBJECT (pad, "Creating Dirac stream"); ps_data->stream = psmux_create_stream (mux->psmux, PSMUX_ST_VIDEO_DIRAC); + is_video = TRUE; } else if (gst_structure_has_name (s, "audio/x-ac3")) { GST_DEBUG_OBJECT (pad, "Creating AC3 stream"); ps_data->stream = psmux_create_stream (mux->psmux, PSMUX_ST_PS_AUDIO_AC3); @@ -252,6 +254,7 @@ mpegpsmux_create_stream (MpegPsMux * mux, MpegPsPadData * ps_data, GstPad * pad) ps_data->codec_data = NULL; } ps_data->stream = psmux_create_stream (mux->psmux, PSMUX_ST_VIDEO_H264); + is_video = TRUE; } else if (gst_structure_has_name (s, "audio/mpeg")) { gint mpegversion; if (!gst_structure_get_int (s, "mpegversion", &mpegversion)) { @@ -312,6 +315,7 @@ mpegpsmux_create_stream (MpegPsMux * mux, MpegPsPadData * ps_data, GstPad * pad) GST_DEBUG_OBJECT (pad, "Creating MPEG Video, version 4 stream"); ps_data->stream = psmux_create_stream (mux->psmux, PSMUX_ST_VIDEO_MPEG4); } + is_video = TRUE; } if (ps_data->stream != NULL) { @@ -327,6 +331,11 @@ mpegpsmux_create_stream (MpegPsMux * mux, MpegPsPadData * ps_data, GstPad * pad) psmux_stream_set_buffer_release_func (ps_data->stream, release_buffer_cb); ret = GST_FLOW_OK; + + if (is_video && mux->video_stream_id == 0) { + mux->video_stream_id = ps_data->stream_id; + GST_INFO_OBJECT (mux, "video pad stream_id 0x%02x", mux->video_stream_id); + } } beach: @@ -590,6 +599,8 @@ mpegpsmux_release_pad (GstElement * element, GstPad * pad) pad_data->codec_data = NULL; } } + if (pad_data->stream_id == mux->video_stream_id) + mux->video_stream_id = 0; GST_OBJECT_UNLOCK (pad); gst_collect_pads_remove_pad (mux->collect, pad); diff --git a/gst/mpegpsmux/mpegpsmux.h b/gst/mpegpsmux/mpegpsmux.h index 4da1bea66d..125f8f6742 100644 --- a/gst/mpegpsmux/mpegpsmux.h +++ b/gst/mpegpsmux/mpegpsmux.h @@ -68,7 +68,9 @@ struct MpegPsMux { GstPad *srcpad; - GstCollectPads *collect; // pads collector + guint video_stream_id; /* stream id of primary video stream */ + + GstCollectPads *collect; /* pads collector */ PsMux *psmux;