]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '5b2ad78f97d43299adcb038c04346999fe9b196c'
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 7 Mar 2014 11:52:59 +0000 (12:52 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 7 Mar 2014 11:53:02 +0000 (12:53 +0100)
* commit '5b2ad78f97d43299adcb038c04346999fe9b196c':
  rtmppkt: Handle extended timestamp field even for one-byte header

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/rtmppkt.c
libavformat/rtmppkt.h

diff --combined libavformat/rtmppkt.c
index f99540cd5103b8765f8afe3522038dd5b73c8d1f,fb3726bdd30bcf7a085823bc9d466a35bc823230..3c99adcbf02f41e9a050e071af9b9804c58b4232
@@@ -2,20 -2,20 +2,20 @@@
   * RTMP input format
   * Copyright (c) 2009 Konstantin Shishkov
   *
 - * This file is part of Libav.
 + * This file is part of FFmpeg.
   *
 - * Libav is free software; you can redistribute it and/or
 + * FFmpeg 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.
   *
 - * Libav is distributed in the hope that it will be useful,
 + * FFmpeg 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 Libav; if not, write to the Free Software
 + * License along with FFmpeg; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
@@@ -169,6 -169,7 +169,7 @@@ static int rtmp_packet_read_one_chunk(U
  
      uint8_t buf[16];
      int channel_id, timestamp, size;
+     uint32_t ts_field; // non-extended timestamp or delta field
      uint32_t extra = 0;
      enum RTMPPacketType type;
      int written = 0;
  
      hdr >>= 6;
      if (hdr == RTMP_PS_ONEBYTE) {
-         timestamp = prev_pkt[channel_id].ts_delta;
+         ts_field = prev_pkt[channel_id].ts_delta;
      } else {
          if (ffurl_read_complete(h, buf, 3) != 3)
              return AVERROR(EIO);
          written += 3;
-         timestamp = AV_RB24(buf);
+         ts_field = AV_RB24(buf);
          if (hdr != RTMP_PS_FOURBYTES) {
              if (ffurl_read_complete(h, buf, 3) != 3)
                  return AVERROR(EIO);
                  extra = AV_RL32(buf);
              }
          }
-         if (timestamp == 0xFFFFFF) {
-             if (ffurl_read_complete(h, buf, 4) != 4)
-                 return AVERROR(EIO);
-             timestamp = AV_RB32(buf);
-         }
+     }
+     if (ts_field == 0xFFFFFF) {
+         if (ffurl_read_complete(h, buf, 4) != 4)
+             return AVERROR(EIO);
+         timestamp = AV_RB32(buf);
+     } else {
+         timestamp = ts_field;
      }
      if (hdr != RTMP_PS_TWELVEBYTES)
          timestamp += prev_pkt[channel_id].timestamp;
              return ret;
          p->read = written;
          p->offset = 0;
-         prev_pkt[channel_id].ts_delta   = timestamp -
-                                           prev_pkt[channel_id].timestamp;
+         prev_pkt[channel_id].ts_delta   = ts_field;
          prev_pkt[channel_id].timestamp  = timestamp;
      } else {
          // previous packet in this channel hasn't completed reading
diff --combined libavformat/rtmppkt.h
index fb79fedac64f12788b64bb582690b51060a2c41f,3ccc6b4110067048ddd0d00103a851e3603b7d2f..741d8930df3a5f8059b4b734d43f7779a4909d73
@@@ -2,20 -2,20 +2,20 @@@
   * RTMP packet utilities
   * Copyright (c) 2009 Konstantin Shishkov
   *
 - * This file is part of Libav.
 + * This file is part of FFmpeg.
   *
 - * Libav is free software; you can redistribute it and/or
 + * FFmpeg 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.
   *
 - * Libav is distributed in the hope that it will be useful,
 + * FFmpeg 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 Libav; if not, write to the Free Software
 + * License along with FFmpeg; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
@@@ -78,7 -78,7 +78,7 @@@ typedef struct RTMPPacket 
      int            channel_id; ///< RTMP channel ID (nothing to do with audio/video channels though)
      RTMPPacketType type;       ///< packet payload type
      uint32_t       timestamp;  ///< packet full timestamp
-     uint32_t       ts_delta;   ///< timestamp increment to the previous one in milliseconds (latter only for media packets)
+     uint32_t       ts_delta;   ///< 24-bit timestamp or increment to the previous one, in milliseconds (latter only for media packets). Clipped to a maximum of 0xFFFFFF, indicating an extended timestamp field.
      uint32_t       extra;      ///< probably an additional channel ID used during streaming data
      uint8_t        *data;      ///< packet payload
      int            size;       ///< packet payload size