Skip to content

Commit

Permalink
Engine: hotfix playing video files with fake or non-standard extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Jan 31, 2025
1 parent 22ddc30 commit ecba911
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Engine/media/video/video_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ static int video_core_slot_init(std::unique_ptr<VideoPlayer> player)
return handle;
}

static std::unique_ptr<VideoPlayer> create_video_player(const AGS::Common::String &ext_hint)
// Creates a video player for the given file extension
static std::unique_ptr<VideoPlayer> create_video_player(const String &ext_hint)
{
std::unique_ptr<VideoPlayer> player;
// Table of video format detection
Expand All @@ -108,12 +109,14 @@ static std::unique_ptr<VideoPlayer> create_video_player(const AGS::Common::Strin
else if (ext_hint.CompareNoCase("ogv") == 0)
player.reset(new TheoraPlayer());
else
return nullptr; // not supported
// FIXME: if file extension does not match any standard one,
// then try each supported player in an order of priority
player.reset(new TheoraPlayer());
return player;
}

int video_core_slot_init(std::unique_ptr<AGS::Common::Stream> in,
const String &name, const AGS::Common::String &ext_hint, const VideoInitParams &params)
int video_core_slot_init(std::unique_ptr<Stream> in,
const String &name, const String &ext_hint, const VideoInitParams &params)
{
auto player = create_video_player(ext_hint);
if (!player)
Expand Down Expand Up @@ -179,8 +182,8 @@ void video_core_init(/*config*/)
Debug::Printf(kDbgMsg_Warn, "VideoCore: video playback is not supported in this engine build.");
}
void video_core_shutdown() { }
int video_core_slot_init(std::unique_ptr<AGS::Common::Stream>,
const AGS::Common::String &, const AGS::Common::String &, const VideoInitParams &)
int video_core_slot_init(std::unique_ptr<Stream>,
const String &, const String &, const VideoInitParams &)
{
return -1;
}
Expand Down

0 comments on commit ecba911

Please sign in to comment.