diff --git a/src/audio/codec.cpp b/src/audio/codec.cpp index 1fc1eeba2..bbbc9987c 100644 --- a/src/audio/codec.cpp +++ b/src/audio/codec.cpp @@ -54,19 +54,26 @@ static constexpr const char *MOD_NAME = "[acodec] "; -using namespace std; +using std::hash; +using std::max; +using std::pair; +using std::unordered_map; +using std::string; +using std::vector; -static const unordered_map> audio_codec_info = { - {AC_NONE, { "(none)", 0 }}, - {AC_PCM, { "PCM", 0x0001 }}, - {AC_ALAW, { "A-law", 0x0006 }}, - {AC_MULAW, { "u-law", 0x0007 }}, - {AC_SPEEX, { "speex", 0xA109 }}, - {AC_OPUS, { "Opus", 0x7375704F }}, // == Opus, the TwoCC isn't defined - {AC_G722, { "G.722", 0x028F }}, - {AC_MP3, { "MP3", 0x0055 }}, - {AC_AAC, { "AAC", 0x00FF }}, - {AC_FLAC, { "FLAC", 0xF1AC }}, +static const unordered_map> + audio_codec_info = { + {AC_NONE, { "(none)", 0, 0 } }, + { AC_PCM, { "PCM", 0x0001, 0 } }, + { AC_ALAW, { "A-law", 0x0006, 0 } }, + { AC_MULAW, { "u-law", 0x0007, 0 } }, + { AC_SPEEX, { "speex", 0xA109, AC_FLAG_DEPRECATED }}, + { AC_OPUS, // fcc is "Opus", the TwoCC isn't defined + { "Opus", 0x7375704F, 0 } }, + { AC_G722, { "G.722", 0x028F, 0 } }, + { AC_MP3, { "MP3", 0x0055, 0 } }, + { AC_AAC, { "AAC", 0x00FF, 0 } }, + { AC_FLAC, { "FLAC", 0xF1AC, 0 } }, }; static struct audio_codec_state *audio_codec_init_real(const char *audio_codec_cfg, @@ -81,8 +88,8 @@ struct audio_codec_state { int bitrate; }; -std::vector> get_audio_codec_list(void){ - std::vector> ret; +vector> get_audio_codec_list() { + vector> ret; for (auto const &it : audio_codec_info) { if(it.first != AC_NONE) { @@ -94,7 +101,7 @@ std::vector> get_audio_codec_list(void){ available = true; audio_codec_done(st); } - ret.emplace_back(it.second.name, available); + ret.emplace_back(it.second, available); } } @@ -114,10 +121,22 @@ void list_audio_codecs(void) { col() << "\t" << SBOLD("bitrate ") << " - codec bitrate " << SBOLD("per channel") << " (with optional k/M suffix)\n"; col() << "\n"; + bool deprecated_present = false; printf("Supported audio codecs:\n"); for (auto const &it : get_audio_codec_list()) { - col() << SBOLD("\t" << it.first) - << (!it.second ? " - " TRED("unavailable") : "") << "\n"; + string notes; + if (!it.second) { + notes += " " TRED("unavailable"); + } + if ((it.first.flags & AC_FLAG_DEPRECATED) != 0) { + notes += " " TYELLOW("deprecated"); + deprecated_present = true; + } + col() << SBOLD("\t" << it.first.name) + << (notes.empty() ? "" : " -") << notes << "\n"; + } + if (deprecated_present) { + col() << "\nCodecs marked as \"deprecated\" may be removed in future.\n"; } } diff --git a/src/audio/codec.h b/src/audio/codec.h index c9f4191f0..96f707dbb 100644 --- a/src/audio/codec.h +++ b/src/audio/codec.h @@ -56,12 +56,17 @@ struct audio_compress_info { void (*done)(void *); }; +enum audio_codec_flag { + AC_FLAG_DEPRECATED = 1 << 0, +}; + typedef struct { const char *name; /** @var tag * @brief TwoCC if defined, otherwise we define our tag */ uint32_t tag; + int flags; ///< enum audio_codec_flag } audio_codec_info_t; #ifdef __cplusplus @@ -76,7 +81,7 @@ audio_frame2 audio_codec_decompress(struct audio_codec_state *, audio_frame2 *); const int *audio_codec_get_supported_samplerates(struct audio_codec_state *); void audio_codec_done(struct audio_codec_state *); -std::vector> get_audio_codec_list(void); +std::vector> get_audio_codec_list(); #endif #ifdef __cplusplus diff --git a/src/host.cpp b/src/host.cpp index 0bf3a1f0d..e0b337132 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -719,7 +719,7 @@ void print_capabilities(const char *cfg) } auto codecs = get_audio_codec_list(); for(const auto& codec : codecs){ - class_mod_map[LIBRARY_CLASS_AUDIO_COMPRESS].emplace(codec.first, nullptr); + class_mod_map[LIBRARY_CLASS_AUDIO_COMPRESS].emplace(codec.first.name, nullptr); } if(conf == "noprobe"){