Debian Codegraph @

scene/resources/video_stream.h

raw symbols SCIP
1 /**************************************************************************/
2 /* video_stream.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
31 #pragma once
32
33 #include "scene/resources/texture.h"
34
35 class VideoStreamPlayback : public Resource {
36 GDCLASS(VideoStreamPlayback, Resource);
37
38 public:
39 typedef int (*AudioMixCallback)(void *p_udata, const float *p_data, int p_frames);
40
41 protected:
42 AudioMixCallback mix_callback = nullptr;
43 void *mix_udata = nullptr;
44 mutable int _channel_count = 0; // Used only to assist with bounds checking in mix_audio.
45
46 static void _bind_methods();
47 GDVIRTUAL0(_stop);
48 GDVIRTUAL0(_play);
49 GDVIRTUAL0RC(bool, _is_playing);
50 GDVIRTUAL1(_set_paused, bool);
51 GDVIRTUAL0RC(bool, _is_paused);
52 GDVIRTUAL0RC(double, _get_length);
53 GDVIRTUAL0RC(double, _get_playback_position);
54 GDVIRTUAL1(_seek, double);
55 GDVIRTUAL1(_set_audio_track, int);
56 GDVIRTUAL0RC(Ref<Texture2D>, _get_texture);
57 GDVIRTUAL1_REQUIRED(_update, double);
58 GDVIRTUAL0RC(int, _get_channels);
59 GDVIRTUAL0RC(int, _get_mix_rate);
60
61 int mix_audio(int num_frames, PackedFloat32Array buffer = {}, int offset = 0);
62
63 public:
64 VideoStreamPlayback();
65 virtual ~VideoStreamPlayback();
66
67 virtual void stop();
68 virtual void play();
69
70 virtual bool is_playing() const;
71
72 virtual void set_paused(bool p_paused);
73 virtual bool is_paused() const;
74
75 virtual double get_length() const;
76
77 virtual double get_playback_position() const;
78 virtual void seek(double p_time);
79
80 virtual void set_audio_track(int p_idx);
81
82 virtual Ref<Texture2D> get_texture() const;
83 virtual void update(double p_delta);
84
85 virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata);
86 virtual int get_channels() const;
87 virtual int get_mix_rate() const;
88 };
89
90 class VideoStream : public Resource {
91 GDCLASS(VideoStream, Resource);
92 OBJ_SAVE_TYPE(VideoStream);
93
94 protected:
95 static void _bind_methods();
96
97 GDVIRTUAL0R_REQUIRED(Ref<VideoStreamPlayback>, _instantiate_playback);
98
99 String file;
100 int audio_track = 0;
101
102 public:
103 void set_file(const String &p_file);
104 String get_file();
105
106 virtual void set_audio_track(int p_track);
107 virtual Ref<VideoStreamPlayback> instantiate_playback();
108
109 VideoStream();
110 ~VideoStream();
111 };