mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 23:36:38 +00:00
adaptivedemux2: Add gst_adaptive_demux_period_add_stream()
Make a function for adding a stream to a period, for better encapsulation. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
This commit is contained in:
parent
82839fb82f
commit
2082c8912d
3 changed files with 35 additions and 12 deletions
|
@ -212,6 +212,33 @@ gst_adaptive_demux_period_transfer_selection (GstAdaptiveDemux * demux,
|
|||
}
|
||||
}
|
||||
|
||||
/* called with TRACKS_LOCK taken. Takes ownership of the stream */
|
||||
gboolean
|
||||
gst_adaptive_demux_period_add_stream (GstAdaptiveDemuxPeriod * period,
|
||||
GstAdaptiveDemux2Stream * stream)
|
||||
{
|
||||
GST_LOG ("period %d stream: %" GST_PTR_FORMAT, period->period_num, stream);
|
||||
|
||||
/* Set the stream's period */
|
||||
stream->period = period;
|
||||
period->streams = g_list_append (period->streams, stream);
|
||||
|
||||
/* Add any pre-existing stream tracks to our set */
|
||||
if (stream->tracks) {
|
||||
GList *iter;
|
||||
for (iter = stream->tracks; iter; iter = iter->next) {
|
||||
GstAdaptiveDemuxTrack *track = (GstAdaptiveDemuxTrack *) iter->data;
|
||||
if (!gst_adaptive_demux_period_add_track (period, track)) {
|
||||
GST_ERROR_OBJECT (period->demux, "period %d failed to add track %p",
|
||||
period->period_num, track);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* called with TRACKS_LOCK taken */
|
||||
gboolean
|
||||
gst_adaptive_demux_period_add_track (GstAdaptiveDemuxPeriod * period,
|
||||
|
|
|
@ -234,6 +234,8 @@ GstAdaptiveDemuxPeriod * gst_adaptive_demux_period_new (GstAdaptiveDemux * demux
|
|||
GstAdaptiveDemuxPeriod * gst_adaptive_demux_period_ref (GstAdaptiveDemuxPeriod * period);
|
||||
void gst_adaptive_demux_period_unref (GstAdaptiveDemuxPeriod * period);
|
||||
|
||||
gboolean gst_adaptive_demux_period_add_stream (GstAdaptiveDemuxPeriod * period,
|
||||
GstAdaptiveDemux2Stream * stream);
|
||||
gboolean gst_adaptive_demux_period_add_track (GstAdaptiveDemuxPeriod * period,
|
||||
GstAdaptiveDemuxTrack * track);
|
||||
gboolean gst_adaptive_demux_track_add_elements (GstAdaptiveDemuxTrack * track,
|
||||
|
|
|
@ -3854,20 +3854,14 @@ gst_adaptive_demux2_add_stream (GstAdaptiveDemux * demux,
|
|||
return FALSE;
|
||||
}
|
||||
stream->demux = demux;
|
||||
stream->period = demux->input_period;
|
||||
demux->input_period->streams =
|
||||
g_list_append (demux->input_period->streams, stream);
|
||||
|
||||
if (stream->tracks) {
|
||||
GList *iter;
|
||||
for (iter = stream->tracks; iter; iter = iter->next)
|
||||
if (!gst_adaptive_demux_period_add_track (demux->input_period,
|
||||
(GstAdaptiveDemuxTrack *) iter->data)) {
|
||||
GST_ERROR_OBJECT (demux, "Failed to add track elements");
|
||||
TRACKS_UNLOCK (demux);
|
||||
return FALSE;
|
||||
}
|
||||
/* Takes ownership of the stream and adds the tracks */
|
||||
if (!gst_adaptive_demux_period_add_stream (demux->input_period, stream)) {
|
||||
GST_ERROR_OBJECT (demux, "Failed to add stream to period");
|
||||
TRACKS_UNLOCK (demux);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
TRACKS_UNLOCK (demux);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue