File: old-vdev.h

package info (click to toggle)
camstream 0.27%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 12,320 kB
  • ctags: 5,393
  • sloc: cpp: 17,031; sh: 8,154; asm: 455; ansic: 440; makefile: 343
file content (153 lines) | stat: -rw-r--r-- 3,823 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#ifndef VIDEO_DEVICE_HPP
#define VIDEO_DEVICE_HPP

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <sys/types.h>
#include <linux/videodev.h>

#include <qarray.h>
#include <qcolor.h>
#include <qimage.h>
#include <qobject.h>
#include <qsocketnotifier.h>
#include <qtimer.h>
#include <qvector.h>

#include "VideoDeviceInput.h"
#include "VideoAudioInput.h"

class CVideoDevice: public QObject
{
friend class CVideoDeviceInput;
friend class CVideoDeviceTuner;
friend class CVideoAudioInput;
   Q_OBJECT
private:
   bool validated;
   QString NodeName, IntfName;
   int CamFD, Opened;
   bool UseSelect, HasFramerate;
   int Capturing;
   int Palette, FrameRate;
   int PalRGB, PalYUV;
   struct video_picture VPic;
   int Buffers, CurBuffer;
   bool m_IsMutable;

   QVector <CVideoDeviceInput>VideoInputs;
   int CurrentVideoInput;
   QVector <CVideoAudioInput>AudioInputs;
   int CurrentAudioInput;

   QVector<QImage> RGB;
   QVector<QImage> Y, U, V;
   QImage *pNullImage;
   QRgb GrayScale[256];

   int image_w, image_h;
   int max_w, max_h;
   int min_w, min_h;
   uchar *vid_io_buffer;		// The buffer used for I/O; this can be mmap()ed or malloc()ed
   uchar *rgb_vid_buffer;		// The buffer for rgb images; may point to vid_io_buffer
   uchar *yuv_vid_buffer;		// The buffer for yuv images; may point to vid_io_buffer
   QArray<int> vid_io_offsets, rgb_vid_offsets, yuv_vid_offsets;
   int vid_io_buffer_size, vid_io_image_size;

   QSocketNotifier *pImageSocket;
   QTimer *pImageTimer;

   void Init();
   void CleanUp();

   bool TryPalette(int pal, int depth);
   void SetPalette();
   void CalcVidIoSize();
   
   int MCapture(int buf);
   int MSync();

   void CreateImagesRGB();
   void ResetImagesRGB();
   void CreateImagesYUV();
   void ResetImagesYUV();
   
   void StartCapture();
   void StopCapture();

private slots:
   void LoadImage();

public:
   CVideoDevice(const QString &node_name);
   ~CVideoDevice();

   bool IsValid();

   int Open(int buffers = 1);
   void Close();
   int GetDescriptor() const;
   
   void EnableRGB(bool isOn);
   void EnableYUV(bool isOn);

   QString GetNodeName() const;
   QString GetIntfName() const;
   
   QSize GetMinSize() const;
   QSize GetSize();
   QSize GetMaxSize() const;
   bool  SetSize(int width, int height);
   bool  SetSize(const QSize &new_size);
   int   GetFramerate() const;
   bool  SetFramerate(int fps);
   int   GetMBuffers() const;
   int   GetBuffers() const;

   int   GetVideoInputs() const;
   int   GetCurrentVideoInput() const;
   CVideoDeviceInput *GetVideoInput(int number = -1) const;
   bool  SelectVideoInput(int number);
   
   int   GetAudioInputs() const;
   CVideoAudioInput *GetAudioInput(int number = -1) const;
   bool  SelectAudioInput(int number);
   
   int GetBrightness() const;
   bool SetBrightness(int val);
   int GetContrast() const;
   bool SetContrast(int val);
   int GetHue() const;
   bool SetHue(int val);
   int GetColour() const;
   bool SetColour(int val);
   int GetWhiteness() const;
   bool SetWhiteness(int val);
   
   int ReadImage();

   QImage *GetRGB(int offset = 0) const;
   QImage *GetY(int offset = 0) const;
   QImage *GetU(int offset = 0) const;
   QImage *GetV(int offset = 0) const;

signals:   
   /** A new image is available. */
   void Notify();
   /** The device is being closed by the last user; the device is not accessible */
   void Closed();
   /** The size has been changed. */
   void Resized(const QSize &new_size);
   /** The frame rate has been changed. */
   void FramerateChanged(int);
   /** The video input channel has changed. */
   void ChangedVideoInput(int input);
   /** The frequency or norm changed. */
   void ChangedTunerNorm(int tuner, int norm);
   /** An error occured. err_num is one of the errno values. */
   void Error(int err_num);
};

#endif