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

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine_unittest.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 years, 2 months 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
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | talk/session/media/audiomonitor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2008 Google Inc. 3 * Copyright 2008 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 static const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0); 50 static const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0);
51 static const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0); 51 static const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0);
52 static const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0); 52 static const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0);
53 static const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0); 53 static const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0);
54 static const cricket::AudioCodec 54 static const cricket::AudioCodec
55 kTelephoneEventCodec(106, "telephone-event", 8000, 0, 1, 0); 55 kTelephoneEventCodec(106, "telephone-event", 8000, 0, 1, 0);
56 static const cricket::AudioCodec* const kAudioCodecs[] = { 56 static const cricket::AudioCodec* const kAudioCodecs[] = {
57 &kPcmuCodec, &kIsacCodec, &kOpusCodec, &kG722CodecVoE, &kRedCodec, 57 &kPcmuCodec, &kIsacCodec, &kOpusCodec, &kG722CodecVoE, &kRedCodec,
58 &kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec, 58 &kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec,
59 }; 59 };
60 static uint32 kSsrc1 = 0x99; 60 static uint32_t kSsrc1 = 0x99;
61 static uint32 kSsrc2 = 0x98; 61 static uint32_t kSsrc2 = 0x98;
62 62
63 class FakeVoEWrapper : public cricket::VoEWrapper { 63 class FakeVoEWrapper : public cricket::VoEWrapper {
64 public: 64 public:
65 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) 65 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine)
66 : cricket::VoEWrapper(engine, // processing 66 : cricket::VoEWrapper(engine, // processing
67 engine, // base 67 engine, // base
68 engine, // codec 68 engine, // codec
69 engine, // dtmf 69 engine, // dtmf
70 engine, // hw 70 engine, // hw
71 engine, // neteq 71 engine, // neteq
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 if (!SetupEngineWithoutStream()) { 111 if (!SetupEngineWithoutStream()) {
112 return false; 112 return false;
113 } 113 }
114 return channel_->AddSendStream( 114 return channel_->AddSendStream(
115 cricket::StreamParams::CreateLegacy(kSsrc1)); 115 cricket::StreamParams::CreateLegacy(kSsrc1));
116 } 116 }
117 void SetupForMultiSendStream() { 117 void SetupForMultiSendStream() {
118 EXPECT_TRUE(SetupEngine()); 118 EXPECT_TRUE(SetupEngine());
119 // Remove stream added in Setup, which is corresponding to default channel. 119 // Remove stream added in Setup, which is corresponding to default channel.
120 int default_channel_num = voe_.GetLastChannel(); 120 int default_channel_num = voe_.GetLastChannel();
121 uint32 default_send_ssrc = 0u; 121 uint32_t default_send_ssrc = 0u;
122 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); 122 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc));
123 EXPECT_EQ(kSsrc1, default_send_ssrc); 123 EXPECT_EQ(kSsrc1, default_send_ssrc);
124 EXPECT_TRUE(channel_->RemoveSendStream(default_send_ssrc)); 124 EXPECT_TRUE(channel_->RemoveSendStream(default_send_ssrc));
125 125
126 // Verify the default channel still exists. 126 // Verify the default channel still exists.
127 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); 127 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc));
128 } 128 }
129 void DeliverPacket(const void* data, int len) { 129 void DeliverPacket(const void* data, int len) {
130 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len); 130 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len);
131 channel_->OnPacketReceived(&packet, rtc::PacketTime()); 131 channel_->OnPacketReceived(&packet, rtc::PacketTime());
132 } 132 }
133 void TearDown() override { 133 void TearDown() override {
134 delete channel_; 134 delete channel_;
135 engine_.Terminate(); 135 engine_.Terminate();
136 } 136 }
137 137
138 void TestInsertDtmf(uint32 ssrc, bool caller) { 138 void TestInsertDtmf(uint32_t ssrc, bool caller) {
139 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 139 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
140 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 140 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
141 EXPECT_TRUE(channel_ != nullptr); 141 EXPECT_TRUE(channel_ != nullptr);
142 if (caller) { 142 if (caller) {
143 // if this is a caller, local description will be applied and add the 143 // if this is a caller, local description will be applied and add the
144 // send stream. 144 // send stream.
145 EXPECT_TRUE(channel_->AddSendStream( 145 EXPECT_TRUE(channel_->AddSendStream(
146 cricket::StreamParams::CreateLegacy(kSsrc1))); 146 cricket::StreamParams::CreateLegacy(kSsrc1)));
147 } 147 }
148 int channel_id = voe_.GetLastChannel(); 148 int channel_id = voe_.GetLastChannel();
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); 1856 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING));
1857 EXPECT_FALSE(voe_.GetSend(channel_num)); 1857 EXPECT_FALSE(voe_.GetSend(channel_num));
1858 EXPECT_TRUE(channel_->SetPlayout(false)); 1858 EXPECT_TRUE(channel_->SetPlayout(false));
1859 EXPECT_FALSE(voe_.GetPlayout(channel_num)); 1859 EXPECT_FALSE(voe_.GetPlayout(channel_num));
1860 } 1860 }
1861 1861
1862 // Test that we can add and remove send streams. 1862 // Test that we can add and remove send streams.
1863 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { 1863 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) {
1864 SetupForMultiSendStream(); 1864 SetupForMultiSendStream();
1865 1865
1866 static const uint32 kSsrcs4[] = {1, 2, 3, 4}; 1866 static const uint32_t kSsrcs4[] = {1, 2, 3, 4};
1867 1867
1868 // Set the global state for sending. 1868 // Set the global state for sending.
1869 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 1869 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
1870 1870
1871 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { 1871 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) {
1872 EXPECT_TRUE(channel_->AddSendStream( 1872 EXPECT_TRUE(channel_->AddSendStream(
1873 cricket::StreamParams::CreateLegacy(kSsrcs4[i]))); 1873 cricket::StreamParams::CreateLegacy(kSsrcs4[i])));
1874 1874
1875 // Verify that we are in a sending state for all the created streams. 1875 // Verify that we are in a sending state for all the created streams.
1876 int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]); 1876 int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]);
(...skipping 14 matching lines...) Expand all
1891 // Stream should already be deleted. 1891 // Stream should already be deleted.
1892 EXPECT_FALSE(channel_->RemoveSendStream(kSsrcs4[i])); 1892 EXPECT_FALSE(channel_->RemoveSendStream(kSsrcs4[i]));
1893 EXPECT_EQ(-1, voe_.GetChannelFromLocalSsrc(kSsrcs4[i])); 1893 EXPECT_EQ(-1, voe_.GetChannelFromLocalSsrc(kSsrcs4[i]));
1894 } 1894 }
1895 } 1895 }
1896 1896
1897 // Test SetSendCodecs correctly configure the codecs in all send streams. 1897 // Test SetSendCodecs correctly configure the codecs in all send streams.
1898 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) { 1898 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) {
1899 SetupForMultiSendStream(); 1899 SetupForMultiSendStream();
1900 1900
1901 static const uint32 kSsrcs4[] = {1, 2, 3, 4}; 1901 static const uint32_t kSsrcs4[] = {1, 2, 3, 4};
1902 // Create send streams. 1902 // Create send streams.
1903 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { 1903 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) {
1904 EXPECT_TRUE(channel_->AddSendStream( 1904 EXPECT_TRUE(channel_->AddSendStream(
1905 cricket::StreamParams::CreateLegacy(kSsrcs4[i]))); 1905 cricket::StreamParams::CreateLegacy(kSsrcs4[i])));
1906 } 1906 }
1907 1907
1908 cricket::AudioSendParameters parameters; 1908 cricket::AudioSendParameters parameters;
1909 // Set ISAC(16K) and CN(16K). VAD should be activated. 1909 // Set ISAC(16K) and CN(16K). VAD should be activated.
1910 parameters.codecs.push_back(kIsacCodec); 1910 parameters.codecs.push_back(kIsacCodec);
1911 parameters.codecs.push_back(kCn16000Codec); 1911 parameters.codecs.push_back(kCn16000Codec);
(...skipping 18 matching lines...) Expand all
1930 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1930 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1931 EXPECT_STREQ("PCMU", gcodec.plname); 1931 EXPECT_STREQ("PCMU", gcodec.plname);
1932 EXPECT_FALSE(voe_.GetVAD(channel_num)); 1932 EXPECT_FALSE(voe_.GetVAD(channel_num));
1933 } 1933 }
1934 } 1934 }
1935 1935
1936 // Test we can SetSend on all send streams correctly. 1936 // Test we can SetSend on all send streams correctly.
1937 TEST_F(WebRtcVoiceEngineTestFake, SetSendWithMultipleSendStreams) { 1937 TEST_F(WebRtcVoiceEngineTestFake, SetSendWithMultipleSendStreams) {
1938 SetupForMultiSendStream(); 1938 SetupForMultiSendStream();
1939 1939
1940 static const uint32 kSsrcs4[] = {1, 2, 3, 4}; 1940 static const uint32_t kSsrcs4[] = {1, 2, 3, 4};
1941 // Create the send channels and they should be a SEND_NOTHING date. 1941 // Create the send channels and they should be a SEND_NOTHING date.
1942 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { 1942 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) {
1943 EXPECT_TRUE(channel_->AddSendStream( 1943 EXPECT_TRUE(channel_->AddSendStream(
1944 cricket::StreamParams::CreateLegacy(kSsrcs4[i]))); 1944 cricket::StreamParams::CreateLegacy(kSsrcs4[i])));
1945 int channel_num = voe_.GetLastChannel(); 1945 int channel_num = voe_.GetLastChannel();
1946 EXPECT_FALSE(voe_.GetSend(channel_num)); 1946 EXPECT_FALSE(voe_.GetSend(channel_num));
1947 } 1947 }
1948 1948
1949 // Set the global state for starting sending. 1949 // Set the global state for starting sending.
1950 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 1950 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
1951 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { 1951 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) {
1952 // Verify that we are in a sending state for all the send streams. 1952 // Verify that we are in a sending state for all the send streams.
1953 int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]); 1953 int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]);
1954 EXPECT_TRUE(voe_.GetSend(channel_num)); 1954 EXPECT_TRUE(voe_.GetSend(channel_num));
1955 } 1955 }
1956 1956
1957 // Set the global state for stopping sending. 1957 // Set the global state for stopping sending.
1958 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); 1958 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING));
1959 for (unsigned int i = 1; i < ARRAY_SIZE(kSsrcs4); ++i) { 1959 for (unsigned int i = 1; i < ARRAY_SIZE(kSsrcs4); ++i) {
1960 // Verify that we are in a stop state for all the send streams. 1960 // Verify that we are in a stop state for all the send streams.
1961 int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]); 1961 int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]);
1962 EXPECT_FALSE(voe_.GetSend(channel_num)); 1962 EXPECT_FALSE(voe_.GetSend(channel_num));
1963 } 1963 }
1964 } 1964 }
1965 1965
1966 // Test we can set the correct statistics on all send streams. 1966 // Test we can set the correct statistics on all send streams.
1967 TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) { 1967 TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) {
1968 SetupForMultiSendStream(); 1968 SetupForMultiSendStream();
1969 1969
1970 static const uint32 kSsrcs4[] = {1, 2, 3, 4}; 1970 static const uint32_t kSsrcs4[] = {1, 2, 3, 4};
1971 // Create send streams. 1971 // Create send streams.
1972 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { 1972 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) {
1973 EXPECT_TRUE(channel_->AddSendStream( 1973 EXPECT_TRUE(channel_->AddSendStream(
1974 cricket::StreamParams::CreateLegacy(kSsrcs4[i]))); 1974 cricket::StreamParams::CreateLegacy(kSsrcs4[i])));
1975 } 1975 }
1976 // Create a receive stream to check that none of the send streams end up in 1976 // Create a receive stream to check that none of the send streams end up in
1977 // the receive stream stats. 1977 // the receive stream stats.
1978 EXPECT_TRUE(channel_->AddRecvStream( 1978 EXPECT_TRUE(channel_->AddRecvStream(
1979 cricket::StreamParams::CreateLegacy(kSsrc2))); 1979 cricket::StreamParams::CreateLegacy(kSsrc2)));
1980 // We need send codec to be set to get all stats. 1980 // We need send codec to be set to get all stats.
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 2384 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
2385 int channel_num1 = voe_.GetLastChannel(); 2385 int channel_num1 = voe_.GetLastChannel();
2386 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2386 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2387 int channel_num2 = voe_.GetLastChannel(); 2387 int channel_num2 = voe_.GetLastChannel();
2388 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); 2388 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3)));
2389 int channel_num3 = voe_.GetLastChannel(); 2389 int channel_num3 = voe_.GetLastChannel();
2390 // Create packets with the right SSRCs. 2390 // Create packets with the right SSRCs.
2391 char packets[4][sizeof(kPcmuFrame)]; 2391 char packets[4][sizeof(kPcmuFrame)];
2392 for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) { 2392 for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) {
2393 memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame)); 2393 memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame));
2394 rtc::SetBE32(packets[i] + 8, static_cast<uint32>(i)); 2394 rtc::SetBE32(packets[i] + 8, static_cast<uint32_t>(i));
2395 } 2395 }
2396 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1)); 2396 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1));
2397 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); 2397 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2));
2398 EXPECT_TRUE(voe_.CheckNoPacket(channel_num3)); 2398 EXPECT_TRUE(voe_.CheckNoPacket(channel_num3));
2399 DeliverPacket(packets[0], sizeof(packets[0])); 2399 DeliverPacket(packets[0], sizeof(packets[0]));
2400 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1)); 2400 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1));
2401 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); 2401 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2));
2402 EXPECT_TRUE(voe_.CheckNoPacket(channel_num3)); 2402 EXPECT_TRUE(voe_.CheckNoPacket(channel_num3));
2403 DeliverPacket(packets[1], sizeof(packets[1])); 2403 DeliverPacket(packets[1], sizeof(packets[1]));
2404 EXPECT_TRUE(voe_.CheckPacket(channel_num1, packets[1], 2404 EXPECT_TRUE(voe_.CheckPacket(channel_num1, packets[1],
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
2914 2914
2915 EXPECT_TRUE(channel_->SetOutputScaling(kSsrc2, 2, 1)); 2915 EXPECT_TRUE(channel_->SetOutputScaling(kSsrc2, 2, 1));
2916 channel_id = voe_.GetLastChannel(); 2916 channel_id = voe_.GetLastChannel();
2917 EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale)); 2917 EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale));
2918 EXPECT_EQ(0, voe_.GetOutputVolumePan(channel_id, left, right)); 2918 EXPECT_EQ(0, voe_.GetOutputVolumePan(channel_id, left, right));
2919 EXPECT_DOUBLE_EQ(2, left * scale); 2919 EXPECT_DOUBLE_EQ(2, left * scale);
2920 EXPECT_DOUBLE_EQ(1, right * scale); 2920 EXPECT_DOUBLE_EQ(1, right * scale);
2921 } 2921 }
2922 2922
2923 TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { 2923 TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) {
2924 const uint32 kAudioSsrc = 123; 2924 const uint32_t kAudioSsrc = 123;
2925 const std::string kSyncLabel = "AvSyncLabel"; 2925 const std::string kSyncLabel = "AvSyncLabel";
2926 2926
2927 EXPECT_TRUE(SetupEngine()); 2927 EXPECT_TRUE(SetupEngine());
2928 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc); 2928 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc);
2929 sp.sync_label = kSyncLabel; 2929 sp.sync_label = kSyncLabel;
2930 // Creating two channels to make sure that sync label is set properly for both 2930 // Creating two channels to make sure that sync label is set properly for both
2931 // the default voice channel and following ones. 2931 // the default voice channel and following ones.
2932 EXPECT_TRUE(channel_->AddRecvStream(sp)); 2932 EXPECT_TRUE(channel_->AddRecvStream(sp));
2933 sp.ssrcs[0] += 1; 2933 sp.ssrcs[0] += 1;
2934 EXPECT_TRUE(channel_->AddRecvStream(sp)); 2934 EXPECT_TRUE(channel_->AddRecvStream(sp));
2935 2935
2936 ASSERT_EQ(2, call_.GetAudioReceiveStreams().size()); 2936 ASSERT_EQ(2, call_.GetAudioReceiveStreams().size());
2937 EXPECT_EQ(kSyncLabel, 2937 EXPECT_EQ(kSyncLabel,
2938 call_.GetAudioReceiveStream(kAudioSsrc)->GetConfig().sync_group) 2938 call_.GetAudioReceiveStream(kAudioSsrc)->GetConfig().sync_group)
2939 << "SyncGroup should be set based on sync_label"; 2939 << "SyncGroup should be set based on sync_label";
2940 EXPECT_EQ(kSyncLabel, 2940 EXPECT_EQ(kSyncLabel,
2941 call_.GetAudioReceiveStream(kAudioSsrc + 1)->GetConfig().sync_group) 2941 call_.GetAudioReceiveStream(kAudioSsrc + 1)->GetConfig().sync_group)
2942 << "SyncGroup should be set based on sync_label"; 2942 << "SyncGroup should be set based on sync_label";
2943 } 2943 }
2944 2944
2945 TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { 2945 TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) {
2946 // Test that changing the combined_audio_video_bwe option results in the 2946 // Test that changing the combined_audio_video_bwe option results in the
2947 // expected state changes on an associated Call. 2947 // expected state changes on an associated Call.
2948 std::vector<uint32> ssrcs; 2948 std::vector<uint32_t> ssrcs;
2949 ssrcs.push_back(223); 2949 ssrcs.push_back(223);
2950 ssrcs.push_back(224); 2950 ssrcs.push_back(224);
2951 2951
2952 EXPECT_TRUE(SetupEngine()); 2952 EXPECT_TRUE(SetupEngine());
2953 cricket::WebRtcVoiceMediaChannel* media_channel = 2953 cricket::WebRtcVoiceMediaChannel* media_channel =
2954 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 2954 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
2955 for (uint32 ssrc : ssrcs) { 2955 for (uint32_t ssrc : ssrcs) {
2956 EXPECT_TRUE(media_channel->AddRecvStream( 2956 EXPECT_TRUE(media_channel->AddRecvStream(
2957 cricket::StreamParams::CreateLegacy(ssrc))); 2957 cricket::StreamParams::CreateLegacy(ssrc)));
2958 } 2958 }
2959 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 2959 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
2960 2960
2961 // Combined BWE should be disabled. 2961 // Combined BWE should be disabled.
2962 for (uint32 ssrc : ssrcs) { 2962 for (uint32_t ssrc : ssrcs) {
2963 const auto* s = call_.GetAudioReceiveStream(ssrc); 2963 const auto* s = call_.GetAudioReceiveStream(ssrc);
2964 EXPECT_NE(nullptr, s); 2964 EXPECT_NE(nullptr, s);
2965 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe); 2965 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe);
2966 } 2966 }
2967 2967
2968 // Enable combined BWE option - now it should be set up. 2968 // Enable combined BWE option - now it should be set up.
2969 send_parameters_.options.combined_audio_video_bwe.Set(true); 2969 send_parameters_.options.combined_audio_video_bwe.Set(true);
2970 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); 2970 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
2971 for (uint32 ssrc : ssrcs) { 2971 for (uint32_t ssrc : ssrcs) {
2972 const auto* s = call_.GetAudioReceiveStream(ssrc); 2972 const auto* s = call_.GetAudioReceiveStream(ssrc);
2973 EXPECT_NE(nullptr, s); 2973 EXPECT_NE(nullptr, s);
2974 EXPECT_EQ(true, s->GetConfig().combined_audio_video_bwe); 2974 EXPECT_EQ(true, s->GetConfig().combined_audio_video_bwe);
2975 } 2975 }
2976 2976
2977 // Disable combined BWE option - should be disabled again. 2977 // Disable combined BWE option - should be disabled again.
2978 send_parameters_.options.combined_audio_video_bwe.Set(false); 2978 send_parameters_.options.combined_audio_video_bwe.Set(false);
2979 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); 2979 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
2980 for (uint32 ssrc : ssrcs) { 2980 for (uint32_t ssrc : ssrcs) {
2981 const auto* s = call_.GetAudioReceiveStream(ssrc); 2981 const auto* s = call_.GetAudioReceiveStream(ssrc);
2982 EXPECT_NE(nullptr, s); 2982 EXPECT_NE(nullptr, s);
2983 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe); 2983 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe);
2984 } 2984 }
2985 2985
2986 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 2986 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
2987 } 2987 }
2988 2988
2989 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { 2989 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) {
2990 // Test that adding receive streams after enabling combined bandwidth 2990 // Test that adding receive streams after enabling combined bandwidth
2991 // estimation will correctly configure each channel. 2991 // estimation will correctly configure each channel.
2992 EXPECT_TRUE(SetupEngine()); 2992 EXPECT_TRUE(SetupEngine());
2993 cricket::WebRtcVoiceMediaChannel* media_channel = 2993 cricket::WebRtcVoiceMediaChannel* media_channel =
2994 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 2994 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
2995 send_parameters_.options.combined_audio_video_bwe.Set(true); 2995 send_parameters_.options.combined_audio_video_bwe.Set(true);
2996 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); 2996 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
2997 2997
2998 static const uint32 kSsrcs[] = {1, 2, 3, 4}; 2998 static const uint32_t kSsrcs[] = {1, 2, 3, 4};
2999 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { 2999 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) {
3000 EXPECT_TRUE(media_channel->AddRecvStream( 3000 EXPECT_TRUE(media_channel->AddRecvStream(
3001 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); 3001 cricket::StreamParams::CreateLegacy(kSsrcs[i])));
3002 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i])); 3002 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i]));
3003 } 3003 }
3004 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size()); 3004 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size());
3005 } 3005 }
3006 3006
3007 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { 3007 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) {
3008 // Test that setting the header extensions results in the expected state 3008 // Test that setting the header extensions results in the expected state
3009 // changes on an associated Call. 3009 // changes on an associated Call.
3010 std::vector<uint32> ssrcs; 3010 std::vector<uint32_t> ssrcs;
3011 ssrcs.push_back(223); 3011 ssrcs.push_back(223);
3012 ssrcs.push_back(224); 3012 ssrcs.push_back(224);
3013 3013
3014 EXPECT_TRUE(SetupEngine()); 3014 EXPECT_TRUE(SetupEngine());
3015 cricket::WebRtcVoiceMediaChannel* media_channel = 3015 cricket::WebRtcVoiceMediaChannel* media_channel =
3016 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3016 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3017 send_parameters_.options.combined_audio_video_bwe.Set(true); 3017 send_parameters_.options.combined_audio_video_bwe.Set(true);
3018 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); 3018 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
3019 for (uint32 ssrc : ssrcs) { 3019 for (uint32_t ssrc : ssrcs) {
3020 EXPECT_TRUE(media_channel->AddRecvStream( 3020 EXPECT_TRUE(media_channel->AddRecvStream(
3021 cricket::StreamParams::CreateLegacy(ssrc))); 3021 cricket::StreamParams::CreateLegacy(ssrc)));
3022 } 3022 }
3023 3023
3024 // Combined BWE should be set up, but with no configured extensions. 3024 // Combined BWE should be set up, but with no configured extensions.
3025 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 3025 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3026 for (uint32 ssrc : ssrcs) { 3026 for (uint32_t ssrc : ssrcs) {
3027 const auto* s = call_.GetAudioReceiveStream(ssrc); 3027 const auto* s = call_.GetAudioReceiveStream(ssrc);
3028 EXPECT_NE(nullptr, s); 3028 EXPECT_NE(nullptr, s);
3029 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); 3029 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size());
3030 } 3030 }
3031 3031
3032 // Set up receive extensions. 3032 // Set up receive extensions.
3033 const auto& e_exts = engine_.rtp_header_extensions(); 3033 const auto& e_exts = engine_.rtp_header_extensions();
3034 cricket::AudioRecvParameters recv_parameters; 3034 cricket::AudioRecvParameters recv_parameters;
3035 recv_parameters.extensions = e_exts; 3035 recv_parameters.extensions = e_exts;
3036 channel_->SetRecvParameters(recv_parameters); 3036 channel_->SetRecvParameters(recv_parameters);
3037 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 3037 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3038 for (uint32 ssrc : ssrcs) { 3038 for (uint32_t ssrc : ssrcs) {
3039 const auto* s = call_.GetAudioReceiveStream(ssrc); 3039 const auto* s = call_.GetAudioReceiveStream(ssrc);
3040 EXPECT_NE(nullptr, s); 3040 EXPECT_NE(nullptr, s);
3041 const auto& s_exts = s->GetConfig().rtp.extensions; 3041 const auto& s_exts = s->GetConfig().rtp.extensions;
3042 EXPECT_EQ(e_exts.size(), s_exts.size()); 3042 EXPECT_EQ(e_exts.size(), s_exts.size());
3043 for (const auto& e_ext : e_exts) { 3043 for (const auto& e_ext : e_exts) {
3044 for (const auto& s_ext : s_exts) { 3044 for (const auto& s_ext : s_exts) {
3045 if (e_ext.id == s_ext.id) { 3045 if (e_ext.id == s_ext.id) {
3046 EXPECT_EQ(e_ext.uri, s_ext.name); 3046 EXPECT_EQ(e_ext.uri, s_ext.name);
3047 } 3047 }
3048 } 3048 }
3049 } 3049 }
3050 } 3050 }
3051 3051
3052 // Disable receive extensions. 3052 // Disable receive extensions.
3053 channel_->SetRecvParameters(cricket::AudioRecvParameters()); 3053 channel_->SetRecvParameters(cricket::AudioRecvParameters());
3054 for (uint32 ssrc : ssrcs) { 3054 for (uint32_t ssrc : ssrcs) {
3055 const auto* s = call_.GetAudioReceiveStream(ssrc); 3055 const auto* s = call_.GetAudioReceiveStream(ssrc);
3056 EXPECT_NE(nullptr, s); 3056 EXPECT_NE(nullptr, s);
3057 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); 3057 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size());
3058 } 3058 }
3059 } 3059 }
3060 3060
3061 TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { 3061 TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) {
3062 // Test that packets are forwarded to the Call when configured accordingly. 3062 // Test that packets are forwarded to the Call when configured accordingly.
3063 const uint32 kAudioSsrc = 1; 3063 const uint32_t kAudioSsrc = 1;
3064 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); 3064 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame));
3065 static const unsigned char kRtcp[] = { 3065 static const unsigned char kRtcp[] = {
3066 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 3066 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
3067 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 3067 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
3068 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3068 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3069 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 3069 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
3070 }; 3070 };
3071 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp)); 3071 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp));
3072 3072
3073 EXPECT_TRUE(SetupEngine()); 3073 EXPECT_TRUE(SetupEngine());
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
3299 cricket::WebRtcVoiceEngine engine; 3299 cricket::WebRtcVoiceEngine engine;
3300 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3300 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3301 rtc::scoped_ptr<webrtc::Call> call( 3301 rtc::scoped_ptr<webrtc::Call> call(
3302 webrtc::Call::Create(webrtc::Call::Config())); 3302 webrtc::Call::Create(webrtc::Call::Config()));
3303 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), 3303 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(),
3304 call.get()); 3304 call.get());
3305 cricket::AudioRecvParameters parameters; 3305 cricket::AudioRecvParameters parameters;
3306 parameters.codecs = engine.codecs(); 3306 parameters.codecs = engine.codecs();
3307 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3307 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3308 } 3308 }
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | talk/session/media/audiomonitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698