OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 return true; | 615 return true; |
616 } | 616 } |
617 | 617 |
618 WebRtcVideoChannel2* WebRtcVideoEngine2::CreateChannel( | 618 WebRtcVideoChannel2* WebRtcVideoEngine2::CreateChannel( |
619 const VideoOptions& options, | 619 const VideoOptions& options, |
620 VoiceMediaChannel* voice_channel) { | 620 VoiceMediaChannel* voice_channel) { |
621 DCHECK(initialized_); | 621 DCHECK(initialized_); |
622 LOG(LS_INFO) << "CreateChannel: " | 622 LOG(LS_INFO) << "CreateChannel: " |
623 << (voice_channel != NULL ? "With" : "Without") | 623 << (voice_channel != NULL ? "With" : "Without") |
624 << " voice channel. Options: " << options.ToString(); | 624 << " voice channel. Options: " << options.ToString(); |
625 WebRtcVideoChannel2* channel = | 625 return new WebRtcVideoChannel2(call_factory_, voice_engine_, |
626 new WebRtcVideoChannel2(call_factory_, voice_engine_, | 626 static_cast<WebRtcVoiceMediaChannel*>(voice_channel), options, |
627 static_cast<WebRtcVoiceMediaChannel*>(voice_channel), options, | 627 video_codecs_, external_encoder_factory_, external_decoder_factory_); |
628 external_encoder_factory_, external_decoder_factory_); | |
629 if (!channel->Init()) { | |
630 delete channel; | |
631 return NULL; | |
632 } | |
633 channel->SetRecvCodecs(video_codecs_); | |
634 return channel; | |
635 } | 628 } |
636 | 629 |
637 const std::vector<VideoCodec>& WebRtcVideoEngine2::codecs() const { | 630 const std::vector<VideoCodec>& WebRtcVideoEngine2::codecs() const { |
638 return video_codecs_; | 631 return video_codecs_; |
639 } | 632 } |
640 | 633 |
641 const std::vector<RtpHeaderExtension>& | 634 const std::vector<RtpHeaderExtension>& |
642 WebRtcVideoEngine2::rtp_header_extensions() const { | 635 WebRtcVideoEngine2::rtp_header_extensions() const { |
643 return rtp_header_extensions_; | 636 return rtp_header_extensions_; |
644 } | 637 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
785 supported_codecs.push_back(codec); | 778 supported_codecs.push_back(codec); |
786 } | 779 } |
787 return supported_codecs; | 780 return supported_codecs; |
788 } | 781 } |
789 | 782 |
790 WebRtcVideoChannel2::WebRtcVideoChannel2( | 783 WebRtcVideoChannel2::WebRtcVideoChannel2( |
791 WebRtcCallFactory* call_factory, | 784 WebRtcCallFactory* call_factory, |
792 WebRtcVoiceEngine* voice_engine, | 785 WebRtcVoiceEngine* voice_engine, |
793 WebRtcVoiceMediaChannel* voice_channel, | 786 WebRtcVoiceMediaChannel* voice_channel, |
794 const VideoOptions& options, | 787 const VideoOptions& options, |
788 const std::vector<VideoCodec>& recv_codecs, | |
795 WebRtcVideoEncoderFactory* external_encoder_factory, | 789 WebRtcVideoEncoderFactory* external_encoder_factory, |
796 WebRtcVideoDecoderFactory* external_decoder_factory) | 790 WebRtcVideoDecoderFactory* external_decoder_factory) |
797 : unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), | 791 : unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), |
798 voice_channel_(voice_channel), | 792 voice_channel_(voice_channel), |
799 voice_channel_id_(voice_channel ? voice_channel->voe_channel() : -1), | 793 voice_channel_id_(voice_channel ? voice_channel->voe_channel() : -1), |
800 external_encoder_factory_(external_encoder_factory), | 794 external_encoder_factory_(external_encoder_factory), |
801 external_decoder_factory_(external_decoder_factory) { | 795 external_decoder_factory_(external_decoder_factory) { |
802 DCHECK(thread_checker_.CalledOnValidThread()); | 796 DCHECK(thread_checker_.CalledOnValidThread()); |
803 SetDefaultOptions(); | 797 SetDefaultOptions(); |
804 options_.SetAll(options); | 798 options_.SetAll(options); |
805 options_.cpu_overuse_detection.Get(&signal_cpu_adaptation_); | 799 options_.cpu_overuse_detection.Get(&signal_cpu_adaptation_); |
806 webrtc::Call::Config config; | 800 webrtc::Call::Config config; |
807 if (voice_engine != NULL) { | 801 if (voice_engine != NULL) { |
808 config.voice_engine = voice_engine->voe()->engine(); | 802 config.voice_engine = voice_engine->voe()->engine(); |
809 } | 803 } |
810 config.bitrate_config.min_bitrate_bps = kMinBandwidthBps; | 804 config.bitrate_config.min_bitrate_bps = kMinBandwidthBps; |
811 config.bitrate_config.start_bitrate_bps = kStartBandwidthBps; | 805 config.bitrate_config.start_bitrate_bps = kStartBandwidthBps; |
812 config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; | 806 config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; |
813 call_.reset(call_factory->CreateCall(config)); | 807 call_.reset(call_factory->CreateCall(config)); |
814 if (voice_channel_) { | 808 if (voice_channel_) { |
815 voice_channel_->SetCall(call_.get()); | 809 voice_channel_->SetCall(call_.get()); |
816 } | 810 } |
817 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; | 811 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; |
818 sending_ = false; | 812 sending_ = false; |
819 default_send_ssrc_ = 0; | 813 default_send_ssrc_ = 0; |
814 SetRecvCodecs(recv_codecs); | |
pthatcher1
2015/09/14 19:42:02
What if SetRecvCodecs fails?
| |
820 } | 815 } |
821 | 816 |
822 void WebRtcVideoChannel2::SetDefaultOptions() { | 817 void WebRtcVideoChannel2::SetDefaultOptions() { |
823 options_.cpu_overuse_detection.Set(true); | 818 options_.cpu_overuse_detection.Set(true); |
824 options_.dscp.Set(false); | 819 options_.dscp.Set(false); |
825 options_.suspend_below_min_bitrate.Set(false); | 820 options_.suspend_below_min_bitrate.Set(false); |
826 options_.video_noise_reduction.Set(true); | 821 options_.video_noise_reduction.Set(true); |
827 options_.screencast_min_bitrate.Set(0); | 822 options_.screencast_min_bitrate.Set(0); |
828 } | 823 } |
829 | 824 |
830 WebRtcVideoChannel2::~WebRtcVideoChannel2() { | 825 WebRtcVideoChannel2::~WebRtcVideoChannel2() { |
831 DetachVoiceChannel(); | 826 DetachVoiceChannel(); |
832 for (auto& kv : send_streams_) | 827 for (auto& kv : send_streams_) |
833 delete kv.second; | 828 delete kv.second; |
834 for (auto& kv : receive_streams_) | 829 for (auto& kv : receive_streams_) |
835 delete kv.second; | 830 delete kv.second; |
836 } | 831 } |
837 | 832 |
838 bool WebRtcVideoChannel2::Init() { return true; } | |
839 | |
840 void WebRtcVideoChannel2::DetachVoiceChannel() { | 833 void WebRtcVideoChannel2::DetachVoiceChannel() { |
841 DCHECK(thread_checker_.CalledOnValidThread()); | 834 DCHECK(thread_checker_.CalledOnValidThread()); |
842 if (voice_channel_) { | 835 if (voice_channel_) { |
843 voice_channel_->SetCall(nullptr); | 836 voice_channel_->SetCall(nullptr); |
844 voice_channel_ = nullptr; | 837 voice_channel_ = nullptr; |
845 } | 838 } |
846 } | 839 } |
847 | 840 |
848 bool WebRtcVideoChannel2::CodecIsExternallySupported( | 841 bool WebRtcVideoChannel2::CodecIsExternallySupported( |
849 const std::string& name) const { | 842 const std::string& name) const { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
935 out << ", "; | 928 out << ", "; |
936 } | 929 } |
937 } | 930 } |
938 out << '}'; | 931 out << '}'; |
939 return out.str(); | 932 return out.str(); |
940 } | 933 } |
941 | 934 |
942 bool WebRtcVideoChannel2::SetRecvCodecs(const std::vector<VideoCodec>& codecs) { | 935 bool WebRtcVideoChannel2::SetRecvCodecs(const std::vector<VideoCodec>& codecs) { |
943 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvCodecs"); | 936 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvCodecs"); |
944 LOG(LS_INFO) << "SetRecvCodecs: " << CodecVectorToString(codecs); | 937 LOG(LS_INFO) << "SetRecvCodecs: " << CodecVectorToString(codecs); |
938 if (codecs.empty()) { | |
939 return true; | |
940 } | |
pthatcher1
2015/09/14 19:42:02
I think this should be handled by the caller of Se
the sun
2015/09/14 19:58:00
I was wondering about wether it should be at all l
pthatcher1
2015/09/16 03:45:30
I think leaving this here as-is just for unit test
| |
945 if (!ValidateCodecFormats(codecs)) { | 941 if (!ValidateCodecFormats(codecs)) { |
946 return false; | 942 return false; |
947 } | 943 } |
948 | 944 |
949 const std::vector<VideoCodecSettings> mapped_codecs = MapCodecs(codecs); | 945 const std::vector<VideoCodecSettings> mapped_codecs = MapCodecs(codecs); |
950 if (mapped_codecs.empty()) { | 946 if (mapped_codecs.empty()) { |
951 LOG(LS_ERROR) << "SetRecvCodecs called without any video codecs."; | 947 LOG(LS_ERROR) << "SetRecvCodecs called without any video codecs."; |
952 return false; | 948 return false; |
953 } | 949 } |
954 | 950 |
(...skipping 24 matching lines...) Expand all Loading... | |
979 ++it) { | 975 ++it) { |
980 it->second->SetRecvCodecs(recv_codecs_); | 976 it->second->SetRecvCodecs(recv_codecs_); |
981 } | 977 } |
982 | 978 |
983 return true; | 979 return true; |
984 } | 980 } |
985 | 981 |
986 bool WebRtcVideoChannel2::SetSendCodecs(const std::vector<VideoCodec>& codecs) { | 982 bool WebRtcVideoChannel2::SetSendCodecs(const std::vector<VideoCodec>& codecs) { |
987 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendCodecs"); | 983 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendCodecs"); |
988 LOG(LS_INFO) << "SetSendCodecs: " << CodecVectorToString(codecs); | 984 LOG(LS_INFO) << "SetSendCodecs: " << CodecVectorToString(codecs); |
985 if (codecs.empty()) { | |
986 return true; | |
987 } | |
989 if (!ValidateCodecFormats(codecs)) { | 988 if (!ValidateCodecFormats(codecs)) { |
990 return false; | 989 return false; |
991 } | 990 } |
992 | 991 |
993 const std::vector<VideoCodecSettings> supported_codecs = | 992 const std::vector<VideoCodecSettings> supported_codecs = |
994 FilterSupportedCodecs(MapCodecs(codecs)); | 993 FilterSupportedCodecs(MapCodecs(codecs)); |
995 | 994 |
996 if (supported_codecs.empty()) { | 995 if (supported_codecs.empty()) { |
997 LOG(LS_ERROR) << "No video codecs supported."; | 996 LOG(LS_ERROR) << "No video codecs supported."; |
998 return false; | 997 return false; |
(...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2788 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2787 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2789 } | 2788 } |
2790 } | 2789 } |
2791 | 2790 |
2792 return video_codecs; | 2791 return video_codecs; |
2793 } | 2792 } |
2794 | 2793 |
2795 } // namespace cricket | 2794 } // namespace cricket |
2796 | 2795 |
2797 #endif // HAVE_WEBRTC_VIDEO | 2796 #endif // HAVE_WEBRTC_VIDEO |
OLD | NEW |