annotate sv/videoio/SDL_ffmpeg.h @ 282:d9319859a4cf tip

(none)
author benoitrigolleau
date Fri, 31 Oct 2008 11:00:24 +0000
parents c946c19e6329
children
rev   line source
ivand_qmul@125 1 /*******************************************************************************
ivand_qmul@125 2 * *
ivand_qmul@125 3 * SDL_ffmpeg is a library for basic multimedia functionality. *
ivand_qmul@125 4 * SDL_ffmpeg is based on ffmpeg. *
ivand_qmul@125 5 * *
ivand_qmul@125 6 * Copyright (C) 2007 Arjan Houben *
ivand_qmul@125 7 * *
ivand_qmul@125 8 * SDL_ffmpeg is free software: you can redistribute it and/or modify *
ivand_qmul@125 9 * it under the terms of the GNU Lesser General Public License as published *
ivand_qmul@125 10 * by the Free Software Foundation, either version 3 of the License, or any *
ivand_qmul@125 11 * later version. *
ivand_qmul@125 12 * *
ivand_qmul@125 13 * This program is distributed in the hope that it will be useful, *
ivand_qmul@125 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
ivand_qmul@125 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
ivand_qmul@125 16 * GNU Lesser General Public License for more details. *
ivand_qmul@125 17 * *
ivand_qmul@125 18 * You should have received a copy of the GNU Lesser General Public License *
ivand_qmul@125 19 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
ivand_qmul@125 20 * *
ivand_qmul@125 21 *******************************************************************************/
ivand_qmul@125 22
ivand_qmul@125 23 #ifndef SDL_FFMPEG_INCLUDED
ivand_qmul@125 24 #define SDL_FFMPEG_INCLUDED
ivand_qmul@125 25 #ifdef __cplusplus
ivand_qmul@125 26 extern "C" {
ivand_qmul@125 27 #endif
ivand_qmul@125 28 #ifdef WIN32
ivand_qmul@125 29 #ifdef SDL_FFMPEG_LIBRARY
ivand_qmul@125 30 #define __STDC_LIMIT_MACROS
ivand_qmul@125 31 #define __STDC_CONSTANT_MACROS
ivand_qmul@125 32 #include "avformat.h"
ivand_qmul@125 33 #include "swscale.h"
ivand_qmul@125 34 #endif
ivand_qmul@125 35 #include "SDL_thread.h"
ivand_qmul@125 36 #include "SDL.h"
ivand_qmul@125 37
ivand_qmul@125 38 #endif
ivand_qmul@125 39
ivand_qmul@125 40 #ifdef __unix__
ivand_qmul@125 41 #include "SDL/SDL_thread.h"
ivand_qmul@125 42 #include "SDL/SDL.h"
ivand_qmul@125 43 #ifdef SDL_FFMPEG_LIBRARY
ivand_qmul@125 44 #include "ffmpeg/avformat.h"
ivand_qmul@125 45 #endif
ivand_qmul@125 46 #endif
ivand_qmul@125 47
ivand_qmul@125 48 #ifdef __cplusplus
ivand_qmul@125 49 }
ivand_qmul@125 50 #endif
ivand_qmul@125 51 #define SWS_BICUBIC 4
ivand_qmul@150 52 const int SDL_FFMPEG_MAX_BUFFERED_FRAMES = 25;
ivand_qmul@125 53 const int SDL_FFMPEG_MAX_BUFFERED_SAMPLES = 512*512;
ivand_qmul@125 54 static int sws_flags = SWS_BICUBIC;
ivand_qmul@125 55 // we pack our decoded images into bufferImage structs
ivand_qmul@125 56 typedef struct bufferImage {
ivand_qmul@125 57 // pointer to image data
ivand_qmul@125 58 SDL_Surface *img;
ivand_qmul@125 59 // timestamp of current image
ivand_qmul@125 60 int64_t timestamp;
ivand_qmul@125 61 } bufferImage;
ivand_qmul@125 62
ivand_qmul@125 63 // this is the basic stream for SDL_ffmpeg
ivand_qmul@125 64 typedef struct SDL_ffmpegStream {
ivand_qmul@125 65
ivand_qmul@125 66 // pointer to ffmpeg data, internal use only!
ivand_qmul@125 67 // points to AVCodecContext
ivand_qmul@125 68 int pixFmt;
ivand_qmul@125 69 void *_ffmpeg;
ivand_qmul@125 70
ivand_qmul@125 71 // semaphore for current stream
ivand_qmul@125 72 SDL_sem *sem;
ivand_qmul@125 73
ivand_qmul@125 74 // audio/video buffers
ivand_qmul@125 75 bufferImage **imageBuffer;
ivand_qmul@125 76 int8_t *audio;
ivand_qmul@129 77 int writeImage;
ivand_qmul@129 78 int readImage;
ivand_qmul@125 79 // userinfo
ivand_qmul@125 80 double frameRate[2];
ivand_qmul@125 81 char language[4];
ivand_qmul@125 82 int sampleRate;
ivand_qmul@125 83 int channels;
ivand_qmul@125 84 char codecName[32];
ivand_qmul@125 85 double timeBase;
ivand_qmul@125 86 uint16_t width;
ivand_qmul@125 87 uint16_t height;
ivand_qmul@125 88
ivand_qmul@125 89 // extra data for audio
ivand_qmul@125 90 int32_t size;
ivand_qmul@125 91 int id;
ivand_qmul@125 92 int64_t lastTimeStamp;
ivand_qmul@125 93 int64_t pts, hardPts;
ivand_qmul@125 94 int64_t totalBytes;
ivand_qmul@125 95
ivand_qmul@125 96 } SDL_ffmpegStream;
ivand_qmul@125 97
ivand_qmul@125 98 typedef struct SDL_ffmpegFile {
ivand_qmul@125 99
ivand_qmul@125 100 // pointer to ffmpeg data, internal use only!
ivand_qmul@125 101 // points to AVFormatContext
ivand_qmul@125 102 void *_ffmpeg;
ivand_qmul@125 103
ivand_qmul@125 104 // our streams
ivand_qmul@125 105 SDL_ffmpegStream **vs;
ivand_qmul@125 106 SDL_ffmpegStream **as;
ivand_qmul@125 107
ivand_qmul@125 108 // data used for syncing/searching
ivand_qmul@125 109 int64_t offset, videoOffset, startTime;
ivand_qmul@125 110 int pause;
ivand_qmul@125 111
ivand_qmul@125 112 // streams and data about threads
ivand_qmul@125 113 int VStreams, AStreams, videoStream, audioStream, threadActive, videoThreadActive;
ivand_qmul@125 114 SDL_Thread *threadID, *videoThread;
ivand_qmul@125 115 SDL_sem *decode;
ivand_qmul@125 116 int skipAudio;
ivand_qmul@125 117 int skipVideo;
ivand_qmul@125 118 int delay;
ivand_qmul@129 119 int64_t timer;
ivand_qmul@129 120 int64_t countFreq;
ivand_qmul@129 121 int timebase;
ivand_qmul@125 122 int64_t audioTime;
ivand_qmul@125 123 } SDL_ffmpegFile;
ivand_qmul@125 124
ivand_qmul@125 125
ivand_qmul@125 126 int SDL_ffmpegStartDecoding(SDL_ffmpegFile* file);
ivand_qmul@125 127
ivand_qmul@125 128 int SDL_ffmpegStopDecoding(SDL_ffmpegFile* file);
ivand_qmul@125 129
ivand_qmul@125 130 SDL_Surface* SDL_ffmpegGetVideo(SDL_ffmpegFile* file);
ivand_qmul@125 131
ivand_qmul@125 132 int SDL_ffmpegReleaseVideo(SDL_ffmpegFile *file, SDL_Surface *bmp);
ivand_qmul@125 133
ivand_qmul@125 134 SDL_ffmpegStream* SDL_ffmpegGetAudioStream(SDL_ffmpegFile *file, int audioID);
ivand_qmul@125 135
ivand_qmul@125 136 int SDL_ffmpegSelectAudioStream(SDL_ffmpegFile* file, int audioID);
ivand_qmul@125 137
ivand_qmul@125 138 SDL_ffmpegStream* SDL_ffmpegGetVideoStream(SDL_ffmpegFile *file, int audioID);
ivand_qmul@125 139
ivand_qmul@125 140 int SDL_ffmpegSelectVideoStream(SDL_ffmpegFile* file, int videoID);
ivand_qmul@125 141
ivand_qmul@125 142 SDL_ffmpegFile* SDL_ffmpegCreateFile();
ivand_qmul@125 143
ivand_qmul@125 144 void SDL_ffmpegFree(SDL_ffmpegFile* file);
ivand_qmul@125 145
ivand_qmul@125 146 SDL_ffmpegFile* SDL_ffmpegOpen(const char* filename);
ivand_qmul@125 147
ivand_qmul@125 148 int SDL_ffmpegDecodeThread(void* data);
ivand_qmul@125 149
ivand_qmul@125 150 int SDL_ffmpegSeek(SDL_ffmpegFile* file, int64_t timestamp);
ivand_qmul@125 151
ivand_qmul@125 152 int SDL_ffmpegSeekRelative(SDL_ffmpegFile* file, int64_t timestamp);
ivand_qmul@125 153
ivand_qmul@125 154 int SDL_ffmpegFlush(SDL_ffmpegFile *file);
ivand_qmul@125 155
ivand_qmul@125 156 int8_t* SDL_ffmpegGetAudio(SDL_ffmpegFile *file, int *len);
ivand_qmul@125 157
ivand_qmul@125 158 int SDL_ffmpegReleaseAudio(SDL_ffmpegFile *file, int len);
ivand_qmul@125 159
ivand_qmul@125 160 int64_t SDL_ffmpegGetPosition(SDL_ffmpegFile *file);
ivand_qmul@125 161
ivand_qmul@125 162 SDL_AudioSpec* SDL_ffmpegGetAudioSpec(SDL_ffmpegFile *file, int samples, void *callback);
ivand_qmul@125 163
ivand_qmul@125 164 int SDL_ffmpegGetVideoSize(SDL_ffmpegFile *file, int *w, int *h);
ivand_qmul@125 165
ivand_qmul@125 166 int64_t SDL_ffmpegGetDuration(SDL_ffmpegFile *file);
ivand_qmul@125 167
ivand_qmul@125 168 int SDL_ffmpegValidAudio(SDL_ffmpegFile *file);
ivand_qmul@125 169
ivand_qmul@125 170 int SDL_ffmpegValidVideo(SDL_ffmpegFile *file);
ivand_qmul@125 171
ivand_qmul@125 172 int SDL_ffmpegPause(SDL_ffmpegFile *file, int state);
ivand_qmul@125 173
ivand_qmul@125 174 int SDL_ffmpegGetState(SDL_ffmpegFile *file);
ivand_qmul@125 175
ivand_qmul@125 176 #endif // SDL_FFMPEG_INCLUDED