summaryrefslogtreecommitdiff
path: root/modules/webm/video_stream_webm.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-07-04 08:17:53 +0200
committerGitHub <noreply@github.com>2018-07-04 08:17:53 +0200
commit0b7df80eb1b1f6415b397f0ac115da5014b7b8a8 (patch)
treeace46cb7aeb9924ff395f87612e94b4d06a1998e /modules/webm/video_stream_webm.cpp
parentac9e736b065f0ec30f3b1af19c41b7cd3a0371e6 (diff)
parent6dc20adadd721bfc31a6b761eb6224975938dbf4 (diff)
Merge pull request #19937 from akien-mga/video-exporting
Fix loading and exporting of Theora and WebM video streams
Diffstat (limited to 'modules/webm/video_stream_webm.cpp')
-rw-r--r--modules/webm/video_stream_webm.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index fac47225bc..1bb9a43886 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -443,3 +443,46 @@ void VideoStreamWebm::set_audio_track(int p_track) {
audio_track = p_track;
}
+
+////////////
+
+RES ResourceFormatLoaderWebm::load(const String &p_path, const String &p_original_path, Error *r_error) {
+
+ FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
+ if (!f) {
+ if (r_error) {
+ *r_error = ERR_CANT_OPEN;
+ }
+ memdelete(f);
+ return RES();
+ }
+
+ VideoStreamWebm *stream = memnew(VideoStreamWebm);
+ stream->set_file(p_path);
+
+ Ref<VideoStreamWebm> webm_stream = Ref<VideoStreamWebm>(stream);
+
+ if (r_error) {
+ *r_error = OK;
+ }
+
+ return webm_stream;
+}
+
+void ResourceFormatLoaderWebm::get_recognized_extensions(List<String> *p_extensions) const {
+
+ p_extensions->push_back("webm");
+}
+
+bool ResourceFormatLoaderWebm::handles_type(const String &p_type) const {
+
+ return ClassDB::is_parent_class(p_type, "VideoStream");
+}
+
+String ResourceFormatLoaderWebm::get_resource_type(const String &p_path) const {
+
+ String el = p_path.get_extension().to_lower();
+ if (el == "webm")
+ return "VideoStreamWebm";
+ return "";
+}