![]() |
Mixxx
|
00001 /* -*- mode:C++; indent-tabs-mode:t; tab-width:8; c-basic-offset:4; -*- */ 00002 /*************************************************************************** 00003 soundsourceffmpeg.h - ffmpeg decoder 00004 ------------------- 00005 copyright : (C) 2003 by Cedric GESTES 00006 email : goctaf@gmail.com 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef SOUNDSOURCEFFMPEG_H 00019 #define SOUNDSOURCEFFMPEG_H 00020 00021 #include <qstring.h> 00022 #include "soundsource.h" 00023 #include <ffmpeg/avcodec.h> 00024 #include <ffmpeg/avformat.h> 00025 00026 class TrackInfoObject; 00027 00028 00029 class SoundSourceFFmpeg : public SoundSource { 00030 public: 00031 SoundSourceFFmpeg(QString qFilename); 00032 ~SoundSourceFFmpeg(); 00033 long seek(long); 00034 unsigned read(unsigned long size, const SAMPLE*); 00035 inline long unsigned length(); 00036 static int ParseHeader(TrackInfoObject * ); 00037 bool readInput(); 00038 00039 protected: 00040 long ffmpeg2mixxx(long pos, const AVRational &time_base); 00041 long mixxx2ffmpeg(long pos, const AVRational &time_base); 00042 void lock(); 00043 void unlock(); 00044 00045 private: 00046 int channels; 00047 unsigned long filelength; 00048 AVFormatContext *pFormatCtx; 00049 AVInputFormat *iformat; 00050 int audioStream; 00051 AVCodecContext *pCodecCtx; 00052 AVCodec *pCodec; 00053 AVFrame *pFrame; 00054 AVPacket packet; 00055 00056 volatile int bufferOffset; 00057 volatile int bufferSize; 00058 SAMPLE buffer[AVCODEC_MAX_AUDIO_FRAME_SIZE]; 00059 }; 00060 00061 #endif