RTSPGrabber.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef RTSPGrabber_H_DEFINED
00039 #define RTSPGrabber_H_DEFINED
00040
00041
00042 #include "Component/ModelParam.H"
00043 #include "Image/Dims.H"
00044 #include "Transport/FrameIstream.H"
00045 #include "Util/Types.H"
00046 #include "Video/VideoFormat.H"
00047 #include "Video/VideoFrame.H"
00048 #include "Media/FfmpegDecoder.H"
00049 #include <pthread.h>
00050
00051 #ifdef INVT_HAVE_LIVEMEDIA
00052 #include <liveMedia/liveMedia.hh>
00053 #include <BasicUsageEnvironment/BasicUsageEnvironment.hh>
00054 #include <UsageEnvironment/UsageEnvironment.hh>
00055 #endif
00056
00057 #ifdef HAVE_FFMPEG_AVCODEC_H
00058 extern "C"
00059 {
00060 #include <ffmpeg/avcodec.h>
00061 #include <ffmpeg/avformat.h>
00062 }
00063 #endif
00064
00065 #ifdef HAVE_LIBAVCODEC_AVCODEC_H
00066 extern "C"
00067 {
00068 #include <libavcodec/avcodec.h>
00069 #include <libavformat/avformat.h>
00070 }
00071 #endif
00072
00073 class VideoFrame;
00074
00075 template <class T> class PixRGB;
00076 template <class T> class Image;
00077
00078 class RTSPGrabber : public FrameIstream
00079 {
00080 public:
00081
00082 RTSPGrabber(OptionManager& mgr,
00083 const std::string& descrName="RTSP Frame Grabber Driver",
00084 const std::string& tagName = "RTSPFrameGrabber",
00085 const ParamFlag flags = USE_MY_VAL,
00086 unsigned int bufferSize = 200000);
00087
00088
00089 virtual ~RTSPGrabber();
00090
00091
00092 virtual GenericFrameSpec peekFrameSpec();
00093
00094
00095 virtual SimTime getNaturalFrameTime() const;
00096
00097
00098
00099
00100 virtual GenericFrame readFrame();
00101
00102
00103 virtual void setConfigInfo(const std::string& url);
00104
00105
00106 unsigned int getFrameBufferSize() { return itsFrameBufferSize; }
00107
00108
00109 char blockingFlag;
00110
00111 unsigned int itsFrameSize;
00112
00113
00114 void run();
00115 protected:
00116
00117
00118 VideoFrame grabRaw();
00119
00120
00121 virtual void start1();
00122
00123
00124 virtual void stop2();
00125
00126
00127 void createDecoder();
00128
00129
00130 private:
00131 virtual void paramChanged(ModelParamBase* const param,
00132 const bool valueChanged,
00133 ParamClient::ChangeStatus* status);
00134
00135 void shutdown();
00136
00137
00138 OModelParam<Dims> itsDims;
00139
00140
00141
00142
00143
00144
00145 OModelParam<VideoFormat> itsGrabMode;
00146
00147
00148 OModelParam<bool> itsByteSwap;
00149
00150
00151 OModelParam<int> itsWhiteBalTarR;
00152 OModelParam<int> itsWhiteBalTarG;
00153 OModelParam<int> itsWhiteBalTarB;
00154 OModelParam<int> itsWhiteBalRefR;
00155 OModelParam<int> itsWhiteBalRefG;
00156 OModelParam<int> itsWhiteBalRefB;
00157
00158
00159 OModelParam<float> itsFPS;
00160
00161
00162 int itsBitDepth;
00163
00164
00165 std::string itsURL;
00166
00167 unsigned int itsFrameBufferSize;
00168 unsigned char *itsFrameBuffer;
00169
00170 #ifdef INVT_HAVE_LIVEMEDIA
00171 UsageEnvironment* itsEnv;
00172 Medium* itsClient;
00173 RTSPClient* itsRTSPClient;
00174 MediaSession* itsSession;
00175 FramedSource* itsFramedSource;
00176 #endif
00177
00178 #ifdef INVT_HAVE_AVCODEC
00179 AVFormatContext* itsFormatContext;
00180 AVCodecContext* itsCodecContext;
00181 AVFrame itsPicture;
00182 int itsGotPicture;
00183 VideoFrame itsCurrentFrame;
00184 #endif
00185
00186 pthread_t itsRunThread;
00187 pthread_mutex_t itsLock;
00188 bool itsThreadRunning;
00189
00190
00191 };
00192
00193 #endif
00194
00195
00196
00197
00198
00199