video_player.h
1 /*************************************************************************/
2 /* video_player.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 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 /*************************************************************************/
29 #ifndef VIDEO_PLAYER_H
30 #define VIDEO_PLAYER_H
31 
32 #include "scene/resources/video_stream.h"
33 #include "scene/gui/control.h"
34 #include "servers/audio/audio_rb_resampler.h"
35 
36 class VideoPlayer : public Control {
37 
38  OBJ_TYPE(VideoPlayer,Control);
39 
40  struct InternalStream : public AudioServer::AudioStream {
41  VideoPlayer *player;
42  virtual int get_channel_count() const;
43  virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate
44  virtual bool mix(int32_t *p_buffer,int p_frames);
45  virtual void update();
46  };
47 
48 
49  InternalStream internal_stream;
50  Ref<VideoStreamPlayback> playback;
51  Ref<VideoStream> stream;
52 
53  int sp_get_channel_count() const;
54  void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate
55  bool sp_mix(int32_t *p_buffer,int p_frames);
56  void sp_update();
57 
58 
59  RID stream_rid;
60 
61  Ref<ImageTexture> texture;
62  Image last_frame;
63 
64  AudioRBResampler resampler;
65 
66  bool paused;
67  bool autoplay;
68  float volume;
69  double last_audio_time;
70  bool expand;
71  bool loops;
72  int buffering_ms;
73  int server_mix_rate;
74  int audio_track;
75 
76  static int _audio_mix_callback(void* p_udata,const int16_t *p_data,int p_frames);
77 
78 
79 protected:
80 
81  static void _bind_methods();
82  void _notification(int p_notification);
83 
84 public:
85 
86  Size2 get_minimum_size() const;
87  void set_expand(bool p_expand);
88  bool has_expand() const;
89 
90 
91  Ref<Texture> get_video_texture();
92 
93  void set_stream(const Ref<VideoStream> &p_stream);
94  Ref<VideoStream> get_stream() const;
95 
96  void play();
97  void stop();
98  bool is_playing() const;
99 
100  void set_paused(bool p_paused);
101  bool is_paused() const;
102 
103  void set_volume(float p_vol);
104  float get_volume() const;
105 
106  void set_volume_db(float p_db);
107  float get_volume_db() const;
108 
109  String get_stream_name() const;
110  float get_stream_pos() const;
111 
112  void set_autoplay(bool p_vol);
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  VideoPlayer();
122  ~VideoPlayer();
123 };
124 
125 #endif
Definition: image.h:47
Definition: rid.h:47
Definition: math_2d.h:65
Definition: control.h:47
Definition: ustring.h:64
Definition: video_player.h:36