Browse Source

Introduce a new num_frames field in RTPDemuxContext so that rtp_aac.c

does not need to abuse read_buf_index

Originally committed as revision 17004 to svn://svn.ffmpeg.org/ffmpeg/trunk
tags/v0.5
Luca Abeni 16 years ago
parent
commit
21da81d784
3 changed files with 7 additions and 6 deletions
  1. +1
    -0
      libavformat/rtp.h
  2. +5
    -5
      libavformat/rtp_aac.c
  3. +1
    -1
      libavformat/rtpenc.c

+ 1
- 0
libavformat/rtp.h View File

@@ -154,6 +154,7 @@ struct RTPDemuxContext {
struct MpegTSContext *ts; /* only used for MP2T payloads */ struct MpegTSContext *ts; /* only used for MP2T payloads */
int read_buf_index; int read_buf_index;
int read_buf_size; int read_buf_size;
int num_frames;
/* used to send back RTCP RR */ /* used to send back RTCP RR */
URLContext *rtp_ctx; URLContext *rtp_ctx;
char hostname[256]; char hostname[256];


+ 5
- 5
libavformat/rtp_aac.c View File

@@ -40,8 +40,8 @@ void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)


/* test if the packet must be sent */ /* test if the packet must be sent */
len = (s->buf_ptr - s->buf); 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; p = s->buf + MAX_AU_HEADERS_SIZE - au_size - 2;
if (p != s->buf) { if (p != s->buf) {
@@ -53,15 +53,15 @@ void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)


ff_rtp_send_data(s1, p, s->buf_ptr - p, 1); 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->buf_ptr = s->buf + MAX_AU_HEADERS_SIZE;
s->timestamp = s->cur_timestamp; s->timestamp = s->cur_timestamp;
} }


if (size < max_packet_size) { 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 >> 5;
*p = (size & 0x1F) << 3; *p = (size & 0x1F) << 3;
memcpy(s->buf_ptr, buff, size); memcpy(s->buf_ptr, buff, size);


+ 1
- 1
libavformat/rtpenc.c View File

@@ -102,7 +102,7 @@ static int rtp_write_header(AVFormatContext *s1)
s->buf_ptr = s->buf; s->buf_ptr = s->buf;
break; break;
case CODEC_ID_AAC: case CODEC_ID_AAC:
s->read_buf_index = 0;
s->num_frames = 0;
default: default:
if (st->codec->codec_type == CODEC_TYPE_AUDIO) { if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
av_set_pts_info(st, 32, 1, st->codec->sample_rate); av_set_pts_info(st, 32, 1, st->codec->sample_rate);


Loading…
Cancel
Save