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

Side by Side Diff: webrtc/media/engine/simulcast_encoder_adapter.cc

Issue 2964953002: Remove webrtc::VideoEncoderFactory (Closed)
Patch Set: Add dep to base:sequenced_task_checker Created 3 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" 11 #include "webrtc/media/engine/simulcast_encoder_adapter.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 14
15 // NOTE(ajm): Path provided by gyp. 15 // NOTE(ajm): Path provided by gyp.
16 #include "libyuv/scale.h" // NOLINT 16 #include "libyuv/scale.h" // NOLINT
17 17
18 #include "webrtc/api/video/i420_buffer.h" 18 #include "webrtc/api/video/i420_buffer.h"
19 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h" 19 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h"
20 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_rate_allocator.h" 20 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_rate_allocator.h"
21 #include "webrtc/rtc_base/checks.h" 21 #include "webrtc/rtc_base/checks.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 120
121 const int adapted_simulcast_id_; 121 const int adapted_simulcast_id_;
122 const TemporalLayersFactory& tl_factory_; 122 const TemporalLayersFactory& tl_factory_;
123 }; 123 };
124 124
125 } // namespace 125 } // namespace
126 126
127 namespace webrtc { 127 namespace webrtc {
128 128
129 SimulcastEncoderAdapter::SimulcastEncoderAdapter(VideoEncoderFactory* factory) 129 SimulcastEncoderAdapter::SimulcastEncoderAdapter(
130 cricket::WebRtcVideoEncoderFactory* factory)
130 : inited_(0), 131 : inited_(0),
131 factory_(factory), 132 factory_(factory),
132 encoded_complete_callback_(nullptr), 133 encoded_complete_callback_(nullptr),
133 implementation_name_("SimulcastEncoderAdapter") { 134 implementation_name_("SimulcastEncoderAdapter") {
134 // The adapter is typically created on the worker thread, but operated on 135 // The adapter is typically created on the worker thread, but operated on
135 // the encoder task queue. 136 // the encoder task queue.
136 encoder_queue_.Detach(); 137 encoder_queue_.Detach();
137 138
138 memset(&codec_, 0, sizeof(webrtc::VideoCodec)); 139 memset(&codec_, 0, sizeof(webrtc::VideoCodec));
139 } 140 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 230 }
230 231
231 // If an existing encoder instance exists, reuse it. 232 // If an existing encoder instance exists, reuse it.
232 // TODO(brandtr): Set initial RTP state (e.g., picture_id/tl0_pic_idx) here, 233 // TODO(brandtr): Set initial RTP state (e.g., picture_id/tl0_pic_idx) here,
233 // when we start storing that state outside the encoder wrappers. 234 // when we start storing that state outside the encoder wrappers.
234 VideoEncoder* encoder; 235 VideoEncoder* encoder;
235 if (!stored_encoders_.empty()) { 236 if (!stored_encoders_.empty()) {
236 encoder = stored_encoders_.top(); 237 encoder = stored_encoders_.top();
237 stored_encoders_.pop(); 238 stored_encoders_.pop();
238 } else { 239 } else {
239 encoder = factory_->Create(); 240 encoder = factory_->CreateVideoEncoder(cricket::VideoCodec("VP8"));
240 } 241 }
241 242
242 ret = encoder->InitEncode(&stream_codec, number_of_cores, max_payload_size); 243 ret = encoder->InitEncode(&stream_codec, number_of_cores, max_payload_size);
243 if (ret < 0) { 244 if (ret < 0) {
244 // Explicitly destroy the current encoder; because we haven't registered a 245 // Explicitly destroy the current encoder; because we haven't registered a
245 // StreamInfo for it yet, Release won't do anything about it. 246 // StreamInfo for it yet, Release won't do anything about it.
246 factory_->Destroy(encoder); 247 factory_->DestroyVideoEncoder(encoder);
247 Release(); 248 Release();
248 return ret; 249 return ret;
249 } 250 }
250 std::unique_ptr<EncodedImageCallback> callback( 251 std::unique_ptr<EncodedImageCallback> callback(
251 new AdapterEncodedImageCallback(this, i)); 252 new AdapterEncodedImageCallback(this, i));
252 encoder->RegisterEncodeCompleteCallback(callback.get()); 253 encoder->RegisterEncodeCompleteCallback(callback.get());
253 streaminfos_.emplace_back(encoder, std::move(callback), stream_codec.width, 254 streaminfos_.emplace_back(encoder, std::move(callback), stream_codec.width,
254 stream_codec.height, start_bitrate_kbps > 0); 255 stream_codec.height, start_bitrate_kbps > 0);
255 256
256 if (i != 0) { 257 if (i != 0) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 stream_codec->startBitrate = start_bitrate_kbps; 494 stream_codec->startBitrate = start_bitrate_kbps;
494 } 495 }
495 496
496 bool SimulcastEncoderAdapter::Initialized() const { 497 bool SimulcastEncoderAdapter::Initialized() const {
497 return rtc::AtomicOps::AcquireLoad(&inited_) == 1; 498 return rtc::AtomicOps::AcquireLoad(&inited_) == 1;
498 } 499 }
499 500
500 void SimulcastEncoderAdapter::DestroyStoredEncoders() { 501 void SimulcastEncoderAdapter::DestroyStoredEncoders() {
501 while (!stored_encoders_.empty()) { 502 while (!stored_encoders_.empty()) {
502 VideoEncoder* encoder = stored_encoders_.top(); 503 VideoEncoder* encoder = stored_encoders_.top();
503 factory_->Destroy(encoder); 504 factory_->DestroyVideoEncoder(encoder);
504 stored_encoders_.pop(); 505 stored_encoders_.pop();
505 } 506 }
506 } 507 }
507 508
508 bool SimulcastEncoderAdapter::SupportsNativeHandle() const { 509 bool SimulcastEncoderAdapter::SupportsNativeHandle() const {
509 RTC_DCHECK_CALLED_SEQUENTIALLY(&encoder_queue_); 510 RTC_DCHECK_CALLED_SEQUENTIALLY(&encoder_queue_);
510 // We should not be calling this method before streaminfos_ are configured. 511 // We should not be calling this method before streaminfos_ are configured.
511 RTC_DCHECK(!streaminfos_.empty()); 512 RTC_DCHECK(!streaminfos_.empty());
512 for (const auto& streaminfo : streaminfos_) { 513 for (const auto& streaminfo : streaminfos_) {
513 if (!streaminfo.encoder->SupportsNativeHandle()) { 514 if (!streaminfo.encoder->SupportsNativeHandle()) {
(...skipping 13 matching lines...) Expand all
527 } 528 }
528 return streaminfos_[0].encoder->GetScalingSettings(); 529 return streaminfos_[0].encoder->GetScalingSettings();
529 } 530 }
530 531
531 const char* SimulcastEncoderAdapter::ImplementationName() const { 532 const char* SimulcastEncoderAdapter::ImplementationName() const {
532 RTC_DCHECK_CALLED_SEQUENTIALLY(&encoder_queue_); 533 RTC_DCHECK_CALLED_SEQUENTIALLY(&encoder_queue_);
533 return implementation_name_.c_str(); 534 return implementation_name_.c_str();
534 } 535 }
535 536
536 } // namespace webrtc 537 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/media/engine/simulcast_encoder_adapter.h ('k') | webrtc/media/engine/simulcast_encoder_adapter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698