Commit 3958244c authored by Marton Balint's avatar Marton Balint

avformat/mpegtsenc: factorize determining stream_type

Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent bcc19933
...@@ -282,47 +282,11 @@ static void put_registration_descriptor(uint8_t **q_ptr, uint32_t tag) ...@@ -282,47 +282,11 @@ static void put_registration_descriptor(uint8_t **q_ptr, uint32_t tag)
*q_ptr = q; *q_ptr = q;
} }
static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) static int get_dvb_stream_type(AVFormatContext *s, AVStream *st)
{ {
MpegTSWrite *ts = s->priv_data; MpegTSWrite *ts = s->priv_data;
uint8_t data[SECTION_LENGTH], *q, *desc_length_ptr, *program_info_length_ptr; int stream_type;
int val, stream_type, i, err = 0;
q = data;
put16(&q, 0xe000 | service->pcr_pid);
program_info_length_ptr = q;
q += 2; /* patched after */
/* put program info here */
val = 0xf000 | (q - program_info_length_ptr - 2);
program_info_length_ptr[0] = val >> 8;
program_info_length_ptr[1] = val;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
MpegTSWriteStream *ts_st = st->priv_data;
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
if (s->nb_programs) {
int k, found = 0;
AVProgram *program = service->program;
for (k = 0; k < program->nb_stream_indexes; k++)
if (program->stream_index[k] == i) {
found = 1;
break;
}
if (!found)
continue;
}
if (q - data > SECTION_LENGTH - 32) {
err = 1;
break;
}
switch (st->codecpar->codec_id) { switch (st->codecpar->codec_id) {
case AV_CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO: case AV_CODEC_ID_MPEG2VIDEO:
...@@ -387,11 +351,58 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) ...@@ -387,11 +351,58 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
break; break;
default: default:
av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a private data stream " av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a private data stream "
"and may not be recognized upon reading.\n", i, avcodec_get_name(st->codecpar->codec_id)); "and may not be recognized upon reading.\n", st->index, avcodec_get_name(st->codecpar->codec_id));
stream_type = STREAM_TYPE_PRIVATE_DATA; stream_type = STREAM_TYPE_PRIVATE_DATA;
break; break;
} }
return stream_type;
}
static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
{
MpegTSWrite *ts = s->priv_data;
uint8_t data[SECTION_LENGTH], *q, *desc_length_ptr, *program_info_length_ptr;
int val, stream_type, i, err = 0;
q = data;
put16(&q, 0xe000 | service->pcr_pid);
program_info_length_ptr = q;
q += 2; /* patched after */
/* put program info here */
val = 0xf000 | (q - program_info_length_ptr - 2);
program_info_length_ptr[0] = val >> 8;
program_info_length_ptr[1] = val;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
MpegTSWriteStream *ts_st = st->priv_data;
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
if (s->nb_programs) {
int k, found = 0;
AVProgram *program = service->program;
for (k = 0; k < program->nb_stream_indexes; k++)
if (program->stream_index[k] == i) {
found = 1;
break;
}
if (!found)
continue;
}
if (q - data > SECTION_LENGTH - 32) {
err = 1;
break;
}
stream_type = get_dvb_stream_type(s, st);
*q++ = stream_type; *q++ = stream_type;
put16(&q, 0xe000 | ts_st->pid); put16(&q, 0xe000 | ts_st->pid);
desc_length_ptr = q; desc_length_ptr = q;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment