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

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

Issue 1823503002: Reland Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2008 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 void SetupForMultiSendStream() { 107 void SetupForMultiSendStream() {
108 EXPECT_TRUE(SetupEngineWithSendStream()); 108 EXPECT_TRUE(SetupEngineWithSendStream());
109 // Remove stream added in Setup. 109 // Remove stream added in Setup.
110 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); 110 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1));
111 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc1)); 111 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc1));
112 // Verify the channel does not exist. 112 // Verify the channel does not exist.
113 EXPECT_FALSE(call_.GetAudioSendStream(kSsrc1)); 113 EXPECT_FALSE(call_.GetAudioSendStream(kSsrc1));
114 } 114 }
115 void DeliverPacket(const void* data, int len) { 115 void DeliverPacket(const void* data, int len) {
116 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len); 116 rtc::CopyOnWriteBuffer packet(reinterpret_cast<const uint8_t*>(data), len);
117 channel_->OnPacketReceived(&packet, rtc::PacketTime()); 117 channel_->OnPacketReceived(&packet, rtc::PacketTime());
118 } 118 }
119 void TearDown() override { 119 void TearDown() override {
120 delete channel_; 120 delete channel_;
121 engine_.Terminate(); 121 engine_.Terminate();
122 } 122 }
123 123
124 const cricket::FakeAudioSendStream& GetSendStream(uint32_t ssrc) { 124 const cricket::FakeAudioSendStream& GetSendStream(uint32_t ssrc) {
125 const auto* send_stream = call_.GetAudioSendStream(ssrc); 125 const auto* send_stream = call_.GetAudioSendStream(ssrc);
126 EXPECT_TRUE(send_stream); 126 EXPECT_TRUE(send_stream);
(...skipping 2947 matching lines...) Expand 10 before | Expand all | Expand 10 after
3074 for (uint32_t ssrc : ssrcs) { 3074 for (uint32_t ssrc : ssrcs) {
3075 const auto* s = call_.GetAudioReceiveStream(ssrc); 3075 const auto* s = call_.GetAudioReceiveStream(ssrc);
3076 EXPECT_NE(nullptr, s); 3076 EXPECT_NE(nullptr, s);
3077 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); 3077 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size());
3078 } 3078 }
3079 } 3079 }
3080 3080
3081 TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { 3081 TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) {
3082 // Test that packets are forwarded to the Call when configured accordingly. 3082 // Test that packets are forwarded to the Call when configured accordingly.
3083 const uint32_t kAudioSsrc = 1; 3083 const uint32_t kAudioSsrc = 1;
3084 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); 3084 rtc::CopyOnWriteBuffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame));
3085 static const unsigned char kRtcp[] = { 3085 static const unsigned char kRtcp[] = {
3086 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 3086 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
3087 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 3087 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
3088 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3088 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3089 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 3089 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
3090 }; 3090 };
3091 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp)); 3091 rtc::CopyOnWriteBuffer kRtcpPacket(kRtcp, sizeof(kRtcp));
3092 3092
3093 EXPECT_TRUE(SetupEngineWithSendStream()); 3093 EXPECT_TRUE(SetupEngineWithSendStream());
3094 cricket::WebRtcVoiceMediaChannel* media_channel = 3094 cricket::WebRtcVoiceMediaChannel* media_channel =
3095 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3095 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3096 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3096 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3097 EXPECT_TRUE(media_channel->AddRecvStream( 3097 EXPECT_TRUE(media_channel->AddRecvStream(
3098 cricket::StreamParams::CreateLegacy(kAudioSsrc))); 3098 cricket::StreamParams::CreateLegacy(kAudioSsrc)));
3099 3099
3100 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size()); 3100 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size());
3101 const cricket::FakeAudioReceiveStream* s = 3101 const cricket::FakeAudioReceiveStream* s =
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3326 cricket::WebRtcVoiceEngine engine; 3326 cricket::WebRtcVoiceEngine engine;
3327 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3327 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3328 std::unique_ptr<webrtc::Call> call( 3328 std::unique_ptr<webrtc::Call> call(
3329 webrtc::Call::Create(webrtc::Call::Config())); 3329 webrtc::Call::Create(webrtc::Call::Config()));
3330 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), 3330 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(),
3331 cricket::AudioOptions(), call.get()); 3331 cricket::AudioOptions(), call.get());
3332 cricket::AudioRecvParameters parameters; 3332 cricket::AudioRecvParameters parameters;
3333 parameters.codecs = engine.codecs(); 3333 parameters.codecs = engine.codecs();
3334 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3334 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3335 } 3335 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698