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

Side by Side Diff: webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc

Issue 1599353003: Name SimulcastEncoderApdater on InitEncode. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 private: 130 private:
131 webrtc::SimulcastEncoderAdapter* const adapter_; 131 webrtc::SimulcastEncoderAdapter* const adapter_;
132 const size_t stream_idx_; 132 const size_t stream_idx_;
133 }; 133 };
134 134
135 } // namespace 135 } // namespace
136 136
137 namespace webrtc { 137 namespace webrtc {
138 138
139 SimulcastEncoderAdapter::SimulcastEncoderAdapter(VideoEncoderFactory* factory) 139 SimulcastEncoderAdapter::SimulcastEncoderAdapter(VideoEncoderFactory* factory)
140 : factory_(factory), encoded_complete_callback_(NULL) { 140 : factory_(factory),
141 encoded_complete_callback_(NULL),
142 implementation_name_("SimulcastEncoderAdapter") {
141 memset(&codec_, 0, sizeof(webrtc::VideoCodec)); 143 memset(&codec_, 0, sizeof(webrtc::VideoCodec));
142 } 144 }
143 145
144 SimulcastEncoderAdapter::~SimulcastEncoderAdapter() { 146 SimulcastEncoderAdapter::~SimulcastEncoderAdapter() {
145 Release(); 147 Release();
146 } 148 }
147 149
148 int SimulcastEncoderAdapter::Release() { 150 int SimulcastEncoderAdapter::Release() {
149 // TODO(pbos): Keep the last encoder instance but call ::Release() on it, then 151 // TODO(pbos): Keep the last encoder instance but call ::Release() on it, then
150 // re-use this instance in ::InitEncode(). This means that changing 152 // re-use this instance in ::InitEncode(). This means that changing
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 codec_ = *inst; 190 codec_ = *inst;
189 191
190 // Special mode when screensharing on a single stream. 192 // Special mode when screensharing on a single stream.
191 if (number_of_streams == 1 && inst->mode == kScreensharing) { 193 if (number_of_streams == 1 && inst->mode == kScreensharing) {
192 screensharing_extra_options_.reset(new Config()); 194 screensharing_extra_options_.reset(new Config());
193 screensharing_extra_options_->Set<TemporalLayers::Factory>( 195 screensharing_extra_options_->Set<TemporalLayers::Factory>(
194 new ScreenshareTemporalLayersFactory()); 196 new ScreenshareTemporalLayersFactory());
195 codec_.extra_options = screensharing_extra_options_.get(); 197 codec_.extra_options = screensharing_extra_options_.get();
196 } 198 }
197 199
200 std::string implementation_name;
198 // Create |number_of_streams| of encoder instances and init them. 201 // Create |number_of_streams| of encoder instances and init them.
199 for (int i = 0; i < number_of_streams; ++i) { 202 for (int i = 0; i < number_of_streams; ++i) {
200 VideoCodec stream_codec; 203 VideoCodec stream_codec;
201 bool send_stream = true; 204 bool send_stream = true;
202 if (!doing_simulcast) { 205 if (!doing_simulcast) {
203 stream_codec = codec_; 206 stream_codec = codec_;
204 stream_codec.numberOfSimulcastStreams = 1; 207 stream_codec.numberOfSimulcastStreams = 1;
205 } else { 208 } else {
206 bool highest_resolution_stream = (i == (number_of_streams - 1)); 209 bool highest_resolution_stream = (i == (number_of_streams - 1));
207 PopulateStreamCodec(&codec_, i, number_of_streams, 210 PopulateStreamCodec(&codec_, i, number_of_streams,
208 highest_resolution_stream, &stream_codec, 211 highest_resolution_stream, &stream_codec,
209 &send_stream); 212 &send_stream);
210 } 213 }
211 214
212 // TODO(ronghuawu): Remove once this is handled in VP8EncoderImpl. 215 // TODO(ronghuawu): Remove once this is handled in VP8EncoderImpl.
213 if (stream_codec.qpMax < kDefaultMinQp) { 216 if (stream_codec.qpMax < kDefaultMinQp) {
214 stream_codec.qpMax = kDefaultMaxQp; 217 stream_codec.qpMax = kDefaultMaxQp;
215 } 218 }
216 219
217 VideoEncoder* encoder = factory_->Create(); 220 VideoEncoder* encoder = factory_->Create();
218 ret = encoder->InitEncode(&stream_codec, number_of_cores, max_payload_size); 221 ret = encoder->InitEncode(&stream_codec, number_of_cores, max_payload_size);
219 if (ret < 0) { 222 if (ret < 0) {
220 Release(); 223 Release();
221 return ret; 224 return ret;
222 } 225 }
223 EncodedImageCallback* callback = new AdapterEncodedImageCallback(this, i); 226 EncodedImageCallback* callback = new AdapterEncodedImageCallback(this, i);
224 encoder->RegisterEncodeCompleteCallback(callback); 227 encoder->RegisterEncodeCompleteCallback(callback);
225 streaminfos_.push_back(StreamInfo(encoder, callback, stream_codec.width, 228 streaminfos_.push_back(StreamInfo(encoder, callback, stream_codec.width,
226 stream_codec.height, send_stream)); 229 stream_codec.height, send_stream));
230 if (i != 0)
231 implementation_name_ += ", ";
232 implementation_name += streaminfos_[0].encoder->ImplementationName();
stefan-webrtc 2016/01/20 14:18:12 i?
pbos-webrtc 2016/01/20 14:44:38 Done.
227 } 233 }
234 implementation_name_ =
235 "SimulcastEncoderAdapter (" + implementation_name + ")";
228 return WEBRTC_VIDEO_CODEC_OK; 236 return WEBRTC_VIDEO_CODEC_OK;
229 } 237 }
230 238
231 int SimulcastEncoderAdapter::Encode( 239 int SimulcastEncoderAdapter::Encode(
232 const VideoFrame& input_image, 240 const VideoFrame& input_image,
233 const CodecSpecificInfo* codec_specific_info, 241 const CodecSpecificInfo* codec_specific_info,
234 const std::vector<FrameType>* frame_types) { 242 const std::vector<FrameType>* frame_types) {
235 if (!Initialized()) { 243 if (!Initialized()) {
236 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; 244 return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
237 } 245 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 bool SimulcastEncoderAdapter::SupportsNativeHandle() const { 498 bool SimulcastEncoderAdapter::SupportsNativeHandle() const {
491 // We should not be calling this method before streaminfos_ are configured. 499 // We should not be calling this method before streaminfos_ are configured.
492 RTC_DCHECK(!streaminfos_.empty()); 500 RTC_DCHECK(!streaminfos_.empty());
493 // TODO(pbos): Support textures when using more than one encoder. 501 // TODO(pbos): Support textures when using more than one encoder.
494 if (streaminfos_.size() != 1) 502 if (streaminfos_.size() != 1)
495 return false; 503 return false;
496 return streaminfos_[0].encoder->SupportsNativeHandle(); 504 return streaminfos_[0].encoder->SupportsNativeHandle();
497 } 505 }
498 506
499 const char* SimulcastEncoderAdapter::ImplementationName() const { 507 const char* SimulcastEncoderAdapter::ImplementationName() const {
500 // We should not be calling this method before streaminfos_ are configured. 508 return implementation_name_.c_str();
501 RTC_DCHECK(!streaminfos_.empty());
502 // TODO(pbos): Support multiple implementation names for different encoders.
503 return streaminfos_[0].encoder->ImplementationName();
504 } 509 }
505 510
506 } // namespace webrtc 511 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698