video_stream_theora.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef VIDEO_STREAM_THEORA_H
  2. #define VIDEO_STREAM_THEORA_H
  3. #ifdef THEORA_ENABLED
  4. #include "theora/theoradec.h"
  5. #include "vorbis/codec.h"
  6. #include "os/file_access.h"
  7. #include "io/resource_loader.h"
  8. #include "scene/resources/video_stream.h"
  9. class VideoStreamTheora : public VideoStream {
  10. OBJ_TYPE(VideoStreamTheora, VideoStream);
  11. enum {
  12. MAX_FRAMES = 4,
  13. };
  14. //Image frames[MAX_FRAMES];
  15. Image::Format format;
  16. DVector<uint8_t> frame_data;
  17. int frames_pending;
  18. FileAccess* file;
  19. String file_name;
  20. int audio_frames_wrote;
  21. Point2i size;
  22. int buffer_data();
  23. int queue_page(ogg_page *page);
  24. void video_write(void);
  25. float get_time() const;
  26. ogg_sync_state oy;
  27. ogg_page og;
  28. ogg_stream_state vo;
  29. ogg_stream_state to;
  30. th_info ti;
  31. th_comment tc;
  32. th_dec_ctx *td;
  33. vorbis_info vi;
  34. vorbis_dsp_state vd;
  35. vorbis_block vb;
  36. vorbis_comment vc;
  37. th_pixel_fmt px_fmt;
  38. double videobuf_time;
  39. int pp_inc;
  40. int theora_p;
  41. int vorbis_p;
  42. int pp_level_max;
  43. int pp_level;
  44. int videobuf_ready;
  45. bool playing;
  46. bool buffering;
  47. double last_update_time;
  48. double time;
  49. protected:
  50. virtual UpdateMode get_update_mode() const;
  51. virtual void update();
  52. void clear();
  53. virtual bool _can_mix() const;
  54. public:
  55. virtual void play();
  56. virtual void stop();
  57. virtual bool is_playing() const;
  58. virtual void set_paused(bool p_paused);
  59. virtual bool is_paused(bool p_paused) const;
  60. virtual void set_loop(bool p_enable);
  61. virtual bool has_loop() const;
  62. virtual float get_length() const;
  63. virtual String get_stream_name() const;
  64. virtual int get_loop_count() const;
  65. virtual float get_pos() const;
  66. virtual void seek_pos(float p_time);
  67. void set_file(const String& p_file);
  68. int get_pending_frame_count() const;
  69. Image pop_frame();
  70. Image peek_frame() const;
  71. VideoStreamTheora();
  72. ~VideoStreamTheora();
  73. };
  74. class ResourceFormatLoaderVideoStreamTheora : public ResourceFormatLoader {
  75. public:
  76. virtual RES load(const String &p_path,const String& p_original_path="");
  77. virtual void get_recognized_extensions(List<String> *p_extensions) const;
  78. virtual bool handles_type(const String& p_type) const;
  79. virtual String get_resource_type(const String &p_path) const;
  80. };
  81. #endif
  82. #endif