Added a flag to AudioCodecSpec to indicate adaptive bitrate support.

It's currently only used to ensure transport-cc is enabled for the format in question. It might be used to toggle more things in future.

BUG=webrtc:5806

Review-Url: https://codereview.webrtc.org/2669583002
Cr-Commit-Position: refs/heads/master@{#16514}
This commit is contained in:
ossu
2017-02-09 05:14:32 -08:00
committed by Commit bot
parent 0289364abc
commit 9def800b70
5 changed files with 135 additions and 32 deletions

View File

@ -77,4 +77,10 @@ std::ostream& operator<<(std::ostream& os, const SdpAudioFormat& saf) {
return os;
}
AudioCodecSpec::AudioCodecSpec(const SdpAudioFormat& format)
: format(format) {}
AudioCodecSpec::AudioCodecSpec(SdpAudioFormat&& format)
: format(std::move(format)) {}
} // namespace webrtc

View File

@ -54,10 +54,26 @@ struct SdpAudioFormat {
void swap(SdpAudioFormat& a, SdpAudioFormat& b);
std::ostream& operator<<(std::ostream& os, const SdpAudioFormat& saf);
// To avoid API breakage, and make the code clearer, AudioCodecSpec should not
// be directly initializable with any flags indicating optional support. If it
// were, these initializers would break any time a new flag was added. It's also
// more difficult to understand:
// AudioCodecSpec spec{{"format", 8000, 1}, true, false, false, true, true};
// than
// AudioCodecSpec spec({"format", 8000, 1});
// spec.allow_comfort_noise = true;
// spec.future_flag_b = true;
// spec.future_flag_c = true;
struct AudioCodecSpec {
explicit AudioCodecSpec(const SdpAudioFormat& format);
explicit AudioCodecSpec(SdpAudioFormat&& format);
~AudioCodecSpec() = default;
SdpAudioFormat format;
bool allow_comfort_noise; // This encoder can be used with an external
// comfort noise generator.
bool allow_comfort_noise = true; // This codec can be used with an external
// comfort noise generator.
bool supports_network_adaption = false; // This codec can adapt to varying
// network conditions.
};
} // namespace webrtc

View File

@ -174,31 +174,36 @@ NamedDecoderConstructor decoder_constructors[] = {
class BuiltinAudioDecoderFactory : public AudioDecoderFactory {
public:
std::vector<AudioCodecSpec> GetSupportedDecoders() override {
static std::vector<AudioCodecSpec> specs = {
// Although this looks a bit strange, it means specs need only be initalized
// once, and that that initialization is thread-safe.
static std::vector<AudioCodecSpec> specs =
[]{
std::vector<AudioCodecSpec> specs;
#ifdef WEBRTC_CODEC_OPUS
{ { "opus", 48000, 2, {
{"minptime", "10" },
{"useinbandfec", "1" }
}
}, false
},
AudioCodecSpec opus({"opus", 48000, 2, {
{"minptime", "10"},
{"useinbandfec", "1"}
}});
opus.allow_comfort_noise = false;
opus.supports_network_adaption = true;
specs.push_back(opus);
#endif
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
{{"isac", 16000, 1}, true},
specs.push_back(AudioCodecSpec({"isac", 16000, 1}));
#endif
#if (defined(WEBRTC_CODEC_ISAC))
{{"isac", 32000, 1}, true},
specs.push_back(AudioCodecSpec({"isac", 32000, 1}));
#endif
#ifdef WEBRTC_CODEC_G722
{{"G722", 8000, 1}, true},
specs.push_back(AudioCodecSpec({"G722", 8000, 1}));
#endif
#ifdef WEBRTC_CODEC_ILBC
{{"iLBC", 8000, 1}, true},
specs.push_back(AudioCodecSpec({"iLBC", 8000, 1}));
#endif
{{"PCMU", 8000, 1}, true},
{{"PCMA", 8000, 1}, true}
};
specs.push_back(AudioCodecSpec({"PCMU", 8000, 1}));
specs.push_back(AudioCodecSpec({"PCMA", 8000, 1}));
return specs;
}();
return specs;
}