Remove Channel::SetRingbackTone() and Channel::PlayRingbackTone(), and the code beneath it (within libjingle).
BUG=webrtc:4690 TBR=juberti Review URL: https://codereview.webrtc.org/1325023005 Cr-Commit-Position: refs/heads/master@{#10011}
This commit is contained in:
parent
7317248ea7
commit
22011c1b54
@ -241,9 +241,6 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
const AudioOptions& options)
|
||||
: engine_(engine),
|
||||
fail_set_send_(false),
|
||||
ringback_tone_ssrc_(0),
|
||||
ringback_tone_play_(false),
|
||||
ringback_tone_loop_(false),
|
||||
time_since_last_typing_(-1) {
|
||||
output_scalings_[0] = OutputScaling(); // For default channel.
|
||||
SetOptions(options);
|
||||
@ -257,10 +254,6 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
}
|
||||
const AudioOptions& options() const { return options_; }
|
||||
|
||||
uint32 ringback_tone_ssrc() const { return ringback_tone_ssrc_; }
|
||||
bool ringback_tone_play() const { return ringback_tone_play_; }
|
||||
bool ringback_tone_loop() const { return ringback_tone_loop_; }
|
||||
|
||||
virtual bool SetSendParameters(const AudioSendParameters& params) {
|
||||
return (SetSendCodecs(params.codecs) &&
|
||||
SetSendRtpHeaderExtensions(params.extensions) &&
|
||||
@ -337,14 +330,6 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
int time_window, int cost_per_typing, int reporting_threshold,
|
||||
int penalty_decay, int type_event_delay) {}
|
||||
|
||||
virtual bool SetRingbackTone(const char* buf, int len) { return true; }
|
||||
virtual bool PlayRingbackTone(uint32 ssrc, bool play, bool loop) {
|
||||
ringback_tone_ssrc_ = ssrc;
|
||||
ringback_tone_play_ = play;
|
||||
ringback_tone_loop_ = loop;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool CanInsertDtmf() {
|
||||
for (std::vector<AudioCodec>::const_iterator it = send_codecs_.begin();
|
||||
it != send_codecs_.end(); ++it) {
|
||||
@ -474,9 +459,6 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
std::map<uint32, OutputScaling> output_scalings_;
|
||||
std::vector<DtmfInfo> dtmf_info_queue_;
|
||||
bool fail_set_send_;
|
||||
uint32 ringback_tone_ssrc_;
|
||||
bool ringback_tone_play_;
|
||||
bool ringback_tone_loop_;
|
||||
int time_since_last_typing_;
|
||||
AudioOptions options_;
|
||||
std::map<uint32, VoiceChannelAudioSink*> local_renderers_;
|
||||
|
||||
@ -1086,10 +1086,6 @@ class VoiceMediaChannel : public MediaChannel {
|
||||
int type_event_delay) = 0;
|
||||
// Set left and right scale for speaker output volume of the specified ssrc.
|
||||
virtual bool SetOutputScaling(uint32 ssrc, double left, double right) = 0;
|
||||
// Specifies a ringback tone to be played during call setup.
|
||||
virtual bool SetRingbackTone(const char *buf, int len) = 0;
|
||||
// Plays or stops the aforementioned ringback tone
|
||||
virtual bool PlayRingbackTone(uint32 ssrc, bool play, bool loop) = 0;
|
||||
// Returns if the telephone-event has been negotiated.
|
||||
virtual bool CanInsertDtmf() { return false; }
|
||||
// Send and/or play a DTMF |event| according to the |flags|.
|
||||
|
||||
@ -2860,53 +2860,6 @@ bool WebRtcVoiceMediaChannel::SetOutputScaling(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRtcVoiceMediaChannel::SetRingbackTone(const char *buf, int len) {
|
||||
ringback_tone_.reset(new WebRtcSoundclipStream(buf, len));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRtcVoiceMediaChannel::PlayRingbackTone(uint32 ssrc,
|
||||
bool play, bool loop) {
|
||||
if (!ringback_tone_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The voe file api is not available in chrome.
|
||||
if (!engine()->voe()->file()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine which VoiceEngine channel to play on.
|
||||
int channel = (ssrc == 0) ? voe_channel() : GetReceiveChannelNum(ssrc);
|
||||
if (channel == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure the ringtone is cued properly, and play it out.
|
||||
if (play) {
|
||||
ringback_tone_->set_loop(loop);
|
||||
ringback_tone_->Rewind();
|
||||
if (engine()->voe()->file()->StartPlayingFileLocally(channel,
|
||||
ringback_tone_.get()) == -1) {
|
||||
LOG_RTCERR2(StartPlayingFileLocally, channel, ringback_tone_.get());
|
||||
LOG(LS_ERROR) << "Unable to start ringback tone";
|
||||
return false;
|
||||
}
|
||||
ringback_channels_.insert(channel);
|
||||
LOG(LS_INFO) << "Started ringback on channel " << channel;
|
||||
} else {
|
||||
if (engine()->voe()->file()->IsPlayingFileLocally(channel) == 1 &&
|
||||
engine()->voe()->file()->StopPlayingFileLocally(channel) == -1) {
|
||||
LOG_RTCERR1(StopPlayingFileLocally, channel);
|
||||
return false;
|
||||
}
|
||||
LOG(LS_INFO) << "Stopped ringback on channel " << channel;
|
||||
ringback_channels_.erase(channel);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRtcVoiceMediaChannel::CanInsertDtmf() {
|
||||
return dtmf_allowed_;
|
||||
}
|
||||
@ -2981,22 +2934,6 @@ void WebRtcVoiceMediaChannel::OnPacketReceived(
|
||||
which_channel = voe_channel();
|
||||
}
|
||||
|
||||
// Stop any ringback that might be playing on the channel.
|
||||
// It's possible the ringback has already stopped, ih which case we'll just
|
||||
// use the opportunity to remove the channel from ringback_channels_.
|
||||
if (engine()->voe()->file()) {
|
||||
const std::set<int>::iterator it = ringback_channels_.find(which_channel);
|
||||
if (it != ringback_channels_.end()) {
|
||||
if (engine()->voe()->file()->IsPlayingFileLocally(
|
||||
which_channel) == 1) {
|
||||
engine()->voe()->file()->StopPlayingFileLocally(which_channel);
|
||||
LOG(LS_INFO) << "Stopped ringback on channel " << which_channel
|
||||
<< " due to incoming media";
|
||||
}
|
||||
ringback_channels_.erase(which_channel);
|
||||
}
|
||||
}
|
||||
|
||||
// Pass it off to the decoder.
|
||||
engine()->voe()->network()->ReceivedRTPPacket(
|
||||
which_channel, packet->data(), packet->size(),
|
||||
@ -3617,18 +3554,6 @@ bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal(
|
||||
return true;
|
||||
}
|
||||
|
||||
int WebRtcSoundclipStream::Read(void *buf, size_t len) {
|
||||
size_t res = 0;
|
||||
mem_.Read(buf, len, &res, NULL);
|
||||
return static_cast<int>(res);
|
||||
}
|
||||
|
||||
int WebRtcSoundclipStream::Rewind() {
|
||||
mem_.Rewind();
|
||||
// Return -1 to keep VoiceEngine from looping.
|
||||
return (loop_) ? 0 : -1;
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // HAVE_WEBRTC_VOICE
|
||||
|
||||
@ -53,23 +53,6 @@ class VideoEngine;
|
||||
|
||||
namespace cricket {
|
||||
|
||||
// WebRtcSoundclipStream is an adapter object that allows a memory stream to be
|
||||
// passed into WebRtc, and support looping.
|
||||
class WebRtcSoundclipStream : public webrtc::InStream {
|
||||
public:
|
||||
WebRtcSoundclipStream(const char* buf, size_t len)
|
||||
: mem_(buf, len), loop_(true) {
|
||||
}
|
||||
void set_loop(bool loop) { loop_ = loop; }
|
||||
|
||||
int Read(void* buf, size_t len) override;
|
||||
int Rewind() override;
|
||||
|
||||
private:
|
||||
rtc::MemoryStream mem_;
|
||||
bool loop_;
|
||||
};
|
||||
|
||||
// WebRtcMonitorStream is used to monitor a stream coming from WebRtc.
|
||||
// For now we just dump the data.
|
||||
class WebRtcMonitorStream : public webrtc::OutStream {
|
||||
@ -316,8 +299,6 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
|
||||
int type_event_delay) override;
|
||||
bool SetOutputScaling(uint32 ssrc, double left, double right) override;
|
||||
|
||||
bool SetRingbackTone(const char* buf, int len) override;
|
||||
bool PlayRingbackTone(uint32 ssrc, bool play, bool loop) override;
|
||||
bool CanInsertDtmf() override;
|
||||
bool InsertDtmf(uint32 ssrc, int event, int duration, int flags) override;
|
||||
|
||||
@ -421,8 +402,6 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
|
||||
|
||||
WebRtcVoiceEngine* const engine_;
|
||||
const int voe_channel_;
|
||||
rtc::scoped_ptr<WebRtcSoundclipStream> ringback_tone_;
|
||||
std::set<int> ringback_channels_; // channels playing ringback
|
||||
std::vector<AudioCodec> recv_codecs_;
|
||||
std::vector<AudioCodec> send_codecs_;
|
||||
rtc::scoped_ptr<webrtc::CodecInst> send_codec_;
|
||||
|
||||
@ -58,7 +58,6 @@ static const cricket::AudioCodec* const kAudioCodecs[] = {
|
||||
&kPcmuCodec, &kIsacCodec, &kOpusCodec, &kG722CodecVoE, &kRedCodec,
|
||||
&kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec,
|
||||
};
|
||||
const char kRingbackTone[] = "RIFF____WAVE____ABCD1234";
|
||||
static uint32 kSsrc1 = 0x99;
|
||||
static uint32 kSsrc2 = 0x98;
|
||||
|
||||
@ -2559,62 +2558,6 @@ TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) {
|
||||
TestInsertDtmf(kSsrc1, false);
|
||||
}
|
||||
|
||||
// Test that we can play a ringback tone properly in a single-stream call.
|
||||
TEST_F(WebRtcVoiceEngineTestFake, PlayRingback) {
|
||||
EXPECT_TRUE(SetupEngine());
|
||||
int channel_num = voe_.GetLastChannel();
|
||||
EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
|
||||
// Check we fail if no ringback tone specified.
|
||||
EXPECT_FALSE(channel_->PlayRingbackTone(0, true, true));
|
||||
EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
|
||||
// Check we can set and play a ringback tone.
|
||||
EXPECT_TRUE(channel_->SetRingbackTone(
|
||||
kRingbackTone, static_cast<int>(strlen(kRingbackTone))));
|
||||
EXPECT_TRUE(channel_->PlayRingbackTone(0, true, true));
|
||||
EXPECT_EQ(1, voe_.IsPlayingFileLocally(channel_num));
|
||||
// Check we can stop the tone manually.
|
||||
EXPECT_TRUE(channel_->PlayRingbackTone(0, false, false));
|
||||
EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
|
||||
// Check we stop the tone if a packet arrives.
|
||||
EXPECT_TRUE(channel_->PlayRingbackTone(0, true, true));
|
||||
EXPECT_EQ(1, voe_.IsPlayingFileLocally(channel_num));
|
||||
DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
|
||||
EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
|
||||
}
|
||||
|
||||
// Test that we can play a ringback tone properly in a multi-stream call.
|
||||
TEST_F(WebRtcVoiceEngineTestFake, PlayRingbackWithMultipleStreams) {
|
||||
EXPECT_TRUE(SetupEngine());
|
||||
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
|
||||
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
|
||||
int channel_num = voe_.GetLastChannel();
|
||||
EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
|
||||
// Check we fail if no ringback tone specified.
|
||||
EXPECT_FALSE(channel_->PlayRingbackTone(2, true, true));
|
||||
EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
|
||||
// Check we can set and play a ringback tone on the correct ssrc.
|
||||
EXPECT_TRUE(channel_->SetRingbackTone(
|
||||
kRingbackTone, static_cast<int>(strlen(kRingbackTone))));
|
||||
EXPECT_FALSE(channel_->PlayRingbackTone(77, true, true));
|
||||
EXPECT_TRUE(channel_->PlayRingbackTone(2, true, true));
|
||||
EXPECT_EQ(1, voe_.IsPlayingFileLocally(channel_num));
|
||||
// Check we can stop the tone manually.
|
||||
EXPECT_TRUE(channel_->PlayRingbackTone(2, false, false));
|
||||
EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
|
||||
// Check we stop the tone if a packet arrives, but only with the right SSRC.
|
||||
EXPECT_TRUE(channel_->PlayRingbackTone(2, true, true));
|
||||
EXPECT_EQ(1, voe_.IsPlayingFileLocally(channel_num));
|
||||
// Send a packet with SSRC 1; the tone should not stop.
|
||||
DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
|
||||
EXPECT_EQ(1, voe_.IsPlayingFileLocally(channel_num));
|
||||
// Send a packet with SSRC 2; the tone should stop.
|
||||
char packet[sizeof(kPcmuFrame)];
|
||||
memcpy(packet, kPcmuFrame, sizeof(kPcmuFrame));
|
||||
rtc::SetBE32(packet + 8, 2);
|
||||
DeliverPacket(packet, sizeof(packet));
|
||||
EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVoiceEngineTestFake, MediaEngineCallbackOnError) {
|
||||
rtc::scoped_ptr<ChannelErrorListener> listener;
|
||||
cricket::WebRtcVoiceMediaChannel* media_channel;
|
||||
|
||||
@ -1271,10 +1271,6 @@ bool VoiceChannel::SetAudioSend(uint32 ssrc, bool mute,
|
||||
media_channel(), ssrc, mute, options, renderer));
|
||||
}
|
||||
|
||||
bool VoiceChannel::SetRingbackTone(const void* buf, int len) {
|
||||
return InvokeOnWorker(Bind(&VoiceChannel::SetRingbackTone_w, this, buf, len));
|
||||
}
|
||||
|
||||
// TODO(juberti): Handle early media the right way. We should get an explicit
|
||||
// ringing message telling us to start playing local ringback, which we cancel
|
||||
// if any early media actually arrives. For now, we do the opposite, which is
|
||||
@ -1291,11 +1287,6 @@ void VoiceChannel::SetEarlyMedia(bool enable) {
|
||||
}
|
||||
}
|
||||
|
||||
bool VoiceChannel::PlayRingbackTone(uint32 ssrc, bool play, bool loop) {
|
||||
return InvokeOnWorker(Bind(&VoiceChannel::PlayRingbackTone_w,
|
||||
this, ssrc, play, loop));
|
||||
}
|
||||
|
||||
bool VoiceChannel::PressDTMF(int digit, bool playout) {
|
||||
int flags = DF_SEND;
|
||||
if (playout) {
|
||||
@ -1505,21 +1496,6 @@ bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VoiceChannel::SetRingbackTone_w(const void* buf, int len) {
|
||||
ASSERT(worker_thread() == rtc::Thread::Current());
|
||||
return media_channel()->SetRingbackTone(static_cast<const char*>(buf), len);
|
||||
}
|
||||
|
||||
bool VoiceChannel::PlayRingbackTone_w(uint32 ssrc, bool play, bool loop) {
|
||||
ASSERT(worker_thread() == rtc::Thread::Current());
|
||||
if (play) {
|
||||
LOG(LS_INFO) << "Playing ringback tone, loop=" << loop;
|
||||
} else {
|
||||
LOG(LS_INFO) << "Stopping ringback tone";
|
||||
}
|
||||
return media_channel()->PlayRingbackTone(ssrc, play, loop);
|
||||
}
|
||||
|
||||
void VoiceChannel::HandleEarlyMediaTimeout() {
|
||||
// This occurs on the main thread, not the worker thread.
|
||||
if (!received_media_) {
|
||||
|
||||
@ -340,14 +340,12 @@ class VoiceChannel : public BaseChannel {
|
||||
return static_cast<VoiceMediaChannel*>(BaseChannel::media_channel());
|
||||
}
|
||||
|
||||
bool SetRingbackTone(const void* buf, int len);
|
||||
void SetEarlyMedia(bool enable);
|
||||
// This signal is emitted when we have gone a period of time without
|
||||
// receiving early media. When received, a UI should start playing its
|
||||
// own ringing sound
|
||||
sigslot::signal1<VoiceChannel*> SignalEarlyMediaTimeout;
|
||||
|
||||
bool PlayRingbackTone(uint32 ssrc, bool play, bool loop);
|
||||
// TODO(ronghuawu): Replace PressDTMF with InsertDtmf.
|
||||
bool PressDTMF(int digit, bool playout);
|
||||
// Returns if the telephone-event has been negotiated.
|
||||
@ -398,8 +396,6 @@ class VoiceChannel : public BaseChannel {
|
||||
virtual bool SetRemoteContent_w(const MediaContentDescription* content,
|
||||
ContentAction action,
|
||||
std::string* error_desc);
|
||||
bool SetRingbackTone_w(const void* buf, int len);
|
||||
bool PlayRingbackTone_w(uint32 ssrc, bool play, bool loop);
|
||||
void HandleEarlyMediaTimeout();
|
||||
bool InsertDtmf_w(uint32 ssrc, int event, int duration, int flags);
|
||||
bool SetOutputScaling_w(uint32 ssrc, double left, double right);
|
||||
|
||||
@ -2091,33 +2091,6 @@ TEST_F(VoiceChannelTest, TestOnReadyToSendWithRtcpMux) {
|
||||
Base::TestOnReadyToSendWithRtcpMux();
|
||||
}
|
||||
|
||||
// Test that we can play a ringback tone properly.
|
||||
TEST_F(VoiceChannelTest, TestRingbackTone) {
|
||||
CreateChannels(RTCP, RTCP);
|
||||
EXPECT_FALSE(media_channel1_->ringback_tone_play());
|
||||
EXPECT_TRUE(channel1_->SetRingbackTone("RIFF", 4));
|
||||
EXPECT_TRUE(SendInitiate());
|
||||
EXPECT_TRUE(SendAccept());
|
||||
// Play ringback tone, no loop.
|
||||
EXPECT_TRUE(channel1_->PlayRingbackTone(0, true, false));
|
||||
EXPECT_EQ(0U, media_channel1_->ringback_tone_ssrc());
|
||||
EXPECT_TRUE(media_channel1_->ringback_tone_play());
|
||||
EXPECT_FALSE(media_channel1_->ringback_tone_loop());
|
||||
// Stop the ringback tone.
|
||||
EXPECT_TRUE(channel1_->PlayRingbackTone(0, false, false));
|
||||
EXPECT_FALSE(media_channel1_->ringback_tone_play());
|
||||
// Add a stream.
|
||||
EXPECT_TRUE(AddStream1(1));
|
||||
// Play ringback tone, looping, on the new stream.
|
||||
EXPECT_TRUE(channel1_->PlayRingbackTone(1, true, true));
|
||||
EXPECT_EQ(1U, media_channel1_->ringback_tone_ssrc());
|
||||
EXPECT_TRUE(media_channel1_->ringback_tone_play());
|
||||
EXPECT_TRUE(media_channel1_->ringback_tone_loop());
|
||||
// Stop the ringback tone.
|
||||
EXPECT_TRUE(channel1_->PlayRingbackTone(1, false, false));
|
||||
EXPECT_FALSE(media_channel1_->ringback_tone_play());
|
||||
}
|
||||
|
||||
// Test that we can scale the output volume properly for 1:1 calls.
|
||||
TEST_F(VoiceChannelTest, TestScaleVolume1to1Call) {
|
||||
CreateChannels(RTCP, RTCP);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user