[Scummvm-git-logs] scummvm master -> 82eacc7959f314a7bd2344c6f7ae7c291ee354e8

dreammaster dreammaster at scummvm.org
Mon Feb 8 05:45:27 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
82eacc7959 AGS: Detect video type if file doesn't have a known extension


Commit: 82eacc7959f314a7bd2344c6f7ae7c291ee354e8
    https://github.com/scummvm/scummvm/commit/82eacc7959f314a7bd2344c6f7ae7c291ee354e8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-02-07T21:45:11-08:00

Commit Message:
AGS: Detect video type if file doesn't have a known extension

Changed paths:
    engines/ags/engine/ac/global_video.cpp
    engines/ags/engine/media/video/video.cpp
    engines/ags/engine/media/video/video.h


diff --git a/engines/ags/engine/ac/global_video.cpp b/engines/ags/engine/ac/global_video.cpp
index a634bb2991..c8f7f29aa2 100644
--- a/engines/ags/engine/ac/global_video.cpp
+++ b/engines/ags/engine/ac/global_video.cpp
@@ -60,13 +60,17 @@ void pause_sound_if_necessary_and_play_video(const char *name, int skip, int fla
 		ambientWas[i] = ambient[i].channel;
 
 	if ((strlen(name) > 3) && (ags_stricmp(&name[strlen(name) - 3], "ogv") == 0)) {
-		play_theora_video(name, skip, flags);
+		play_theora_video(name, skip, flags, true);
 	} else if ((strlen(name) > 3) && (ags_stricmp(&name[strlen(name) - 3], "mpg") == 0)) {
-		play_mpeg_video(name, skip, flags);
+		play_mpeg_video(name, skip, flags, true);
 	} else if ((strlen(name) > 3) && (ags_stricmp(&name[strlen(name) - 3], "avi") == 0)) {
-		play_avi_video(name, skip, flags);
+		play_avi_video(name, skip, flags, true);
 	} else {
-		Display("Unsupported video '%s'", name);
+		// Unsure what the video type is, so try each in turn
+		if (!play_avi_video(name, skip, flags, false) &&
+				!play_mpeg_video(name, skip, flags, false) &&
+				!play_theora_video(name, skip, flags, false))
+			Display("Unsupported video '%s'", name);
 	}
 
 	if (flags < 10) {
diff --git a/engines/ags/engine/media/video/video.cpp b/engines/ags/engine/media/video/video.cpp
index 09ef28dca1..8bd12f5dcf 100644
--- a/engines/ags/engine/media/video/video.cpp
+++ b/engines/ags/engine/media/video/video.cpp
@@ -53,11 +53,21 @@ namespace AGS3 {
 
 using AGS::Shared::AssetManager;
 
-static void play_video(Video::VideoDecoder *decoder, const char *name, int skip, int flags) {
+static bool play_video(Video::VideoDecoder *decoder, const char *name, int skip, int flags, bool showError) {
 	std::unique_ptr<Stream> video_stream(AssetManager::OpenAsset(name));
 	if (!video_stream) {
-		Display("Unable to load theora video '%s'", name);
-		return;
+		if (showError)
+			Display("Unable to load video '%s'", name);
+		return false;
+	}
+
+	AGS::Shared::ScummVMReadStream *stream = new AGS::Shared::ScummVMReadStream(video_stream.get(), DisposeAfterUse::NO);
+
+	if (!decoder->loadStream(stream)) {
+		delete stream;
+		if (showError)
+			Display("Unable to decode video '%s'", name);
+		return false;
 	}
 
 	update_polled_stuff_if_runtime();
@@ -71,14 +81,6 @@ static void play_video(Video::VideoDecoder *decoder, const char *name, int skip,
 		stop_all_sound_and_music();
 	}
 
-	AGS::Shared::ScummVMReadStream *stream = new AGS::Shared::ScummVMReadStream(video_stream.get(), DisposeAfterUse::NO);
-
-	if (!decoder->loadStream(stream)) {
-		delete stream;
-		Display("Unable to decode theora video '%s'", name);
-		return;
-	}
-
 	update_polled_stuff_if_runtime();
 
 	decoder->start();
@@ -110,40 +112,46 @@ static void play_video(Video::VideoDecoder *decoder, const char *name, int skip,
 			int key, mbut, mwheelz;
 			if (run_service_key_controls(key)) {
 				if (key == 27 && canAbort)
-					return;
+					return true;
 				if (canAbort >= 2)
-					return;  // skip on any key
+					return true;  // skip on any key
 			}
+
 			if (run_service_mb_controls(mbut, mwheelz) && mbut >= 0 && canAbort == 3) {
-				return; // skip on mouse click
+				return true; // skip on mouse click
 			}
 		}
 	}
 
 	invalidate_screen();
+
+	return true;
 }
 
-void play_avi_video(const char *name, int skip, int flags) {
+bool play_avi_video(const char *name, int skip, int flags, bool showError) {
 	Video::AVIDecoder decoder;
-	play_video(&decoder, name, skip, flags);
+	return play_video(&decoder, name, skip, flags, showError);
 }
 
-void play_mpeg_video(const char *name, int skip, int flags) {
+bool play_mpeg_video(const char *name, int skip, int flags, bool showError) {
 	Video::MPEGPSDecoder decoder;
-	play_video(&decoder, name, skip, flags);
+	return play_video(&decoder, name, skip, flags, showError);
 }
 
-void play_theora_video(const char *name, int skip, int flags) {
+bool play_theora_video(const char *name, int skip, int flags, bool showError) {
 #if !defined (USE_THEORADEC)
-	Display("This games uses Theora videos but ScummVM has been compiled without Theora support");
+	if (showError)
+		Display("This games uses Theora videos but ScummVM has been compiled without Theora support");
+	return false;
 #else
 	Video::TheoraDecoder decoder;
-	play_video(&decoder, name, skip, flags);
+	return play_video(&decoder, name, skip, flags, showError);
 #endif
 }
 
-void play_flc_file(int numb, int playflags) {
+bool play_flc_file(int numb, int playflags) {
 	warning("TODO: play_flc_file");
+	return false;
 }
 
 void video_on_gfxmode_changed() {
diff --git a/engines/ags/engine/media/video/video.h b/engines/ags/engine/media/video/video.h
index 77f9cd560a..537977eb81 100644
--- a/engines/ags/engine/media/video/video.h
+++ b/engines/ags/engine/media/video/video.h
@@ -25,10 +25,10 @@
 
 namespace AGS3 {
 
-void play_avi_video(const char *name, int skip, int flags);
-void play_mpeg_video(const char *name, int skip, int flags);
-void play_theora_video(const char *name, int skip, int flags);
-void play_flc_file(int numb, int playflags);
+extern bool play_avi_video(const char *name, int skip, int flags, bool showError);
+extern bool play_mpeg_video(const char *name, int skip, int flags, bool showError);
+extern bool play_theora_video(const char *name, int skip, int flags, bool showError);
+extern bool play_flc_file(int numb, int playflags);
 
 // Update video playback if the display mode has changed
 void video_on_gfxmode_changed();




More information about the Scummvm-git-logs mailing list