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