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

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

Issue 185403020: Make VEA client of command buffer; move sync. IPC to VDA/VEA::Initialize() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: f2a9ccb5 Rebase, posciak@ comments. 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 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 // Initialize the real HW encoder. 67 // Initialize the real HW encoder.
68 void Initialize(const VideoSenderConfig& video_config) { 68 void Initialize(const VideoSenderConfig& video_config) {
69 DCHECK(gpu_factories_); 69 DCHECK(gpu_factories_);
70 DCHECK(encoder_task_runner_); 70 DCHECK(encoder_task_runner_);
71 71
72 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread()); 72 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread());
73 73
74 video_encode_accelerator_ = 74 video_encode_accelerator_ =
75 gpu_factories_->CreateVideoEncodeAccelerator().Pass(); 75 gpu_factories_->CreateVideoEncodeAccelerator().Pass();
76 if (!video_encode_accelerator_) 76 if (!video_encode_accelerator_) {
77 NotifyError(VideoEncodeAccelerator::kPlatformFailureError);
77 return; 78 return;
79 }
78 80
79 VideoCodecProfile output_profile = media::VIDEO_CODEC_PROFILE_UNKNOWN; 81 VideoCodecProfile output_profile = media::VIDEO_CODEC_PROFILE_UNKNOWN;
80 switch (video_config.codec) { 82 switch (video_config.codec) {
81 case transport::kVp8: 83 case transport::kVp8:
82 output_profile = media::VP8PROFILE_MAIN; 84 output_profile = media::VP8PROFILE_MAIN;
83 break; 85 break;
84 case transport::kH264: 86 case transport::kH264:
85 output_profile = media::H264PROFILE_MAIN; 87 output_profile = media::H264PROFILE_MAIN;
86 break; 88 break;
87 } 89 }
88 codec_ = video_config.codec; 90 codec_ = video_config.codec;
89 max_frame_rate_ = video_config.max_frame_rate; 91 max_frame_rate_ = video_config.max_frame_rate;
90 92
91 // Asynchronous initialization call; NotifyInitializeDone or NotifyError 93 if (!video_encode_accelerator_->Initialize(
92 // will be called once the HW is initialized. 94 media::VideoFrame::I420,
93 video_encode_accelerator_->Initialize( 95 gfx::Size(video_config.width, video_config.height),
94 media::VideoFrame::I420, 96 output_profile,
95 gfx::Size(video_config.width, video_config.height), 97 video_config.start_bitrate,
96 output_profile, 98 this)) {
97 video_config.start_bitrate, 99 NotifyError(VideoEncodeAccelerator::kInvalidArgumentError);
98 this); 100 return;
101 }
102
103 cast_environment_->PostTask(
104 CastEnvironment::MAIN,
105 FROM_HERE,
106 base::Bind(&ExternalVideoEncoder::EncoderInitialized, weak_owner_));
99 } 107 }
100 108
101 // Free the HW. 109 // Free the HW.
102 void Destroy() { 110 void Destroy() {
103 DCHECK(encoder_task_runner_); 111 DCHECK(encoder_task_runner_);
104 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread()); 112 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread());
105 113
106 if (video_encode_accelerator_) { 114 if (video_encode_accelerator_) {
107 video_encode_accelerator_.release()->Destroy(); 115 video_encode_accelerator_.release()->Destroy();
108 } 116 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 frame.get()); 177 frame.get());
170 178
171 encoded_frame_data_storage_.push_back( 179 encoded_frame_data_storage_.push_back(
172 EncodedFrameReturnData(capture_time, frame_encoded_callback)); 180 EncodedFrameReturnData(capture_time, frame_encoded_callback));
173 181
174 // BitstreamBufferReady will be called once the encoder is done. 182 // BitstreamBufferReady will be called once the encoder is done.
175 video_encode_accelerator_->Encode(frame, key_frame_requested); 183 video_encode_accelerator_->Encode(frame, key_frame_requested);
176 } 184 }
177 185
178 protected: 186 protected:
179 virtual void NotifyInitializeDone() OVERRIDE {
180 DCHECK(encoder_task_runner_);
181 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread());
182
183 cast_environment_->PostTask(
184 CastEnvironment::MAIN,
185 FROM_HERE,
186 base::Bind(&ExternalVideoEncoder::EncoderInitialized, weak_owner_));
187 }
188
189 virtual void NotifyError(VideoEncodeAccelerator::Error error) OVERRIDE { 187 virtual void NotifyError(VideoEncodeAccelerator::Error error) OVERRIDE {
190 DCHECK(encoder_task_runner_); 188 DCHECK(encoder_task_runner_);
191 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread()); 189 DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread());
192 VLOG(1) << "ExternalVideoEncoder NotifyError: " << error; 190 VLOG(1) << "ExternalVideoEncoder NotifyError: " << error;
193 191
194 if (video_encode_accelerator_) { 192 if (video_encode_accelerator_) {
195 video_encode_accelerator_.release()->Destroy(); 193 video_encode_accelerator_.release()->Destroy();
196 } 194 }
197 cast_environment_->PostTask( 195 cast_environment_->PostTask(
198 CastEnvironment::MAIN, 196 CastEnvironment::MAIN,
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 // Do nothing not supported. 447 // Do nothing not supported.
450 } 448 }
451 449
452 int ExternalVideoEncoder::NumberOfSkippedFrames() const { 450 int ExternalVideoEncoder::NumberOfSkippedFrames() const {
453 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 451 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
454 return skip_count_; 452 return skip_count_;
455 } 453 }
456 454
457 } // namespace cast 455 } // namespace cast
458 } // namespace media 456 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698