OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/rtc_video_encoder.h" | 5 #include "content/renderer/media/rtc_video_encoder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 void RTCVideoEncoder::Impl::Destroy() { | 243 void RTCVideoEncoder::Impl::Destroy() { |
244 DVLOG(3) << "Impl::Destroy()"; | 244 DVLOG(3) << "Impl::Destroy()"; |
245 DCHECK(thread_checker_.CalledOnValidThread()); | 245 DCHECK(thread_checker_.CalledOnValidThread()); |
246 if (video_encoder_) | 246 if (video_encoder_) |
247 video_encoder_.release()->Destroy(); | 247 video_encoder_.release()->Destroy(); |
248 } | 248 } |
249 | 249 |
250 void RTCVideoEncoder::Impl::NotifyInitializeDone() { | 250 void RTCVideoEncoder::Impl::NotifyInitializeDone() { |
251 DVLOG(3) << "Impl::NotifyInitializeDone()"; | 251 DVLOG(3) << "Impl::NotifyInitializeDone()"; |
252 DCHECK(thread_checker_.CalledOnValidThread()); | 252 DCHECK(thread_checker_.CalledOnValidThread()); |
253 SignalAsyncWaiter(WEBRTC_VIDEO_CODEC_OK); | |
254 } | 253 } |
255 | 254 |
256 void RTCVideoEncoder::Impl::RequireBitstreamBuffers( | 255 void RTCVideoEncoder::Impl::RequireBitstreamBuffers( |
257 unsigned int input_count, | 256 unsigned int input_count, |
258 const gfx::Size& input_coded_size, | 257 const gfx::Size& input_coded_size, |
259 size_t output_buffer_size) { | 258 size_t output_buffer_size) { |
260 DVLOG(3) << "Impl::RequireBitstreamBuffers(): input_count=" << input_count | 259 DVLOG(3) << "Impl::RequireBitstreamBuffers(): input_count=" << input_count |
261 << ", input_coded_size=" << input_coded_size.ToString() | 260 << ", input_coded_size=" << input_coded_size.ToString() |
262 << ", output_buffer_size=" << output_buffer_size; | 261 << ", output_buffer_size=" << output_buffer_size; |
263 DCHECK(thread_checker_.CalledOnValidThread()); | 262 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 27 matching lines...) Expand all Loading... | |
291 return; | 290 return; |
292 } | 291 } |
293 output_buffers_.push_back(shm); | 292 output_buffers_.push_back(shm); |
294 } | 293 } |
295 | 294 |
296 // Immediately provide all output buffers to the VEA. | 295 // Immediately provide all output buffers to the VEA. |
297 for (size_t i = 0; i < output_buffers_.size(); ++i) { | 296 for (size_t i = 0; i < output_buffers_.size(); ++i) { |
298 video_encoder_->UseOutputBitstreamBuffer(media::BitstreamBuffer( | 297 video_encoder_->UseOutputBitstreamBuffer(media::BitstreamBuffer( |
299 i, output_buffers_[i]->handle(), output_buffers_[i]->mapped_size())); | 298 i, output_buffers_[i]->handle(), output_buffers_[i]->mapped_size())); |
300 } | 299 } |
300 SignalAsyncWaiter(WEBRTC_VIDEO_CODEC_OK); | |
Ami GONE FROM CHROMIUM
2013/09/03 20:09:54
Nothing guarantees that RequireBB will be called u
Pawel Osciak
2013/09/04 01:34:47
Well, if you look at how this class does it right
Ami GONE FROM CHROMIUM
2013/09/04 20:47:56
sheu@'s point about input_coded_size is reasonable
| |
301 } | 301 } |
302 | 302 |
303 void RTCVideoEncoder::Impl::BitstreamBufferReady(int32 bitstream_buffer_id, | 303 void RTCVideoEncoder::Impl::BitstreamBufferReady(int32 bitstream_buffer_id, |
304 size_t payload_size, | 304 size_t payload_size, |
305 bool key_frame) { | 305 bool key_frame) { |
306 DVLOG(3) << "Impl::BitstreamBufferReady(): " | 306 DVLOG(3) << "Impl::BitstreamBufferReady(): " |
307 "bitstream_buffer_id=" << bitstream_buffer_id | 307 "bitstream_buffer_id=" << bitstream_buffer_id |
308 << ", payload_size=" << payload_size | 308 << ", payload_size=" << payload_size |
309 << ", key_frame=" << key_frame; | 309 << ", key_frame=" << key_frame; |
310 DCHECK(thread_checker_.CalledOnValidThread()); | 310 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 void RTCVideoEncoder::ReturnEncodedImage(scoped_ptr<webrtc::EncodedImage> image, | 607 void RTCVideoEncoder::ReturnEncodedImage(scoped_ptr<webrtc::EncodedImage> image, |
608 int32 bitstream_buffer_id) { | 608 int32 bitstream_buffer_id) { |
609 DCHECK(thread_checker_.CalledOnValidThread()); | 609 DCHECK(thread_checker_.CalledOnValidThread()); |
610 DVLOG(3) << "ReturnEncodedImage(): " | 610 DVLOG(3) << "ReturnEncodedImage(): " |
611 "bitstream_buffer_id=" << bitstream_buffer_id; | 611 "bitstream_buffer_id=" << bitstream_buffer_id; |
612 | 612 |
613 if (!encoded_image_callback_) | 613 if (!encoded_image_callback_) |
614 return; | 614 return; |
615 | 615 |
616 webrtc::CodecSpecificInfo info; | 616 webrtc::CodecSpecificInfo info; |
617 memset(&info, 0, sizeof(info)); | |
617 info.codecType = video_codec_type_; | 618 info.codecType = video_codec_type_; |
618 | 619 |
619 // Generate a header describing a single fragment. | 620 // Generate a header describing a single fragment. |
620 webrtc::RTPFragmentationHeader header; | 621 webrtc::RTPFragmentationHeader header; |
622 memset(&header, 0, sizeof(header)); | |
621 header.VerifyAndAllocateFragmentationHeader(1); | 623 header.VerifyAndAllocateFragmentationHeader(1); |
622 header.fragmentationOffset[0] = 0; | 624 header.fragmentationOffset[0] = 0; |
623 header.fragmentationLength[0] = image->_length; | 625 header.fragmentationLength[0] = image->_length; |
624 header.fragmentationPlType[0] = 0; | 626 header.fragmentationPlType[0] = 0; |
625 header.fragmentationTimeDiff[0] = 0; | 627 header.fragmentationTimeDiff[0] = 0; |
626 | 628 |
627 int32_t retval = encoded_image_callback_->Encoded(*image, &info, &header); | 629 int32_t retval = encoded_image_callback_->Encoded(*image, &info, &header); |
628 if (retval < 0) { | 630 if (retval < 0) { |
629 DVLOG(2) << "ReturnEncodedImage(): encoded_image_callback_ returned " | 631 DVLOG(2) << "ReturnEncodedImage(): encoded_image_callback_ returned " |
630 << retval; | 632 << retval; |
(...skipping 12 matching lines...) Expand all Loading... | |
643 DCHECK(thread_checker_.CalledOnValidThread()); | 645 DCHECK(thread_checker_.CalledOnValidThread()); |
644 DVLOG(1) << "NotifyError(): error=" << error; | 646 DVLOG(1) << "NotifyError(): error=" << error; |
645 | 647 |
646 impl_status_ = error; | 648 impl_status_ = error; |
647 gpu_factories_->GetMessageLoop()->PostTask( | 649 gpu_factories_->GetMessageLoop()->PostTask( |
648 FROM_HERE, base::Bind(&RTCVideoEncoder::Impl::Destroy, impl_)); | 650 FROM_HERE, base::Bind(&RTCVideoEncoder::Impl::Destroy, impl_)); |
649 impl_ = NULL; | 651 impl_ = NULL; |
650 } | 652 } |
651 | 653 |
652 } // namespace content | 654 } // namespace content |
OLD | NEW |