00001 00002 00003 #ifndef __MPLAYERVIDEOSOURCE_H 00004 #define __MPLAYERVIDEOSOURCE_H 00005 00006 #include <stdio.h> 00007 #include "videosource.h" 00008 #include "bidirpipe.h" 00009 00010 #define BIDIR_PIPE 00011 00016 class MPlayerVideoSource : public VideoSource { 00017 public: 00018 00019 MPlayerVideoSource(char *input_string, char *mencoder, char *options); 00020 virtual bool initialize(); 00021 virtual bool getFrame(IplImage *dst); 00022 void getSize(int &width, int &height); 00023 virtual ~MPlayerVideoSource(); 00024 virtual void start(); 00025 virtual void stop(); 00026 virtual bool isPlaying() { return playing; }; 00027 virtual const char *getStreamName() const { return input_string; } 00028 virtual const char *getStreamType() const { return "MPlayerVideoSource"; } 00029 virtual int getId(); 00030 00031 private: 00032 00033 void readInfo(); 00034 bool execPlayer(); 00035 void closePlayer(); 00036 00037 char *input_string; 00038 char *mencoder; 00039 char *mencoder_options; 00040 int frameCnt; 00041 bool playing; 00042 char pipe_dir[64]; 00043 char video_pipe[64]; 00044 char mencoder_cmd[4096]; 00045 IplImage *tmp_im; 00046 int width, height; 00047 00048 #ifdef BIDIR_PIPE 00049 bidir_pipe pipe; 00050 #endif 00051 FILE *info_pipe; 00052 int data_pipe; 00053 }; 00054 00055 class MPlayerFactory : public ParticularVSFactory { 00056 public: 00057 MPlayerFactory() { name="MPlayer"; input_string=0; mencoder=0; }; 00058 virtual void registerParameters(ParamSection *sec); 00059 virtual VideoSource *construct(); 00060 private: 00061 char *input_string; 00062 char *mencoder; 00063 char *mencoder_options; 00064 bool use; 00065 }; 00066 00067 #endif 00068