Skip to content

Commit

Permalink
nvm change format again
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnut committed Oct 14, 2024
1 parent b33312c commit f5c0a0a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 3 additions & 2 deletions include/recorder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <vector>
#include <string>
#include <memory>
#include <unordered_map>

class AVFormatContext;
class AVCodec;
Expand Down Expand Up @@ -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<std::pair<int, std::string>> getAvailableCodecs();
std::unordered_map<std::string, int> getAvailableCodecs();

private:
AVFormatContext* m_formatContext = nullptr;
Expand Down
10 changes: 4 additions & 6 deletions src/recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@ extern "C" {

namespace ffmpeg {

std::vector<std::pair<int, std::string>> Recorder::getAvailableCodecs() {
std::vector<std::pair<int, std::string>> vet;
std::unordered_map<std::string, int> Recorder::getAvailableCodecs() {
std::unordered_map<std::string, int> 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<int, std::string>& a, std::pair<int, std::string>& b) { return a.second < b.second; });

return vet;
return map;
}

bool Recorder::init(const RenderSettings& settings) {
Expand Down

0 comments on commit f5c0a0a

Please sign in to comment.