ffmpeg.h
Go to the documentation of this file.
00001 /* This file is part of the Pangolin Project.
00002  * http://github.com/stevenlovegrove/Pangolin
00003  *
00004  * Copyright (c) 2011 Steven Lovegrove
00005  *
00006  * Permission is hereby granted, free of charge, to any person
00007  * obtaining a copy of this software and associated documentation
00008  * files (the "Software"), to deal in the Software without
00009  * restriction, including without limitation the rights to use,
00010  * copy, modify, merge, publish, distribute, sublicense, and/or sell
00011  * copies of the Software, and to permit persons to whom the
00012  * Software is furnished to do so, subject to the following
00013  * conditions:
00014  *
00015  * The above copyright notice and this permission notice shall be
00016  * included in all copies or substantial portions of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00019  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00020  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00021  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00022  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00023  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00024  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00025  * OTHER DEALINGS IN THE SOFTWARE.
00026  */
00027 
00028 #ifndef PANGOLIN_FFMPEG_H
00029 #define PANGOLIN_FFMPEG_H
00030 
00031 #include <pangolin/pangolin.h>
00032 #include <pangolin/video.h>
00033 
00034 extern "C"
00035 {
00036 
00037 // HACK for some versions of FFMPEG
00038 #ifndef INT64_C
00039 #define INT64_C(c) (c ## LL)
00040 #define UINT64_C(c) (c ## ULL)
00041 #endif
00042 
00043 #include <avformat.h>
00044 #include <swscale.h>
00045 #include <pixdesc.h>
00046 }
00047 
00048 namespace pangolin
00049 {
00050 
00051 class FfmpegVideo : public VideoInterface
00052 {
00053 public:
00054     FfmpegVideo(const std::string filename, const std::string fmtout = "RGB24", const std::string codec_hint = "", bool dump_info = false, int user_video_stream = -1);
00055     ~FfmpegVideo();
00056 
00058     void Start();
00059 
00061     void Stop();
00062 
00063     unsigned Width() const;
00064 
00065     unsigned Height() const;
00066 
00067     size_t SizeBytes() const;
00068 
00069     std::string PixFormat() const;
00070 
00071     bool GrabNext( unsigned char* image, bool wait = true );
00072 
00073     bool GrabNewest( unsigned char* image, bool wait = true );
00074 
00075 protected:
00076     void InitUrl(const std::string filename, const std::string fmtout = "RGB24", const std::string codec_hint = "", bool dump_info = false , int user_video_stream = -1);
00077 
00078     SwsContext      *img_convert_ctx;
00079     AVFormatContext *pFormatCtx;
00080     int             videoStream;
00081     int             audioStream;
00082     AVCodecContext  *pVidCodecCtx;
00083     AVCodecContext  *pAudCodecCtx;
00084     AVCodec         *pVidCodec;
00085     AVCodec         *pAudCodec;
00086     AVFrame         *pFrame;
00087     AVFrame         *pFrameOut;
00088     AVPacket        packet;
00089     int             numBytesOut;
00090     uint8_t         *buffer;
00091     PixelFormat     fmtout;
00092 };
00093 
00094 enum FfmpegMethod
00095 {
00096     FFMPEG_FAST_BILINEAR =    1,
00097     FFMPEG_BILINEAR      =    2,
00098     FFMPEG_BICUBIC       =    4,
00099     FFMPEG_X             =    8,
00100     FFMPEG_POINT         = 0x10,
00101     FFMPEG_AREA          = 0x20,
00102     FFMPEG_BICUBLIN      = 0x40,
00103     FFMPEG_GAUSS         = 0x80,
00104     FFMPEG_SINC          =0x100,
00105     FFMPEG_LANCZOS       =0x200,
00106     FFMPEG_SPLINE        =0x400
00107 };
00108 
00109 class FfmpegConverter : public VideoInterface
00110 {
00111 public:
00112     FfmpegConverter(VideoInterface* videoin, const std::string pixelfmtout = "RGB24", FfmpegMethod method = FFMPEG_POINT);
00113     ~FfmpegConverter();
00114 
00115     void Start();
00116     void Stop();
00117     unsigned Width() const;
00118     unsigned Height() const;
00119     size_t SizeBytes() const;
00120     std::string PixFormat() const;
00121 
00122     bool GrabNext( unsigned char* image, bool wait = true );
00123     bool GrabNewest( unsigned char* image, bool wait = true );
00124 
00125 protected:
00126     VideoInterface* videoin;
00127     SwsContext *img_convert_ctx;
00128 
00129     PixelFormat     fmtsrc;
00130     PixelFormat     fmtdst;
00131     AVFrame*        avsrc;
00132     AVFrame*        avdst;
00133     uint8_t*        bufsrc;
00134     uint8_t*        bufdst;
00135     int             numbytessrc;
00136     int             numbytesdst;
00137     unsigned        w,h;
00138 };
00139 
00140 }
00141 
00142 #endif //PANGOLIN_FFMPEG_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


pangolin_wrapper
Author(s): Todor Stoyanov
autogenerated on Wed Feb 13 2013 14:03:25