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

Side by Side Diff: talk/app/webrtc/rtpsenderreceiver_unittest.cc

Issue 1505253004: Support for remote audio into tracks (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add thread check, Remove bits_per_sample and use int16_t. 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 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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,
11 * this list of conditions and the following disclaimer in the documentation 11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products 13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include <string> 28 #include <string>
29 #include <utility>
29 30
30 #include "talk/app/webrtc/audiotrack.h" 31 #include "talk/app/webrtc/audiotrack.h"
31 #include "talk/app/webrtc/mediastream.h" 32 #include "talk/app/webrtc/mediastream.h"
32 #include "talk/app/webrtc/remoteaudiosource.h" 33 #include "talk/app/webrtc/remoteaudiosource.h"
34 #include "talk/app/webrtc/remoteaudiotrack.h"
33 #include "talk/app/webrtc/rtpreceiver.h" 35 #include "talk/app/webrtc/rtpreceiver.h"
34 #include "talk/app/webrtc/rtpsender.h" 36 #include "talk/app/webrtc/rtpsender.h"
35 #include "talk/app/webrtc/streamcollection.h" 37 #include "talk/app/webrtc/streamcollection.h"
36 #include "talk/app/webrtc/videosource.h" 38 #include "talk/app/webrtc/videosource.h"
37 #include "talk/app/webrtc/videotrack.h" 39 #include "talk/app/webrtc/videotrack.h"
38 #include "talk/media/base/fakevideocapturer.h" 40 #include "talk/media/base/fakevideocapturer.h"
39 #include "talk/media/base/mediachannel.h" 41 #include "talk/media/base/mediachannel.h"
40 #include "testing/gmock/include/gmock/gmock.h" 42 #include "testing/gmock/include/gmock/gmock.h"
41 #include "testing/gtest/include/gtest/gtest.h" 43 #include "testing/gtest/include/gtest/gtest.h"
42 #include "webrtc/base/gunit.h" 44 #include "webrtc/base/gunit.h"
43 45
44 using ::testing::_; 46 using ::testing::_;
45 using ::testing::Exactly; 47 using ::testing::Exactly;
46 48
47 static const char kStreamLabel1[] = "local_stream_1"; 49 static const char kStreamLabel1[] = "local_stream_1";
48 static const char kVideoTrackId[] = "video_1"; 50 static const char kVideoTrackId[] = "video_1";
49 static const char kAudioTrackId[] = "audio_1"; 51 static const char kAudioTrackId[] = "audio_1";
50 static const uint32_t kVideoSsrc = 98; 52 static const uint32_t kVideoSsrc = 98;
51 static const uint32_t kVideoSsrc2 = 100; 53 static const uint32_t kVideoSsrc2 = 100;
52 static const uint32_t kAudioSsrc = 99; 54 static const uint32_t kAudioSsrc = 99;
53 static const uint32_t kAudioSsrc2 = 101; 55 static const uint32_t kAudioSsrc2 = 101;
54 56
55 namespace webrtc { 57 namespace webrtc {
56 58
57 // Helper class to test RtpSender/RtpReceiver. 59 // Helper class to test RtpSender/RtpReceiver.
58 class MockAudioProvider : public AudioProviderInterface { 60 class MockAudioProvider : public AudioProviderInterface {
59 public: 61 public:
60 virtual ~MockAudioProvider() {} 62 ~MockAudioProvider() override {}
63
61 MOCK_METHOD2(SetAudioPlayout, 64 MOCK_METHOD2(SetAudioPlayout,
62 void(uint32_t ssrc, 65 void(uint32_t ssrc,
63 bool enable)); 66 bool enable));
64 MOCK_METHOD4(SetAudioSend, 67 MOCK_METHOD4(SetAudioSend,
65 void(uint32_t ssrc, 68 void(uint32_t ssrc,
66 bool enable, 69 bool enable,
67 const cricket::AudioOptions& options, 70 const cricket::AudioOptions& options,
68 cricket::AudioRenderer* renderer)); 71 cricket::AudioRenderer* renderer));
69 MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32_t ssrc, double volume)); 72 MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32_t ssrc, double volume));
73
74 void SetRawAudioSink(uint32_t,
the sun 2015/12/11 16:32:04 No. You just turned the mock into a fake. Please a
tommi (sloooow) - chröme 2015/12/11 17:51:18 There is some functionality here though and it's t
the sun 2015/12/11 19:46:28 Does it work to add in SetUp() or CreateAudioRtpSe
75 rtc::scoped_ptr<AudioSinkInterface> sink) override {
76 sink_ = std::move(sink);
77 }
78
79 private:
80 rtc::scoped_ptr<AudioSinkInterface> sink_;
70 }; 81 };
71 82
72 // Helper class to test RtpSender/RtpReceiver. 83 // Helper class to test RtpSender/RtpReceiver.
73 class MockVideoProvider : public VideoProviderInterface { 84 class MockVideoProvider : public VideoProviderInterface {
74 public: 85 public:
75 virtual ~MockVideoProvider() {} 86 virtual ~MockVideoProvider() {}
76 MOCK_METHOD2(SetCaptureDevice, 87 MOCK_METHOD2(SetCaptureDevice,
77 bool(uint32_t ssrc, cricket::VideoCapturer* camera)); 88 bool(uint32_t ssrc, cricket::VideoCapturer* camera));
78 MOCK_METHOD3(SetVideoPlayout, 89 MOCK_METHOD3(SetVideoPlayout,
79 void(uint32_t ssrc, 90 void(uint32_t ssrc,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 audio_rtp_sender_ = nullptr; 155 audio_rtp_sender_ = nullptr;
145 } 156 }
146 157
147 void DestroyVideoRtpSender() { 158 void DestroyVideoRtpSender() {
148 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, NULL)).Times(1); 159 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, NULL)).Times(1);
149 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1); 160 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
150 video_rtp_sender_ = nullptr; 161 video_rtp_sender_ = nullptr;
151 } 162 }
152 163
153 void CreateAudioRtpReceiver() { 164 void CreateAudioRtpReceiver() {
154 audio_track_ = 165 audio_track_ = RemoteAudioTrack::Create(
155 AudioTrack::Create(kAudioTrackId, RemoteAudioSource::Create().get()); 166 kAudioTrackId, RemoteAudioSource::Create(kAudioSsrc, NULL));
156 EXPECT_TRUE(stream_->AddTrack(audio_track_)); 167 EXPECT_TRUE(stream_->AddTrack(audio_track_));
157 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true)); 168 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true));
158 audio_rtp_receiver_ = new AudioRtpReceiver(stream_->GetAudioTracks()[0], 169 audio_rtp_receiver_ = new AudioRtpReceiver(stream_->GetAudioTracks()[0],
159 kAudioSsrc, &audio_provider_); 170 kAudioSsrc, &audio_provider_);
160 } 171 }
161 172
162 void CreateVideoRtpReceiver() { 173 void CreateVideoRtpReceiver() {
163 EXPECT_CALL(video_provider_, 174 EXPECT_CALL(video_provider_,
164 SetVideoPlayout(kVideoSsrc, true, 175 SetVideoPlayout(kVideoSsrc, true,
165 video_track_->GetSource()->FrameInput())); 176 video_track_->GetSource()->FrameInput()));
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 video_track_->GetSource()->GetVideoCapturer())); 492 video_track_->GetSource()->GetVideoCapturer()));
482 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, true, _)); 493 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, true, _));
483 sender->SetSsrc(kVideoSsrc2); 494 sender->SetSsrc(kVideoSsrc2);
484 495
485 // Calls expected from destructor. 496 // Calls expected from destructor.
486 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc2, nullptr)).Times(1); 497 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc2, nullptr)).Times(1);
487 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, false, _)).Times(1); 498 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, false, _)).Times(1);
488 } 499 }
489 500
490 } // namespace webrtc 501 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698