summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@centricular.com>2020-09-08 10:48:56 +0200
committerTim-Philipp Müller <tim@centricular.com>2020-09-30 10:35:48 +0100
commit78ad3bcf9b72d72f9f78436b2b439c1c9b78c222 (patch)
tree7a728f8b3802b9a50f4d32e8a34323ad47ddf755
parentdd1fe7c91dc3d2593790151c87165869efd3b3b8 (diff)
downloadgstreamer-plugins-bad-78ad3bcf9b72d72f9f78436b2b439c1c9b78c222.tar.gz
mpegtsmux: Don't create streams with reserved PID
There are quite a few reserved PID in the various MPEG-TS (and derivate) specifications which we should definitely not use. Those PID have a certain meaning and purpose. Furthermore, a lot of the code in the muxer implementation also makes assumption on the purpose of streams based on their PID. Therefore, when requesting a pad with a specific PID, make sure it is not a restricted PID. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1620>
-rw-r--r--gst/mpegtsmux/gstbasetsmux.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gst/mpegtsmux/gstbasetsmux.c b/gst/mpegtsmux/gstbasetsmux.c
index d2a73dd4f..045c34ddb 100644
--- a/gst/mpegtsmux/gstbasetsmux.c
+++ b/gst/mpegtsmux/gstbasetsmux.c
@@ -1268,6 +1268,10 @@ gst_base_ts_mux_request_new_pad (GstElement * element, GstPadTemplate * templ,
if (name != NULL && sscanf (name, "sink_%d", &pid) == 1) {
if (tsmux_find_stream (mux->tsmux, pid))
goto stream_exists;
+ /* Make sure we don't use reserved PID.
+ * FIXME : This should be extended to other variants (ex: ATSC) reserved PID */
+ if (pid < TSMUX_START_ES_PID)
+ goto invalid_stream_pid;
} else {
pid = tsmux_get_new_pid (mux->tsmux);
}
@@ -1288,6 +1292,13 @@ stream_exists:
(NULL));
return NULL;
}
+
+invalid_stream_pid:
+ {
+ GST_ELEMENT_ERROR (element, STREAM, MUX,
+ ("Invalid Elementary stream PID (< 0x40)"), (NULL));
+ return NULL;
+ }
}
static void