diff --git a/include/recorder.hpp b/include/recorder.hpp index b80ba9a..abf3806 100644 --- a/include/recorder.hpp +++ b/include/recorder.hpp @@ -6,6 +6,7 @@ #include #include #include +#include class AVFormatContext; class AVCodec; @@ -61,9 +62,9 @@ class FFMPEG_API_DLL Recorder { * This function iterates through all available codecs in FFmpeg and * returns a sorted vector of codec names. * - * @return A vector of pairs representing the ids and names of available codecs. + * @return A map of representing the names and ids of available codecs. */ - std::vector> getAvailableCodecs(); + std::unordered_map getAvailableCodecs(); private: AVFormatContext* m_formatContext = nullptr; diff --git a/src/recorder.cpp b/src/recorder.cpp index 0827714..5808ecc 100644 --- a/src/recorder.cpp +++ b/src/recorder.cpp @@ -12,20 +12,18 @@ extern "C" { namespace ffmpeg { -std::vector> Recorder::getAvailableCodecs() { - std::vector> vet; +std::unordered_map Recorder::getAvailableCodecs() { + std::unordered_map map; void* iter = nullptr; const AVCodec * codec; while ((codec = av_codec_iterate(&iter))) { if(codec->type == AVMEDIA_TYPE_VIDEO) - vet.push_back({(int)codec->id, codec->name}); + map.insert({codec->name, (int)codec->id}); } - - std::sort(vet.begin(), vet.end(), [](std::pair& a, std::pair& b) { return a.second < b.second; }); - return vet; + return map; } bool Recorder::init(const RenderSettings& settings) {