mpegtsenc: add flag to embed an AC-3 ES the DVB way

So far an AC-3 elementary stream is refered to in the PMT according to
System A (ATSC). However System B (DVB) has a different way to signal an AC-3
ES within the PMT. This different way can be enabled by a new flag. The flag is
more generally named 'system_b' as there are further differences between ATSC
and DVB (e.g. the signalling of E-AC-3) which should then also be covered by it
in the future.

Bug-Id: 73

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
Stefan Pöschel 2015-12-12 20:26:38 +01:00 committed by Luca Barbato
parent cc4c242081
commit dbce017913

View File

@ -86,6 +86,7 @@ typedef struct MpegTSWrite {
int pcr_period; int pcr_period;
#define MPEGTS_FLAG_REEMIT_PAT_PMT 0x01 #define MPEGTS_FLAG_REEMIT_PAT_PMT 0x01
#define MPEGTS_FLAG_AAC_LATM 0x02 #define MPEGTS_FLAG_AAC_LATM 0x02
#define MPEGTS_FLAG_SYSTEM_B 0x04
int flags; int flags;
} MpegTSWrite; } MpegTSWrite;
@ -284,7 +285,9 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
stream_type = STREAM_TYPE_AUDIO_AAC_LATM; stream_type = STREAM_TYPE_AUDIO_AAC_LATM;
break; break;
case AV_CODEC_ID_AC3: case AV_CODEC_ID_AC3:
stream_type = STREAM_TYPE_AUDIO_AC3; stream_type = (ts->flags & MPEGTS_FLAG_SYSTEM_B)
? STREAM_TYPE_PRIVATE_DATA
: STREAM_TYPE_AUDIO_AC3;
break; break;
default: default:
stream_type = STREAM_TYPE_PRIVATE_DATA; stream_type = STREAM_TYPE_PRIVATE_DATA;
@ -298,6 +301,12 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
/* write optional descriptors here */ /* write optional descriptors here */
switch (st->codec->codec_type) { switch (st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
if (st->codec->codec_id == AV_CODEC_ID_AC3 && (ts->flags & MPEGTS_FLAG_SYSTEM_B)) {
*q++ = 0x6a; /* ETSI EN 300 468 AC-3 descriptor */
*q++ = 1;
*q++ = 0x00;
}
if (lang) { if (lang) {
char *p; char *p;
char *next = lang->value; char *next = lang->value;
@ -1252,6 +1261,9 @@ static const AVOption options[] = {
{ "latm", "Use LATM packetization for AAC", { "latm", "Use LATM packetization for AAC",
0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_AAC_LATM }, 0, INT_MAX, 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_AAC_LATM }, 0, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" }, AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
{ "system_b", "Conform to System B (DVB) instead of System A (ATSC)",
0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_SYSTEM_B }, 0, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
// backward compatibility // backward compatibility
{ "resend_headers", "Reemit PAT/PMT before writing the next packet", { "resend_headers", "Reemit PAT/PMT before writing the next packet",
offsetof(MpegTSWrite, reemit_pat_pmt), AV_OPT_TYPE_INT, offsetof(MpegTSWrite, reemit_pat_pmt), AV_OPT_TYPE_INT,