Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: webrtc/modules/audio_coding/neteq/decoder_database_unittest.cc

Issue 1484343003: NetEq: Add codec name and RTP timestamp rate to DecoderInfo (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 EXPECT_FALSE(db.IsType(kPayloadTypePcmU, NetEqDecoder::kDecoderISAC)); 105 EXPECT_FALSE(db.IsType(kPayloadTypePcmU, NetEqDecoder::kDecoderISAC));
106 EXPECT_TRUE(db.IsType(kPayloadTypePcmU, NetEqDecoder::kDecoderPCMu)); 106 EXPECT_TRUE(db.IsType(kPayloadTypePcmU, NetEqDecoder::kDecoderPCMu));
107 EXPECT_TRUE(db.IsComfortNoise(kPayloadTypeCng)); 107 EXPECT_TRUE(db.IsComfortNoise(kPayloadTypeCng));
108 EXPECT_TRUE(db.IsDtmf(kPayloadTypeDtmf)); 108 EXPECT_TRUE(db.IsDtmf(kPayloadTypeDtmf));
109 EXPECT_TRUE(db.IsRed(kPayloadTypeRed)); 109 EXPECT_TRUE(db.IsRed(kPayloadTypeRed));
110 } 110 }
111 111
112 TEST(DecoderDatabase, ExternalDecoder) { 112 TEST(DecoderDatabase, ExternalDecoder) {
113 DecoderDatabase db; 113 DecoderDatabase db;
114 const uint8_t kPayloadType = 0; 114 const uint8_t kPayloadType = 0;
115 const std::string kCodecName = "Robert\'); DROP TABLE Students;";
kwiberg-webrtc 2015/12/02 13:41:37 Note that it's allowed but not necessary to escape
hlundin-webrtc 2015/12/02 16:19:24 Acknowledged.
115 MockAudioDecoder decoder; 116 MockAudioDecoder decoder;
116 // Load into database. 117 // Load into database.
117 EXPECT_EQ(DecoderDatabase::kOK, 118 EXPECT_EQ(DecoderDatabase::kOK,
118 db.InsertExternal(kPayloadType, NetEqDecoder::kDecoderPCMu, 8000, 119 db.InsertExternal(kPayloadType, NetEqDecoder::kDecoderPCMu,
119 &decoder)); 120 kCodecName, 8000, &decoder));
120 EXPECT_EQ(1, db.Size()); 121 EXPECT_EQ(1, db.Size());
121 // Get decoder and make sure we get the external one. 122 // Get decoder and make sure we get the external one.
122 EXPECT_EQ(&decoder, db.GetDecoder(kPayloadType)); 123 EXPECT_EQ(&decoder, db.GetDecoder(kPayloadType));
123 // Get the decoder info struct and check it too. 124 // Get the decoder info struct and check it too.
124 const DecoderDatabase::DecoderInfo* info; 125 const DecoderDatabase::DecoderInfo* info;
125 info = db.GetDecoderInfo(kPayloadType); 126 info = db.GetDecoderInfo(kPayloadType);
126 ASSERT_TRUE(info != NULL); 127 ASSERT_TRUE(info != NULL);
127 EXPECT_EQ(NetEqDecoder::kDecoderPCMu, info->codec_type); 128 EXPECT_EQ(NetEqDecoder::kDecoderPCMu, info->codec_type);
129 EXPECT_EQ(kCodecName, info->name);
128 EXPECT_EQ(&decoder, info->decoder); 130 EXPECT_EQ(&decoder, info->decoder);
129 EXPECT_EQ(8000, info->fs_hz); 131 EXPECT_EQ(8000, info->fs_hz);
130 EXPECT_TRUE(info->external); 132 EXPECT_TRUE(info->external);
131 // Expect not to delete the decoder when removing it from the database, since 133 // Expect not to delete the decoder when removing it from the database, since
132 // it was declared externally. 134 // it was declared externally.
133 EXPECT_CALL(decoder, Die()).Times(0); 135 EXPECT_CALL(decoder, Die()).Times(0);
134 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(kPayloadType)); 136 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(kPayloadType));
135 EXPECT_TRUE(db.Empty()); 137 EXPECT_TRUE(db.Empty());
136 138
137 EXPECT_CALL(decoder, Die()).Times(1); // Will be called when |db| is deleted. 139 EXPECT_CALL(decoder, Die()).Times(1); // Will be called when |db| is deleted.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13)); 228 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13));
227 EXPECT_EQ(NULL, db.GetActiveCngDecoder()); 229 EXPECT_EQ(NULL, db.GetActiveCngDecoder());
228 230
229 // Try to set non-existing codecs as active. 231 // Try to set non-existing codecs as active.
230 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, 232 EXPECT_EQ(DecoderDatabase::kDecoderNotFound,
231 db.SetActiveDecoder(17, &changed)); 233 db.SetActiveDecoder(17, &changed));
232 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, 234 EXPECT_EQ(DecoderDatabase::kDecoderNotFound,
233 db.SetActiveCngDecoder(17)); 235 db.SetActiveCngDecoder(17));
234 } 236 }
235 } // namespace webrtc 237 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698