OLD | NEW |
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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 bool VCMCodecDataBase::DeregisterExternalDecoder(uint8_t payload_type) { | 416 bool VCMCodecDataBase::DeregisterExternalDecoder(uint8_t payload_type) { |
417 ExternalDecoderMap::iterator it = dec_external_map_.find(payload_type); | 417 ExternalDecoderMap::iterator it = dec_external_map_.find(payload_type); |
418 if (it == dec_external_map_.end()) { | 418 if (it == dec_external_map_.end()) { |
419 // Not found | 419 // Not found |
420 return false; | 420 return false; |
421 } | 421 } |
422 // We can't use payload_type to check if the decoder is currently in use, | 422 // We can't use payload_type to check if the decoder is currently in use, |
423 // because payload type may be out of date (e.g. before we decode the first | 423 // because payload type may be out of date (e.g. before we decode the first |
424 // frame after RegisterReceiveCodec) | 424 // frame after RegisterReceiveCodec) |
425 if (ptr_decoder_ != nullptr && | 425 if (ptr_decoder_ != nullptr && |
426 &ptr_decoder_->_decoder == (*it).second->external_decoder_instance) { | 426 ptr_decoder_->_decoder == (*it).second->external_decoder_instance) { |
427 // Release it if it was registered and in use. | 427 // Release it if it was registered and in use. |
428 ReleaseDecoder(ptr_decoder_); | 428 ReleaseDecoder(ptr_decoder_); |
429 ptr_decoder_ = nullptr; | 429 ptr_decoder_ = nullptr; |
430 } | 430 } |
431 DeregisterReceiveCodec(payload_type); | 431 DeregisterReceiveCodec(payload_type); |
432 delete (*it).second; | 432 delete (*it).second; |
433 dec_external_map_.erase(it); | 433 dec_external_map_.erase(it); |
434 return true; | 434 return true; |
435 } | 435 } |
436 | 436 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 LOG(LS_ERROR) << "Can't find a decoder associated with payload type: " | 564 LOG(LS_ERROR) << "Can't find a decoder associated with payload type: " |
565 << static_cast<int>(payload_type); | 565 << static_cast<int>(payload_type); |
566 return nullptr; | 566 return nullptr; |
567 } | 567 } |
568 VCMGenericDecoder* ptr_decoder = nullptr; | 568 VCMGenericDecoder* ptr_decoder = nullptr; |
569 const VCMExtDecoderMapItem* external_dec_item = | 569 const VCMExtDecoderMapItem* external_dec_item = |
570 FindExternalDecoderItem(payload_type); | 570 FindExternalDecoderItem(payload_type); |
571 if (external_dec_item) { | 571 if (external_dec_item) { |
572 // External codec. | 572 // External codec. |
573 ptr_decoder = new VCMGenericDecoder( | 573 ptr_decoder = new VCMGenericDecoder( |
574 *external_dec_item->external_decoder_instance, true); | 574 external_dec_item->external_decoder_instance, true); |
575 } else { | 575 } else { |
576 // Create decoder. | 576 // Create decoder. |
577 ptr_decoder = CreateDecoder(decoder_item->settings->codecType); | 577 ptr_decoder = CreateDecoder(decoder_item->settings->codecType); |
578 } | 578 } |
579 if (!ptr_decoder) | 579 if (!ptr_decoder) |
580 return nullptr; | 580 return nullptr; |
581 | 581 |
582 // Copy over input resolutions to prevent codec reinitialization due to | 582 // Copy over input resolutions to prevent codec reinitialization due to |
583 // the first frame being of a different resolution than the database values. | 583 // the first frame being of a different resolution than the database values. |
584 // This is best effort, since there's no guarantee that width/height have been | 584 // This is best effort, since there's no guarantee that width/height have been |
(...skipping 15 matching lines...) Expand all Loading... |
600 void VCMCodecDataBase::DeleteEncoder() { | 600 void VCMCodecDataBase::DeleteEncoder() { |
601 if (!ptr_encoder_) | 601 if (!ptr_encoder_) |
602 return; | 602 return; |
603 ptr_encoder_->Release(); | 603 ptr_encoder_->Release(); |
604 ptr_encoder_.reset(); | 604 ptr_encoder_.reset(); |
605 } | 605 } |
606 | 606 |
607 VCMGenericDecoder* VCMCodecDataBase::CreateDecoder(VideoCodecType type) const { | 607 VCMGenericDecoder* VCMCodecDataBase::CreateDecoder(VideoCodecType type) const { |
608 switch (type) { | 608 switch (type) { |
609 case kVideoCodecVP8: | 609 case kVideoCodecVP8: |
610 return new VCMGenericDecoder(*(VP8Decoder::Create())); | 610 return new VCMGenericDecoder(VP8Decoder::Create(), false); |
611 case kVideoCodecVP9: | 611 case kVideoCodecVP9: |
612 return new VCMGenericDecoder(*(VP9Decoder::Create())); | 612 return new VCMGenericDecoder(VP9Decoder::Create(), false); |
613 case kVideoCodecI420: | 613 case kVideoCodecI420: |
614 return new VCMGenericDecoder(*(new I420Decoder)); | 614 return new VCMGenericDecoder(new I420Decoder(), false); |
615 case kVideoCodecH264: | 615 case kVideoCodecH264: |
616 if (H264Decoder::IsSupported()) { | 616 if (H264Decoder::IsSupported()) { |
617 return new VCMGenericDecoder(*(H264Decoder::Create())); | 617 return new VCMGenericDecoder(H264Decoder::Create(), false); |
618 } | 618 } |
619 break; | 619 break; |
620 default: | 620 default: |
621 break; | 621 break; |
622 } | 622 } |
623 LOG(LS_WARNING) << "No internal decoder of this type exists."; | 623 LOG(LS_WARNING) << "No internal decoder of this type exists."; |
624 return nullptr; | 624 return nullptr; |
625 } | 625 } |
626 | 626 |
627 const VCMDecoderMapItem* VCMCodecDataBase::FindDecoderItem( | 627 const VCMDecoderMapItem* VCMCodecDataBase::FindDecoderItem( |
628 uint8_t payload_type) const { | 628 uint8_t payload_type) const { |
629 DecoderMap::const_iterator it = dec_map_.find(payload_type); | 629 DecoderMap::const_iterator it = dec_map_.find(payload_type); |
630 if (it != dec_map_.end()) { | 630 if (it != dec_map_.end()) { |
631 return (*it).second; | 631 return (*it).second; |
632 } | 632 } |
633 return nullptr; | 633 return nullptr; |
634 } | 634 } |
635 | 635 |
636 const VCMExtDecoderMapItem* VCMCodecDataBase::FindExternalDecoderItem( | 636 const VCMExtDecoderMapItem* VCMCodecDataBase::FindExternalDecoderItem( |
637 uint8_t payload_type) const { | 637 uint8_t payload_type) const { |
638 ExternalDecoderMap::const_iterator it = dec_external_map_.find(payload_type); | 638 ExternalDecoderMap::const_iterator it = dec_external_map_.find(payload_type); |
639 if (it != dec_external_map_.end()) { | 639 if (it != dec_external_map_.end()) { |
640 return (*it).second; | 640 return (*it).second; |
641 } | 641 } |
642 return nullptr; | 642 return nullptr; |
643 } | 643 } |
644 } // namespace webrtc | 644 } // namespace webrtc |
OLD | NEW |