| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "scene/gui/control.h" |
| 34 |
#include "scene/resources/video_stream.h" |
| 35 |
#include "servers/audio/audio_rb_resampler.h" |
| 36 |
|
| 37 |
class VideoStreamPlayer : public Control { |
| 38 |
GDCLASS(VideoStreamPlayer, Control); |
| 39 |
|
| 40 |
Ref<VideoStreamPlayback> playback; |
| 41 |
Ref<VideoStream> stream; |
| 42 |
|
| 43 |
int sp_get_channel_count() const; |
| 44 |
bool mix(AudioFrame *p_buffer, int p_frames); |
| 45 |
|
| 46 |
Ref<Texture2D> texture; |
| 47 |
Size2 texture_size; |
| 48 |
void texture_changed(const Ref<Texture2D> &p_texture); |
| 49 |
|
| 50 |
AudioRBResampler resampler; |
| 51 |
Vector<AudioFrame> mix_buffer; |
| 52 |
int wait_resampler = 0; |
| 53 |
int wait_resampler_limit = 2; |
| 54 |
|
| 55 |
bool paused = false; |
| 56 |
bool paused_from_tree = false; |
| 57 |
bool autoplay = false; |
| 58 |
float volume = 1.0; |
| 59 |
float speed_scale = 1.0; |
| 60 |
bool expand = false; |
| 61 |
bool loop = false; |
| 62 |
bool first_frame = false; |
| 63 |
int buffering_ms = 500; |
| 64 |
int audio_track = 0; |
| 65 |
int bus_index = 0; |
| 66 |
|
| 67 |
StringName bus; |
| 68 |
|
| 69 |
void _mix_audio(); |
| 70 |
static int _audio_mix_callback(void *p_udata, const float *p_data, int p_frames); |
| 71 |
static void _mix_audios(void *p_self); |
| 72 |
|
| 73 |
protected: |
| 74 |
static void _bind_methods(); |
| 75 |
void _notification(int p_notification); |
| 76 |
void _validate_property(PropertyInfo &p_property) const; |
| 77 |
|
| 78 |
public: |
| 79 |
Size2 get_minimum_size() const override; |
| 80 |
void set_expand(bool p_expand); |
| 81 |
bool has_expand() const; |
| 82 |
|
| 83 |
Ref<Texture2D> get_video_texture() const; |
| 84 |
|
| 85 |
void set_stream(const Ref<VideoStream> &p_stream); |
| 86 |
Ref<VideoStream> get_stream() const; |
| 87 |
|
| 88 |
void play(); |
| 89 |
void stop(); |
| 90 |
bool is_playing() const; |
| 91 |
|
| 92 |
void set_loop(bool p_loop); |
| 93 |
bool has_loop() const; |
| 94 |
|
| 95 |
void set_paused(bool p_paused); |
| 96 |
bool is_paused() const; |
| 97 |
|
| 98 |
void set_volume(float p_vol); |
| 99 |
float get_volume() const; |
| 100 |
|
| 101 |
void set_volume_db(float p_db); |
| 102 |
float get_volume_db() const; |
| 103 |
|
| 104 |
void set_speed_scale(float p_speed_scale); |
| 105 |
float get_speed_scale() const; |
| 106 |
|
| 107 |
String get_stream_name() const; |
| 108 |
double get_stream_length() const; |
| 109 |
double get_stream_position() const; |
| 110 |
void set_stream_position(double p_position); |
| 111 |
|
| 112 |
void set_autoplay(bool p_enable); |
| 113 |
bool has_autoplay() const; |
| 114 |
|
| 115 |
void set_audio_track(int p_track); |
| 116 |
int get_audio_track() const; |
| 117 |
|
| 118 |
void set_buffering_msec(int p_msec); |
| 119 |
int get_buffering_msec() const; |
| 120 |
|
| 121 |
void set_bus(const StringName &p_bus); |
| 122 |
StringName get_bus() const; |
| 123 |
|
| 124 |
~VideoStreamPlayer(); |
| 125 |
}; |