movie_writer.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**************************************************************************/
  2. /* movie_writer.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef MOVIE_WRITER_H
  31. #define MOVIE_WRITER_H
  32. #include "core/templates/local_vector.h"
  33. #include "servers/audio/audio_driver_dummy.h"
  34. #include "servers/audio_server.h"
  35. class MovieWriter : public Object {
  36. GDCLASS(MovieWriter, Object);
  37. uint64_t fps = 0;
  38. uint64_t mix_rate = 0;
  39. uint32_t audio_channels = 0;
  40. String project_name;
  41. LocalVector<int32_t> audio_mix_buffer;
  42. enum {
  43. MAX_WRITERS = 8
  44. };
  45. static MovieWriter *writers[];
  46. static uint32_t writer_count;
  47. protected:
  48. virtual uint32_t get_audio_mix_rate() const;
  49. virtual AudioServer::SpeakerMode get_audio_speaker_mode() const;
  50. virtual Error write_begin(const Size2i &p_movie_size, uint32_t p_fps, const String &p_base_path);
  51. virtual Error write_frame(const Ref<Image> &p_image, const int32_t *p_audio_data);
  52. virtual void write_end();
  53. GDVIRTUAL0RC(uint32_t, _get_audio_mix_rate)
  54. GDVIRTUAL0RC(AudioServer::SpeakerMode, _get_audio_speaker_mode)
  55. GDVIRTUAL1RC(bool, _handles_file, const String &)
  56. GDVIRTUAL0RC(Vector<String>, _get_supported_extensions)
  57. GDVIRTUAL3R(Error, _write_begin, const Size2i &, uint32_t, const String &)
  58. GDVIRTUAL2R(Error, _write_frame, const Ref<Image> &, GDExtensionConstPtr<int32_t>)
  59. GDVIRTUAL0(_write_end)
  60. static void _bind_methods();
  61. public:
  62. virtual bool handles_file(const String &p_path) const;
  63. virtual void get_supported_extensions(List<String> *r_extensions) const;
  64. static void add_writer(MovieWriter *p_writer);
  65. static MovieWriter *find_writer_for_file(const String &p_file);
  66. void begin(const Size2i &p_movie_size, uint32_t p_fps, const String &p_base_path);
  67. void add_frame(const Ref<Image> &p_image);
  68. static void set_extensions_hint();
  69. void end();
  70. };
  71. #endif // MOVIE_WRITER_H