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 "videodev.h" // video4linux
|
---|
11 | #endif
|
---|
12 | #endif
|
---|
13 |
|
---|
14 | class MVideo
|
---|
15 | {
|
---|
16 | private:
|
---|
17 | TString fPath; // Device path
|
---|
18 |
|
---|
19 | int fFileDesc; // File descriptor
|
---|
20 |
|
---|
21 | char *fMapBuffer;
|
---|
22 |
|
---|
23 | protected:
|
---|
24 | struct video_capability fCaps; // Device capabilities
|
---|
25 | struct video_channel fChannel; // Channel information
|
---|
26 | struct video_mbuf fBuffer; // Buffer information
|
---|
27 | struct video_picture fProp; // Picture properties
|
---|
28 |
|
---|
29 | private:
|
---|
30 | int Ioctl(int req, void *opt, bool allowirq=true) const;
|
---|
31 |
|
---|
32 | void Reset();
|
---|
33 |
|
---|
34 | Bool_t GetCapabilities();
|
---|
35 | Bool_t GetProperties();
|
---|
36 | Bool_t Init(Int_t channel);
|
---|
37 |
|
---|
38 | // Conversion functions
|
---|
39 | TString GetDevType(int type) const;
|
---|
40 | TString GetChannelFlags(Int_t flags) const;
|
---|
41 | TString GetChannelType(Int_t type) const;
|
---|
42 | TString GetPalette(Int_t pal) const;
|
---|
43 |
|
---|
44 | public:
|
---|
45 | MVideo(const char *path="/dev/video");
|
---|
46 | virtual ~MVideo() { Close(); }
|
---|
47 |
|
---|
48 | // Getter
|
---|
49 | Bool_t IsOpen() const { return fFileDesc>0 && fMapBuffer; }
|
---|
50 | Bool_t CanCapture() const;
|
---|
51 | Int_t GetNumBuffers() const;
|
---|
52 |
|
---|
53 | Int_t GetWidth() const;
|
---|
54 | Int_t GetHeight() const;
|
---|
55 |
|
---|
56 | // Control
|
---|
57 | Bool_t Open(Int_t channel=0);
|
---|
58 | Int_t Close();
|
---|
59 |
|
---|
60 | Bool_t SetChannel(Int_t chan);
|
---|
61 |
|
---|
62 | // Image capture
|
---|
63 | Bool_t CaptureStart(unsigned int frame) const;
|
---|
64 | Int_t CaptureWait(unsigned int frame, char **ptr) const;
|
---|
65 |
|
---|
66 | // Support
|
---|
67 | void Print() const;
|
---|
68 |
|
---|
69 | // hardware features
|
---|
70 | //void SetPicPar(int bright, int hue, int contrast);
|
---|
71 | //void GetPicPar(int *bright, int *hue, int *contrast);
|
---|
72 |
|
---|
73 | //ClassDef(MVideo, 0) // Interface to Video4Linux at a simple level
|
---|
74 |
|
---|
75 | };
|
---|
76 |
|
---|
77 | #endif
|
---|