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

Side by Side Diff: webrtc/modules/video_coding/codec_database.cc

Issue 1541803002: Lint fix for webrtc/modules/video_coding PART 1! (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years 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 | « no previous file | webrtc/modules/video_coding/codec_timer.h » ('j') | 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 max_payload_size_ = max_payload_size; 211 max_payload_size_ = max_payload_size;
212 reset_required = true; 212 reset_required = true;
213 } 213 }
214 214
215 VideoCodec new_send_codec; 215 VideoCodec new_send_codec;
216 memcpy(&new_send_codec, send_codec, sizeof(new_send_codec)); 216 memcpy(&new_send_codec, send_codec, sizeof(new_send_codec));
217 217
218 if (new_send_codec.maxBitrate == 0) { 218 if (new_send_codec.maxBitrate == 0) {
219 // max is one bit per pixel 219 // max is one bit per pixel
220 new_send_codec.maxBitrate = (static_cast<int>(send_codec->height) * 220 new_send_codec.maxBitrate = (static_cast<int>(send_codec->height) *
221 static_cast<int>(send_codec->width) * 221 static_cast<int>(send_codec->width) *
222 static_cast<int>(send_codec->maxFramerate)) / 1000; 222 static_cast<int>(send_codec->maxFramerate)) /
223 1000;
223 if (send_codec->startBitrate > new_send_codec.maxBitrate) { 224 if (send_codec->startBitrate > new_send_codec.maxBitrate) {
224 // But if the user tries to set a higher start bit rate we will 225 // But if the user tries to set a higher start bit rate we will
225 // increase the max accordingly. 226 // increase the max accordingly.
226 new_send_codec.maxBitrate = send_codec->startBitrate; 227 new_send_codec.maxBitrate = send_codec->startBitrate;
227 } 228 }
228 } 229 }
229 230
230 if (new_send_codec.startBitrate > new_send_codec.maxBitrate) 231 if (new_send_codec.startBitrate > new_send_codec.maxBitrate)
231 new_send_codec.startBitrate = new_send_codec.maxBitrate; 232 new_send_codec.startBitrate = new_send_codec.maxBitrate;
232 233
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return true; 276 return true;
276 } 277 }
277 278
278 VideoCodecType VCMCodecDataBase::SendCodec() const { 279 VideoCodecType VCMCodecDataBase::SendCodec() const {
279 if (!ptr_encoder_) { 280 if (!ptr_encoder_) {
280 return kVideoCodecUnknown; 281 return kVideoCodecUnknown;
281 } 282 }
282 return send_codec_.codecType; 283 return send_codec_.codecType;
283 } 284 }
284 285
285 bool VCMCodecDataBase::DeregisterExternalEncoder( 286 bool VCMCodecDataBase::DeregisterExternalEncoder(uint8_t payload_type,
286 uint8_t payload_type, bool* was_send_codec) { 287 bool* was_send_codec) {
287 assert(was_send_codec); 288 assert(was_send_codec);
288 *was_send_codec = false; 289 *was_send_codec = false;
289 if (encoder_payload_type_ != payload_type) { 290 if (encoder_payload_type_ != payload_type) {
290 return false; 291 return false;
291 } 292 }
292 if (send_codec_.plType == payload_type) { 293 if (send_codec_.plType == payload_type) {
293 // De-register as send codec if needed. 294 // De-register as send codec if needed.
294 DeleteEncoder(); 295 DeleteEncoder();
295 memset(&send_codec_, 0, sizeof(VideoCodec)); 296 memset(&send_codec_, 0, sizeof(VideoCodec));
296 *was_send_codec = true; 297 *was_send_codec = true;
297 } 298 }
298 encoder_payload_type_ = 0; 299 encoder_payload_type_ = 0;
299 external_encoder_ = nullptr; 300 external_encoder_ = nullptr;
300 internal_source_ = false; 301 internal_source_ = false;
301 return true; 302 return true;
302 } 303 }
303 304
304 void VCMCodecDataBase::RegisterExternalEncoder( 305 void VCMCodecDataBase::RegisterExternalEncoder(VideoEncoder* external_encoder,
305 VideoEncoder* external_encoder, 306 uint8_t payload_type,
306 uint8_t payload_type, 307 bool internal_source) {
307 bool internal_source) {
308 // Since only one encoder can be used at a given time, only one external 308 // Since only one encoder can be used at a given time, only one external
309 // encoder can be registered/used. 309 // encoder can be registered/used.
310 external_encoder_ = external_encoder; 310 external_encoder_ = external_encoder;
311 encoder_payload_type_ = payload_type; 311 encoder_payload_type_ = payload_type;
312 internal_source_ = internal_source; 312 internal_source_ = internal_source;
313 pending_encoder_reset_ = true; 313 pending_encoder_reset_ = true;
314 } 314 }
315 315
316 bool VCMCodecDataBase::RequiresEncoderReset(const VideoCodec& new_send_codec) { 316 bool VCMCodecDataBase::RequiresEncoderReset(const VideoCodec& new_send_codec) {
317 if (!ptr_encoder_) 317 if (!ptr_encoder_)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // Unknown codec type, reset just to be sure. 365 // Unknown codec type, reset just to be sure.
366 case kVideoCodecUnknown: 366 case kVideoCodecUnknown:
367 return true; 367 return true;
368 } 368 }
369 369
370 if (new_send_codec.numberOfSimulcastStreams > 0) { 370 if (new_send_codec.numberOfSimulcastStreams > 0) {
371 for (unsigned char i = 0; i < new_send_codec.numberOfSimulcastStreams; 371 for (unsigned char i = 0; i < new_send_codec.numberOfSimulcastStreams;
372 ++i) { 372 ++i) {
373 if (memcmp(&new_send_codec.simulcastStream[i], 373 if (memcmp(&new_send_codec.simulcastStream[i],
374 &send_codec_.simulcastStream[i], 374 &send_codec_.simulcastStream[i],
375 sizeof(new_send_codec.simulcastStream[i])) != 375 sizeof(new_send_codec.simulcastStream[i])) != 0) {
376 0) {
377 return true; 376 return true;
378 } 377 }
379 } 378 }
380 } 379 }
381 return false; 380 return false;
382 } 381 }
383 382
384 VCMGenericEncoder* VCMCodecDataBase::GetEncoder() { 383 VCMGenericEncoder* VCMCodecDataBase::GetEncoder() {
385 return ptr_encoder_.get(); 384 return ptr_encoder_.get();
386 } 385 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 VCMExtDecoderMapItem* ext_decoder = 421 VCMExtDecoderMapItem* ext_decoder =
423 new VCMExtDecoderMapItem(external_decoder, payload_type); 422 new VCMExtDecoderMapItem(external_decoder, payload_type);
424 DeregisterExternalDecoder(payload_type); 423 DeregisterExternalDecoder(payload_type);
425 dec_external_map_[payload_type] = ext_decoder; 424 dec_external_map_[payload_type] = ext_decoder;
426 } 425 }
427 426
428 bool VCMCodecDataBase::DecoderRegistered() const { 427 bool VCMCodecDataBase::DecoderRegistered() const {
429 return !dec_map_.empty(); 428 return !dec_map_.empty();
430 } 429 }
431 430
432 bool VCMCodecDataBase::RegisterReceiveCodec( 431 bool VCMCodecDataBase::RegisterReceiveCodec(const VideoCodec* receive_codec,
433 const VideoCodec* receive_codec, 432 int number_of_cores,
434 int number_of_cores, 433 bool require_key_frame) {
435 bool require_key_frame) {
436 if (number_of_cores < 0) { 434 if (number_of_cores < 0) {
437 return false; 435 return false;
438 } 436 }
439 // Check if payload value already exists, if so - erase old and insert new. 437 // Check if payload value already exists, if so - erase old and insert new.
440 DeregisterReceiveCodec(receive_codec->plType); 438 DeregisterReceiveCodec(receive_codec->plType);
441 if (receive_codec->codecType == kVideoCodecUnknown) { 439 if (receive_codec->codecType == kVideoCodecUnknown) {
442 return false; 440 return false;
443 } 441 }
444 VideoCodec* new_receive_codec = new VideoCodec(*receive_codec); 442 VideoCodec* new_receive_codec = new VideoCodec(*receive_codec);
445 dec_map_[receive_codec->plType] = new VCMDecoderMapItem(new_receive_codec, 443 dec_map_[receive_codec->plType] = new VCMDecoderMapItem(
446 number_of_cores, 444 new_receive_codec, number_of_cores, require_key_frame);
447 require_key_frame);
448 return true; 445 return true;
449 } 446 }
450 447
451 bool VCMCodecDataBase::DeregisterReceiveCodec( 448 bool VCMCodecDataBase::DeregisterReceiveCodec(uint8_t payload_type) {
452 uint8_t payload_type) {
453 DecoderMap::iterator it = dec_map_.find(payload_type); 449 DecoderMap::iterator it = dec_map_.find(payload_type);
454 if (it == dec_map_.end()) { 450 if (it == dec_map_.end()) {
455 return false; 451 return false;
456 } 452 }
457 delete it->second; 453 delete it->second;
458 dec_map_.erase(it); 454 dec_map_.erase(it);
459 if (receive_codec_.plType == payload_type) { 455 if (receive_codec_.plType == payload_type) {
460 // This codec is currently in use. 456 // This codec is currently in use.
461 memset(&receive_codec_, 0, sizeof(VideoCodec)); 457 memset(&receive_codec_, 0, sizeof(VideoCodec));
462 } 458 }
(...skipping 27 matching lines...) Expand all
490 if (ptr_decoder_) { 486 if (ptr_decoder_) {
491 ReleaseDecoder(ptr_decoder_); 487 ReleaseDecoder(ptr_decoder_);
492 ptr_decoder_ = nullptr; 488 ptr_decoder_ = nullptr;
493 memset(&receive_codec_, 0, sizeof(VideoCodec)); 489 memset(&receive_codec_, 0, sizeof(VideoCodec));
494 } 490 }
495 ptr_decoder_ = CreateAndInitDecoder(frame, &receive_codec_); 491 ptr_decoder_ = CreateAndInitDecoder(frame, &receive_codec_);
496 if (!ptr_decoder_) { 492 if (!ptr_decoder_) {
497 return nullptr; 493 return nullptr;
498 } 494 }
499 VCMReceiveCallback* callback = decoded_frame_callback->UserReceiveCallback(); 495 VCMReceiveCallback* callback = decoded_frame_callback->UserReceiveCallback();
500 if (callback) callback->OnIncomingPayloadType(receive_codec_.plType); 496 if (callback)
501 if (ptr_decoder_->RegisterDecodeCompleteCallback(decoded_frame_callback) 497 callback->OnIncomingPayloadType(receive_codec_.plType);
502 < 0) { 498 if (ptr_decoder_->RegisterDecodeCompleteCallback(decoded_frame_callback) <
499 0) {
503 ReleaseDecoder(ptr_decoder_); 500 ReleaseDecoder(ptr_decoder_);
504 ptr_decoder_ = nullptr; 501 ptr_decoder_ = nullptr;
505 memset(&receive_codec_, 0, sizeof(VideoCodec)); 502 memset(&receive_codec_, 0, sizeof(VideoCodec));
506 return nullptr; 503 return nullptr;
507 } 504 }
508 return ptr_decoder_; 505 return ptr_decoder_;
509 } 506 }
510 507
511 void VCMCodecDataBase::ReleaseDecoder(VCMGenericDecoder* decoder) const { 508 void VCMCodecDataBase::ReleaseDecoder(VCMGenericDecoder* decoder) const {
512 if (decoder) { 509 if (decoder) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 607
611 const VCMExtDecoderMapItem* VCMCodecDataBase::FindExternalDecoderItem( 608 const VCMExtDecoderMapItem* VCMCodecDataBase::FindExternalDecoderItem(
612 uint8_t payload_type) const { 609 uint8_t payload_type) const {
613 ExternalDecoderMap::const_iterator it = dec_external_map_.find(payload_type); 610 ExternalDecoderMap::const_iterator it = dec_external_map_.find(payload_type);
614 if (it != dec_external_map_.end()) { 611 if (it != dec_external_map_.end()) {
615 return (*it).second; 612 return (*it).second;
616 } 613 }
617 return nullptr; 614 return nullptr;
618 } 615 }
619 } // namespace webrtc 616 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/video_coding/codec_timer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698