Panda3D
 All Classes Functions Variables Enumerations
movieAudioCursor.h
00001 // Filename: movieAudioCursor.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 MOVIEAUDIOCURSOR_H
00016 #define MOVIEAUDIOCURSOR_H
00017 
00018 #include "pandabase.h"
00019 #include "namable.h"
00020 #include "texture.h"
00021 #include "pointerTo.h"
00022 class MovieAudio;
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //       Class : MovieAudioCursor
00026 // Description : A MovieAudio is actually any source that provides
00027 //               a sequence of audio samples.  That could include an
00028 //               AVI file, a microphone, or an internet TV station.
00029 //               A MovieAudioCursor is a handle that lets you read
00030 //               data sequentially from a MovieAudio.
00031 //
00032 //               Thread safety: each individual MovieAudioCursor
00033 //               must be owned and accessed by a single thread.
00034 //               It is OK for two different threads to open
00035 //               the same file at the same time, as long as they
00036 //               use separate MovieAudioCursor objects.
00037 ////////////////////////////////////////////////////////////////////
00038 class EXPCL_PANDA_MOVIES MovieAudioCursor : public TypedWritableReferenceCount {
00039 
00040 PUBLISHED:
00041   MovieAudioCursor(MovieAudio *src);
00042   virtual ~MovieAudioCursor();
00043   INLINE PT(MovieAudio) get_source() const;
00044   INLINE int audio_rate() const;
00045   INLINE int audio_channels() const;
00046   INLINE double length() const;
00047   INLINE bool can_seek() const;
00048   INLINE bool can_seek_fast() const;
00049   INLINE double tell() const;
00050   INLINE void skip_samples(int n);
00051   INLINE bool aborted() const;
00052   virtual int ready() const;
00053   virtual void seek(double offset);
00054   void read_samples(int n, Datagram *dg);
00055   string read_samples(int n);
00056 
00057 public:
00058   virtual void read_samples(int n, PN_int16 *data);
00059 
00060 protected:
00061   PT(MovieAudio) _source;
00062   int _audio_rate;
00063   int _audio_channels;
00064   double _length;
00065   bool _can_seek;
00066   bool _can_seek_fast;
00067   bool _aborted;
00068   double _last_seek;
00069   PN_int64 _samples_read;
00070   
00071 public:
00072   static TypeHandle get_class_type() {
00073     return _type_handle;
00074   }
00075   static void init_type() {
00076     TypedWritableReferenceCount::init_type();
00077     register_type(_type_handle, "MovieAudioCursor",
00078                   TypedWritableReferenceCount::get_class_type());
00079   }
00080   virtual TypeHandle get_type() const {
00081     return get_class_type();
00082   }
00083   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00084 
00085 private:
00086   static TypeHandle _type_handle;
00087 };
00088 
00089 #include "movieAudioCursor.I"
00090 #include "movieAudio.h"
00091 
00092 #endif
 All Classes Functions Variables Enumerations