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

Side by Side Diff: media/cast/video_sender/external_video_encoder.cc

Issue 288103002: [Cast] EncodedAudioFrame+EncodedVideoFrame+reference_time --> EncodedFrame (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/video_sender/external_video_encoder.h" 5 #include "media/cast/video_sender/external_video_encoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 if (key_frame) 216 if (key_frame)
217 key_frame_encountered_ = true; 217 key_frame_encountered_ = true;
218 if (!key_frame_encountered_) { 218 if (!key_frame_encountered_) {
219 // Do not send video until we have encountered the first key frame. 219 // Do not send video until we have encountered the first key frame.
220 // Save the bitstream buffer in |stream_header_| to be sent later along 220 // Save the bitstream buffer in |stream_header_| to be sent later along
221 // with the first key frame. 221 // with the first key frame.
222 stream_header_.append(static_cast<const char*>(output_buffer->memory()), 222 stream_header_.append(static_cast<const char*>(output_buffer->memory()),
223 payload_size); 223 payload_size);
224 } else if (!encoded_frame_data_storage_.empty()) { 224 } else if (!encoded_frame_data_storage_.empty()) {
225 scoped_ptr<transport::EncodedVideoFrame> encoded_frame( 225 scoped_ptr<transport::EncodedFrame> encoded_frame(
226 new transport::EncodedVideoFrame()); 226 new transport::EncodedFrame());
227 227 encoded_frame->dependency = key_frame ? transport::EncodedFrame::KEY :
228 encoded_frame->codec = codec_; 228 transport::EncodedFrame::DEPENDENT;
229 encoded_frame->key_frame = key_frame; 229 encoded_frame->frame_id = ++last_encoded_frame_id_;
230 encoded_frame->last_referenced_frame_id = last_encoded_frame_id_; 230 if (key_frame)
231 last_encoded_frame_id_++; 231 encoded_frame->referenced_frame_id = encoded_frame->frame_id;
232 encoded_frame->frame_id = last_encoded_frame_id_; 232 else
233 encoded_frame->rtp_timestamp = GetVideoRtpTimestamp( 233 encoded_frame->referenced_frame_id = encoded_frame->frame_id - 1;
234 encoded_frame_data_storage_.front().capture_time); 234 encoded_frame->reference_time =
235 if (key_frame) { 235 encoded_frame_data_storage_.front().capture_time;
236 // Self referenced. 236 encoded_frame->rtp_timestamp =
237 encoded_frame->last_referenced_frame_id = encoded_frame->frame_id; 237 GetVideoRtpTimestamp(encoded_frame->reference_time);
238 }
239
240 if (!stream_header_.empty()) { 238 if (!stream_header_.empty()) {
241 encoded_frame->data = stream_header_; 239 encoded_frame->data = stream_header_;
242 stream_header_.clear(); 240 stream_header_.clear();
243 } 241 }
244 encoded_frame->data.append( 242 encoded_frame->data.append(
245 static_cast<const char*>(output_buffer->memory()), payload_size); 243 static_cast<const char*>(output_buffer->memory()), payload_size);
246 244
247 cast_environment_->PostTask( 245 cast_environment_->PostTask(
248 CastEnvironment::MAIN, 246 CastEnvironment::MAIN,
249 FROM_HERE, 247 FROM_HERE,
250 base::Bind(&LogFrameEncodedEvent, 248 base::Bind(&LogFrameEncodedEvent,
251 cast_environment_, 249 cast_environment_,
252 cast_environment_->Clock()->NowTicks(), 250 cast_environment_->Clock()->NowTicks(),
253 encoded_frame->rtp_timestamp, 251 encoded_frame->rtp_timestamp,
254 encoded_frame->frame_id)); 252 encoded_frame->frame_id));
255 253
256 cast_environment_->PostTask( 254 cast_environment_->PostTask(
257 CastEnvironment::MAIN, 255 CastEnvironment::MAIN,
258 FROM_HERE, 256 FROM_HERE,
259 base::Bind(encoded_frame_data_storage_.front().frame_encoded_callback, 257 base::Bind(encoded_frame_data_storage_.front().frame_encoded_callback,
260 base::Passed(&encoded_frame), 258 base::Passed(&encoded_frame)));
261 encoded_frame_data_storage_.front().capture_time));
262 259
263 encoded_frame_data_storage_.pop_front(); 260 encoded_frame_data_storage_.pop_front();
264 } else { 261 } else {
265 VLOG(1) << "BitstreamBufferReady(): no encoded frame data available"; 262 VLOG(1) << "BitstreamBufferReady(): no encoded frame data available";
266 } 263 }
267 264
268 // We need to re-add the output buffer to the encoder after we are done 265 // We need to re-add the output buffer to the encoder after we are done
269 // with it. 266 // with it.
270 video_encode_accelerator_->UseOutputBitstreamBuffer(media::BitstreamBuffer( 267 video_encode_accelerator_->UseOutputBitstreamBuffer(media::BitstreamBuffer(
271 bitstream_buffer_id, 268 bitstream_buffer_id,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 // Do nothing not supported. 439 // Do nothing not supported.
443 } 440 }
444 441
445 int ExternalVideoEncoder::NumberOfSkippedFrames() const { 442 int ExternalVideoEncoder::NumberOfSkippedFrames() const {
446 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 443 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
447 return skip_count_; 444 return skip_count_;
448 } 445 }
449 446
450 } // namespace cast 447 } // namespace cast
451 } // namespace media 448 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/video_sender/codecs/vp8/vp8_encoder.cc ('k') | media/cast/video_sender/external_video_encoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698