00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Kamil Pawlowski * 00003 * kamilpe@gmail.com * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00025 #ifndef _OGGDECODER_H_ 00026 #define _OGGDECODER_H_ 00027 00029 #define FILE_READ_BUFFER 4096 00030 00031 #define AUDIO_TEMP_BUFFER 4096 00032 00033 #include <fstream> 00034 #include <iostream> 00035 #include <SDL.h> 00036 #include <SDL_audio.h> 00037 #include <ogg/ogg.h> 00038 #include "audiobuffer.h" 00039 #include "codec_base.h" 00040 #include "codec_theora.h" 00041 00042 using namespace std; 00043 00045 class CStreamReader 00046 { 00047 public: 00052 virtual void read(char *buffer, int len) = 0; 00053 }; 00054 00056 class CFileStreamReader : public CStreamReader 00057 { 00058 public: 00059 virtual void read(char *buffer, int len); 00060 00062 CFileStreamReader(char *filename); 00063 CFileStreamReader(); 00064 ~CFileStreamReader(); 00065 00069 void open(char *filename); 00071 void close(); 00072 private: 00074 ifstream stream; 00076 int file_is_open; 00077 }; 00078 00079 00081 class COggDecoder 00082 { 00083 public: 00085 COggDecoder(CStreamReader *data_stream); 00086 00090 void InitStreams(); 00091 00098 int Decode(); 00099 00103 int HasData(); 00104 00105 private: 00107 ogg_sync_state ogg_state; 00109 CStreamReader *data_stream; 00110 protected: 00112 unsigned char buffer[AUDIO_TEMP_BUFFER]; 00114 int buffer_len; 00116 yuv_buffer yuv; 00118 CVideoCodec *video_codec; 00120 CAudioCodec *audio_codec; 00122 int play_video; 00124 int play_audio; 00125 00127 virtual int making_video_buffer() = 0; 00129 virtual int making_audio_buffer() = 0; 00130 00131 }; 00132 00133 #endif 00134
1.4.4