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

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

Issue 304593004: H264 decoder for webRTC. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Using fragmentation header. Created 6 years, 4 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_decoder.cc ('k') | content/renderer/media/rtc_video_encoder_factory.cc » ('j') | 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 1b33fc54c90abe6881a48565c6d9fbb4aa58b513..591c9cb9c04c10fe3ee52897b0918731ffa57d11 100644
--- a/content/renderer/media/rtc_video_encoder.cc
+++ b/content/renderer/media/rtc_video_encoder.cc
@@ -648,6 +648,20 @@ void RTCVideoEncoder::ReturnEncodedImage(scoped_ptr<webrtc::EncodedImage> image,
if (!encoded_image_callback_)
return;
+ std::vector<int> offsets;
+ size_t i;
+ uint32 acc = 0;
+ for (i = 0; i < image->_length; ++i) {
+ acc = (acc << 8) | image->_buffer[i];
+ if ((acc & 0xffffff00) == 0x100)
+ offsets.push_back(i - 3);
+ }
+
+ // Generate a header describing a single fragment.
+ webrtc::RTPFragmentationHeader header;
+ memset(&header, 0, sizeof(header));
+ header.VerifyAndAllocateFragmentationHeader(offsets.size());
+
webrtc::CodecSpecificInfo info;
memset(&info, 0, sizeof(info));
info.codecType = video_codec_type_;
@@ -657,14 +671,15 @@ void RTCVideoEncoder::ReturnEncodedImage(scoped_ptr<webrtc::EncodedImage> image,
info.codecSpecific.VP8.keyIdx = -1;
}
- // Generate a header describing a single fragment.
- webrtc::RTPFragmentationHeader header;
- memset(&header, 0, sizeof(header));
- header.VerifyAndAllocateFragmentationHeader(1);
- header.fragmentationOffset[0] = 0;
- header.fragmentationLength[0] = image->_length;
- header.fragmentationPlType[0] = 0;
- header.fragmentationTimeDiff[0] = 0;
+ for (i = 0; i < offsets.size(); ++i) {
+ uint32_t length = (i == offsets.size() - 1) ?
+ (image->_length - offsets[i]) : (offsets[i + 1] - offsets[i]);
+
+ header.fragmentationOffset[i] = offsets[i] + 3;
+ header.fragmentationLength[0] = length - 3;
Stefan 2014/08/07 19:17:27 Shouldn't this be header.fragmentationLength[i]
hshi1 2014/08/07 19:32:10 sorry for the typo, yes this should be [i] not [0]
+ header.fragmentationPlType[0] = 0;
+ header.fragmentationTimeDiff[0] = 0;
+ }
int32_t retval = encoded_image_callback_->Encoded(*image, &info, &header);
if (retval < 0) {
« no previous file with comments | « content/renderer/media/rtc_video_decoder.cc ('k') | content/renderer/media/rtc_video_encoder_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698