| 1 | #ifndef MARS_MVideo
|
|---|
| 2 | #define MARS_MVideo
|
|---|
| 3 |
|
|---|
| 4 | #ifndef MAGIC_MAGIC
|
|---|
| 5 | #include "MAGIC.h"
|
|---|
| 6 | #endif
|
|---|
| 7 |
|
|---|
| 8 | #ifndef __CINT__
|
|---|
| 9 | #ifndef __LINUX_VIDEODEV_H
|
|---|
| 10 | #include <linux/videodev.h> // video4linux
|
|---|
| 11 | #endif
|
|---|
| 12 | #ifndef __LINUX_VIDEODEV2_H
|
|---|
| 13 | #include <linux/videodev2.h> // video4linux2
|
|---|
| 14 | #endif
|
|---|
| 15 | #endif
|
|---|
| 16 |
|
|---|
| 17 | struct v4l2_queryctrl;
|
|---|
| 18 | class TEnv;
|
|---|
| 19 |
|
|---|
| 20 | class MVideoCtrl : public TObject
|
|---|
| 21 | {
|
|---|
| 22 | friend class MVideo;
|
|---|
| 23 | private:
|
|---|
| 24 | UInt_t fId;
|
|---|
| 25 | //enum v4l2_ctrl_type type;
|
|---|
| 26 | TString fName;
|
|---|
| 27 | Int_t fMinimum;
|
|---|
| 28 | Int_t fMaximum;
|
|---|
| 29 | Int_t fStep;
|
|---|
| 30 | Int_t fDefault;
|
|---|
| 31 | UInt_t fFlags;
|
|---|
| 32 |
|
|---|
| 33 | UInt_t fValue;
|
|---|
| 34 |
|
|---|
| 35 | public:
|
|---|
| 36 | MVideoCtrl(const v4l2_queryctrl &ctrl);
|
|---|
| 37 | const char *GetName() const { return fName; }
|
|---|
| 38 | const char *GetTitle() const { return Form("Range=[%d;%d] Step=%d Def=%d", fMinimum, fMaximum, fStep, fDefault); }
|
|---|
| 39 |
|
|---|
| 40 | //ClassDef(MVideoCtrl, 0) // Helper class to enumare device controls
|
|---|
| 41 | };
|
|---|
| 42 |
|
|---|
| 43 | class MVideo
|
|---|
| 44 | {
|
|---|
| 45 | private:
|
|---|
| 46 | TString fPath; // Device path
|
|---|
| 47 |
|
|---|
| 48 | int fFileDesc; // File descriptor
|
|---|
| 49 |
|
|---|
| 50 | unsigned char *fMapBuffer;
|
|---|
| 51 |
|
|---|
| 52 | protected:
|
|---|
| 53 | struct video_capability fCaps; // Device capabilities
|
|---|
| 54 | struct video_channel fChannel; // Channel information
|
|---|
| 55 | struct video_mbuf fBuffer; // Buffer information
|
|---|
| 56 | struct video_picture fProp; // Picture properties
|
|---|
| 57 | struct video_tuner fAbil; // Tuner abilities
|
|---|
| 58 |
|
|---|
| 59 | ULong64_t fVideoStandard;
|
|---|
| 60 |
|
|---|
| 61 | TList fControls;
|
|---|
| 62 |
|
|---|
| 63 | private:
|
|---|
| 64 | int Ioctl(int req, void *opt, bool allowirq=true, bool force=false) const;
|
|---|
| 65 |
|
|---|
| 66 | void Reset();
|
|---|
| 67 |
|
|---|
| 68 | Bool_t EnumerateControls(UInt_t id);
|
|---|
| 69 | Bool_t EnumerateControls();
|
|---|
| 70 | Bool_t GetCapabilities();
|
|---|
| 71 | Bool_t GetProperties();
|
|---|
| 72 | Bool_t GetTunerAbilities();
|
|---|
| 73 | Bool_t GetVideoStandard();
|
|---|
| 74 | Bool_t Init(Int_t channel);
|
|---|
| 75 |
|
|---|
| 76 | // Conversion functions
|
|---|
| 77 | TString GetDevType(int type) const;
|
|---|
| 78 | TString GetChannelFlags(Int_t flags) const;
|
|---|
| 79 | TString GetChannelType(Int_t type) const;
|
|---|
| 80 | TString GetTunerFlags(Int_t type) const;
|
|---|
| 81 | TString GetTunerMode(Int_t type) const;
|
|---|
| 82 | TString GetPalette(Int_t pal) const;
|
|---|
| 83 |
|
|---|
| 84 | public:
|
|---|
| 85 | MVideo(const char *path="/dev/video");
|
|---|
| 86 | virtual ~MVideo() { Close(); }
|
|---|
| 87 |
|
|---|
| 88 | // Getter
|
|---|
| 89 | Bool_t IsOpen() const { return fFileDesc>0 && fMapBuffer; }
|
|---|
| 90 | Bool_t CanCapture() const;
|
|---|
| 91 | Bool_t HasTuner() const;
|
|---|
| 92 | Int_t GetNumBuffers() const;
|
|---|
| 93 |
|
|---|
| 94 | Int_t GetWidth() const;
|
|---|
| 95 | Int_t GetHeight() const;
|
|---|
| 96 |
|
|---|
| 97 | // Control
|
|---|
| 98 | Bool_t Open(Int_t channel=0);
|
|---|
| 99 | Int_t Close();
|
|---|
| 100 |
|
|---|
| 101 | Int_t SetChannel(Int_t chan);
|
|---|
| 102 | Bool_t ReadControl(MVideoCtrl &vctrl) const;
|
|---|
| 103 | Bool_t WriteControl(MVideoCtrl &vctrl, Int_t val) const;
|
|---|
| 104 | Bool_t SetControls(TEnv &env) const;
|
|---|
| 105 | Bool_t ResetControl(MVideoCtrl &vctrl) const;
|
|---|
| 106 | Bool_t ResetControls() const;
|
|---|
| 107 |
|
|---|
| 108 | // Image capture
|
|---|
| 109 | Bool_t CaptureStart(unsigned int frame) const;
|
|---|
| 110 | Int_t CaptureWait(unsigned int frame, unsigned char **ptr=0) const;
|
|---|
| 111 |
|
|---|
| 112 | // Support
|
|---|
| 113 | void Print() const;
|
|---|
| 114 |
|
|---|
| 115 | // hardware features
|
|---|
| 116 | //void SetPicPar(int bright, int hue, int contrast);
|
|---|
| 117 | //void GetPicPar(int *bright, int *hue, int *contrast);
|
|---|
| 118 |
|
|---|
| 119 | //ClassDef(MVideo, 0) // Interface to Video4Linux at a simple level
|
|---|
| 120 |
|
|---|
| 121 | };
|
|---|
| 122 |
|
|---|
| 123 | #endif
|
|---|