aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-06-28 23:44:09 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-06-28 23:44:09 +0000
commitce34182dd75c8cfdde134944f6de83e17c73ff9d (patch)
treef41e31d712bf689203102d26c1f958f85fcd4d2e /libavformat
parentd3b150363c0d7a43a918586a30d651c26e9b0fcf (diff)
downloadffmpeg-ce34182dd75c8cfdde134944f6de83e17c73ff9d.tar.gz
try to filter _all_ PATs if no SDT could be found patch by (<gbazin at altern dot org>)
+ mpegtsenc.c compile fix by me Originally committed as revision 1995 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mpegts.c40
-rw-r--r--libavformat/mpegts.h6
-rw-r--r--libavformat/mpegtsenc.c4
3 files changed, 29 insertions, 21 deletions
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 8e2898398b..ab621dbb81 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -348,7 +348,7 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
#ifdef DEBUG_SI
printf("sid=0x%x sec_num=%d/%d\n", h->id, h->sec_num, h->last_sec_num);
#endif
- if (h->tid != PMT_TID || h->id != ts->req_sid)
+ if (h->tid != PMT_TID || (ts->req_sid >= 0 && h->id != ts->req_sid) )
return;
pcr_pid = get16(&p, p_end) & 0x1fff;
@@ -383,8 +383,10 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
/* now create ffmpeg stream */
switch(stream_type) {
- case STREAM_TYPE_AUDIO:
- case STREAM_TYPE_VIDEO:
+ case STREAM_TYPE_AUDIO_MPEG1:
+ case STREAM_TYPE_AUDIO_MPEG2:
+ case STREAM_TYPE_VIDEO_MPEG1:
+ case STREAM_TYPE_VIDEO_MPEG2:
add_pes_stream(ts->stream, pid);
break;
default:
@@ -429,7 +431,7 @@ static void pat_cb(void *opaque, const uint8_t *section, int section_len)
if (sid == 0x0000) {
/* NIT info */
} else {
- if (ts->req_sid == sid) {
+ if (ts->req_sid == sid || ts->req_sid < 0) {
ts->pmt_filter = mpegts_open_section_filter(ts, pmt_pid,
pmt_cb, ts, 1);
goto found;
@@ -861,28 +863,32 @@ static int mpegts_read_header(AVFormatContext *s,
ts->auto_guess = 0;
if (!ts->auto_guess) {
+ int sid = -1;
+ ts->set_service_ret = -1;
/* first do a scaning to get all the services */
url_fseek(pb, pos, SEEK_SET);
mpegts_scan_sdt(ts);
handle_packets(s, MAX_SCAN_PACKETS);
-
- /* if no service found, no need to do anything */
- if (ts->nb_services <= 0)
- return -1;
-
- /* now find the info for the first service */
-
- url_fseek(pb, pos, SEEK_SET);
- service = ts->services[0];
+
+ if (ts->nb_services > 0)
+ {
+ /* tune to first service found */
+ service = ts->services[0];
+ sid = service->sid;
#ifdef DEBUG_SI
- printf("tuning to '%s'\n", service->name);
+ printf("tuning to '%s'\n", service->name);
#endif
- /* tune to first service found */
+ }
+
+ /* now find the info for the first service if we found any,
+ otherwise try to filter all PATs */
+
+ url_fseek(pb, pos, SEEK_SET);
ts->stream = s;
- mpegts_set_service(ts, service->sid, set_service_cb, ts);
-
+ mpegts_set_service(ts, sid, set_service_cb, ts);
+
handle_packets(s, MAX_SCAN_PACKETS);
/* if could not find service, exit */
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index df0b6de216..8296ccfb98 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -31,8 +31,10 @@
#define PMT_TID 0x02
#define SDT_TID 0x42
-#define STREAM_TYPE_VIDEO 0x02
-#define STREAM_TYPE_AUDIO 0x03
+#define STREAM_TYPE_VIDEO_MPEG1 0x01
+#define STREAM_TYPE_VIDEO_MPEG2 0x02
+#define STREAM_TYPE_AUDIO_MPEG1 0x03
+#define STREAM_TYPE_AUDIO_MPEG2 0x04
#define STREAM_TYPE_PRIVATE_SECTION 0x05
#define STREAM_TYPE_PRIVATE_DATA 0x06
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 079f4c724c..60520de540 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -259,10 +259,10 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
MpegTSWriteStream *ts_st = st->priv_data;
switch(st->codec.codec_type) {
case CODEC_TYPE_VIDEO:
- stream_type = STREAM_TYPE_VIDEO;
+ stream_type = STREAM_TYPE_VIDEO_MPEG2; //XXX/FIXME is this (and the define) correct?
break;
case CODEC_TYPE_AUDIO:
- stream_type = STREAM_TYPE_AUDIO;
+ stream_type = STREAM_TYPE_AUDIO_MPEG1;
break;
default:
stream_type = STREAM_TYPE_PRIVATE_DATA;