Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Unified Diff: webrtc/api/audio_codecs/audio_format.h

Issue 2695243005: Injectable audio encoders: BuiltinAudioEncoderFactory (Closed)
Patch Set: Wrote tests for BuiltinAudioEncoderFactory; addressed many comments. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..08bcd38008bf24e04c4b98b50d951ac692a3040c 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,71 @@ 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, AudioCodecInfo 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};
+// AudioCodecInfo 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;
+// AudioCodecInfo info(16000, 1, 32000);
+// info.allow_comfort_noise = true;
+// info.future_flag_b = true;
+// info.future_flag_c = true;
+struct AudioCodecInfo {
+ AudioCodecInfo(int sample_rate_hz, int num_channels, int bitrate_bps);
+ AudioCodecInfo(int sample_rate_hz,
+ int num_channels,
+ int default_bitrate_bps,
+ int min_bitrate_bps,
+ int max_bitrate_bps);
+ AudioCodecInfo(const AudioCodecInfo& b) = default;
+ ~AudioCodecInfo() = default;
- SdpAudioFormat format;
- bool allow_comfort_noise = true; // This codec can be used with an external
- // comfort noise generator.
+ bool operator==(const AudioCodecInfo& 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 AudioCodecInfo& b) const {
+ return !(*this == b);
+ }
+
+ bool HasFixedBitrate() const {
+ RTC_DCHECK(min_bitrate_bps != max_bitrate_bps ||
+ min_bitrate_bps == default_bitrate_bps == max_bitrate_bps);
the sun 2017/03/17 09:07:31 Do you really want to compare max_bitrate_bps with
ossu 2017/03/17 09:55:39 I... no, I don't know what I was thinking here. I'
+ 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 !(*this == b);
+ }
+
+ SdpAudioFormat format;
+ AudioCodecInfo info;
+};
+
} // namespace webrtc
#endif // WEBRTC_API_AUDIO_CODECS_AUDIO_FORMAT_H_

Powered by Google App Engine
This is Rietveld 408576698