changeset 4380:1b695f013cd3 libavformat

Introduce a new num_frames field in RTPDemuxContext so that rtp_aac.c does not need to abuse read_buf_index
author lucabe
date Thu, 05 Feb 2009 14:53:25 +0000
parents 7c628699cc3d
children c535276fb3ff
files rtp.h rtp_aac.c rtpenc.c
diffstat 3 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/rtp.h	Thu Feb 05 08:59:38 2009 +0000
+++ b/rtp.h	Thu Feb 05 14:53:25 2009 +0000
@@ -154,6 +154,7 @@
     struct MpegTSContext *ts;   /* only used for MP2T payloads */
     int read_buf_index;
     int read_buf_size;
+    int num_frames;
     /* used to send back RTCP RR */
     URLContext *rtp_ctx;
     char hostname[256];
--- a/rtp_aac.c	Thu Feb 05 08:59:38 2009 +0000
+++ b/rtp_aac.c	Thu Feb 05 14:53:25 2009 +0000
@@ -40,8 +40,8 @@
 
     /* test if the packet must be sent */
     len = (s->buf_ptr - s->buf);
-    if ((s->read_buf_index == MAX_FRAMES_PER_PACKET) || (len && (len + size) > max_packet_size)) {
-        int au_size = s->read_buf_index * 2;
+    if ((s->num_frames == MAX_FRAMES_PER_PACKET) || (len && (len + size) > max_packet_size)) {
+        int au_size = s->num_frames * 2;
 
         p = s->buf + MAX_AU_HEADERS_SIZE - au_size - 2;
         if (p != s->buf) {
@@ -53,15 +53,15 @@
 
         ff_rtp_send_data(s1, p, s->buf_ptr - p, 1);
 
-        s->read_buf_index = 0;
+        s->num_frames = 0;
     }
-    if (s->read_buf_index == 0) {
+    if (s->num_frames == 0) {
         s->buf_ptr = s->buf + MAX_AU_HEADERS_SIZE;
         s->timestamp = s->cur_timestamp;
     }
 
     if (size < max_packet_size) {
-        p = s->buf + s->read_buf_index++ * 2 + 2;
+        p = s->buf + s->num_frames++ * 2 + 2;
         *p++ = size >> 5;
         *p = (size & 0x1F) << 3;
         memcpy(s->buf_ptr, buff, size);
--- a/rtpenc.c	Thu Feb 05 08:59:38 2009 +0000
+++ b/rtpenc.c	Thu Feb 05 14:53:25 2009 +0000
@@ -102,7 +102,7 @@
         s->buf_ptr = s->buf;
         break;
     case CODEC_ID_AAC:
-        s->read_buf_index = 0;
+        s->num_frames = 0;
     default:
         if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
             av_set_pts_info(st, 32, 1, st->codec->sample_rate);