Go to the documentation of this file.00001 #ifndef ffmpegServer_H
00002 #define ffmpegServer_H
00003
00004 #include <epicsTypes.h>
00005 #include <asynStandardInterfaces.h>
00006
00007 #include "NDPluginDriver.h"
00008
00009
00010 #ifndef __STDC_CONSTANT_MACROS
00011 #define __STDC_CONSTANT_MACROS
00012 #endif
00013 extern "C" {
00014 #include "nullhttpd.h"
00015 }
00016 #include "ffmpegCommon.h"
00017
00018
00020 #define MAX_FFMPEG_STREAMS 64
00021
00022 #define ffmpegServerQualityString "FFMPEG_QUALITY"
00023 #define ffmpegServerFalseColString "FFMPEG_FALSE_COL"
00024 #define ffmpegServerHttpPortString "FFMPEG_HTTP_PORT"
00025 #define ffmpegServerHostString "FFMPEG_HOST"
00026 #define ffmpegServerJpgUrlString "FFMPEG_JPG_URL"
00027 #define ffmpegServerMjpgUrlString "FFMPEG_MJPG_URL"
00028 #define ffmpegServerClientsString "FFMPEG_CLIENTS"
00029 #define ffmpegServerAlwaysOnString "FFMPEG_ALWAYS_ON"
00030 #define ffmpegServerMaxWString "FFMPEG_MAXW"
00031 #define ffmpegServerMaxHString "FFMPEG_MAXH"
00032
00034 class ffmpegStream : public NDPluginDriver {
00035 public:
00036 ffmpegStream(const char *portName, int queueSize, int blockingCallbacks,
00037 const char *NDArrayPort, int NDArrayAddr, int maxBuffers, int maxMemory,
00038 int priority, int stackSize);
00039
00040 void processCallbacks(NDArray *pArray);
00041
00042 int send_frame(int sid, NDArray *pArray);
00043 void send_stream(int sid);
00044 void send_snapshot(int sid, int index);
00045
00046 protected:
00047 int ffmpegServerQuality;
00048 #define FIRST_FFMPEG_SERVER_PARAM ffmpegServerQuality
00049 int ffmpegServerFalseCol;
00050 int ffmpegServerHttpPort;
00051 int ffmpegServerHost;
00052 int ffmpegServerJpgUrl;
00053 int ffmpegServerMjpgUrl;
00054 int ffmpegServerClients;
00055 int ffmpegServerMaxW;
00056 int ffmpegServerMaxH;
00057 int ffmpegServerAlwaysOn;
00058 #define LAST_FFMPEG_SERVER_PARAM ffmpegServerAlwaysOn
00059
00060 private:
00061 NDArray *scArray;
00062 NDArray *jpeg;
00063 int nclients;
00064
00065 AVCodec *codec;
00066 AVCodecContext *c;
00067 AVFrame *inPicture;
00068 AVFrame *scPicture;
00069 struct SwsContext *ctx;
00070
00071
00072 pthread_cond_t *cond;
00073 pthread_mutex_t mutex;
00074
00075 NDArray* get_jpeg();
00076 NDArray* wait_for_jpeg(int sid);
00077 void allocScArray(size_t size);
00078 };
00079 #define NUM_FFMPEG_SERVER_PARAMS (&LAST_FFMPEG_SERVER_PARAM - &FIRST_FFMPEG_SERVER_PARAM + 1)
00080
00081
00082 static ffmpegStream **streams;
00083 static int nstreams;
00084
00085 #endif
00086