| Index: webrtc/api/audio_codecs/audio_format.h
|
| diff --git a/webrtc/api/audio_codecs/audio_format.h b/webrtc/api/audio_codecs/audio_format.h
|
| index db3990f1143bf5fffc5ff233abb837dda79b533c..cfc544da04637e7b61e8163456ce8853ccb53c20 100644
|
| --- a/webrtc/api/audio_codecs/audio_format.h
|
| +++ b/webrtc/api/audio_codecs/audio_format.h
|
| @@ -16,6 +16,8 @@
|
| #include <string>
|
| #include <utility>
|
|
|
| +#include "webrtc/base/optional.h"
|
| +
|
| namespace webrtc {
|
|
|
| // SDP specification for a single audio codec.
|
| @@ -54,28 +56,68 @@ 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
|
| +// To avoid API breakage, and make the code clearer, AudioFormatInfo 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};
|
| +// AudioFormatInfo info{16000, 1, 32000, 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;
|
| +// AudioFormatInfo info(16000, 1, 32000);
|
| +// info.allow_comfort_noise = true;
|
| +// info.future_flag_b = true;
|
| +// info.future_flag_c = true;
|
| +struct AudioFormatInfo {
|
| + AudioFormatInfo();
|
| + AudioFormatInfo(int sample_rate_hz, int num_channels, int bitrate_bps);
|
| + AudioFormatInfo(int sample_rate_hz,
|
| + int num_channels,
|
| + int default_bitrate_bps,
|
| + int min_bitrate_bps,
|
| + int max_bitrate_bps);
|
| + AudioFormatInfo(const AudioFormatInfo& b) = default;
|
| + ~AudioFormatInfo() = default;
|
|
|
| - SdpAudioFormat format;
|
| - bool allow_comfort_noise = true; // This codec can be used with an external
|
| - // comfort noise generator.
|
| + bool operator==(const AudioFormatInfo& b) const {
|
| + return sample_rate_hz == b.sample_rate_hz &&
|
| + num_channels == b.num_channels &&
|
| + default_bitrate_bps == b.default_bitrate_bps &&
|
| + min_bitrate_bps == b.min_bitrate_bps &&
|
| + max_bitrate_bps == b.max_bitrate_bps &&
|
| + allow_comfort_noise == b.allow_comfort_noise &&
|
| + supports_network_adaption == b.supports_network_adaption;
|
| + }
|
| +
|
| + bool operator!=(const AudioFormatInfo& b) const {
|
| + return !(*this == b);
|
| + }
|
| +
|
| + bool HasFixedBitrate() const { return min_bitrate_bps == max_bitrate_bps; }
|
| +
|
| + int sample_rate_hz;
|
| + int num_channels;
|
| + int default_bitrate_bps;
|
| + int min_bitrate_bps;
|
| + int max_bitrate_bps;
|
| +
|
| + 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.
|
| };
|
|
|
| +struct AudioCodecSpec {
|
| + bool operator==(const AudioCodecSpec& b) const {
|
| + return format == b.format && info == b.info;
|
| + }
|
| +
|
| + bool operator!=(const AudioCodecSpec& b) const {
|
| + return format != b.format || info != b.info;
|
| + }
|
| +
|
| + SdpAudioFormat format;
|
| + AudioFormatInfo info;
|
| +};
|
| +
|
| } // namespace webrtc
|
|
|
| #endif // WEBRTC_API_AUDIO_CODECS_AUDIO_FORMAT_H_
|
|
|