Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8206)

Unified Diff: content/renderer/media/rtc_video_encoder.cc

Issue 216793002: Add picture ID support in RtcVideoEncoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/media/rtc_video_encoder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/rtc_video_encoder.cc
diff --git a/content/renderer/media/rtc_video_encoder.cc b/content/renderer/media/rtc_video_encoder.cc
index 047bb8c3faf39497dcb531c8cb8605b72dc9b318..c930a7cea7565f4854ef19b2e6b1e98b4084636c 100644
--- a/content/renderer/media/rtc_video_encoder.cc
+++ b/content/renderer/media/rtc_video_encoder.cc
@@ -10,6 +10,7 @@
#include "base/memory/scoped_vector.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/histogram.h"
+#include "base/rand_util.h"
#include "base/synchronization/waitable_event.h"
#include "media/base/bitstream_buffer.h"
#include "media/base/video_frame.h"
@@ -152,6 +153,9 @@ class RTCVideoEncoder::Impl
// encoder.
int output_buffers_free_count_;
+ // 15 bits running index of the VP8 frames. See VP8 RTP spec for details.
+ uint16 picture_id_;
+
DISALLOW_COPY_AND_ASSIGN(Impl);
};
@@ -167,6 +171,8 @@ RTCVideoEncoder::Impl::Impl(
input_next_frame_keyframe_(false),
output_buffers_free_count_(0) {
thread_checker_.DetachFromThread();
+ // Picture ID should start on a random number.
+ picture_id_ = static_cast<uint16_t>(base::RandInt(0, 0x7FFF));
}
void RTCVideoEncoder::Impl::CreateAndInitializeVEA(
@@ -378,7 +384,10 @@ void RTCVideoEncoder::Impl::BitstreamBufferReady(int32 bitstream_buffer_id,
base::Bind(&RTCVideoEncoder::ReturnEncodedImage,
weak_encoder_,
base::Passed(&image),
- bitstream_buffer_id));
+ bitstream_buffer_id,
+ picture_id_));
+ // Picture ID must wrap after reaching the maximum.
+ picture_id_ = (picture_id_ + 1) & 0x7FFF;
}
void RTCVideoEncoder::Impl::NotifyError(
@@ -637,10 +646,12 @@ int32_t RTCVideoEncoder::SetRates(uint32_t new_bit_rate, uint32_t frame_rate) {
}
void RTCVideoEncoder::ReturnEncodedImage(scoped_ptr<webrtc::EncodedImage> image,
- int32 bitstream_buffer_id) {
+ int32 bitstream_buffer_id,
+ uint16 picture_id) {
DCHECK(thread_checker_.CalledOnValidThread());
DVLOG(3) << "ReturnEncodedImage(): "
- "bitstream_buffer_id=" << bitstream_buffer_id;
+ << "bitstream_buffer_id=" << bitstream_buffer_id
+ << ", picture_id=" << picture_id;
if (!encoded_image_callback_)
return;
@@ -649,7 +660,7 @@ void RTCVideoEncoder::ReturnEncodedImage(scoped_ptr<webrtc::EncodedImage> image,
memset(&info, 0, sizeof(info));
info.codecType = video_codec_type_;
if (video_codec_type_ == webrtc::kVideoCodecVP8) {
- info.codecSpecific.VP8.pictureId = -1;
+ info.codecSpecific.VP8.pictureId = picture_id;
info.codecSpecific.VP8.tl0PicIdx = -1;
info.codecSpecific.VP8.keyIdx = -1;
}
« no previous file with comments | « content/renderer/media/rtc_video_encoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698