diff mbox series

[FFmpeg-devel] Add constants for MPEG-TS transport stream identifiers

Message ID 20200603100729.25707-1-bradh@frogmouth.net
State Accepted
Commit fb819697f6977981ab864214025e041ebf30f2b4
Headers show
Series [FFmpeg-devel] Add constants for MPEG-TS transport stream identifiers | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Brad Hards June 3, 2020, 10:07 a.m. UTC
Signed-off-by: Brad Hards <bradh@frogmouth.net>
---
 libavformat/mpegts.h    |  7 +++++++
 libavformat/mpegtsenc.c | 16 ++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)

Comments

Marton Balint June 8, 2020, 11:10 p.m. UTC | #1
On Wed, 3 Jun 2020, Brad Hards wrote:

> Signed-off-by: Brad Hards <bradh@frogmouth.net>
> ---
> libavformat/mpegts.h    |  7 +++++++
> libavformat/mpegtsenc.c | 16 ++++++++--------
> 2 files changed, 15 insertions(+), 8 deletions(-)

Will apply, thanks.

Regards,
Marton

>
> diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
> index 059b693f07..fe10b38691 100644
> --- a/libavformat/mpegts.h
> +++ b/libavformat/mpegts.h
> @@ -137,6 +137,13 @@
> #define STREAM_TYPE_AUDIO_TRUEHD    0x83
> #define STREAM_TYPE_AUDIO_EAC3      0x87
> 
> +/* ISO/IEC 13818-1 Table 2-22 */
> +#define STREAM_ID_PRIVATE_STREAM_1   0xbd
> +#define STREAM_ID_AUDIO_STREAM_0     0xc0
> +#define STREAM_ID_VIDEO_STREAM_0     0xe0
> +#define STREAM_ID_METADATA_STREAM    0xfc
> +#define STREAM_ID_EXTENDED_STREAM_ID 0xfd
> +
> typedef struct MpegTSContext MpegTSContext;
> 
> MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext *s);
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index b5ee48d015..d827ba3e28 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -1382,28 +1382,28 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
>             is_dvb_teletext = 0;
>             if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
>                 if (st->codecpar->codec_id == AV_CODEC_ID_DIRAC)
> -                    *q++ = 0xfd;
> +                    *q++ = STREAM_ID_EXTENDED_STREAM_ID;
>                 else
> -                    *q++ = 0xe0;
> +                    *q++ = STREAM_ID_VIDEO_STREAM_0;
>             } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
>                        (st->codecpar->codec_id == AV_CODEC_ID_MP2 ||
>                         st->codecpar->codec_id == AV_CODEC_ID_MP3 ||
>                         st->codecpar->codec_id == AV_CODEC_ID_AAC)) {
> -                *q++ = 0xc0;
> +                *q++ = STREAM_ID_AUDIO_STREAM_0;
>             } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
>                         st->codecpar->codec_id == AV_CODEC_ID_AC3 &&
>                         ts->m2ts_mode) {
> -                *q++ = 0xfd;
> +                *q++ = STREAM_ID_EXTENDED_STREAM_ID;
>             } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA &&
>                        st->codecpar->codec_id == AV_CODEC_ID_TIMED_ID3) {
> -                *q++ = 0xbd;
> +                *q++ = STREAM_ID_PRIVATE_STREAM_1;
>             } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
> -                *q++ = stream_id != -1 ? stream_id : 0xfc;
> +                *q++ = stream_id != -1 ? stream_id : STREAM_ID_METADATA_STREAM;
> 
> -                if (stream_id == 0xbd) /* asynchronous KLV */
> +                if (stream_id == STREAM_ID_PRIVATE_STREAM_1) /* asynchronous KLV */
>                     pts = dts = AV_NOPTS_VALUE;
>             } else {
> -                *q++ = 0xbd;
> +                *q++ = STREAM_ID_PRIVATE_STREAM_1;
>                 if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
>                     if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
>                         is_dvb_subtitle = 1;
> -- 
> 2.17.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index 059b693f07..fe10b38691 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -137,6 +137,13 @@ 
 #define STREAM_TYPE_AUDIO_TRUEHD    0x83
 #define STREAM_TYPE_AUDIO_EAC3      0x87
 
+/* ISO/IEC 13818-1 Table 2-22 */
+#define STREAM_ID_PRIVATE_STREAM_1   0xbd
+#define STREAM_ID_AUDIO_STREAM_0     0xc0
+#define STREAM_ID_VIDEO_STREAM_0     0xe0
+#define STREAM_ID_METADATA_STREAM    0xfc
+#define STREAM_ID_EXTENDED_STREAM_ID 0xfd
+
 typedef struct MpegTSContext MpegTSContext;
 
 MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext *s);
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index b5ee48d015..d827ba3e28 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1382,28 +1382,28 @@  static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
             is_dvb_teletext = 0;
             if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
                 if (st->codecpar->codec_id == AV_CODEC_ID_DIRAC)
-                    *q++ = 0xfd;
+                    *q++ = STREAM_ID_EXTENDED_STREAM_ID;
                 else
-                    *q++ = 0xe0;
+                    *q++ = STREAM_ID_VIDEO_STREAM_0;
             } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
                        (st->codecpar->codec_id == AV_CODEC_ID_MP2 ||
                         st->codecpar->codec_id == AV_CODEC_ID_MP3 ||
                         st->codecpar->codec_id == AV_CODEC_ID_AAC)) {
-                *q++ = 0xc0;
+                *q++ = STREAM_ID_AUDIO_STREAM_0;
             } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
                         st->codecpar->codec_id == AV_CODEC_ID_AC3 &&
                         ts->m2ts_mode) {
-                *q++ = 0xfd;
+                *q++ = STREAM_ID_EXTENDED_STREAM_ID;
             } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA &&
                        st->codecpar->codec_id == AV_CODEC_ID_TIMED_ID3) {
-                *q++ = 0xbd;
+                *q++ = STREAM_ID_PRIVATE_STREAM_1;
             } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
-                *q++ = stream_id != -1 ? stream_id : 0xfc;
+                *q++ = stream_id != -1 ? stream_id : STREAM_ID_METADATA_STREAM;
 
-                if (stream_id == 0xbd) /* asynchronous KLV */
+                if (stream_id == STREAM_ID_PRIVATE_STREAM_1) /* asynchronous KLV */
                     pts = dts = AV_NOPTS_VALUE;
             } else {
-                *q++ = 0xbd;
+                *q++ = STREAM_ID_PRIVATE_STREAM_1;
                 if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
                     if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
                         is_dvb_subtitle = 1;