Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
code: Fix incorrect behavior for encoder::ffmpeg
Browse files Browse the repository at this point in the history
As we previously relied on an additional function call, we should now merge this call into the constructor.
  • Loading branch information
Xaymar committed May 14, 2023
1 parent a8704e6 commit 8817248
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
15 changes: 6 additions & 9 deletions source/encoders/encoder-ffmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,15 +1165,7 @@ ffmpeg_manager::ffmpeg_manager() : _factories(), _handlers(), _debug_handler()
#ifdef ENABLE_ENCODER_FFMPEG_DNXHR
register_handler("dnxhd", ::std::make_shared<handler::dnxhd_handler>());
#endif
}

ffmpeg_manager::~ffmpeg_manager()
{
_factories.clear();
}

void ffmpeg_manager::register_encoders()
{

// Encoders
void* iterator = nullptr;
for (const AVCodec* codec = av_codec_iterate(&iterator); codec != nullptr; codec = av_codec_iterate(&iterator)) {
Expand All @@ -1191,6 +1183,11 @@ void ffmpeg_manager::register_encoders()
}
}

ffmpeg_manager::~ffmpeg_manager()
{
_factories.clear();
}

void ffmpeg_manager::register_handler(std::string codec, std::shared_ptr<handler::handler> handler)
{
_handlers.emplace(codec, handler);
Expand Down
6 changes: 0 additions & 6 deletions source/encoders/encoder-ffmpeg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,13 @@ namespace streamfx::encoder::ffmpeg {
ffmpeg_manager();
~ffmpeg_manager();

void register_encoders();

void register_handler(std::string codec, std::shared_ptr<handler::handler> handler);

std::shared_ptr<handler::handler> get_handler(std::string codec);

bool has_handler(std::string_view codec);

public: // Singleton
static void initialize();

static void finalize();

static std::shared_ptr<ffmpeg_manager> instance();
};
} // namespace streamfx::encoder::ffmpeg

0 comments on commit 8817248

Please sign in to comment.