| OLD | NEW |
| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 // Wait until shared memory is allocated to indicate that encoder is | 125 // Wait until shared memory is allocated to indicate that encoder is |
| 126 // initialized. | 126 // initialized. |
| 127 } | 127 } |
| 128 | 128 |
| 129 // Free the HW. | 129 // Free the HW. |
| 130 void Destroy() { | 130 void Destroy() { |
| 131 DCHECK(encoder_task_runner_); | 131 DCHECK(encoder_task_runner_); |
| 132 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread()); | 132 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread()); |
| 133 | 133 |
| 134 if (video_encode_accelerator_) { | 134 video_encode_accelerator_.reset(NULL); |
| 135 video_encode_accelerator_.release()->Destroy(); | |
| 136 } | |
| 137 } | 135 } |
| 138 | 136 |
| 139 void SetBitRate(uint32 bit_rate) { | 137 void SetBitRate(uint32 bit_rate) { |
| 140 DCHECK(encoder_task_runner_); | 138 DCHECK(encoder_task_runner_); |
| 141 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread()); | 139 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread()); |
| 142 | 140 |
| 143 video_encode_accelerator_->RequestEncodingParametersChange(bit_rate, | 141 video_encode_accelerator_->RequestEncodingParametersChange(bit_rate, |
| 144 max_frame_rate_); | 142 max_frame_rate_); |
| 145 } | 143 } |
| 146 | 144 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 158 // BitstreamBufferReady will be called once the encoder is done. | 156 // BitstreamBufferReady will be called once the encoder is done. |
| 159 video_encode_accelerator_->Encode(video_frame, key_frame_requested); | 157 video_encode_accelerator_->Encode(video_frame, key_frame_requested); |
| 160 } | 158 } |
| 161 | 159 |
| 162 protected: | 160 protected: |
| 163 virtual void NotifyError(VideoEncodeAccelerator::Error error) OVERRIDE { | 161 virtual void NotifyError(VideoEncodeAccelerator::Error error) OVERRIDE { |
| 164 DCHECK(encoder_task_runner_); | 162 DCHECK(encoder_task_runner_); |
| 165 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread()); | 163 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread()); |
| 166 VLOG(1) << "ExternalVideoEncoder NotifyError: " << error; | 164 VLOG(1) << "ExternalVideoEncoder NotifyError: " << error; |
| 167 | 165 |
| 168 if (video_encode_accelerator_) { | 166 video_encode_accelerator_.reset(NULL); |
| 169 video_encode_accelerator_.release()->Destroy(); | |
| 170 } | |
| 171 cast_environment_->PostTask( | 167 cast_environment_->PostTask( |
| 172 CastEnvironment::MAIN, | 168 CastEnvironment::MAIN, |
| 173 FROM_HERE, | 169 FROM_HERE, |
| 174 base::Bind(&ExternalVideoEncoder::EncoderError, weak_owner_)); | 170 base::Bind(&ExternalVideoEncoder::EncoderError, weak_owner_)); |
| 175 } | 171 } |
| 176 | 172 |
| 177 // Called to allocate the input and output buffers. | 173 // Called to allocate the input and output buffers. |
| 178 virtual void RequireBitstreamBuffers(unsigned int input_count, | 174 virtual void RequireBitstreamBuffers(unsigned int input_count, |
| 179 const gfx::Size& input_coded_size, | 175 const gfx::Size& input_coded_size, |
| 180 size_t output_buffer_size) OVERRIDE { | 176 size_t output_buffer_size) OVERRIDE { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 // Do nothing not supported. | 435 // Do nothing not supported. |
| 440 } | 436 } |
| 441 | 437 |
| 442 int ExternalVideoEncoder::NumberOfSkippedFrames() const { | 438 int ExternalVideoEncoder::NumberOfSkippedFrames() const { |
| 443 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 439 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 444 return skip_count_; | 440 return skip_count_; |
| 445 } | 441 } |
| 446 | 442 |
| 447 } // namespace cast | 443 } // namespace cast |
| 448 } // namespace media | 444 } // namespace media |
| OLD | NEW |