|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef V4LRADIOCONTROL_H |
|
43 #define V4LRADIOCONTROL_H |
|
44 |
|
45 #include <QtCore/qobject.h> |
|
46 #include <QtCore/qtimer.h> |
|
47 |
|
48 #include <qradiotunercontrol.h> |
|
49 |
|
50 #include <QtDBus/QtDBus> |
|
51 #include <gst/gst.h> |
|
52 |
|
53 #include <alsa/asoundlib.h> |
|
54 |
|
55 QT_USE_NAMESPACE |
|
56 |
|
57 class V4LRadioService; |
|
58 |
|
59 class V4LRadioControl : public QRadioTunerControl |
|
60 { |
|
61 Q_OBJECT |
|
62 public: |
|
63 V4LRadioControl(QObject *parent = 0); |
|
64 ~V4LRadioControl(); |
|
65 |
|
66 bool isAvailable() const; |
|
67 QtMultimediaKit::AvailabilityError availabilityError() const; |
|
68 |
|
69 QRadioTuner::State state() const; |
|
70 |
|
71 QRadioTuner::Band band() const; |
|
72 void setBand(QRadioTuner::Band b); |
|
73 bool isBandSupported(QRadioTuner::Band b) const; |
|
74 |
|
75 int frequency() const; |
|
76 int frequencyStep(QRadioTuner::Band b) const; |
|
77 QPair<int,int> frequencyRange(QRadioTuner::Band b) const; |
|
78 void setFrequency(int frequency); |
|
79 |
|
80 bool isStereo() const; |
|
81 QRadioTuner::StereoMode stereoMode() const; |
|
82 void setStereoMode(QRadioTuner::StereoMode mode); |
|
83 |
|
84 int signalStrength() const; |
|
85 |
|
86 int volume() const; |
|
87 void setVolume(int volume); |
|
88 |
|
89 bool isMuted() const; |
|
90 void setMuted(bool muted); |
|
91 |
|
92 bool isSearching() const; |
|
93 void cancelSearch(); |
|
94 |
|
95 void searchForward(); |
|
96 void searchBackward(); |
|
97 |
|
98 void start(); |
|
99 void stop(); |
|
100 |
|
101 QRadioTuner::Error error() const; |
|
102 QString errorString() const; |
|
103 |
|
104 public slots: |
|
105 void enablePipeline(bool enable = true); |
|
106 |
|
107 private slots: |
|
108 void search(); |
|
109 void enableFMRX(); |
|
110 |
|
111 private: |
|
112 bool initRadio(); |
|
113 void setupHeadPhone(); |
|
114 bool createGstPipeline(); |
|
115 void callAmixer(const QString& target, const QString& value); |
|
116 int getEnumItemIndex(snd_ctl_t *handle, snd_ctl_elem_info_t *info, const QString &value); |
|
117 int vol(snd_hctl_elem_t *elem) const; |
|
118 |
|
119 private: |
|
120 int fd; |
|
121 |
|
122 bool m_error; |
|
123 bool muted; |
|
124 bool stereo; |
|
125 bool low; |
|
126 bool available; |
|
127 int tuners; |
|
128 int step; |
|
129 int sig; |
|
130 bool scanning; |
|
131 bool forward; |
|
132 QTimer* timer; |
|
133 QTimer* tickTimer; |
|
134 QRadioTuner::Band currentBand; |
|
135 qint64 freqMin; |
|
136 qint64 freqMax; |
|
137 qint64 currentFreq; |
|
138 |
|
139 GstElement *pipeline; |
|
140 |
|
141 QDBusInterface* FMRXEnablerIFace; |
|
142 }; |
|
143 |
|
144 #endif |