Path: blob/master/servers/movie_writer/movie_writer.h
22851 views
/**************************************************************************/1/* movie_writer.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/io/image.h"33#include "core/templates/local_vector.h"34#include "servers/audio/audio_server.h"3536class MovieWriter : public Object {37GDCLASS(MovieWriter, Object);3839uint64_t fps = 0;40uint64_t mix_rate = 0;41uint32_t audio_channels = 0;4243// The output resolution, which can differ from the window size.44// Used as a base for resizing all subsequent frames if their resolution differs.45Vector2i movie_size;4647float cpu_time = 0.0f;48float gpu_time = 0.0f;49uint64_t encoding_time_usec = 0;5051String project_name;5253LocalVector<int32_t> audio_mix_buffer;5455enum {56MAX_WRITERS = 857};58static MovieWriter *writers[];59static uint32_t writer_count;6061protected:62virtual uint32_t get_audio_mix_rate() const;63virtual AudioServer::SpeakerMode get_audio_speaker_mode() const;6465virtual Error write_begin(const Size2i &p_movie_size, uint32_t p_fps, const String &p_base_path);66virtual Error write_frame(const Ref<Image> &p_image, const int32_t *p_audio_data);67virtual void write_end();6869GDVIRTUAL0RC_REQUIRED(uint32_t, _get_audio_mix_rate)70GDVIRTUAL0RC_REQUIRED(AudioServer::SpeakerMode, _get_audio_speaker_mode)7172GDVIRTUAL1RC_REQUIRED(bool, _handles_file, const String &)73GDVIRTUAL0RC_REQUIRED(Vector<String>, _get_supported_extensions)7475GDVIRTUAL3R_REQUIRED(Error, _write_begin, const Size2i &, uint32_t, const String &)76GDVIRTUAL2R_REQUIRED(Error, _write_frame, const Ref<Image> &, GDExtensionConstPtr<int32_t>)77GDVIRTUAL0_REQUIRED(_write_end)7879static void _bind_methods();8081public:82virtual bool handles_file(const String &p_path) const;83virtual void get_supported_extensions(List<String> *r_extensions) const;8485static void add_writer(MovieWriter *p_writer);86static MovieWriter *find_writer_for_file(const String &p_file);8788void begin(const Size2i &p_movie_size, uint32_t p_fps, const String &p_base_path);89void add_frame();9091static void set_extensions_hint();9293void end();94};959697