Home | History | Annotate | Download | only in src
      1 #ifndef __OPENCV_FFMPEG_H__
      2 #define __OPENCV_FFMPEG_H__
      3 
      4 #ifdef __cplusplus
      5 extern "C"
      6 {
      7 #endif
      8 
      9 #if defined WIN32 || defined _WIN32
     10 #   define OPENCV_FFMPEG_API __declspec(dllexport)
     11 #elif defined __GNUC__ && __GNUC__ >= 4
     12 #   define OPENCV_FFMPEG_API __attribute__ ((visibility ("default")))
     13 #else
     14 #   define OPENCV_FFMPEG_API
     15 #endif
     16 
     17 enum
     18 {
     19     CV_FFMPEG_CAP_PROP_POS_MSEC=0,
     20     CV_FFMPEG_CAP_PROP_POS_FRAMES=1,
     21     CV_FFMPEG_CAP_PROP_POS_AVI_RATIO=2,
     22     CV_FFMPEG_CAP_PROP_FRAME_WIDTH=3,
     23     CV_FFMPEG_CAP_PROP_FRAME_HEIGHT=4,
     24     CV_FFMPEG_CAP_PROP_FPS=5,
     25     CV_FFMPEG_CAP_PROP_FOURCC=6,
     26     CV_FFMPEG_CAP_PROP_FRAME_COUNT=7
     27 };
     28 
     29 
     30 OPENCV_FFMPEG_API struct CvCapture_FFMPEG* cvCreateFileCapture_FFMPEG(const char* filename);
     31 OPENCV_FFMPEG_API struct CvCapture_FFMPEG_2* cvCreateFileCapture_FFMPEG_2(const char* filename);
     32 OPENCV_FFMPEG_API int cvSetCaptureProperty_FFMPEG(struct CvCapture_FFMPEG* cap,
     33                                                   int prop, double value);
     34 OPENCV_FFMPEG_API int cvSetCaptureProperty_FFMPEG_2(struct CvCapture_FFMPEG_2* cap,
     35                                                     int prop, double value);
     36 OPENCV_FFMPEG_API double cvGetCaptureProperty_FFMPEG(struct CvCapture_FFMPEG* cap, int prop);
     37 OPENCV_FFMPEG_API double cvGetCaptureProperty_FFMPEG_2(struct CvCapture_FFMPEG_2* cap, int prop);
     38 OPENCV_FFMPEG_API int cvGrabFrame_FFMPEG(struct CvCapture_FFMPEG* cap);
     39 OPENCV_FFMPEG_API int cvGrabFrame_FFMPEG_2(struct CvCapture_FFMPEG_2* cap);
     40 OPENCV_FFMPEG_API int cvRetrieveFrame_FFMPEG(struct CvCapture_FFMPEG* capture, unsigned char** data,
     41                                              int* step, int* width, int* height, int* cn);
     42 OPENCV_FFMPEG_API int cvRetrieveFrame_FFMPEG_2(struct CvCapture_FFMPEG_2* capture, unsigned char** data,
     43                                              int* step, int* width, int* height, int* cn);
     44 OPENCV_FFMPEG_API void cvReleaseCapture_FFMPEG(struct CvCapture_FFMPEG** cap);
     45 OPENCV_FFMPEG_API void cvReleaseCapture_FFMPEG_2(struct CvCapture_FFMPEG_2** cap);
     46 OPENCV_FFMPEG_API struct CvVideoWriter_FFMPEG* cvCreateVideoWriter_FFMPEG(const char* filename,
     47             int fourcc, double fps, int width, int height, int isColor );
     48 OPENCV_FFMPEG_API struct CvVideoWriter_FFMPEG_2* cvCreateVideoWriter_FFMPEG_2(const char* filename,
     49             int fourcc, double fps, int width, int height, int isColor );
     50 
     51 OPENCV_FFMPEG_API int cvWriteFrame_FFMPEG(struct CvVideoWriter_FFMPEG* writer, const unsigned char* data,
     52                                           int step, int width, int height, int cn, int origin);
     53 
     54 OPENCV_FFMPEG_API void cvReleaseVideoWriter_FFMPEG(struct CvVideoWriter_FFMPEG** writer);
     55 
     56 typedef void* (*CvCreateFileCapture_Plugin)( const char* filename );
     57 typedef void* (*CvCreateCameraCapture_Plugin)( int index );
     58 typedef int (*CvGrabFrame_Plugin)( void* capture_handle );
     59 typedef int (*CvRetrieveFrame_Plugin)( void* capture_handle, unsigned char** data, int* step,
     60                                        int* width, int* height, int* cn );
     61 typedef int (*CvSetCaptureProperty_Plugin)( void* capture_handle, int prop_id, double value );
     62 typedef double (*CvGetCaptureProperty_Plugin)( void* capture_handle, int prop_id );
     63 typedef void (*CvReleaseCapture_Plugin)( void** capture_handle );
     64 typedef void* (*CvCreateVideoWriter_Plugin)( const char* filename, int fourcc,
     65                                              double fps, int width, int height, int iscolor );
     66 typedef int (*CvWriteFrame_Plugin)( void* writer_handle, const unsigned char* data, int step,
     67                                     int width, int height, int cn, int origin);
     68 typedef void (*CvReleaseVideoWriter_Plugin)( void** writer );
     69 
     70 /*
     71  * For CUDA encoder
     72  */
     73 
     74 OPENCV_FFMPEG_API struct OutputMediaStream_FFMPEG* create_OutputMediaStream_FFMPEG(const char* fileName, int width, int height, double fps);
     75 OPENCV_FFMPEG_API void release_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream);
     76 OPENCV_FFMPEG_API void write_OutputMediaStream_FFMPEG(struct OutputMediaStream_FFMPEG* stream, unsigned char* data, int size, int keyFrame);
     77 
     78 typedef struct OutputMediaStream_FFMPEG* (*Create_OutputMediaStream_FFMPEG_Plugin)(const char* fileName, int width, int height, double fps);
     79 typedef void (*Release_OutputMediaStream_FFMPEG_Plugin)(struct OutputMediaStream_FFMPEG* stream);
     80 typedef void (*Write_OutputMediaStream_FFMPEG_Plugin)(struct OutputMediaStream_FFMPEG* stream, unsigned char* data, int size, int keyFrame);
     81 
     82 /*
     83  * For CUDA decoder
     84  */
     85 
     86 OPENCV_FFMPEG_API struct InputMediaStream_FFMPEG* create_InputMediaStream_FFMPEG(const char* fileName, int* codec, int* chroma_format, int* width, int* height);
     87 OPENCV_FFMPEG_API void release_InputMediaStream_FFMPEG(struct InputMediaStream_FFMPEG* stream);
     88 OPENCV_FFMPEG_API int read_InputMediaStream_FFMPEG(struct InputMediaStream_FFMPEG* stream, unsigned char** data, int* size, int* endOfFile);
     89 
     90 typedef struct InputMediaStream_FFMPEG* (*Create_InputMediaStream_FFMPEG_Plugin)(const char* fileName, int* codec, int* chroma_format, int* width, int* height);
     91 typedef void (*Release_InputMediaStream_FFMPEG_Plugin)(struct InputMediaStream_FFMPEG* stream);
     92 typedef int (*Read_InputMediaStream_FFMPEG_Plugin)(struct InputMediaStream_FFMPEG* stream, unsigned char** data, int* size, int* endOfFile);
     93 
     94 #ifdef __cplusplus
     95 }
     96 #endif
     97 
     98 #endif
     99