Remove dual stream functionality in VoiceEngine
This is old code that is no longer in use. The clean-up is part of the ACM redesign work. The corresponding code in ACM will be deleted in a follow-up CL. BUG=3520 R=henrika@webrtc.org, pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/32999004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@8060 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
b4e5d1b34e
commit
8315d7de85
@ -534,12 +534,6 @@ class FakeWebRtcVoiceEngine
|
||||
codec = channels_[channel]->send_codec;
|
||||
return 0;
|
||||
}
|
||||
WEBRTC_STUB(SetSecondarySendCodec, (int channel,
|
||||
const webrtc::CodecInst& codec,
|
||||
int red_payload_type));
|
||||
WEBRTC_STUB(RemoveSecondarySendCodec, (int channel));
|
||||
WEBRTC_STUB(GetSecondarySendCodec, (int channel,
|
||||
webrtc::CodecInst& codec));
|
||||
WEBRTC_FUNC(GetRecCodec, (int channel, webrtc::CodecInst& codec)) {
|
||||
WEBRTC_CHECK_CHANNEL(channel);
|
||||
const Channel* c = channels_[channel];
|
||||
|
@ -4134,47 +4134,6 @@ Channel::RegisterReceiveCodecsToRTPModule()
|
||||
}
|
||||
}
|
||||
|
||||
int Channel::SetSecondarySendCodec(const CodecInst& codec,
|
||||
int red_payload_type) {
|
||||
// Sanity check for payload type.
|
||||
if (red_payload_type < 0 || red_payload_type > 127) {
|
||||
_engineStatisticsPtr->SetLastError(
|
||||
VE_PLTYPE_ERROR, kTraceError,
|
||||
"SetRedPayloadType() invalid RED payload type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (SetRedPayloadType(red_payload_type) < 0) {
|
||||
_engineStatisticsPtr->SetLastError(
|
||||
VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
|
||||
"SetSecondarySendCodec() Failed to register RED ACM");
|
||||
return -1;
|
||||
}
|
||||
if (audio_coding_->RegisterSecondarySendCodec(codec) < 0) {
|
||||
_engineStatisticsPtr->SetLastError(
|
||||
VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
|
||||
"SetSecondarySendCodec() Failed to register secondary send codec in "
|
||||
"ACM");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Channel::RemoveSecondarySendCodec() {
|
||||
audio_coding_->UnregisterSecondarySendCodec();
|
||||
}
|
||||
|
||||
int Channel::GetSecondarySendCodec(CodecInst* codec) {
|
||||
if (audio_coding_->SecondarySendCodec(codec) < 0) {
|
||||
_engineStatisticsPtr->SetLastError(
|
||||
VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
|
||||
"GetSecondarySendCodec() Failed to get secondary sent codec from ACM");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Assuming this method is called with valid payload type.
|
||||
int Channel::SetRedPayloadType(int red_payload_type) {
|
||||
CodecInst codec;
|
||||
|
@ -206,11 +206,6 @@ public:
|
||||
int32_t SetSendCNPayloadType(int type, PayloadFrequencies frequency);
|
||||
int SetOpusMaxPlaybackRate(int frequency_hz);
|
||||
|
||||
// VoE dual-streaming.
|
||||
int SetSecondarySendCodec(const CodecInst& codec, int red_payload_type);
|
||||
void RemoveSecondarySendCodec();
|
||||
int GetSecondarySendCodec(CodecInst* codec);
|
||||
|
||||
// VoENetwork
|
||||
int32_t RegisterExternalTransport(Transport& transport);
|
||||
int32_t DeRegisterExternalTransport();
|
||||
|
@ -64,23 +64,6 @@ public:
|
||||
// |channel|.
|
||||
virtual int GetSendCodec(int channel, CodecInst& codec) = 0;
|
||||
|
||||
// Sets the |codec| as secondary codec for |channel|. Registering a
|
||||
// secondary send codec enables dual-streaming. In dual-streaming mode,
|
||||
// payloads of the primary and the secondary codecs are packed in RED
|
||||
// payloads with |red_payload_type| as payload type. The Secondary codec
|
||||
// MUST have the same sampling rate as the primary codec, otherwise the
|
||||
// codec cannot be registered and -1 is returned. This method fails if a
|
||||
// primary codec is not yet set.
|
||||
virtual int SetSecondarySendCodec(int channel, const CodecInst& codec,
|
||||
int red_payload_type) = 0;
|
||||
|
||||
// Removes the secondary codec from |channel|. This will terminate
|
||||
// dual-streaming.
|
||||
virtual int RemoveSecondarySendCodec(int channel) = 0;
|
||||
|
||||
// Gets |codec| which is used as secondary codec in |channel|.
|
||||
virtual int GetSecondarySendCodec(int channel, CodecInst& codec) = 0;
|
||||
|
||||
// Gets the currently received |codec| for a specific |channel|.
|
||||
virtual int GetRecCodec(int channel, CodecInst& codec) = 0;
|
||||
|
||||
|
@ -514,111 +514,6 @@ void VoECodecImpl::ExternalToACMCodecRepresentation(CodecInst& toInst,
|
||||
}
|
||||
}
|
||||
|
||||
int VoECodecImpl::SetSecondarySendCodec(int channel, const CodecInst& codec,
|
||||
int red_payload_type) {
|
||||
CodecInst copy_codec;
|
||||
ExternalToACMCodecRepresentation(copy_codec, codec);
|
||||
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
|
||||
"SetSecondarySendCodec(channel=%d, codec)", channel);
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1),
|
||||
"codec: plname=%s, pacsize=%d, plfreq=%d, pltype=%d, "
|
||||
"channels=%d, rate=%d", codec.plname, codec.pacsize,
|
||||
codec.plfreq, codec.pltype, codec.channels, codec.rate);
|
||||
if (!_shared->statistics().Initialized()) {
|
||||
_shared->SetLastError(VE_NOT_INITED, kTraceError);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// External sanity checks performed outside the ACM
|
||||
if ((STR_CASE_CMP(copy_codec.plname, "L16") == 0) &&
|
||||
(copy_codec.pacsize >= 960)) {
|
||||
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
|
||||
"SetSecondarySendCodec() invalid L16 packet size");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// None of the following codecs can be registered as the secondary encoder.
|
||||
if (!STR_CASE_CMP(copy_codec.plname, "CN") ||
|
||||
!STR_CASE_CMP(copy_codec.plname, "TELEPHONE-EVENT") ||
|
||||
!STR_CASE_CMP(copy_codec.plname, "RED")) {
|
||||
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
|
||||
"SetSecondarySendCodec() invalid codec name");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Only mono and stereo are supported.
|
||||
if ((copy_codec.channels != 1) && (copy_codec.channels != 2)) {
|
||||
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
|
||||
"SetSecondarySendCodec() invalid number of channels");
|
||||
return -1;
|
||||
}
|
||||
voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
|
||||
voe::Channel* channelPtr = ch.channel();
|
||||
if (channelPtr == NULL) {
|
||||
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
|
||||
"SetSecondarySendCodec() failed to locate channel");
|
||||
return -1;
|
||||
}
|
||||
if (!AudioCodingModule::IsCodecValid(copy_codec)) {
|
||||
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
|
||||
"SetSecondarySendCodec() invalid codec");
|
||||
return -1;
|
||||
}
|
||||
if (channelPtr->SetSecondarySendCodec(copy_codec, red_payload_type) != 0) {
|
||||
_shared->SetLastError(VE_CANNOT_SET_SECONDARY_SEND_CODEC, kTraceError,
|
||||
"SetSecondarySendCodec() failed to set secondary "
|
||||
"send codec");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VoECodecImpl::GetSecondarySendCodec(int channel, CodecInst& codec) {
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
|
||||
"GetSecondarySendCodec(channel=%d, codec=?)", channel);
|
||||
if (!_shared->statistics().Initialized()) {
|
||||
_shared->SetLastError(VE_NOT_INITED, kTraceError);
|
||||
return -1;
|
||||
}
|
||||
voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
|
||||
voe::Channel* channelPtr = ch.channel();
|
||||
if (channelPtr == NULL) {
|
||||
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
|
||||
"GetSecondarySendCodec() failed to locate channel");
|
||||
return -1;
|
||||
}
|
||||
CodecInst acm_codec;
|
||||
if (channelPtr->GetSecondarySendCodec(&acm_codec) != 0) {
|
||||
_shared->SetLastError(VE_CANNOT_GET_SECONDARY_SEND_CODEC, kTraceError,
|
||||
"GetSecondarySendCodec() failed to get secondary "
|
||||
"send codec");
|
||||
return -1;
|
||||
}
|
||||
ACMToExternalCodecRepresentation(codec, acm_codec);
|
||||
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
|
||||
VoEId(_shared->instance_id(), -1),
|
||||
"GetSecondarySendCodec() => plname=%s, pacsize=%d, plfreq=%d, "
|
||||
"channels=%d, rate=%d", codec.plname, codec.pacsize,
|
||||
codec.plfreq, codec.channels, codec.rate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VoECodecImpl::RemoveSecondarySendCodec(int channel) {
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
|
||||
"RemoveSecondarySendCodec(channel=%d)", channel);
|
||||
voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
|
||||
voe::Channel* channelPtr = ch.channel();
|
||||
if (channelPtr == NULL) {
|
||||
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
|
||||
"RemoveSecondarySendCodec() failed to locate "
|
||||
"channel");
|
||||
return -1;
|
||||
}
|
||||
channelPtr->RemoveSecondarySendCodec();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // WEBRTC_VOICE_ENGINE_CODEC_API
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -56,14 +56,6 @@ public:
|
||||
|
||||
virtual int SetOpusMaxPlaybackRate(int channel, int frequency_hz);
|
||||
|
||||
// Dual-streaming
|
||||
virtual int SetSecondarySendCodec(int channel, const CodecInst& codec,
|
||||
int red_payload_type);
|
||||
|
||||
virtual int RemoveSecondarySendCodec(int channel);
|
||||
|
||||
virtual int GetSecondarySendCodec(int channel, CodecInst& codec);
|
||||
|
||||
protected:
|
||||
VoECodecImpl(voe::SharedData* shared);
|
||||
virtual ~VoECodecImpl();
|
||||
|
@ -101,74 +101,6 @@ class VoECodecTest : public ::testing::Test {
|
||||
int red_payload_type_;
|
||||
};
|
||||
|
||||
|
||||
TEST_F(VoECodecTest,
|
||||
DISABLED_ON_ANDROID(DualStreamSetSecondaryBeforePrimaryFails)) {
|
||||
// Setting secondary before a primary is registered should fail.
|
||||
EXPECT_EQ(-1, voe_codec_->SetSecondarySendCodec(channel_, valid_secondary_,
|
||||
red_payload_type_));
|
||||
red_payload_type_ = 1;
|
||||
}
|
||||
|
||||
TEST_F(VoECodecTest,
|
||||
DISABLED_ON_ANDROID(DualStreamRegisterWithWrongInputsFails)) {
|
||||
// Register primary codec.
|
||||
EXPECT_EQ(0, voe_codec_->SetSendCodec(channel_, primary_));
|
||||
|
||||
// Wrong secondary.
|
||||
EXPECT_EQ(-1, voe_codec_->SetSecondarySendCodec(channel_, invalid_secondary_,
|
||||
red_payload_type_));
|
||||
|
||||
// Wrong payload.
|
||||
EXPECT_EQ(-1, voe_codec_->SetSecondarySendCodec(channel_, valid_secondary_,
|
||||
-1));
|
||||
// Wrong channel.
|
||||
EXPECT_EQ(-1, voe_codec_->SetSecondarySendCodec(channel_ + 1,
|
||||
valid_secondary_,
|
||||
red_payload_type_));
|
||||
}
|
||||
|
||||
TEST_F(VoECodecTest, DISABLED_ON_ANDROID(DualStreamGetSecodaryEncoder)) {
|
||||
// Register primary codec.
|
||||
EXPECT_EQ(0, voe_codec_->SetSendCodec(channel_, primary_));
|
||||
|
||||
// Register a valid codec.
|
||||
EXPECT_EQ(0, voe_codec_->SetSecondarySendCodec(channel_, valid_secondary_,
|
||||
red_payload_type_));
|
||||
CodecInst my_codec;
|
||||
|
||||
// Get secondary codec from wrong channel.
|
||||
EXPECT_EQ(-1, voe_codec_->GetSecondarySendCodec(channel_ + 1, my_codec));
|
||||
|
||||
// Get secondary and compare.
|
||||
memset(&my_codec, 0, sizeof(my_codec));
|
||||
EXPECT_EQ(0, voe_codec_->GetSecondarySendCodec(channel_, my_codec));
|
||||
|
||||
EXPECT_EQ(valid_secondary_.plfreq, my_codec.plfreq);
|
||||
EXPECT_EQ(valid_secondary_.channels, my_codec.channels);
|
||||
EXPECT_EQ(valid_secondary_.pacsize, my_codec.pacsize);
|
||||
EXPECT_EQ(valid_secondary_.rate, my_codec.rate);
|
||||
EXPECT_EQ(valid_secondary_.pltype, my_codec.pltype);
|
||||
EXPECT_EQ(0, STR_CASE_CMP(valid_secondary_.plname, my_codec.plname));
|
||||
}
|
||||
|
||||
TEST_F(VoECodecTest, DISABLED_ON_ANDROID(DualStreamRemoveSecondaryCodec)) {
|
||||
// Register primary codec.
|
||||
EXPECT_EQ(0, voe_codec_->SetSendCodec(channel_, primary_));
|
||||
|
||||
// Register a valid codec.
|
||||
EXPECT_EQ(0, voe_codec_->SetSecondarySendCodec(channel_, valid_secondary_,
|
||||
red_payload_type_));
|
||||
// Remove from wrong channel.
|
||||
EXPECT_EQ(-1, voe_codec_->RemoveSecondarySendCodec(channel_ + 1));
|
||||
EXPECT_EQ(0, voe_codec_->RemoveSecondarySendCodec(channel_));
|
||||
|
||||
CodecInst my_codec;
|
||||
|
||||
// Get should fail, if secondary is removed.
|
||||
EXPECT_EQ(-1, voe_codec_->GetSecondarySendCodec(channel_, my_codec));
|
||||
}
|
||||
|
||||
TEST(VoECodecInst, TestCompareCodecInstances) {
|
||||
CodecInst codec1, codec2;
|
||||
memset(&codec1, 0, sizeof(CodecInst));
|
||||
|
Loading…
x
Reference in New Issue
Block a user