Updated AudioDecoderFactory to list AudioCodecSpecs instead of SdpAudioFormats.
BUG=webrtc:5805 Review-Url: https://codereview.webrtc.org/2123923004 Cr-Commit-Position: refs/heads/master@{#13810}
This commit is contained in:
@ -1093,8 +1093,8 @@ webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() {
|
||||
AudioCodecs WebRtcVoiceEngine::CollectRecvCodecs() const {
|
||||
PayloadTypeMapper mapper;
|
||||
AudioCodecs out;
|
||||
const std::vector<webrtc::SdpAudioFormat>& formats =
|
||||
decoder_factory_->GetSupportedFormats();
|
||||
const std::vector<webrtc::AudioCodecSpec>& specs =
|
||||
decoder_factory_->GetSupportedDecoders();
|
||||
|
||||
// Only generate CN payload types for these clockrates
|
||||
std::map<int, bool, std::greater<int>> generate_cn = {{ 8000, false },
|
||||
@ -1119,14 +1119,12 @@ AudioCodecs WebRtcVoiceEngine::CollectRecvCodecs() const {
|
||||
return true;
|
||||
};
|
||||
|
||||
for (const auto& format : formats) {
|
||||
if (map_format(format)) {
|
||||
// TODO(ossu): We should get more than just a format from the factory, so
|
||||
// we can determine if a format should be used with CN or not. For now,
|
||||
// generate a CN entry for each supported clock rate also used by a format
|
||||
// supported by the factory.
|
||||
auto cn = generate_cn.find(format.clockrate_hz);
|
||||
if (cn != generate_cn.end() /* && format.allow_comfort_noise */) {
|
||||
for (const auto& spec : specs) {
|
||||
if (map_format(spec.format) && spec.allow_comfort_noise) {
|
||||
// Generate a CN entry if the decoder allows it and we support the
|
||||
// clockrate.
|
||||
auto cn = generate_cn.find(spec.format.clockrate_hz);
|
||||
if (cn != generate_cn.end()) {
|
||||
cn->second = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ namespace webrtc {
|
||||
// NOTE: This class is still under development and may change without notice.
|
||||
class AudioDecoderFactory : public rtc::RefCountInterface {
|
||||
public:
|
||||
virtual std::vector<SdpAudioFormat> GetSupportedFormats() = 0;
|
||||
virtual std::vector<AudioCodecSpec> GetSupportedDecoders() = 0;
|
||||
|
||||
virtual std::unique_ptr<AudioDecoder> MakeAudioDecoder(
|
||||
const SdpAudioFormat& format) = 0;
|
||||
|
||||
@ -39,12 +39,17 @@ struct SdpAudioFormat {
|
||||
int clockrate_hz;
|
||||
int num_channels;
|
||||
Parameters parameters;
|
||||
// Parameters feedback_parameters; ??
|
||||
};
|
||||
|
||||
void swap(SdpAudioFormat& a, SdpAudioFormat& b);
|
||||
std::ostream& operator<<(std::ostream& os, const SdpAudioFormat& saf);
|
||||
|
||||
struct AudioCodecSpec {
|
||||
SdpAudioFormat format;
|
||||
bool allow_comfort_noise; // This encoder can be used with an external
|
||||
// comfort noise generator.
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_FORMAT_H_
|
||||
|
||||
@ -129,32 +129,33 @@ NamedDecoderConstructor decoder_constructors[] = {
|
||||
|
||||
class BuiltinAudioDecoderFactory : public AudioDecoderFactory {
|
||||
public:
|
||||
std::vector<SdpAudioFormat> GetSupportedFormats() override {
|
||||
static std::vector<SdpAudioFormat> formats = {
|
||||
std::vector<AudioCodecSpec> GetSupportedDecoders() override {
|
||||
static std::vector<AudioCodecSpec> specs = {
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
{ "opus", 48000, 2, {
|
||||
{"minptime", "10" },
|
||||
{"useinbandfec", "1" }
|
||||
}
|
||||
{ { "opus", 48000, 2, {
|
||||
{"minptime", "10" },
|
||||
{"useinbandfec", "1" }
|
||||
}
|
||||
}, false
|
||||
},
|
||||
#endif
|
||||
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
|
||||
{ "isac", 16000, 1 },
|
||||
{ { "isac", 16000, 1 }, true },
|
||||
#endif
|
||||
#if (defined(WEBRTC_CODEC_ISAC))
|
||||
{ "isac", 32000, 1 },
|
||||
{ { "isac", 32000, 1 }, true },
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_G722
|
||||
{ "G722", 8000, 1 },
|
||||
{ { "G722", 8000, 1 }, true },
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_ILBC
|
||||
{ "iLBC", 8000, 1 },
|
||||
{ { "iLBC", 8000, 1 }, true },
|
||||
#endif
|
||||
{ "PCMU", 8000, 1 },
|
||||
{ "PCMA", 8000, 1 }
|
||||
{ { "PCMU", 8000, 1 }, true },
|
||||
{ { "PCMA", 8000, 1 }, true }
|
||||
};
|
||||
|
||||
return formats;
|
||||
return specs;
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioDecoder> MakeAudioDecoder(
|
||||
|
||||
@ -21,7 +21,7 @@ namespace webrtc {
|
||||
|
||||
class MockAudioDecoderFactory : public AudioDecoderFactory {
|
||||
public:
|
||||
MOCK_METHOD0(GetSupportedFormats, std::vector<SdpAudioFormat>());
|
||||
MOCK_METHOD0(GetSupportedDecoders, std::vector<AudioCodecSpec>());
|
||||
std::unique_ptr<AudioDecoder> MakeAudioDecoder(
|
||||
const SdpAudioFormat& format) {
|
||||
std::unique_ptr<AudioDecoder> return_value;
|
||||
@ -43,9 +43,9 @@ class MockAudioDecoderFactory : public AudioDecoderFactory {
|
||||
|
||||
rtc::scoped_refptr<webrtc::MockAudioDecoderFactory> factory =
|
||||
new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>;
|
||||
ON_CALL(*factory.get(), GetSupportedFormats())
|
||||
.WillByDefault(Return(std::vector<webrtc::SdpAudioFormat>()));
|
||||
EXPECT_CALL(*factory.get(), GetSupportedFormats()).Times(AnyNumber());
|
||||
ON_CALL(*factory.get(), GetSupportedDecoders())
|
||||
.WillByDefault(Return(std::vector<webrtc::AudioCodecSpec>()));
|
||||
EXPECT_CALL(*factory.get(), GetSupportedDecoders()).Times(AnyNumber());
|
||||
EXPECT_CALL(*factory.get(), MakeAudioDecoderMock(_, _)).Times(0);
|
||||
return factory;
|
||||
}
|
||||
@ -62,9 +62,9 @@ class MockAudioDecoderFactory : public AudioDecoderFactory {
|
||||
|
||||
rtc::scoped_refptr<webrtc::MockAudioDecoderFactory> factory =
|
||||
new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>;
|
||||
ON_CALL(*factory.get(), GetSupportedFormats())
|
||||
.WillByDefault(Return(std::vector<webrtc::SdpAudioFormat>()));
|
||||
EXPECT_CALL(*factory.get(), GetSupportedFormats()).Times(AnyNumber());
|
||||
ON_CALL(*factory.get(), GetSupportedDecoders())
|
||||
.WillByDefault(Return(std::vector<webrtc::AudioCodecSpec>()));
|
||||
EXPECT_CALL(*factory.get(), GetSupportedDecoders()).Times(AnyNumber());
|
||||
ON_CALL(*factory.get(), MakeAudioDecoderMock(_, _))
|
||||
.WillByDefault(SetArgPointee<1>(nullptr));
|
||||
EXPECT_CALL(*factory.get(), MakeAudioDecoderMock(_, _)).Times(AnyNumber());
|
||||
|
||||
Reference in New Issue
Block a user