зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1524145: set Opus stereo on send stream with 2 channels. r=dminor
Differential Revision: https://phabricator.services.mozilla.com/D18175 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
73a9848a1b
Коммит
c8aea55c6b
|
@ -89,6 +89,17 @@ TEST_F(AudioConduitTest, TestConfigureSendMediaCodec) {
|
||||||
AudioCodecConfig codecConfig(114, "opus", 48000, 2, false);
|
AudioCodecConfig codecConfig(114, "opus", 48000, 2, false);
|
||||||
ec = mAudioConduit->ConfigureSendMediaCodec(&codecConfig);
|
ec = mAudioConduit->ConfigureSendMediaCodec(&codecConfig);
|
||||||
ASSERT_EQ(ec, kMediaConduitNoError);
|
ASSERT_EQ(ec, kMediaConduitNoError);
|
||||||
|
{
|
||||||
|
const webrtc::SdpAudioFormat& f =
|
||||||
|
mCall->mAudioSendConfig.send_codec_spec->format;
|
||||||
|
ASSERT_EQ(f.name, "opus");
|
||||||
|
ASSERT_EQ(f.clockrate_hz, 48000);
|
||||||
|
ASSERT_EQ(f.num_channels, 2UL);
|
||||||
|
ASSERT_NE(f.parameters.find("stereo"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.at("stereo"), "1");
|
||||||
|
ASSERT_EQ(f.parameters.find("maxplaybackrate"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.find("useinbandfec"), f.parameters.end());
|
||||||
|
}
|
||||||
|
|
||||||
// null codec
|
// null codec
|
||||||
ec = mAudioConduit->ConfigureSendMediaCodec(nullptr);
|
ec = mAudioConduit->ConfigureSendMediaCodec(nullptr);
|
||||||
|
@ -110,10 +121,71 @@ TEST_F(AudioConduitTest, TestConfigureSendMediaCodec) {
|
||||||
delete[] longName;
|
delete[] longName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(AudioConduitTest, TestConfigureSendOpusMono) {
|
||||||
|
MediaConduitErrorCode ec;
|
||||||
|
|
||||||
|
// opus mono
|
||||||
|
AudioCodecConfig codecConfig = AudioCodecConfig(114, "opus", 48000, 1, false);
|
||||||
|
ec = mAudioConduit->ConfigureSendMediaCodec(&codecConfig);
|
||||||
|
ASSERT_EQ(ec, kMediaConduitNoError);
|
||||||
|
{
|
||||||
|
const webrtc::SdpAudioFormat& f =
|
||||||
|
mCall->mAudioSendConfig.send_codec_spec->format;
|
||||||
|
ASSERT_EQ(f.name, "opus");
|
||||||
|
ASSERT_EQ(f.clockrate_hz, 48000);
|
||||||
|
ASSERT_EQ(f.num_channels, 1UL);
|
||||||
|
ASSERT_EQ(f.parameters.find("stereo"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.find("maxplaybackrate"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.find("useinbandfec"), f.parameters.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AudioConduitTest, TestConfigureSendOpusFEC) {
|
||||||
|
MediaConduitErrorCode ec;
|
||||||
|
|
||||||
|
// opus with inband Forward Error Correction
|
||||||
|
AudioCodecConfig codecConfig = AudioCodecConfig(114, "opus", 48000, 2, true);
|
||||||
|
ec = mAudioConduit->ConfigureSendMediaCodec(&codecConfig);
|
||||||
|
ASSERT_EQ(ec, kMediaConduitNoError);
|
||||||
|
{
|
||||||
|
const webrtc::SdpAudioFormat& f =
|
||||||
|
mCall->mAudioSendConfig.send_codec_spec->format;
|
||||||
|
ASSERT_EQ(f.name, "opus");
|
||||||
|
ASSERT_EQ(f.clockrate_hz, 48000);
|
||||||
|
ASSERT_EQ(f.num_channels, 2UL);
|
||||||
|
ASSERT_NE(f.parameters.find("stereo"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.at("stereo"), "1");
|
||||||
|
ASSERT_NE(f.parameters.find("useinbandfec"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.at("useinbandfec"), "1");
|
||||||
|
ASSERT_EQ(f.parameters.find("maxplaybackrate"), f.parameters.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AudioConduitTest, TestConfigureSendMaxPlaybackRate) {
|
||||||
|
MediaConduitErrorCode ec;
|
||||||
|
|
||||||
|
AudioCodecConfig codecConfig = AudioCodecConfig(114, "opus", 48000, 2, false);
|
||||||
|
codecConfig.mMaxPlaybackRate = 1234;
|
||||||
|
ec = mAudioConduit->ConfigureSendMediaCodec(&codecConfig);
|
||||||
|
ASSERT_EQ(ec, kMediaConduitNoError);
|
||||||
|
{
|
||||||
|
const webrtc::SdpAudioFormat& f =
|
||||||
|
mCall->mAudioSendConfig.send_codec_spec->format;
|
||||||
|
ASSERT_EQ(f.name, "opus");
|
||||||
|
ASSERT_EQ(f.clockrate_hz, 48000);
|
||||||
|
ASSERT_EQ(f.num_channels, 2UL);
|
||||||
|
ASSERT_NE(f.parameters.find("stereo"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.at("stereo"), "1");
|
||||||
|
ASSERT_EQ(f.parameters.find("useinbandfec"), f.parameters.end());
|
||||||
|
ASSERT_NE(f.parameters.find("maxplaybackrate"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.at("maxplaybackrate"), "1234");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(AudioConduitTest, TestConfigureReceiveMediaCodecs) {
|
TEST_F(AudioConduitTest, TestConfigureReceiveMediaCodecs) {
|
||||||
MediaConduitErrorCode ec;
|
MediaConduitErrorCode ec;
|
||||||
|
|
||||||
// just opus
|
// just default opus stereo
|
||||||
std::vector<UniquePtr<mozilla::AudioCodecConfig>> codecs;
|
std::vector<UniquePtr<mozilla::AudioCodecConfig>> codecs;
|
||||||
codecs.emplace_back(new AudioCodecConfig(114, "opus", 48000, 2, false));
|
codecs.emplace_back(new AudioCodecConfig(114, "opus", 48000, 2, false));
|
||||||
ec = mAudioConduit->ConfigureRecvMediaCodecs(codecs);
|
ec = mAudioConduit->ConfigureRecvMediaCodecs(codecs);
|
||||||
|
@ -127,6 +199,8 @@ TEST_F(AudioConduitTest, TestConfigureReceiveMediaCodecs) {
|
||||||
ASSERT_EQ(f.clockrate_hz, 48000);
|
ASSERT_EQ(f.clockrate_hz, 48000);
|
||||||
ASSERT_EQ(f.num_channels, 2UL);
|
ASSERT_EQ(f.num_channels, 2UL);
|
||||||
ASSERT_EQ(f.parameters.at("stereo"), "1");
|
ASSERT_EQ(f.parameters.at("stereo"), "1");
|
||||||
|
ASSERT_EQ(f.parameters.find("maxplaybackrate"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.find("useinbandfec"), f.parameters.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
// multiple codecs
|
// multiple codecs
|
||||||
|
@ -189,7 +263,53 @@ TEST_F(AudioConduitTest, TestConfigureReceiveMediaCodecs) {
|
||||||
delete[] longName;
|
delete[] longName;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AudioConduitTest, TestConfigureMaxPlaybackRate) {
|
TEST_F(AudioConduitTest, TestConfigureReceiveOpusMono) {
|
||||||
|
MediaConduitErrorCode ec;
|
||||||
|
|
||||||
|
// opus mono
|
||||||
|
std::vector<UniquePtr<mozilla::AudioCodecConfig>> codecs;
|
||||||
|
codecs.emplace_back(new AudioCodecConfig(114, "opus", 48000, 1, false));
|
||||||
|
ec = mAudioConduit->ConfigureRecvMediaCodecs(codecs);
|
||||||
|
ASSERT_EQ(ec, kMediaConduitNoError);
|
||||||
|
ASSERT_EQ(mCall->mAudioReceiveConfig.sync_group, "");
|
||||||
|
ASSERT_EQ(mCall->mAudioReceiveConfig.decoder_map.size(), 1U);
|
||||||
|
{
|
||||||
|
const webrtc::SdpAudioFormat& f =
|
||||||
|
mCall->mAudioReceiveConfig.decoder_map.at(114);
|
||||||
|
ASSERT_EQ(f.name, "opus");
|
||||||
|
ASSERT_EQ(f.clockrate_hz, 48000);
|
||||||
|
ASSERT_EQ(f.num_channels, 1UL);
|
||||||
|
ASSERT_EQ(f.parameters.find("stereo"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.find("maxplaybackrate"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.find("useinbandfec"), f.parameters.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AudioConduitTest, TestConfigureReceiveOpusFEC) {
|
||||||
|
MediaConduitErrorCode ec;
|
||||||
|
|
||||||
|
// opus with inband Forward Error Correction
|
||||||
|
std::vector<UniquePtr<mozilla::AudioCodecConfig>> codecs;
|
||||||
|
codecs.emplace_back(new AudioCodecConfig(114, "opus", 48000, 2, true));
|
||||||
|
ec = mAudioConduit->ConfigureRecvMediaCodecs(codecs);
|
||||||
|
ASSERT_EQ(ec, kMediaConduitNoError);
|
||||||
|
ASSERT_EQ(mCall->mAudioReceiveConfig.sync_group, "");
|
||||||
|
ASSERT_EQ(mCall->mAudioReceiveConfig.decoder_map.size(), 1U);
|
||||||
|
{
|
||||||
|
const webrtc::SdpAudioFormat& f =
|
||||||
|
mCall->mAudioReceiveConfig.decoder_map.at(114);
|
||||||
|
ASSERT_EQ(f.name, "opus");
|
||||||
|
ASSERT_EQ(f.clockrate_hz, 48000);
|
||||||
|
ASSERT_EQ(f.num_channels, 2UL);
|
||||||
|
ASSERT_NE(f.parameters.find("stereo"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.at("stereo"), "1");
|
||||||
|
ASSERT_NE(f.parameters.find("useinbandfec"), f.parameters.end());
|
||||||
|
ASSERT_EQ(f.parameters.at("useinbandfec"), "1");
|
||||||
|
ASSERT_EQ(f.parameters.find("maxplaybackrate"), f.parameters.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AudioConduitTest, TestConfigureReceiveMaxPlaybackRate) {
|
||||||
MediaConduitErrorCode ec;
|
MediaConduitErrorCode ec;
|
||||||
|
|
||||||
std::vector<UniquePtr<mozilla::AudioCodecConfig>> codecs;
|
std::vector<UniquePtr<mozilla::AudioCodecConfig>> codecs;
|
||||||
|
|
|
@ -412,8 +412,12 @@ MediaConduitErrorCode WebrtcAudioConduit::ConfigureRecvMediaCodecs(
|
||||||
|
|
||||||
webrtc::SdpAudioFormat::Parameters parameters;
|
webrtc::SdpAudioFormat::Parameters parameters;
|
||||||
if (codec->mName == "opus") {
|
if (codec->mName == "opus") {
|
||||||
parameters = {{"stereo", "1"}};
|
if (codec->mChannels == 2) {
|
||||||
|
parameters = {{"stereo", "1"}};
|
||||||
|
}
|
||||||
|
if (codec->mFECEnabled) {
|
||||||
|
parameters["useinbandfec"] = "1";
|
||||||
|
}
|
||||||
if (codec->mMaxPlaybackRate) {
|
if (codec->mMaxPlaybackRate) {
|
||||||
std::ostringstream o;
|
std::ostringstream o;
|
||||||
o << codec->mMaxPlaybackRate;
|
o << codec->mMaxPlaybackRate;
|
||||||
|
@ -853,14 +857,18 @@ bool WebrtcAudioConduit::CodecConfigToWebRTCCodec(
|
||||||
config.encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory();
|
config.encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory();
|
||||||
|
|
||||||
webrtc::SdpAudioFormat::Parameters parameters;
|
webrtc::SdpAudioFormat::Parameters parameters;
|
||||||
if (codecInfo->mFECEnabled) {
|
if (codecInfo->mName == "opus") {
|
||||||
parameters["useinbandfec"] = "1";
|
if (codecInfo->mChannels == 2) {
|
||||||
}
|
parameters["stereo"] = "1";
|
||||||
|
}
|
||||||
if (codecInfo->mName == "opus" && codecInfo->mMaxPlaybackRate) {
|
if (codecInfo->mFECEnabled) {
|
||||||
std::ostringstream o;
|
parameters["useinbandfec"] = "1";
|
||||||
o << codecInfo->mMaxPlaybackRate;
|
}
|
||||||
parameters["maxplaybackrate"] = o.str();
|
if (codecInfo->mMaxPlaybackRate) {
|
||||||
|
std::ostringstream o;
|
||||||
|
o << codecInfo->mMaxPlaybackRate;
|
||||||
|
parameters["maxplaybackrate"] = o.str();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
webrtc::SdpAudioFormat format(codecInfo->mName, codecInfo->mFreq,
|
webrtc::SdpAudioFormat format(codecInfo->mName, codecInfo->mFreq,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче