2013-07-10 00:45:36 +00:00
|
|
|
/*
|
|
|
|
|
* libjingle
|
2015-01-20 21:36:13 +00:00
|
|
|
* Copyright 2012 Google Inc.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
|
|
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include "talk/app/webrtc/audiotrack.h"
|
|
|
|
|
#include "talk/app/webrtc/mediastream.h"
|
2014-02-13 23:18:49 +00:00
|
|
|
#include "talk/app/webrtc/remoteaudiosource.h"
|
2015-09-28 16:53:55 -07:00
|
|
|
#include "talk/app/webrtc/rtpreceiver.h"
|
|
|
|
|
#include "talk/app/webrtc/rtpsender.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
#include "talk/app/webrtc/streamcollection.h"
|
2013-09-19 05:49:50 +00:00
|
|
|
#include "talk/app/webrtc/videosource.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
#include "talk/app/webrtc/videotrack.h"
|
|
|
|
|
#include "talk/media/base/fakevideocapturer.h"
|
|
|
|
|
#include "talk/media/base/mediachannel.h"
|
2014-06-12 14:57:05 +00:00
|
|
|
#include "testing/gmock/include/gmock/gmock.h"
|
|
|
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
2014-08-13 17:26:08 +00:00
|
|
|
#include "webrtc/base/gunit.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
using ::testing::_;
|
|
|
|
|
using ::testing::Exactly;
|
|
|
|
|
|
|
|
|
|
static const char kStreamLabel1[] = "local_stream_1";
|
|
|
|
|
static const char kVideoTrackId[] = "video_1";
|
|
|
|
|
static const char kAudioTrackId[] = "audio_1";
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
static const uint32_t kVideoSsrc = 98;
|
2015-11-25 11:26:01 -08:00
|
|
|
static const uint32_t kVideoSsrc2 = 100;
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
static const uint32_t kAudioSsrc = 99;
|
2015-11-25 11:26:01 -08:00
|
|
|
static const uint32_t kAudioSsrc2 = 101;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
// Helper class to test RtpSender/RtpReceiver.
|
2013-07-10 00:45:36 +00:00
|
|
|
class MockAudioProvider : public AudioProviderInterface {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~MockAudioProvider() {}
|
2015-10-09 08:55:48 -07:00
|
|
|
MOCK_METHOD2(SetAudioPlayout,
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
void(uint32_t ssrc,
|
2015-10-09 08:55:48 -07:00
|
|
|
bool enable));
|
2015-09-28 16:53:55 -07:00
|
|
|
MOCK_METHOD4(SetAudioSend,
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
void(uint32_t ssrc,
|
2015-09-28 16:53:55 -07:00
|
|
|
bool enable,
|
|
|
|
|
const cricket::AudioOptions& options,
|
|
|
|
|
cricket::AudioRenderer* renderer));
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32_t ssrc, double volume));
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
// Helper class to test RtpSender/RtpReceiver.
|
2013-07-10 00:45:36 +00:00
|
|
|
class MockVideoProvider : public VideoProviderInterface {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~MockVideoProvider() {}
|
2015-09-28 16:53:55 -07:00
|
|
|
MOCK_METHOD2(SetCaptureDevice,
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool(uint32_t ssrc, cricket::VideoCapturer* camera));
|
2015-09-28 16:53:55 -07:00
|
|
|
MOCK_METHOD3(SetVideoPlayout,
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
void(uint32_t ssrc,
|
2015-09-28 16:53:55 -07:00
|
|
|
bool enable,
|
|
|
|
|
cricket::VideoRenderer* renderer));
|
|
|
|
|
MOCK_METHOD3(SetVideoSend,
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
void(uint32_t ssrc,
|
2015-09-28 16:53:55 -07:00
|
|
|
bool enable,
|
|
|
|
|
const cricket::VideoOptions* options));
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class FakeVideoSource : public Notifier<VideoSourceInterface> {
|
|
|
|
|
public:
|
2014-07-29 17:36:52 +00:00
|
|
|
static rtc::scoped_refptr<FakeVideoSource> Create() {
|
|
|
|
|
return new rtc::RefCountedObject<FakeVideoSource>();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-09-28 16:53:55 -07:00
|
|
|
virtual cricket::VideoCapturer* GetVideoCapturer() { return &fake_capturer_; }
|
2015-02-17 13:53:56 +00:00
|
|
|
virtual void Stop() {}
|
|
|
|
|
virtual void Restart() {}
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual void AddSink(cricket::VideoRenderer* output) {}
|
|
|
|
|
virtual void RemoveSink(cricket::VideoRenderer* output) {}
|
|
|
|
|
virtual SourceState state() const { return state_; }
|
|
|
|
|
virtual const cricket::VideoOptions* options() const { return &options_; }
|
2013-09-19 05:49:50 +00:00
|
|
|
virtual cricket::VideoRenderer* FrameInput() { return NULL; }
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
FakeVideoSource() : state_(kLive) {}
|
|
|
|
|
~FakeVideoSource() {}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
cricket::FakeVideoCapturer fake_capturer_;
|
|
|
|
|
SourceState state_;
|
|
|
|
|
cricket::VideoOptions options_;
|
|
|
|
|
};
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
class RtpSenderReceiverTest : public testing::Test {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
|
|
|
|
virtual void SetUp() {
|
|
|
|
|
stream_ = MediaStream::Create(kStreamLabel1);
|
2015-09-28 16:53:55 -07:00
|
|
|
rtc::scoped_refptr<VideoSourceInterface> source(FakeVideoSource::Create());
|
2013-07-10 00:45:36 +00:00
|
|
|
video_track_ = VideoTrack::Create(kVideoTrackId, source);
|
|
|
|
|
EXPECT_TRUE(stream_->AddTrack(video_track_));
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
void CreateAudioRtpSender() {
|
2014-02-13 23:18:49 +00:00
|
|
|
audio_track_ = AudioTrack::Create(kAudioTrackId, NULL);
|
|
|
|
|
EXPECT_TRUE(stream_->AddTrack(audio_track_));
|
2013-07-26 19:17:59 +00:00
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _));
|
2015-11-25 11:26:01 -08:00
|
|
|
audio_rtp_sender_ =
|
|
|
|
|
new AudioRtpSender(stream_->GetAudioTracks()[0], stream_->label(),
|
|
|
|
|
&audio_provider_, nullptr);
|
|
|
|
|
audio_rtp_sender_->SetSsrc(kAudioSsrc);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
void CreateVideoRtpSender() {
|
|
|
|
|
EXPECT_CALL(video_provider_,
|
|
|
|
|
SetCaptureDevice(
|
|
|
|
|
kVideoSsrc, video_track_->GetSource()->GetVideoCapturer()));
|
2013-07-10 00:45:36 +00:00
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
|
2015-09-28 16:53:55 -07:00
|
|
|
video_rtp_sender_ = new VideoRtpSender(stream_->GetVideoTracks()[0],
|
2015-11-25 11:26:01 -08:00
|
|
|
stream_->label(), &video_provider_);
|
|
|
|
|
video_rtp_sender_->SetSsrc(kVideoSsrc);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
void DestroyAudioRtpSender() {
|
2013-07-26 19:17:59 +00:00
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _))
|
2013-07-10 00:45:36 +00:00
|
|
|
.Times(1);
|
2015-09-28 16:53:55 -07:00
|
|
|
audio_rtp_sender_ = nullptr;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
void DestroyVideoRtpSender() {
|
|
|
|
|
EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, NULL)).Times(1);
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
|
|
|
|
|
video_rtp_sender_ = nullptr;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
void CreateAudioRtpReceiver() {
|
|
|
|
|
audio_track_ =
|
|
|
|
|
AudioTrack::Create(kAudioTrackId, RemoteAudioSource::Create().get());
|
2014-02-13 23:18:49 +00:00
|
|
|
EXPECT_TRUE(stream_->AddTrack(audio_track_));
|
2015-10-09 08:55:48 -07:00
|
|
|
EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true));
|
2015-09-28 16:53:55 -07:00
|
|
|
audio_rtp_receiver_ = new AudioRtpReceiver(stream_->GetAudioTracks()[0],
|
|
|
|
|
kAudioSsrc, &audio_provider_);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
void CreateVideoRtpReceiver() {
|
|
|
|
|
EXPECT_CALL(video_provider_,
|
|
|
|
|
SetVideoPlayout(kVideoSsrc, true,
|
|
|
|
|
video_track_->GetSource()->FrameInput()));
|
|
|
|
|
video_rtp_receiver_ = new VideoRtpReceiver(stream_->GetVideoTracks()[0],
|
|
|
|
|
kVideoSsrc, &video_provider_);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
void DestroyAudioRtpReceiver() {
|
2015-10-09 08:55:48 -07:00
|
|
|
EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false));
|
2015-09-28 16:53:55 -07:00
|
|
|
audio_rtp_receiver_ = nullptr;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
void DestroyVideoRtpReceiver() {
|
2013-07-10 00:45:36 +00:00
|
|
|
EXPECT_CALL(video_provider_, SetVideoPlayout(kVideoSsrc, false, NULL));
|
2015-09-28 16:53:55 -07:00
|
|
|
video_rtp_receiver_ = nullptr;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
MockAudioProvider audio_provider_;
|
|
|
|
|
MockVideoProvider video_provider_;
|
2015-09-28 16:53:55 -07:00
|
|
|
rtc::scoped_refptr<AudioRtpSender> audio_rtp_sender_;
|
|
|
|
|
rtc::scoped_refptr<VideoRtpSender> video_rtp_sender_;
|
|
|
|
|
rtc::scoped_refptr<AudioRtpReceiver> audio_rtp_receiver_;
|
|
|
|
|
rtc::scoped_refptr<VideoRtpReceiver> video_rtp_receiver_;
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<MediaStreamInterface> stream_;
|
|
|
|
|
rtc::scoped_refptr<VideoTrackInterface> video_track_;
|
|
|
|
|
rtc::scoped_refptr<AudioTrackInterface> audio_track_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Test that |audio_provider_| is notified when an audio track is associated
|
2015-09-28 16:53:55 -07:00
|
|
|
// and disassociated with an AudioRtpSender.
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, AddAndDestroyAudioRtpSender) {
|
|
|
|
|
CreateAudioRtpSender();
|
|
|
|
|
DestroyAudioRtpSender();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test that |video_provider_| is notified when a video track is associated and
|
2015-09-28 16:53:55 -07:00
|
|
|
// disassociated with a VideoRtpSender.
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, AddAndDestroyVideoRtpSender) {
|
|
|
|
|
CreateVideoRtpSender();
|
|
|
|
|
DestroyVideoRtpSender();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test that |audio_provider_| is notified when a remote audio and track is
|
2015-09-28 16:53:55 -07:00
|
|
|
// associated and disassociated with an AudioRtpReceiver.
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, AddAndDestroyAudioRtpReceiver) {
|
|
|
|
|
CreateAudioRtpReceiver();
|
|
|
|
|
DestroyAudioRtpReceiver();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test that |video_provider_| is notified when a remote
|
2015-09-28 16:53:55 -07:00
|
|
|
// video track is associated and disassociated with a VideoRtpReceiver.
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, AddAndDestroyVideoRtpReceiver) {
|
|
|
|
|
CreateVideoRtpReceiver();
|
|
|
|
|
DestroyVideoRtpReceiver();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
TEST_F(RtpSenderReceiverTest, LocalAudioTrackDisable) {
|
|
|
|
|
CreateAudioRtpSender();
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2013-07-26 19:17:59 +00:00
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _));
|
2013-07-10 00:45:36 +00:00
|
|
|
audio_track_->set_enabled(false);
|
|
|
|
|
|
2013-07-26 19:17:59 +00:00
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _));
|
2013-07-10 00:45:36 +00:00
|
|
|
audio_track_->set_enabled(true);
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
DestroyAudioRtpSender();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
TEST_F(RtpSenderReceiverTest, RemoteAudioTrackDisable) {
|
|
|
|
|
CreateAudioRtpReceiver();
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-10-09 08:55:48 -07:00
|
|
|
EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false));
|
2013-07-10 00:45:36 +00:00
|
|
|
audio_track_->set_enabled(false);
|
|
|
|
|
|
2015-10-09 08:55:48 -07:00
|
|
|
EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true));
|
2013-07-10 00:45:36 +00:00
|
|
|
audio_track_->set_enabled(true);
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
DestroyAudioRtpReceiver();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
TEST_F(RtpSenderReceiverTest, LocalVideoTrackDisable) {
|
|
|
|
|
CreateVideoRtpSender();
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _));
|
|
|
|
|
video_track_->set_enabled(false);
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
|
|
|
|
|
video_track_->set_enabled(true);
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
DestroyVideoRtpSender();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
TEST_F(RtpSenderReceiverTest, RemoteVideoTrackDisable) {
|
|
|
|
|
CreateVideoRtpReceiver();
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
video_track_->set_enabled(false);
|
|
|
|
|
|
|
|
|
|
video_track_->set_enabled(true);
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
DestroyVideoRtpReceiver();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
TEST_F(RtpSenderReceiverTest, RemoteAudioTrackSetVolume) {
|
|
|
|
|
CreateAudioRtpReceiver();
|
2014-02-13 23:18:49 +00:00
|
|
|
|
|
|
|
|
double volume = 0.5;
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, volume));
|
|
|
|
|
audio_track_->GetSource()->SetVolume(volume);
|
|
|
|
|
|
|
|
|
|
// Disable the audio track, this should prevent setting the volume.
|
2015-10-09 08:55:48 -07:00
|
|
|
EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false));
|
2014-02-13 23:18:49 +00:00
|
|
|
audio_track_->set_enabled(false);
|
|
|
|
|
audio_track_->GetSource()->SetVolume(1.0);
|
|
|
|
|
|
2015-10-09 08:55:48 -07:00
|
|
|
EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true));
|
2014-02-13 23:18:49 +00:00
|
|
|
audio_track_->set_enabled(true);
|
|
|
|
|
|
|
|
|
|
double new_volume = 0.8;
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, new_volume));
|
|
|
|
|
audio_track_->GetSource()->SetVolume(new_volume);
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
DestroyAudioRtpReceiver();
|
2014-02-13 23:18:49 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-25 11:26:01 -08:00
|
|
|
// Test that provider methods aren't called without both a track and an SSRC.
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, AudioSenderWithoutTrackAndSsrc) {
|
|
|
|
|
rtc::scoped_refptr<AudioRtpSender> sender =
|
|
|
|
|
new AudioRtpSender(&audio_provider_, nullptr);
|
|
|
|
|
rtc::scoped_refptr<AudioTrackInterface> track =
|
|
|
|
|
AudioTrack::Create(kAudioTrackId, nullptr);
|
|
|
|
|
EXPECT_TRUE(sender->SetTrack(track));
|
|
|
|
|
EXPECT_TRUE(sender->SetTrack(nullptr));
|
|
|
|
|
sender->SetSsrc(kAudioSsrc);
|
|
|
|
|
sender->SetSsrc(0);
|
|
|
|
|
// Just let it get destroyed and make sure it doesn't call any methods on the
|
|
|
|
|
// provider interface.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test that provider methods aren't called without both a track and an SSRC.
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, VideoSenderWithoutTrackAndSsrc) {
|
|
|
|
|
rtc::scoped_refptr<VideoRtpSender> sender =
|
|
|
|
|
new VideoRtpSender(&video_provider_);
|
|
|
|
|
EXPECT_TRUE(sender->SetTrack(video_track_));
|
|
|
|
|
EXPECT_TRUE(sender->SetTrack(nullptr));
|
|
|
|
|
sender->SetSsrc(kVideoSsrc);
|
|
|
|
|
sender->SetSsrc(0);
|
|
|
|
|
// Just let it get destroyed and make sure it doesn't call any methods on the
|
|
|
|
|
// provider interface.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test that an audio sender calls the expected methods on the provider once
|
|
|
|
|
// it has a track and SSRC, when the SSRC is set first.
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, AudioSenderEarlyWarmupSsrcThenTrack) {
|
|
|
|
|
rtc::scoped_refptr<AudioRtpSender> sender =
|
|
|
|
|
new AudioRtpSender(&audio_provider_, nullptr);
|
|
|
|
|
rtc::scoped_refptr<AudioTrackInterface> track =
|
|
|
|
|
AudioTrack::Create(kAudioTrackId, nullptr);
|
|
|
|
|
sender->SetSsrc(kAudioSsrc);
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _));
|
|
|
|
|
sender->SetTrack(track);
|
|
|
|
|
|
|
|
|
|
// Calls expected from destructor.
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)).Times(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test that an audio sender calls the expected methods on the provider once
|
|
|
|
|
// it has a track and SSRC, when the SSRC is set last.
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, AudioSenderEarlyWarmupTrackThenSsrc) {
|
|
|
|
|
rtc::scoped_refptr<AudioRtpSender> sender =
|
|
|
|
|
new AudioRtpSender(&audio_provider_, nullptr);
|
|
|
|
|
rtc::scoped_refptr<AudioTrackInterface> track =
|
|
|
|
|
AudioTrack::Create(kAudioTrackId, nullptr);
|
|
|
|
|
sender->SetTrack(track);
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _));
|
|
|
|
|
sender->SetSsrc(kAudioSsrc);
|
|
|
|
|
|
|
|
|
|
// Calls expected from destructor.
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)).Times(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test that a video sender calls the expected methods on the provider once
|
|
|
|
|
// it has a track and SSRC, when the SSRC is set first.
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, VideoSenderEarlyWarmupSsrcThenTrack) {
|
|
|
|
|
rtc::scoped_refptr<VideoRtpSender> sender =
|
|
|
|
|
new VideoRtpSender(&video_provider_);
|
|
|
|
|
sender->SetSsrc(kVideoSsrc);
|
|
|
|
|
EXPECT_CALL(video_provider_,
|
|
|
|
|
SetCaptureDevice(kVideoSsrc,
|
|
|
|
|
video_track_->GetSource()->GetVideoCapturer()));
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
|
|
|
|
|
sender->SetTrack(video_track_);
|
|
|
|
|
|
|
|
|
|
// Calls expected from destructor.
|
|
|
|
|
EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, nullptr)).Times(1);
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test that a video sender calls the expected methods on the provider once
|
|
|
|
|
// it has a track and SSRC, when the SSRC is set last.
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, VideoSenderEarlyWarmupTrackThenSsrc) {
|
|
|
|
|
rtc::scoped_refptr<VideoRtpSender> sender =
|
|
|
|
|
new VideoRtpSender(&video_provider_);
|
|
|
|
|
sender->SetTrack(video_track_);
|
|
|
|
|
EXPECT_CALL(video_provider_,
|
|
|
|
|
SetCaptureDevice(kVideoSsrc,
|
|
|
|
|
video_track_->GetSource()->GetVideoCapturer()));
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
|
|
|
|
|
sender->SetSsrc(kVideoSsrc);
|
|
|
|
|
|
|
|
|
|
// Calls expected from destructor.
|
|
|
|
|
EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, nullptr)).Times(1);
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test that the sender is disconnected from the provider when its SSRC is
|
|
|
|
|
// set to 0.
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, AudioSenderSsrcSetToZero) {
|
|
|
|
|
rtc::scoped_refptr<AudioTrackInterface> track =
|
|
|
|
|
AudioTrack::Create(kAudioTrackId, nullptr);
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _));
|
|
|
|
|
rtc::scoped_refptr<AudioRtpSender> sender =
|
|
|
|
|
new AudioRtpSender(track, kStreamLabel1, &audio_provider_, nullptr);
|
|
|
|
|
sender->SetSsrc(kAudioSsrc);
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)).Times(1);
|
|
|
|
|
sender->SetSsrc(0);
|
|
|
|
|
|
|
|
|
|
// Make sure it's SetSsrc that called methods on the provider, and not the
|
|
|
|
|
// destructor.
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(_, _, _, _)).Times(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test that the sender is disconnected from the provider when its SSRC is
|
|
|
|
|
// set to 0.
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, VideoSenderSsrcSetToZero) {
|
|
|
|
|
EXPECT_CALL(video_provider_,
|
|
|
|
|
SetCaptureDevice(kVideoSsrc,
|
|
|
|
|
video_track_->GetSource()->GetVideoCapturer()));
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
|
|
|
|
|
rtc::scoped_refptr<VideoRtpSender> sender =
|
|
|
|
|
new VideoRtpSender(video_track_, kStreamLabel1, &video_provider_);
|
|
|
|
|
sender->SetSsrc(kVideoSsrc);
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, nullptr)).Times(1);
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
|
|
|
|
|
sender->SetSsrc(0);
|
|
|
|
|
|
|
|
|
|
// Make sure it's SetSsrc that called methods on the provider, and not the
|
|
|
|
|
// destructor.
|
|
|
|
|
EXPECT_CALL(video_provider_, SetCaptureDevice(_, _)).Times(0);
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(_, _, _)).Times(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, AudioSenderTrackSetToNull) {
|
|
|
|
|
rtc::scoped_refptr<AudioTrackInterface> track =
|
|
|
|
|
AudioTrack::Create(kAudioTrackId, nullptr);
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _));
|
|
|
|
|
rtc::scoped_refptr<AudioRtpSender> sender =
|
|
|
|
|
new AudioRtpSender(track, kStreamLabel1, &audio_provider_, nullptr);
|
|
|
|
|
sender->SetSsrc(kAudioSsrc);
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)).Times(1);
|
|
|
|
|
EXPECT_TRUE(sender->SetTrack(nullptr));
|
|
|
|
|
|
|
|
|
|
// Make sure it's SetTrack that called methods on the provider, and not the
|
|
|
|
|
// destructor.
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(_, _, _, _)).Times(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, VideoSenderTrackSetToNull) {
|
|
|
|
|
EXPECT_CALL(video_provider_,
|
|
|
|
|
SetCaptureDevice(kVideoSsrc,
|
|
|
|
|
video_track_->GetSource()->GetVideoCapturer()));
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
|
|
|
|
|
rtc::scoped_refptr<VideoRtpSender> sender =
|
|
|
|
|
new VideoRtpSender(video_track_, kStreamLabel1, &video_provider_);
|
|
|
|
|
sender->SetSsrc(kVideoSsrc);
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, nullptr)).Times(1);
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
|
|
|
|
|
EXPECT_TRUE(sender->SetTrack(nullptr));
|
|
|
|
|
|
|
|
|
|
// Make sure it's SetTrack that called methods on the provider, and not the
|
|
|
|
|
// destructor.
|
|
|
|
|
EXPECT_CALL(video_provider_, SetCaptureDevice(_, _)).Times(0);
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(_, _, _)).Times(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, AudioSenderSsrcChanged) {
|
|
|
|
|
rtc::scoped_refptr<AudioTrackInterface> track =
|
|
|
|
|
AudioTrack::Create(kAudioTrackId, nullptr);
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _));
|
|
|
|
|
rtc::scoped_refptr<AudioRtpSender> sender =
|
|
|
|
|
new AudioRtpSender(track, kStreamLabel1, &audio_provider_, nullptr);
|
|
|
|
|
sender->SetSsrc(kAudioSsrc);
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)).Times(1);
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc2, true, _, _)).Times(1);
|
|
|
|
|
sender->SetSsrc(kAudioSsrc2);
|
|
|
|
|
|
|
|
|
|
// Calls expected from destructor.
|
|
|
|
|
EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc2, false, _, _)).Times(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(RtpSenderReceiverTest, VideoSenderSsrcChanged) {
|
|
|
|
|
EXPECT_CALL(video_provider_,
|
|
|
|
|
SetCaptureDevice(kVideoSsrc,
|
|
|
|
|
video_track_->GetSource()->GetVideoCapturer()));
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
|
|
|
|
|
rtc::scoped_refptr<VideoRtpSender> sender =
|
|
|
|
|
new VideoRtpSender(video_track_, kStreamLabel1, &video_provider_);
|
|
|
|
|
sender->SetSsrc(kVideoSsrc);
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, nullptr)).Times(1);
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
|
|
|
|
|
EXPECT_CALL(video_provider_,
|
|
|
|
|
SetCaptureDevice(kVideoSsrc2,
|
|
|
|
|
video_track_->GetSource()->GetVideoCapturer()));
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, true, _));
|
|
|
|
|
sender->SetSsrc(kVideoSsrc2);
|
|
|
|
|
|
|
|
|
|
// Calls expected from destructor.
|
|
|
|
|
EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc2, nullptr)).Times(1);
|
|
|
|
|
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, false, _)).Times(1);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace webrtc
|