[FFmpeg-devel] [PATCH 15/16] mpegts: fix return value when enough ts packets have been parsed or when the first PMT has been seen.

Michael Niedermayer michaelni at gmx.at
Wed Oct 19 16:09:33 CEST 2011


On Sun, Oct 09, 2011 at 01:44:38PM -0700, Baptiste Coudurier wrote:
> Hi Laurent,
> 
> On 10/8/11 2:40 PM, fenrir at elivagar.org wrote:
> >From: Laurent Aimar<fenrir at videolan.org>
> >
> >---
> >  libavformat/mpegts.c |   12 ++++++++----
> >  1 files changed, 8 insertions(+), 4 deletions(-)
> >
> >diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> >index 02f0d56..f3d8b35 100644
> >--- a/libavformat/mpegts.c
> >+++ b/libavformat/mpegts.c
> >@@ -1106,7 +1106,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
> >
> >      // stop parsing after pmt, we found header
> >      if (!ts->stream->nb_streams)
> >-        ts->stop_parse = 1;
> >+        ts->stop_parse = 2;
> >
> >      for(;;) {
> >          st = 0;
> >@@ -1462,11 +1462,15 @@ static int handle_packets(MpegTSContext *ts, int nb_packets)
> >      ts->stop_parse = 0;
> >      packet_num = 0;
> >      for(;;) {
> >-        if (ts->stop_parse>0)
> >-            break;
> >          packet_num++;
> >-        if (nb_packets != 0&&  packet_num>= nb_packets)
> >+        if (nb_packets != 0&&  packet_num>= nb_packets ||
> >+            ts->stop_parse>  1) {
> >+            ret = AVERROR(EAGAIN);
> >              break;
> >+        }
> >+        if (ts->stop_parse>  0)
> >+            break;
> >+
> >          ret = read_packet(s, packet, ts->raw_packet_size);
> >          if (ret != 0)
> >              break;
> 
> I'm a bit confused by the change. What's the intended goal ?
> pmt_cb setting stop_parse = 1 is only when no streams are present
> yet, ie we did not parse PMT yet, this should only happen during
> init.
> Is that triggered in other scenario ?

i think this can happen when no streams are found during "header"
parsing and the user application continues.
Also when too many packets (nb_packets) are read the return code should
not just be ok without a packet.
Thus i applied this locally and will push very soon, unless i hear a
"stop"

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111019/2d89689e/attachment.asc>


More information about the ffmpeg-devel mailing list