00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef MOVIEVIDEOCURSOR_H
00016 #define MOVIEVIDEOCURSOR_H
00017
00018 #include "pandabase.h"
00019 #include "texture.h"
00020 #include "pointerTo.h"
00021 #include "memoryBase.h"
00022 #include "pStatCollector.h"
00023 #include "deletedChain.h"
00024 #include "typedReferenceCount.h"
00025
00026 class MovieVideo;
00027 class FactoryParams;
00028 class BamWriter;
00029 class BamReader;
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 class EXPCL_PANDA_MOVIES MovieVideoCursor : public TypedWritableReferenceCount {
00046 protected:
00047 MovieVideoCursor(MovieVideo *src = NULL);
00048
00049 PUBLISHED:
00050 virtual ~MovieVideoCursor();
00051 PT(MovieVideo) get_source() const;
00052 INLINE int size_x() const;
00053 INLINE int size_y() const;
00054 INLINE int get_num_components() const;
00055 INLINE double length() const;
00056 INLINE bool can_seek() const;
00057 INLINE bool can_seek_fast() const;
00058 INLINE bool aborted() const;
00059
00060 INLINE bool ready() const;
00061 INLINE bool streaming() const;
00062 void setup_texture(Texture *tex) const;
00063
00064 virtual bool set_time(double timestamp, int loop_count);
00065
00066 class EXPCL_PANDA_MOVIES Buffer : public TypedReferenceCount {
00067 public:
00068 ALLOC_DELETED_CHAIN(Buffer);
00069 Buffer(size_t block_size);
00070
00071 PUBLISHED:
00072 virtual ~Buffer();
00073
00074 virtual int compare_timestamp(const Buffer *other) const;
00075 virtual double get_timestamp() const;
00076
00077 public:
00078 unsigned char *_block;
00079 size_t _block_size;
00080
00081 private:
00082 DeletedBufferChain *_deleted_chain;
00083
00084 public:
00085 static TypeHandle get_class_type() {
00086 return _type_handle;
00087 }
00088 static void init_type() {
00089 TypedReferenceCount::init_type();
00090 register_type(_type_handle, "MovieVideoCursor::Buffer",
00091 TypedReferenceCount::get_class_type());
00092 }
00093 virtual TypeHandle get_type() const {
00094 return get_class_type();
00095 }
00096 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00097
00098 private:
00099 static TypeHandle _type_handle;
00100 };
00101 virtual PT(Buffer) fetch_buffer();
00102
00103 virtual void apply_to_texture(const Buffer *buffer, Texture *t, int page);
00104 virtual void apply_to_texture_rgb(const Buffer *buffer, Texture *t, int page);
00105 virtual void apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src);
00106
00107 protected:
00108 Buffer *get_standard_buffer();
00109 virtual PT(Buffer) make_new_buffer();
00110
00111 protected:
00112 PT(MovieVideo) _source;
00113 int _size_x;
00114 int _size_y;
00115 int _num_components;
00116 double _length;
00117 bool _can_seek;
00118 bool _can_seek_fast;
00119 bool _aborted;
00120 bool _streaming;
00121 bool _ready;
00122
00123 PT(Buffer) _standard_buffer;
00124
00125 static PStatCollector _copy_pcollector;
00126 static PStatCollector _copy_pcollector_ram;
00127 static PStatCollector _copy_pcollector_copy;
00128
00129 public:
00130 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00131 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
00132
00133 protected:
00134 void fillin(DatagramIterator &scan, BamReader *manager);
00135
00136 public:
00137 static TypeHandle get_class_type() {
00138 return _type_handle;
00139 }
00140 static void init_type() {
00141 TypedWritableReferenceCount::init_type();
00142 register_type(_type_handle, "MovieVideoCursor",
00143 TypedWritableReferenceCount::get_class_type());
00144 Buffer::init_type();
00145 }
00146 virtual TypeHandle get_type() const {
00147 return get_class_type();
00148 }
00149 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00150
00151 private:
00152 static TypeHandle _type_handle;
00153 };
00154
00155 #include "movieVideoCursor.I"
00156 #include "movieVideo.h"
00157
00158 #endif