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

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

Issue 1588693002: Revert of Storing raw audio sink for default audio track. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 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/channel.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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 engine, // base 65 engine, // base
66 engine, // codec 66 engine, // codec
67 engine, // hw 67 engine, // hw
68 engine, // network 68 engine, // network
69 engine, // rtp 69 engine, // rtp
70 engine) { // volume 70 engine) { // volume
71 } 71 }
72 }; 72 };
73 } // namespace 73 } // namespace
74 74
75 class FakeAudioSink : public rtc::RefCountedObject<webrtc::AudioSinkInterface> {
76 public:
77 void OnData(const Data& audio) override {}
78 };
79
80 class WebRtcVoiceEngineTestFake : public testing::Test { 75 class WebRtcVoiceEngineTestFake : public testing::Test {
81 public: 76 public:
82 WebRtcVoiceEngineTestFake() 77 WebRtcVoiceEngineTestFake()
83 : call_(webrtc::Call::Config()), 78 : call_(webrtc::Call::Config()),
84 engine_(new FakeVoEWrapper(&voe_)), 79 engine_(new FakeVoEWrapper(&voe_)),
85 channel_(nullptr) { 80 channel_(nullptr) {
86 send_parameters_.codecs.push_back(kPcmuCodec); 81 send_parameters_.codecs.push_back(kPcmuCodec);
87 recv_parameters_.codecs.push_back(kPcmuCodec); 82 recv_parameters_.codecs.push_back(kPcmuCodec);
88 } 83 }
89 bool SetupEngine() { 84 bool SetupEngine() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 delete channel_; 118 delete channel_;
124 engine_.Terminate(); 119 engine_.Terminate();
125 } 120 }
126 121
127 const cricket::FakeAudioSendStream& GetSendStream(uint32_t ssrc) { 122 const cricket::FakeAudioSendStream& GetSendStream(uint32_t ssrc) {
128 const auto* send_stream = call_.GetAudioSendStream(ssrc); 123 const auto* send_stream = call_.GetAudioSendStream(ssrc);
129 EXPECT_TRUE(send_stream); 124 EXPECT_TRUE(send_stream);
130 return *send_stream; 125 return *send_stream;
131 } 126 }
132 127
133 const cricket::FakeAudioReceiveStream& GetRecvStream(uint32_t ssrc) {
134 const auto* recv_stream = call_.GetAudioReceiveStream(ssrc);
135 EXPECT_TRUE(recv_stream);
136 return *recv_stream;
137 }
138
139 const webrtc::AudioSendStream::Config& GetSendStreamConfig(uint32_t ssrc) { 128 const webrtc::AudioSendStream::Config& GetSendStreamConfig(uint32_t ssrc) {
140 const auto* send_stream = call_.GetAudioSendStream(ssrc); 129 const auto* send_stream = call_.GetAudioSendStream(ssrc);
141 EXPECT_TRUE(send_stream); 130 EXPECT_TRUE(send_stream);
142 return send_stream->GetConfig(); 131 return send_stream->GetConfig();
143 } 132 }
144 133
145 const webrtc::AudioReceiveStream::Config& GetRecvStreamConfig(uint32_t ssrc) { 134 const webrtc::AudioReceiveStream::Config& GetRecvStreamConfig(uint32_t ssrc) {
146 const auto* recv_stream = call_.GetAudioReceiveStream(ssrc); 135 const auto* recv_stream = call_.GetAudioReceiveStream(ssrc);
147 EXPECT_TRUE(recv_stream); 136 EXPECT_TRUE(recv_stream);
148 return recv_stream->GetConfig(); 137 return recv_stream->GetConfig();
(...skipping 2960 matching lines...) Expand 10 before | Expand all | Expand 10 after
3109 // channel of |recv_ch|.This is not a common case, since, normally, only the 3098 // channel of |recv_ch|.This is not a common case, since, normally, only the
3110 // default channel can be associated. However, the default is not deletable. 3099 // default channel can be associated. However, the default is not deletable.
3111 // So we force the |recv_ch| to associate with a non-default channel. 3100 // So we force the |recv_ch| to associate with a non-default channel.
3112 EXPECT_EQ(0, voe_.AssociateSendChannel(recv_ch, send_ch)); 3101 EXPECT_EQ(0, voe_.AssociateSendChannel(recv_ch, send_ch));
3113 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), send_ch); 3102 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), send_ch);
3114 3103
3115 EXPECT_TRUE(channel_->RemoveSendStream(2)); 3104 EXPECT_TRUE(channel_->RemoveSendStream(2));
3116 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); 3105 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1);
3117 } 3106 }
3118 3107
3119 TEST_F(WebRtcVoiceEngineTestFake, SetRawAudioSink) {
3120 EXPECT_TRUE(SetupEngine());
3121 rtc::scoped_refptr<FakeAudioSink> fake_sink = new FakeAudioSink();
3122
3123 // This should do nothing, since there's no recv stream yet.
3124 channel_->SetRawAudioSink(kSsrc1, fake_sink);
3125 // Ensure the ref count wasn't incremented.
3126 EXPECT_TRUE(fake_sink->HasOneRef());
3127
3128 EXPECT_TRUE(
3129 channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc1)));
3130 // Now, the channel should latch on to the sink.
3131 channel_->SetRawAudioSink(kSsrc1, fake_sink);
3132 EXPECT_FALSE(fake_sink->HasOneRef());
3133 EXPECT_EQ(fake_sink.get(), GetRecvStream(kSsrc1).sink().get());
3134
3135 // Setting a nullptr should release the reference.
3136 channel_->SetRawAudioSink(kSsrc1, nullptr);
3137 EXPECT_TRUE(fake_sink->HasOneRef());
3138 }
3139
3140 TEST_F(WebRtcVoiceEngineTestFake, SetRawAudioSinkDefaultRecvStream) {
3141 EXPECT_TRUE(SetupEngine());
3142 rtc::scoped_refptr<FakeAudioSink> fake_sink_1 = new FakeAudioSink();
3143 rtc::scoped_refptr<FakeAudioSink> fake_sink_2 = new FakeAudioSink();
3144
3145 // Should be able to set a default sink even when no stream exists.
3146 channel_->SetRawAudioSink(0, fake_sink_1);
3147 EXPECT_FALSE(fake_sink_1->HasOneRef());
3148
3149 // Create default channel.
3150 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
3151 EXPECT_EQ(fake_sink_1.get(), GetRecvStream(0x01).sink().get());
3152
3153 // Should be able to set the default sink after a stream exists.
3154 channel_->SetRawAudioSink(0, fake_sink_2);
3155 EXPECT_TRUE(fake_sink_1->HasOneRef());
3156 EXPECT_FALSE(fake_sink_2->HasOneRef());
3157 EXPECT_EQ(fake_sink_2.get(), GetRecvStream(0x01).sink().get());
3158
3159 // If we remove and add a default stream, it should get the same sink.
3160 EXPECT_TRUE(channel_->RemoveRecvStream(0x01));
3161 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
3162 EXPECT_FALSE(fake_sink_2->HasOneRef());
3163 EXPECT_EQ(fake_sink_2.get(), GetRecvStream(0x01).sink().get());
3164
3165 // Finally, try resetting the default sink.
3166 channel_->SetRawAudioSink(0, nullptr);
3167 EXPECT_TRUE(fake_sink_2->HasOneRef());
3168 }
3169
3170 // Tests that the library initializes and shuts down properly. 3108 // Tests that the library initializes and shuts down properly.
3171 TEST(WebRtcVoiceEngineTest, StartupShutdown) { 3109 TEST(WebRtcVoiceEngineTest, StartupShutdown) {
3172 cricket::WebRtcVoiceEngine engine; 3110 cricket::WebRtcVoiceEngine engine;
3173 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3111 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3174 rtc::scoped_ptr<webrtc::Call> call( 3112 rtc::scoped_ptr<webrtc::Call> call(
3175 webrtc::Call::Create(webrtc::Call::Config())); 3113 webrtc::Call::Create(webrtc::Call::Config()));
3176 cricket::VoiceMediaChannel* channel = 3114 cricket::VoiceMediaChannel* channel =
3177 engine.CreateChannel(call.get(), cricket::AudioOptions()); 3115 engine.CreateChannel(call.get(), cricket::AudioOptions());
3178 EXPECT_TRUE(channel != nullptr); 3116 EXPECT_TRUE(channel != nullptr);
3179 delete channel; 3117 delete channel;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3300 cricket::WebRtcVoiceEngine engine; 3238 cricket::WebRtcVoiceEngine engine;
3301 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3239 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3302 rtc::scoped_ptr<webrtc::Call> call( 3240 rtc::scoped_ptr<webrtc::Call> call(
3303 webrtc::Call::Create(webrtc::Call::Config())); 3241 webrtc::Call::Create(webrtc::Call::Config()));
3304 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), 3242 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(),
3305 call.get()); 3243 call.get());
3306 cricket::AudioRecvParameters parameters; 3244 cricket::AudioRecvParameters parameters;
3307 parameters.codecs = engine.codecs(); 3245 parameters.codecs = engine.codecs();
3308 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3246 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3309 } 3247 }
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | talk/session/media/channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698