File: VideoDeviceInput.cpp

package info (click to toggle)
camstream 0.27%2Bdfsg-4
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 12,368 kB
  • ctags: 5,393
  • sloc: cpp: 17,031; sh: 8,154; asm: 455; ansic: 440; makefile: 343
file content (134 lines) | stat: -rw-r--r-- 2,752 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
/**
  \class CVideoDeviceInput
  
  Every video device has one or more inputs (called channels in the
  Video4Linux API). Each input refers to one of the physical inputs
  on the card/chip, like Tuner, Composite, S-video, etc. This class represents
  such an input.
  
  In addition, each input can have 0 or more tuners attached to it (to keep
  matters simple...). A tuner does the actual frequency and norm setting, 
  and is represented by a \ref CVideoDeviceTuner class.
*/

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

#include <stdio.h>
#include <string.h>

#include "VideoDeviceInput.h"
#include "VideoDevice.h"

/** 
  \brief Constructor
  
  In the constructor the channel information is queried and stored. It
  will also create any Tuner objects that may be needed.
*/

CVideoDeviceInput::CVideoDeviceInput(CVideoDevice *video, int channel)
{
   pVideo = video;
   Channel = channel;
   
   Type = Unknown;
   flags = 0;
   CurrentTuner = -1;

   Tuners.setAutoDelete(TRUE);
}  

/**
  \brief Return channel number.
*/
int CVideoDeviceInput::GetNumber() const
{
   return Channel;
}

/**
  \brief Return symbolic name for input.
*/
QString CVideoDeviceInput::GetName() const
{
   return Name;
}

/**
  \brief Returns whether this input has audio settings associated with it.
*/
bool CVideoDeviceInput::HasAudio() const
{
   return false;
}

/**
  \brief Return type for this input.
  
  Returns a value from the \ref InputTypes enum, either TV or Camera
*/  
int CVideoDeviceInput::GetType() const
{
   return Type;
}

/**
  \brief Return number of tuners.

  Most inputs don't have a tuner, or at most 1. Multiple tuners could
  be used for multi-norm cards (each norm having a separate tuner), but
  this hasn't happened sofar.
*/
int CVideoDeviceInput::GetTuners() const
{
   return Tuners.count();
}

/**
  \brief Get a Tuner object
  \param number The desired input (0 to GetTuners() - 1); -1 for default (current) one
*/
CVideoDeviceTuner *CVideoDeviceInput::GetTuner(int number) const
{
   if (number == -1) {
     if (CurrentTuner < 0)
       return NULL;
     else
       return Tuners.at((uint) CurrentTuner);
   }
   else
     return Tuners.at((uint) number);
}

/**
  \brief Return current tuner number
  \return Tuner number, or -1 if the current tuner is unknown
  
  Since there is no way to query the current selected tuner from the device,
  this function returns -1 until a tuner has been selected.
*/
int CVideoDeviceInput::GetCurrentTuner() const
{
   return CurrentTuner;
}


bool CVideoDeviceInput::SelectTuner(int number)
{
   return true;
}



/**
  \brief Make this input the current one.
  
*/
bool CVideoDeviceInput::Select()
{
   if (pVideo)
     return pVideo->SelectVideoInput(Channel);
   return FALSE;
}