1 /* 2 * (c) 2005, 2008 Nico Pranke <Nico.Pranke@googlemail.com>, Robin Luedtke <RobinLu@gmx.de> 3 * 4 * This file is part of avcap. 5 * 6 * avcap is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * avcap is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with avcap. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 /* avcap is free for non-commercial use. 21 * To use it in commercial endeavors, please contact Nico Pranke <Nico.Pranke@googlemail.com> 22 */ 23 24 #ifndef TUNER_H_ 25 #define TUNER_H_ 26 27 #include <string> 28 29 #include "avcap-export.h" 30 31 namespace avcap 32 { 33 class DeviceDescriptor; 34 35 //! Interface of a tuner. 36 37 /*! This class provides access to the tuner functionality of TV or Radio-cards. 38 * Applications can adjust things like frequency, audio mode etc. 39 * Applications don't create Tuner objects themselfes but get them from the Connector 40 * the tuner is associated with. The connector in turn can be obtained from the 41 * ConnectorManager of the CaptureDevice. 42 **/ 43 44 class AVCAP_Export Tuner 45 { 46 private: 47 public: ~Tuner()48 virtual inline ~Tuner() 49 {} 50 51 //! Determine whether the tuner is able to receive radio frequencies. 52 /*! The default implementation returns false. 53 * \return true if radio tuner, false else */ isRadioTuner()54 virtual inline bool isRadioTuner() const 55 { return false; } 56 57 //! Determine whether the tuner is able to receive TV frequencies. 58 /*! The default implementation returns false. 59 * \return true if TV tuner, false else */ isTVTuner()60 virtual inline bool isTVTuner() const 61 { return false; }; 62 63 //! Set the audio mode to stereo. 64 /*! The default implementation is noop and returns -1. 65 * \return 0, if successful, -1 else. */ setStereo()66 virtual inline int setStereo() 67 { return -1; } 68 69 //! Set the audio mode to mono. 70 /*! Default implementation is noop and return -1. 71 * \return 0, if successful, -1 else. */ setMono()72 virtual inline int setMono() 73 { return -1; } 74 75 //! Set the audio mode to secondary audio program (SAP). 76 /*! The default implementation is noop and returns -1. 77 * \return 0, if successful, -1 else. */ setSAP()78 virtual inline int setSAP() 79 { return -1; } 80 81 //! Set the audio mode to language 1. 82 /*! The default implementation is noop and returns -1. 83 * \return 0, if successful, -1 else. */ setLang1()84 virtual inline int setLang1() 85 { return -1; } 86 87 //! Set the audio mode to language 2. 88 /*! The default implementation is noop and returns -1. 89 * \return 0, if successful, -1 else. */ setLang2()90 virtual inline int setLang2() 91 { return -1; } 92 93 //! Returns the current frequency in MHz. 94 /*! The default implementation is noop and returns -1. 95 * \return tuner frequency */ getFreq()96 virtual inline double getFreq() const 97 { return -1.0f; } 98 99 //! Returns the step with in which the frequency can be increased or decreased. 100 /*! The default implementation is noop and returns -1. 101 * \return frequency step width*/ getFreqStep()102 virtual inline double getFreqStep() const 103 { return -1.0f; } 104 105 //! Returns the minimum possible frequency in MHz which can be applied to the tuner. 106 /*! The default implementation is noop and returns -1. 107 * \return minimal tuner frequency */ getMinFreq()108 virtual inline double getMinFreq() const 109 { return -1.0f; } 110 111 //! Returns the maximum possible frequency in MHz which can be applied to the tuner. 112 /*! The default implementation is noop and returns -1. 113 * \return maximal tuner frequency */ getMaxFreq()114 virtual inline double getMaxFreq() const 115 { return -1.0f; } 116 117 //! Returns the tuner name. 118 /*! Default implementation returns an empty string. 119 * \return tuner name */ getName()120 virtual inline const std::string getName() const 121 { return ""; } 122 123 //! This method tries to readjust and to fine-tune the frequency by means of the current AFC-value. 124 /*! The default implementation is noop and returns -1. 125 * \return 0, if successful, -1 else. */ finetune(int maxsteps)126 virtual inline int finetune(int maxsteps) 127 { return -1; } 128 129 //! Get the current automatic frequency control (AFC) value. 130 /*! If the afc value is negative, the frequency is too low, if positive it is too high. 131 *! The default implementation is noop and returns -1. 132 * \return afc */ getAFCValue()133 virtual inline int getAFCValue() const 134 { return -1; } 135 136 //! Return the strength of the signal. 137 /*! The default implementation is noop and returns -1. 138 * \return signal strength */ getSignalStrength()139 virtual inline int getSignalStrength() const 140 { return -1; } 141 142 //! Increase the frequency a step corresponding to getFreqStep(). 143 /*! The default implementation is noop and returns -1. 144 * \return 0, if successful, -1 else. */ increaseFreq()145 virtual inline int increaseFreq() 146 { return 0; } 147 148 //! Decrease the frequency a step corresponding to getFreqStep(). 149 /*! The default implementation is noop and returns -1. 150 * \return 0, if successful, -1 else. */ decreaseFreq()151 virtual inline int decreaseFreq() 152 { return 0; } 153 154 //! Set the new frequency. The frequency is given in MHz. 155 /*! The default implementation is noop and returns -1. 156 * \param f The new frequency. 157 * \return 0, if successful, -1 else. */ setFreq(double f)158 virtual inline int setFreq(double f) 159 { return -1; } 160 }; 161 162 /*! Known european terrestric analog TV channels. They must be multiplied by 10^6 163 * to obtain the frequency in Hz. */ 164 static const double TV_Channels[] = 165 { 166 48.25, 55.25, 62.25, 175.25, 182.25, 189.25, 196.25, 203.25, 210.25, 217.25, 224.25, 471.25, 479.25, 487.25, 167 495.25, 503.25, 511.25, 519.25, 527.25, 535.25, 543.25, 551.25, 559.25, 567.25, 575.25, 583.25, 591.25, 168 599.25, 607.25, 615.25, 623.25, 631.25, 639.25, 647.25, 655.25, 663.25, 671.25, 679.25, 687.25, 695.25, 169 703.25, 711.25, 719.25, 727.25, 735.25, 743.25, 751.25, 759.25, 767.25, 775.25, 783.25, 791.25, 799.25, 170 807.25, 815.25, 823.25, 831.25, 839.25, 847.25, 855.25 171 }; 172 173 /*! The number of TV channels */ 174 static const int TV_Num_Channels = 60; 175 176 /*! Some german analog radio channels. They must be multiplied by 10^6 177 * to obtain the frequency in Hz. */ 178 static const double Radio_Channels[] = 179 { 180 102.4, 102.0 181 }; 182 183 /*! The number of radio channels */ 184 static const int Radio_Num_Channels = 2; 185 186 } 187 188 #endif // TUNER_H_ 189