Panda3D

ffmpegAudioCursor.h

00001 // Filename: ffmpegAudioCursor.h
00002 // Created by: jyelon (01Aug2007)
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 FFMPEGAUDIOCURSOR_H
00016 #define FFMPEGAUDIOCURSOR_H
00017 #ifdef HAVE_FFMPEG
00018 
00019 #include "pandabase.h"
00020 #include "namable.h"
00021 #include "texture.h"
00022 #include "pointerTo.h"
00023 
00024 struct AVFormatContext;
00025 struct AVCodecContext;
00026 struct AVStream;
00027 struct AVPacket;
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : FfmpegAudioCursor
00031 // Description : A stream that generates a sequence of audio samples.
00032 ////////////////////////////////////////////////////////////////////
00033 class EXPCL_PANDA_MOVIES FfmpegAudioCursor : public MovieAudioCursor {
00034   friend class FfmpegAudio;
00035 
00036 PUBLISHED:
00037   FfmpegAudioCursor(FfmpegAudio *src);
00038   virtual ~FfmpegAudioCursor();
00039   virtual void seek(double offset);
00040   
00041 public:
00042   virtual void read_samples(int n, PN_int16 *data);
00043   
00044 protected:
00045   void fetch_packet();
00046   bool reload_buffer();
00047   void cleanup();
00048   Filename _filename;
00049   int _initial_dts;
00050   AVPacket *_packet;
00051   int            _packet_size;
00052   unsigned char *_packet_data;
00053   AVFormatContext *_format_ctx;
00054   AVCodecContext  *_audio_ctx;
00055   int _audio_index;
00056   double _audio_timebase;
00057 
00058   PN_int16 *_buffer;
00059   int       _buffer_size;
00060   PN_int16 *_buffer_alloc;
00061   int       _buffer_head;
00062   int       _buffer_tail;
00063   
00064 public:
00065   static TypeHandle get_class_type() {
00066     return _type_handle;
00067   }
00068   static void init_type() {
00069     TypedWritableReferenceCount::init_type();
00070     register_type(_type_handle, "FfmpegAudioCursor",
00071                   MovieAudioCursor::get_class_type());
00072   }
00073   virtual TypeHandle get_type() const {
00074     return get_class_type();
00075   }
00076   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00077 
00078 private:
00079   static TypeHandle _type_handle;
00080 };
00081 
00082 #include "ffmpegAudioCursor.I"
00083 
00084 #endif // HAVE_FFMPEG
00085 #endif // FFMPEG_AUDIO.H
 All Classes Functions Variables Enumerations