OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 19 matching lines...) Expand all Loading... |
30 EXPECT_CALL(*enc, Max10MsFramesInAPacket()).WillRepeatedly(Return(1)); | 30 EXPECT_CALL(*enc, Max10MsFramesInAPacket()).WillRepeatedly(Return(1)); |
31 EXPECT_CALL(*enc, Die()); | 31 EXPECT_CALL(*enc, Die()); |
32 return enc; | 32 return enc; |
33 } | 33 } |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 TEST(CodecManagerTest, ExternalEncoderFec) { | 37 TEST(CodecManagerTest, ExternalEncoderFec) { |
38 auto enc0 = CreateMockEncoder(); | 38 auto enc0 = CreateMockEncoder(); |
39 auto enc1 = CreateMockEncoder(); | 39 auto enc1 = CreateMockEncoder(); |
| 40 auto enc2 = CreateMockEncoder(); |
40 { | 41 { |
41 ::testing::InSequence s; | 42 ::testing::InSequence s; |
42 EXPECT_CALL(*enc0, SetFec(false)).WillOnce(Return(true)); | 43 EXPECT_CALL(*enc0, SetFec(false)).WillOnce(Return(true)); |
43 EXPECT_CALL(*enc0, Mark("A")); | |
44 EXPECT_CALL(*enc0, SetFec(true)).WillOnce(Return(true)); | |
45 EXPECT_CALL(*enc1, SetFec(true)).WillOnce(Return(true)); | 44 EXPECT_CALL(*enc1, SetFec(true)).WillOnce(Return(true)); |
46 EXPECT_CALL(*enc1, SetFec(false)).WillOnce(Return(true)); | 45 EXPECT_CALL(*enc2, SetFec(true)).WillOnce(Return(false)); |
47 EXPECT_CALL(*enc0, Mark("B")); | |
48 EXPECT_CALL(*enc0, SetFec(false)).WillOnce(Return(true)); | |
49 } | 46 } |
50 | 47 |
51 CodecManager cm; | 48 CodecManager cm; |
52 RentACodec rac; | 49 RentACodec rac; |
| 50 |
| 51 // use_codec_fec starts out false. |
53 EXPECT_FALSE(cm.GetStackParams()->use_codec_fec); | 52 EXPECT_FALSE(cm.GetStackParams()->use_codec_fec); |
54 cm.GetStackParams()->speech_encoder = enc0.get(); | 53 cm.GetStackParams()->speech_encoder = std::move(enc0); |
55 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); | 54 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); |
56 EXPECT_FALSE(cm.GetStackParams()->use_codec_fec); | 55 EXPECT_FALSE(cm.GetStackParams()->use_codec_fec); |
57 enc0->Mark("A"); | 56 |
| 57 // Set it to true. |
58 EXPECT_EQ(true, cm.SetCodecFEC(true)); | 58 EXPECT_EQ(true, cm.SetCodecFEC(true)); |
59 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); | |
60 EXPECT_TRUE(cm.GetStackParams()->use_codec_fec); | 59 EXPECT_TRUE(cm.GetStackParams()->use_codec_fec); |
61 cm.GetStackParams()->speech_encoder = enc1.get(); | 60 cm.GetStackParams()->speech_encoder = std::move(enc1); |
62 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); | 61 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); |
63 EXPECT_TRUE(cm.GetStackParams()->use_codec_fec); | 62 EXPECT_TRUE(cm.GetStackParams()->use_codec_fec); |
64 | 63 |
65 EXPECT_EQ(true, cm.SetCodecFEC(false)); | 64 // Switch to a codec that doesn't support it. |
66 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); | 65 cm.GetStackParams()->speech_encoder = std::move(enc2); |
67 enc0->Mark("B"); | |
68 EXPECT_FALSE(cm.GetStackParams()->use_codec_fec); | |
69 cm.GetStackParams()->speech_encoder = enc0.get(); | |
70 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); | 66 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); |
71 EXPECT_FALSE(cm.GetStackParams()->use_codec_fec); | 67 EXPECT_FALSE(cm.GetStackParams()->use_codec_fec); |
72 } | 68 } |
73 | 69 |
74 } // namespace acm2 | 70 } // namespace acm2 |
75 } // namespace webrtc | 71 } // namespace webrtc |
OLD | NEW |