diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-12-17 14:06:06 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-12-17 14:06:11 +0100 |
commit | 8d07bbca6360a938c607dab4dcb333e12f3d915b (patch) | |
tree | 9f253cc9866c746732ab2d07edb4d87b25e3799c | |
parent | 021b3497e1bccd4d6b2e54ecf89cfd43793a2489 (diff) | |
parent | f322b2073581119de5da74f92a03309a36891cfa (diff) | |
download | ffmpeg-8d07bbca6360a938c607dab4dcb333e12f3d915b.tar.gz |
Merge commit 'f322b2073581119de5da74f92a03309a36891cfa'
* commit 'f322b2073581119de5da74f92a03309a36891cfa':
lavr: only save/restore the mixing matrix if mixing is being done
rtpdec_vp8: Cosmetics: Fix bad alignment/indentation
rtpenc: Allow including a SDES/CNAME block in RTCP SR packets
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/rtpdec_vp8.c | 4 | ||||
-rw-r--r-- | libavformat/rtpenc.c | 17 | ||||
-rw-r--r-- | libavformat/rtpenc.h | 1 | ||||
-rw-r--r-- | libavresample/resample.c | 18 |
4 files changed, 32 insertions, 8 deletions
diff --git a/libavformat/rtpdec_vp8.c b/libavformat/rtpdec_vp8.c index 1edc152a48..58dc24d010 100644 --- a/libavformat/rtpdec_vp8.c +++ b/libavformat/rtpdec_vp8.c @@ -33,7 +33,7 @@ struct PayloadContext { AVIOContext *data; - uint32_t timestamp; + uint32_t timestamp; }; static int vp8_handle_packet(AVFormatContext *ctx, @@ -100,7 +100,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, if ((res = avio_open_dyn_buf(&vp8->data)) < 0) return res; vp8->timestamp = *timestamp; - } + } if (!vp8->data || vp8->timestamp != *timestamp) { av_log(ctx, AV_LOG_WARNING, diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index 0010a92e2d..b7502704b1 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -34,6 +34,7 @@ static const AVOption options[] = { FF_RTP_FLAG_OPTS(RTPMuxContext, flags), { "payload_type", "Specify RTP payload type", offsetof(RTPMuxContext, payload_type), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 127, AV_OPT_FLAG_ENCODING_PARAM }, { "ssrc", "Stream identifier", offsetof(RTPMuxContext, ssrc), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, + { "cname", "CNAME to include in RTCP SR packets", offsetof(RTPMuxContext, cname), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { NULL }, }; @@ -271,6 +272,22 @@ static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time) avio_wb32(s1->pb, rtp_ts); avio_wb32(s1->pb, s->packet_count); avio_wb32(s1->pb, s->octet_count); + + if (s->cname) { + int len = FFMIN(strlen(s->cname), 255); + avio_w8(s1->pb, (RTP_VERSION << 6) + 1); + avio_w8(s1->pb, RTCP_SDES); + avio_wb16(s1->pb, (7 + len + 3) / 4); /* length in words - 1 */ + + avio_wb32(s1->pb, s->ssrc); + avio_w8(s1->pb, 0x01); /* CNAME */ + avio_w8(s1->pb, len); + avio_write(s1->pb, s->cname, len); + avio_w8(s1->pb, 0); /* END */ + for (len = (7 + len) % 4; len % 4; len++) + avio_w8(s1->pb, 0); + } + avio_flush(s1->pb); } diff --git a/libavformat/rtpenc.h b/libavformat/rtpenc.h index 04b8fc7305..f304ea8c58 100644 --- a/libavformat/rtpenc.h +++ b/libavformat/rtpenc.h @@ -30,6 +30,7 @@ struct RTPMuxContext { AVStream *st; int payload_type; uint32_t ssrc; + const char *cname; uint16_t seq; uint32_t timestamp; uint32_t base_timestamp; diff --git a/libavresample/resample.c b/libavresample/resample.c index 381d673717..15eaa50e23 100644 --- a/libavresample/resample.c +++ b/libavresample/resample.c @@ -259,6 +259,7 @@ int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta, AVAudioResampleContext and force resampling */ if (!avr->resample_needed) { int fifo_samples; + int restore_matrix = 0; double matrix[AVRESAMPLE_MAX_CHANNELS * AVRESAMPLE_MAX_CHANNELS] = { 0 }; /* buffer any remaining samples in the output FIFO before closing */ @@ -274,9 +275,12 @@ int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta, goto reinit_fail; } /* save the channel mixing matrix */ - ret = avresample_get_matrix(avr, matrix, AVRESAMPLE_MAX_CHANNELS); - if (ret < 0) - goto reinit_fail; + if (avr->am) { + ret = avresample_get_matrix(avr, matrix, AVRESAMPLE_MAX_CHANNELS); + if (ret < 0) + goto reinit_fail; + restore_matrix = 1; + } /* close the AVAudioResampleContext */ avresample_close(avr); @@ -284,9 +288,11 @@ int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta, avr->force_resampling = 1; /* restore the channel mixing matrix */ - ret = avresample_set_matrix(avr, matrix, AVRESAMPLE_MAX_CHANNELS); - if (ret < 0) - goto reinit_fail; + if (restore_matrix) { + ret = avresample_set_matrix(avr, matrix, AVRESAMPLE_MAX_CHANNELS); + if (ret < 0) + goto reinit_fail; + } /* re-open the AVAudioResampleContext */ ret = avresample_open(avr); |