| 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 |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" | 12 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" |
| 13 #include "webrtc/modules/audio_coding/acm2/codec_manager.h" | 13 #include "webrtc/modules/audio_coding/acm2/codec_manager.h" |
| 14 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" |
| 14 | 15 |
| 15 namespace webrtc { | 16 namespace webrtc { |
| 16 namespace acm2 { | 17 namespace acm2 { |
| 17 | 18 |
| 18 using ::testing::Return; | 19 using ::testing::Return; |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // Create a MockAudioEncoder with some reasonable default behavior. | 23 // Create a MockAudioEncoder with some reasonable default behavior. |
| 23 rtc::scoped_ptr<MockAudioEncoder> CreateMockEncoder() { | 24 rtc::scoped_ptr<MockAudioEncoder> CreateMockEncoder() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 39 EXPECT_CALL(*enc0, SetFec(false)).WillOnce(Return(true)); | 40 EXPECT_CALL(*enc0, SetFec(false)).WillOnce(Return(true)); |
| 40 EXPECT_CALL(*enc0, Mark("A")); | 41 EXPECT_CALL(*enc0, Mark("A")); |
| 41 EXPECT_CALL(*enc0, SetFec(true)).WillOnce(Return(true)); | 42 EXPECT_CALL(*enc0, SetFec(true)).WillOnce(Return(true)); |
| 42 EXPECT_CALL(*enc1, SetFec(true)).WillOnce(Return(true)); | 43 EXPECT_CALL(*enc1, SetFec(true)).WillOnce(Return(true)); |
| 43 EXPECT_CALL(*enc1, SetFec(false)).WillOnce(Return(true)); | 44 EXPECT_CALL(*enc1, SetFec(false)).WillOnce(Return(true)); |
| 44 EXPECT_CALL(*enc0, Mark("B")); | 45 EXPECT_CALL(*enc0, Mark("B")); |
| 45 EXPECT_CALL(*enc0, SetFec(false)).WillOnce(Return(true)); | 46 EXPECT_CALL(*enc0, SetFec(false)).WillOnce(Return(true)); |
| 46 } | 47 } |
| 47 | 48 |
| 48 CodecManager cm; | 49 CodecManager cm; |
| 49 EXPECT_FALSE(cm.codec_fec_enabled()); | 50 RentACodec rac; |
| 50 cm.RegisterEncoder(enc0.get()); | 51 EXPECT_FALSE(cm.GetStackParams()->use_codec_fec); |
| 51 EXPECT_FALSE(cm.codec_fec_enabled()); | 52 cm.GetStackParams()->speech_encoder = enc0.get(); |
| 53 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); |
| 54 EXPECT_FALSE(cm.GetStackParams()->use_codec_fec); |
| 52 enc0->Mark("A"); | 55 enc0->Mark("A"); |
| 53 EXPECT_EQ(0, cm.SetCodecFEC(true)); | 56 EXPECT_EQ(true, cm.SetCodecFEC(true)); |
| 54 EXPECT_TRUE(cm.codec_fec_enabled()); | 57 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); |
| 55 cm.RegisterEncoder(enc1.get()); | 58 EXPECT_TRUE(cm.GetStackParams()->use_codec_fec); |
| 56 EXPECT_TRUE(cm.codec_fec_enabled()); | 59 cm.GetStackParams()->speech_encoder = enc1.get(); |
| 60 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); |
| 61 EXPECT_TRUE(cm.GetStackParams()->use_codec_fec); |
| 57 | 62 |
| 58 EXPECT_EQ(0, cm.SetCodecFEC(false)); | 63 EXPECT_EQ(true, cm.SetCodecFEC(false)); |
| 64 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); |
| 59 enc0->Mark("B"); | 65 enc0->Mark("B"); |
| 60 EXPECT_FALSE(cm.codec_fec_enabled()); | 66 EXPECT_FALSE(cm.GetStackParams()->use_codec_fec); |
| 61 cm.RegisterEncoder(enc0.get()); | 67 cm.GetStackParams()->speech_encoder = enc0.get(); |
| 62 EXPECT_FALSE(cm.codec_fec_enabled()); | 68 EXPECT_TRUE(rac.RentEncoderStack(cm.GetStackParams())); |
| 69 EXPECT_FALSE(cm.GetStackParams()->use_codec_fec); |
| 63 } | 70 } |
| 64 | 71 |
| 65 } // namespace acm2 | 72 } // namespace acm2 |
| 66 } // namespace webrtc | 73 } // namespace webrtc |
| OLD | NEW |