* MPEG2 transport stream (aka DVB) demuxer
* Copyright (c) 2002-2003 Fabrice Bellard
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
static const StreamType REGD_types[] = {
{ MKTAG('d','r','a','c'), AVMEDIA_TYPE_VIDEO, CODEC_ID_DIRAC },
{ MKTAG('A','C','-','3'), AVMEDIA_TYPE_AUDIO, CODEC_ID_AC3 },
+ { MKTAG('B','S','S','D'), AVMEDIA_TYPE_AUDIO, CODEC_ID_S302M },
{ 0 },
};
if (pes->data_index == PES_START_SIZE) {
/* we got all the PES or section header. We can now
decide */
-#if 0
- av_hex_dump_log(pes->stream, AV_LOG_DEBUG, pes->header, pes->data_index);
-#endif
if (pes->header[0] == 0x00 && pes->header[1] == 0x00 &&
pes->header[2] == 0x01) {
/* it must be an mpeg2 PES stream */
code == 0x1be) /* padding_stream */
goto skip;
-#if FF_API_MAX_STREAMS
- if (!pes->st && pes->stream->nb_streams == MAX_STREAMS)
- goto skip;
-#endif
-
/* stream not present in PMT */
if (!pes->st) {
pes->st = av_new_stream(ts->stream, pes->pid);
* a couple of seconds to milliseconds for properly muxed files.
* total_size is the number of bytes following pes_packet_length
* in the pes header, i.e. not counting the first 6 bytes */
- if (pes->total_size < MAX_PES_PAYLOAD &&
+ if (!ts->stop_parse && pes->total_size < MAX_PES_PAYLOAD &&
pes->pes_header_size + pes->data_index == pes->total_size + 6) {
ts->stop_parse = 1;
new_pes_packet(pes, ts->pkt);
{
const uint8_t *desc_end;
int desc_len, desc_tag;
- char language[4];
+ char language[252];
+ int i;
desc_tag = get8(pp, desc_list_end);
if (desc_tag < 0)
language[1] = get8(pp, desc_end);
language[2] = get8(pp, desc_end);
language[3] = 0;
- get8(pp, desc_end);
+ /* hearing impaired subtitles detection */
+ switch(get8(pp, desc_end)) {
+ case 0x20: /* DVB subtitles (for the hard of hearing) with no monitor aspect ratio criticality */
+ case 0x21: /* DVB subtitles (for the hard of hearing) for display on 4:3 aspect ratio monitor */
+ case 0x22: /* DVB subtitles (for the hard of hearing) for display on 16:9 aspect ratio monitor */
+ case 0x23: /* DVB subtitles (for the hard of hearing) for display on 2.21:1 aspect ratio monitor */
+ case 0x24: /* DVB subtitles (for the hard of hearing) for display on a high definition monitor */
+ case 0x25: /* DVB subtitles (for the hard of hearing) with plano-stereoscopic disparity for display on a high definition monitor */
+ st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED;
+ break;
+ }
if (st->codec->extradata) {
if (st->codec->extradata_size == 4 && memcmp(st->codec->extradata, *pp, 4))
av_log_ask_for_sample(fc, "DVB sub with multiple IDs\n");
av_metadata_set2(&st->metadata, "language", language, 0);
break;
case 0x0a: /* ISO 639 language descriptor */
- language[0] = get8(pp, desc_end);
- language[1] = get8(pp, desc_end);
- language[2] = get8(pp, desc_end);
- language[3] = 0;
- av_metadata_set2(&st->metadata, "language", language, 0);
+ for (i = 0; i + 4 <= desc_len; i += 4) {
+ language[i + 0] = get8(pp, desc_end);
+ language[i + 1] = get8(pp, desc_end);
+ language[i + 2] = get8(pp, desc_end);
+ language[i + 3] = ',';
switch (get8(pp, desc_end)) {
case 0x01: st->disposition |= AV_DISPOSITION_CLEAN_EFFECTS; break;
case 0x02: st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED; break;
case 0x03: st->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED; break;
}
+ }
+ if (i) {
+ language[i - 1] = 0;
+ av_metadata_set2(&st->metadata, "language", language, 0);
+ }
break;
case 0x05: /* registration descriptor */
st->codec->codec_tag = bytestream_get_le32(pp);
if (p >= p_end)
return 0;
- pos = url_ftell(ts->stream->pb);
+ pos = avio_tell(ts->stream->pb);
ts->pos47= pos % ts->raw_packet_size;
if (tss->type == MPEGTS_SECTION) {
int c, i;
for(i = 0;i < MAX_RESYNC_SIZE; i++) {
- c = url_fgetc(pb);
- if (c < 0)
+ c = avio_r8(pb);
+ if (pb->eof_reached)
return -1;
if (c == 0x47) {
avio_seek(pb, -1, SEEK_CUR);
for(;;) {
len = avio_read(pb, buf, TS_PACKET_SIZE);
if (len != TS_PACKET_SIZE)
- return AVERROR(EIO);
+ return len < 0 ? len : AVERROR_EOF;
/* check paquet sync byte */
if (buf[0] != 0x47) {
/* find a new packet start */
} else {
skip = raw_packet_size - TS_PACKET_SIZE;
if (skip > 0)
- url_fskip(pb, skip);
+ avio_skip(pb, skip);
break;
}
}
}
/* read the first 1024 bytes to get packet size */
- pos = url_ftell(pb);
+ pos = avio_tell(pb);
len = avio_read(pb, buf, sizeof(buf));
if (len != sizeof(buf))
goto fail;
s->bit_rate = (TS_PACKET_SIZE * 8) * 27e6 / ts->pcr_incr;
st->codec->bit_rate = s->bit_rate;
st->start_time = ts->cur_pcr;
-#if 0
- av_log(ts->stream, AV_LOG_DEBUG, "start=%0.3f pcr=%0.3f incr=%d\n",
- st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr);
-#endif
+ av_dlog(ts->stream, AV_LOG_DEBUG, "start=%0.3f pcr=%0.3f incr=%d\n",
+ st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr);
}
avio_seek(pb, pos, SEEK_SET);
if (av_new_packet(pkt, TS_PACKET_SIZE) < 0)
return AVERROR(ENOMEM);
- pkt->pos= url_ftell(s->pb);
+ pkt->pos= avio_tell(s->pb);
ret = read_packet(s, pkt->data, ts->raw_packet_size);
if (ret < 0) {
av_free_packet(pkt);
/* compute exact PCR for each packet */
if (parse_pcr(&pcr_h, &pcr_l, pkt->data) == 0) {
/* we read the next PCR (XXX: optimize it by using a bigger buffer */
- pos = url_ftell(s->pb);
+ pos = avio_tell(s->pb);
for(i = 0; i < MAX_PACKET_READAHEAD; i++) {
avio_seek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET);
avio_read(s->pb, pcr_buf, 12);
MpegTSContext *ts = s->priv_data;
int ret, i;
- if (url_ftell(s->pb) != ts->last_pos) {
+ if (avio_tell(s->pb) != ts->last_pos) {
/* seek detected, flush pes buffer */
for (i = 0; i < NB_PID_MAX; i++) {
if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) {
}
}
- ts->last_pos = url_ftell(s->pb);
+ ts->last_pos = avio_tell(s->pb);
return ret;
}
if(av_seek_frame_binary(s, stream_index, target_ts, flags) < 0)
return -1;
- pos= url_ftell(s->pb);
+ pos= avio_tell(s->pb);
for(;;) {
avio_seek(s->pb, pos, SEEK_SET);