Panda3D

movieVideoCursor.h

00001 // Filename: movieVideoCursor.h
00002 // Created by: jyelon (02Jul07)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
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 class MovieVideo;
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //       Class : MovieVideoCursor
00025 // Description : A MovieVideo is actually any source that provides
00026 //               a sequence of video frames.  That could include an
00027 //               AVI file, a digital camera, or an internet TV station.
00028 //               A MovieVideoCursor is a handle that lets you read
00029 //               data sequentially from a MovieVideo.
00030 //
00031 //               Thread safety: each individual MovieVideoCursor
00032 //               must be owned and accessed by a single thread.
00033 //               It is OK for two different threads to open
00034 //               the same file at the same time, as long as they
00035 //               use separate MovieVideoCursor objects.
00036 ////////////////////////////////////////////////////////////////////
00037 class EXPCL_PANDA_MOVIES MovieVideoCursor : public TypedWritableReferenceCount {
00038 
00039  PUBLISHED:
00040   MovieVideoCursor(MovieVideo *src);
00041   virtual ~MovieVideoCursor();
00042   PT(MovieVideo) get_source() const;
00043   INLINE int size_x() const;
00044   INLINE int size_y() const;
00045   INLINE int get_num_components() const;
00046   INLINE double length() const;
00047   INLINE bool can_seek() const;
00048   INLINE bool can_seek_fast() const;
00049   INLINE bool aborted() const;
00050   INLINE double last_start() const;
00051   INLINE double next_start() const;
00052   INLINE bool ready() const;
00053   INLINE bool streaming() const;
00054   void setup_texture(Texture *tex) const;
00055   virtual void fetch_into_bitbucket(double time);
00056   virtual void fetch_into_texture(double time, Texture *t, int page);
00057   virtual void fetch_into_texture_rgb(double time, Texture *t, int page);
00058   virtual void fetch_into_texture_alpha(double time, Texture *t, int page, int alpha_src);
00059 
00060  public:
00061   virtual void fetch_into_buffer(double time, unsigned char *block, bool bgra);
00062   
00063  private:
00064   void allocate_conversion_buffer();
00065   unsigned char *_conversion_buffer;
00066   
00067  protected:
00068   PT(MovieVideo) _source;
00069   int _size_x;
00070   int _size_y;
00071   int _num_components;
00072   double _length;
00073   bool _can_seek;
00074   bool _can_seek_fast;
00075   bool _aborted;
00076   double _last_start;
00077   double _next_start;
00078   bool _streaming;
00079   bool _ready;
00080   
00081 public:
00082   static TypeHandle get_class_type() {
00083     return _type_handle;
00084   }
00085   static void init_type() {
00086     TypedWritableReferenceCount::init_type();
00087     register_type(_type_handle, "MovieVideoCursor",
00088                   TypedWritableReferenceCount::get_class_type());
00089   }
00090   virtual TypeHandle get_type() const {
00091     return get_class_type();
00092   }
00093   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00094 
00095 private:
00096   static TypeHandle _type_handle;
00097 };
00098 
00099 #include "movieVideoCursor.I"
00100 #include "movieVideo.h"
00101 
00102 #endif
 All Classes Functions Variables Enumerations