| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2  *  Copyright (c) 2004 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 71     if (cricket::CodecNamesEq(codec.name.c_str(), "rtx") && | 71     if (cricket::CodecNamesEq(codec.name.c_str(), "rtx") && | 
| 72         codec.GetParam(cricket::kCodecParamAssociatedPayloadType, | 72         codec.GetParam(cricket::kCodecParamAssociatedPayloadType, | 
| 73                        &associated_payload_type) && | 73                        &associated_payload_type) && | 
| 74         associated_payload_type == payload_type) { | 74         associated_payload_type == payload_type) { | 
| 75       return true; | 75       return true; | 
| 76     } | 76     } | 
| 77   } | 77   } | 
| 78   return false; | 78   return false; | 
| 79 } | 79 } | 
| 80 | 80 | 
| 81 static rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateBlackFrameBuffer( | 81 rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateBlackFrameBuffer( | 
| 82     int width, | 82     int width, | 
| 83     int height) { | 83     int height) { | 
| 84   rtc::scoped_refptr<webrtc::I420Buffer> buffer = | 84   rtc::scoped_refptr<webrtc::I420Buffer> buffer = | 
| 85       webrtc::I420Buffer::Create(width, height); | 85       webrtc::I420Buffer::Create(width, height); | 
| 86   buffer->SetToBlack(); | 86   buffer->SetToBlack(); | 
| 87   return buffer; | 87   return buffer; | 
| 88 } | 88 } | 
| 89 | 89 | 
| 90 void VerifySendStreamHasRtxTypes(const webrtc::VideoSendStream::Config& config, | 90 void VerifySendStreamHasRtxTypes(const webrtc::VideoSendStream::Config& config, | 
| 91                                  const std::map<int, int>& rtx_types) { | 91                                  const std::map<int, int>& rtx_types) { | 
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 742   EXPECT_TRUE(capturer.CaptureFrame()); | 742   EXPECT_TRUE(capturer.CaptureFrame()); | 
| 743 | 743 | 
| 744   ASSERT_EQ(1u, encoder_factory.encoders().size()); | 744   ASSERT_EQ(1u, encoder_factory.encoders().size()); | 
| 745   FakeWebRtcVideoEncoder* encoder = encoder_factory.encoders()[0]; | 745   FakeWebRtcVideoEncoder* encoder = encoder_factory.encoders()[0]; | 
| 746   ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode()); | 746   ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode()); | 
| 747   EXPECT_EQ(webrtc::kVideoCodecH264, encoder->GetCodecSettings().codecType); | 747   EXPECT_EQ(webrtc::kVideoCodecH264, encoder->GetCodecSettings().codecType); | 
| 748   EXPECT_EQ(1u, encoder->GetCodecSettings().numberOfSimulcastStreams); | 748   EXPECT_EQ(1u, encoder->GetCodecSettings().numberOfSimulcastStreams); | 
| 749   EXPECT_TRUE(channel->SetVideoSend(ssrcs[0], true, nullptr, nullptr)); | 749   EXPECT_TRUE(channel->SetVideoSend(ssrcs[0], true, nullptr, nullptr)); | 
| 750 } | 750 } | 
| 751 | 751 | 
|  | 752 // Test that the FlexFEC field trial properly alters the output of | 
|  | 753 // WebRtcVideoEngine2::codecs(), for an existing |engine_| object. | 
|  | 754 // | 
|  | 755 // TODO(brandtr): Remove this test, when the FlexFEC field trial is gone. | 
|  | 756 TEST_F(WebRtcVideoEngine2Test, | 
|  | 757        Flexfec03SupportedAsInternalCodecBehindFieldTrial) { | 
|  | 758   auto is_flexfec = [](const VideoCodec& codec) { | 
|  | 759     if (codec.name == "flexfec-03") | 
|  | 760       return true; | 
|  | 761     return false; | 
|  | 762   }; | 
|  | 763 | 
|  | 764   // FlexFEC is not active without field trial. | 
|  | 765   engine_.Init(); | 
|  | 766   const std::vector<VideoCodec> codecs_before = engine_.codecs(); | 
|  | 767   EXPECT_EQ(codecs_before.end(), std::find_if(codecs_before.begin(), | 
|  | 768                                               codecs_before.end(), is_flexfec)); | 
|  | 769 | 
|  | 770   // FlexFEC is active with field trial. | 
|  | 771   webrtc::test::ScopedFieldTrials override_field_trials_( | 
|  | 772       "WebRTC-FlexFEC-03/Enabled/"); | 
|  | 773   const std::vector<VideoCodec> codecs_after = engine_.codecs(); | 
|  | 774   EXPECT_NE(codecs_after.end(), | 
|  | 775             std::find_if(codecs_after.begin(), codecs_after.end(), is_flexfec)); | 
|  | 776 } | 
|  | 777 | 
| 752 // Test that external codecs are added to the end of the supported codec list. | 778 // Test that external codecs are added to the end of the supported codec list. | 
| 753 TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecs) { | 779 TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecs) { | 
| 754   cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 780   cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 
| 755   encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec"); | 781   encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec"); | 
| 756   engine_.SetExternalEncoderFactory(&encoder_factory); | 782   engine_.SetExternalEncoderFactory(&encoder_factory); | 
| 757   engine_.Init(); | 783   engine_.Init(); | 
| 758 | 784 | 
| 759   std::vector<cricket::VideoCodec> codecs(engine_.codecs()); | 785   std::vector<cricket::VideoCodec> codecs(engine_.codecs()); | 
| 760   ASSERT_GE(codecs.size(), 2u); | 786   ASSERT_GE(codecs.size(), 2u); | 
| 761   cricket::VideoCodec internal_codec = codecs.front(); | 787   cricket::VideoCodec internal_codec = codecs.front(); | 
| 762   cricket::VideoCodec external_codec = codecs.back(); | 788   cricket::VideoCodec external_codec = codecs.back(); | 
| 763 | 789 | 
| 764   // The external codec will appear at last. | 790   // The external codec will appear last in the vector. | 
| 765   EXPECT_EQ("VP8", internal_codec.name); | 791   EXPECT_EQ("VP8", internal_codec.name); | 
| 766   EXPECT_EQ("FakeExternalCodec", external_codec.name); | 792   EXPECT_EQ("FakeExternalCodec", external_codec.name); | 
| 767 } | 793 } | 
| 768 | 794 | 
|  | 795 // Test that an external codec that was added after the engine was initialized | 
|  | 796 // does show up in the codec list after it was added. | 
|  | 797 TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecsWithAddedCodec) { | 
|  | 798   // Set up external encoder factory with first codec, and initialize engine. | 
|  | 799   cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 
|  | 800   encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec1"); | 
|  | 801   engine_.SetExternalEncoderFactory(&encoder_factory); | 
|  | 802   engine_.Init(); | 
|  | 803 | 
|  | 804   // The first external codec will appear last in the vector. | 
|  | 805   std::vector<cricket::VideoCodec> codecs_before(engine_.codecs()); | 
|  | 806   EXPECT_EQ("FakeExternalCodec1", codecs_before.back().name); | 
|  | 807 | 
|  | 808   // Add second codec. | 
|  | 809   encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec2"); | 
|  | 810   std::vector<cricket::VideoCodec> codecs_after(engine_.codecs()); | 
|  | 811   EXPECT_EQ(codecs_before.size() + 1, codecs_after.size()); | 
|  | 812   EXPECT_EQ("FakeExternalCodec2", codecs_after.back().name); | 
|  | 813 } | 
|  | 814 | 
| 769 TEST_F(WebRtcVideoEngine2Test, RegisterExternalDecodersIfSupported) { | 815 TEST_F(WebRtcVideoEngine2Test, RegisterExternalDecodersIfSupported) { | 
| 770   cricket::FakeWebRtcVideoDecoderFactory decoder_factory; | 816   cricket::FakeWebRtcVideoDecoderFactory decoder_factory; | 
| 771   decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); | 817   decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); | 
| 772   cricket::VideoRecvParameters parameters; | 818   cricket::VideoRecvParameters parameters; | 
| 773   parameters.codecs.push_back(GetEngineCodec("VP8")); | 819   parameters.codecs.push_back(GetEngineCodec("VP8")); | 
| 774 | 820 | 
| 775   std::unique_ptr<VideoMediaChannel> channel( | 821   std::unique_ptr<VideoMediaChannel> channel( | 
| 776       SetUpForExternalDecoderFactory(&decoder_factory, parameters.codecs)); | 822       SetUpForExternalDecoderFactory(&decoder_factory, parameters.codecs)); | 
| 777 | 823 | 
| 778   EXPECT_TRUE( | 824   EXPECT_TRUE( | 
| (...skipping 3210 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3989 | 4035 | 
| 3990 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { | 4036 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { | 
| 3991   VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 3); | 4037   VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 3); | 
| 3992 } | 4038 } | 
| 3993 | 4039 | 
| 3994 // Test that we normalize send codec format size in simulcast. | 4040 // Test that we normalize send codec format size in simulcast. | 
| 3995 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 4041 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 
| 3996   VerifySimulcastSettings(cricket::VideoCodec("VP8"), 541, 271, 2, 2); | 4042   VerifySimulcastSettings(cricket::VideoCodec("VP8"), 541, 271, 2, 2); | 
| 3997 } | 4043 } | 
| 3998 }  // namespace cricket | 4044 }  // namespace cricket | 
| OLD | NEW | 
|---|