From bb6c0d3e8bb1982bce3e1c219c1a4a2d187227f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 26 Jan 2020 11:24:14 +0100 Subject: [PATCH] doc: Complete documentation for VideoStreams Also quick clean up of the matching C++ files. --- doc/classes/VideoPlayer.xml | 5 ++- doc/classes/VideoStream.xml | 1 + .../doc_classes/VideoStreamGDNative.xml | 5 +++ modules/stb_vorbis/audio_stream_ogg_vorbis.h | 2 +- .../theora/doc_classes/VideoStreamTheora.xml | 4 ++ modules/theora/video_stream_theora.cpp | 1 - modules/webm/doc_classes/VideoStreamWebm.xml | 4 ++ modules/webm/video_stream_webm.cpp | 27 ++++++------- scene/resources/audio_stream_sample.cpp | 3 +- scene/resources/audio_stream_sample.h | 6 +-- scene/resources/material.h | 2 +- scene/resources/texture.h | 3 +- scene/resources/video_stream.cpp | 39 ------------------- scene/resources/video_stream.h | 11 +----- servers/audio/audio_stream.cpp | 1 + servers/audio/audio_stream.h | 2 +- 16 files changed, 43 insertions(+), 73 deletions(-) delete mode 100644 scene/resources/video_stream.cpp diff --git a/doc/classes/VideoPlayer.xml b/doc/classes/VideoPlayer.xml index 3ed53aa4478..3bc3898b9fc 100644 --- a/doc/classes/VideoPlayer.xml +++ b/doc/classes/VideoPlayer.xml @@ -4,7 +4,8 @@ Control for playing video streams. - Control node for playing video streams. Supported formats are [url=https://www.webmproject.org/]WebM[/url] and [url=https://www.theora.org/]Ogg Theora[/url]. + Control node for playing video streams using [VideoStream] resources. + Supported video formats are [url=https://www.webmproject.org/]WebM[/url] ([VideoStreamWebm]), [url=https://www.theora.org/]Ogg Theora[/url] ([VideoStreamTheora]), and any format exposed via a GDNative plugin using [VideoStreamGDNative]. @@ -61,7 +62,7 @@ Audio bus to use for sound playback. - If [code]true[/code], the video scales to the control size. + If [code]true[/code], the video scales to the control size. Otherwise, the control minimum size will be automatically adjusted to match the video stream's dimensions. If [code]true[/code], the video is paused. diff --git a/doc/classes/VideoStream.xml b/doc/classes/VideoStream.xml index 7772c61e850..635baf85a2f 100644 --- a/doc/classes/VideoStream.xml +++ b/doc/classes/VideoStream.xml @@ -4,6 +4,7 @@ Base resource for video streams. + Base resource type for all video streams. Classes that derive from [VideoStream] can all be used as resource types to play back videos in [VideoPlayer]. diff --git a/modules/gdnative/doc_classes/VideoStreamGDNative.xml b/modules/gdnative/doc_classes/VideoStreamGDNative.xml index ed7678b7be9..c4d9a58fbb1 100644 --- a/modules/gdnative/doc_classes/VideoStreamGDNative.xml +++ b/modules/gdnative/doc_classes/VideoStreamGDNative.xml @@ -1,8 +1,11 @@ + [VideoStream] resource for for video formats implemented via GDNative. + [VideoStream] resource for for video formats implemented via GDNative. + It can be used via [url=https://github.com/KidRigger/godot-videodecoder]godot-videodecoder[/url] which uses the [url=https://ffmpeg.org]FFmpeg[/url] library. @@ -11,6 +14,7 @@ + Returns the video file handled by this [VideoStreamGDNative]. @@ -19,6 +23,7 @@ + Sets the video file that this [VideoStreamGDNative] resource handles. The supported extensions depend on the GDNative plugins used to expose video formats. diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h index cfa5e97faae..e909759acb2 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.h +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h @@ -73,7 +73,7 @@ public: class AudioStreamOGGVorbis : public AudioStream { GDCLASS(AudioStreamOGGVorbis, AudioStream); - OBJ_SAVE_TYPE(AudioStream) //children are all saved as AudioStream, so they can be exchanged + OBJ_SAVE_TYPE(AudioStream); // Saves derived classes with common type so they can be interchanged. RES_BASE_EXTENSION("oggstr"); friend class AudioStreamPlaybackOGGVorbis; diff --git a/modules/theora/doc_classes/VideoStreamTheora.xml b/modules/theora/doc_classes/VideoStreamTheora.xml index 696101e252a..ab1fcdcfb49 100644 --- a/modules/theora/doc_classes/VideoStreamTheora.xml +++ b/modules/theora/doc_classes/VideoStreamTheora.xml @@ -1,8 +1,10 @@ + [VideoStream] resource for Ogg Theora videos. + [VideoStream] resource handling the [url=https://www.theora.org/]Ogg Theora[/url] video format with [code].ogv[/code] extension. @@ -11,6 +13,7 @@ + Returns the Ogg Theora video file handled by this [VideoStreamTheora]. @@ -19,6 +22,7 @@ + Sets the Ogg Theora video file that this [VideoStreamTheora] resource handles. The [code]file[/code] name should have the [code].o[/code] extension. diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index 9ba77d3c774..cf1fc3f175a 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -147,7 +147,6 @@ void VideoStreamPlaybackTheora::clear() { thread = NULL; ring_buffer.clear(); #endif - //file_name = ""; theora_p = 0; vorbis_p = 0; diff --git a/modules/webm/doc_classes/VideoStreamWebm.xml b/modules/webm/doc_classes/VideoStreamWebm.xml index ff11bbb37d5..48076723380 100644 --- a/modules/webm/doc_classes/VideoStreamWebm.xml +++ b/modules/webm/doc_classes/VideoStreamWebm.xml @@ -1,8 +1,10 @@ + [VideoStream] resource for WebM videos. + [VideoStream] resource handling the [url=https://www.webmproject.org/]WebM[/url] video format with [code].webm[/code] extension. @@ -11,6 +13,7 @@ + Returns the WebM video file handled by this [VideoStreamWebm]. @@ -19,6 +22,7 @@ + Sets the WebM video file that this [VideoStreamWebm] resource handles. The [code]file[/code] name should have the [code].webm[/code] extension. diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 6e2527595b0..41f9e676724 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -30,21 +30,22 @@ #include "video_stream_webm.h" -#include "OpusVorbisDecoder.hpp" -#include "VPXDecoder.hpp" -#include - -#include "mkvparser/mkvparser.h" - #include "core/os/file_access.h" #include "core/os/os.h" #include "core/project_settings.h" +#include "servers/audio_server.h" #include "thirdparty/misc/yuv2rgb.h" -#include "servers/audio_server.h" +// libsimplewebm +#include +#include -#include +// libvpx +#include + +// libwebm +#include class MkvReader : public mkvparser::IMkvReader { @@ -335,22 +336,22 @@ void VideoStreamPlaybackWebm::update(float p_delta) { } else if (image.chromaShiftW == 1 && image.chromaShiftH == 1) { yuv420_2_rgb8888(w.ptr(), image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2); - // libyuv::I420ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); + //libyuv::I420ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); converted = true; } else if (image.chromaShiftW == 1 && image.chromaShiftH == 0) { yuv422_2_rgb8888(w.ptr(), image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2); - // libyuv::I422ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); + //libyuv::I422ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); converted = true; } else if (image.chromaShiftW == 0 && image.chromaShiftH == 0) { yuv444_2_rgb8888(w.ptr(), image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2); - // libyuv::I444ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); + //libyuv::I444ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); converted = true; } else if (image.chromaShiftW == 2 && image.chromaShiftH == 0) { - // libyuv::I411ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); - // converted = true; + //libyuv::I411ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2] image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); + //converted = true; } if (converted) { diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index bfc7f407ebc..e8cb40154e1 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "audio_stream_sample.h" + #include "core/io/marshalls.h" #include "core/os/file_access.h" @@ -656,8 +657,8 @@ AudioStreamSample::AudioStreamSample() { data = NULL; data_bytes = 0; } -AudioStreamSample::~AudioStreamSample() { +AudioStreamSample::~AudioStreamSample() { if (data) { AudioServer::get_singleton()->audio_data_free(data); data = NULL; diff --git a/scene/resources/audio_stream_sample.h b/scene/resources/audio_stream_sample.h index d5d8f073fb3..adcac14ea8d 100644 --- a/scene/resources/audio_stream_sample.h +++ b/scene/resources/audio_stream_sample.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef AUDIOSTREAMSAMPLE_H -#define AUDIOSTREAMSAMPLE_H +#ifndef AUDIO_STREAM_SAMPLE_H +#define AUDIO_STREAM_SAMPLE_H #include "servers/audio/audio_stream.h" @@ -153,4 +153,4 @@ public: VARIANT_ENUM_CAST(AudioStreamSample::Format) VARIANT_ENUM_CAST(AudioStreamSample::LoopMode) -#endif // AUDIOSTREAMSample_H +#endif // AUDIO_STREAM_SAMPLE_H diff --git a/scene/resources/material.h b/scene/resources/material.h index 3c2a7c928a6..c2501a258f4 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -42,7 +42,7 @@ class Material : public Resource { GDCLASS(Material, Resource); RES_BASE_EXTENSION("material") - OBJ_SAVE_TYPE(Material) + OBJ_SAVE_TYPE(Material); RID material; Ref next_pass; diff --git a/scene/resources/texture.h b/scene/resources/texture.h index fcd8547d077..fa698d387b8 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -45,7 +45,8 @@ class Texture : public Resource { GDCLASS(Texture, Resource); - OBJ_SAVE_TYPE(Texture); //children are all saved as Texture, so they can be exchanged + OBJ_SAVE_TYPE(Texture); // Saves derived classes with common type so they can be interchanged. + protected: static void _bind_methods(); diff --git a/scene/resources/video_stream.cpp b/scene/resources/video_stream.cpp deleted file mode 100644 index 81b4477c9a7..00000000000 --- a/scene/resources/video_stream.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************/ -/* video_stream.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "video_stream.h" - -void VideoStreamPlayback::_bind_methods(){ - -}; - -VideoStreamPlayback::VideoStreamPlayback(){ - -}; diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h index d8aee2eac3d..444bb698aee 100644 --- a/scene/resources/video_stream.h +++ b/scene/resources/video_stream.h @@ -37,9 +37,6 @@ class VideoStreamPlayback : public Resource { GDCLASS(VideoStreamPlayback, Resource); -protected: - static void _bind_methods(); - public: typedef int (*AudioMixCallback)(void *p_udata, const float *p_data, int p_frames); @@ -61,28 +58,22 @@ public: virtual void set_audio_track(int p_idx) = 0; - //virtual int mix(int16_t* p_buffer,int p_frames)=0; - virtual Ref get_texture() const = 0; virtual void update(float p_delta) = 0; virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata) = 0; virtual int get_channels() const = 0; virtual int get_mix_rate() const = 0; - - VideoStreamPlayback(); }; class VideoStream : public Resource { GDCLASS(VideoStream, Resource); - OBJ_SAVE_TYPE(VideoStream); //children are all saved as AudioStream, so they can be exchanged + OBJ_SAVE_TYPE(VideoStream); // Saves derived classes with common type so they can be interchanged. public: virtual void set_audio_track(int p_track) = 0; virtual Ref instance_playback() = 0; - - VideoStream() {} }; #endif diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index 58742c82d42..a58e4eb9664 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "audio_stream.h" + #include "core/os/os.h" #include "core/project_settings.h" diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h index 6d62eabec13..155b683d7da 100644 --- a/servers/audio/audio_stream.h +++ b/servers/audio/audio_stream.h @@ -82,7 +82,7 @@ public: class AudioStream : public Resource { GDCLASS(AudioStream, Resource); - OBJ_SAVE_TYPE(AudioStream) //children are all saved as AudioStream, so they can be exchanged + OBJ_SAVE_TYPE(AudioStream); // Saves derived classes with common type so they can be interchanged. protected: static void _bind_methods();