| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QRADIOTUNER_H |
| 41 | #define QRADIOTUNER_H |
| 42 | |
| 43 | #include <QtCore/qobject.h> |
| 44 | |
| 45 | #include <QtMultimedia/qmediaobject.h> |
| 46 | #include <QtMultimedia/qmediaenumdebug.h> |
| 47 | |
| 48 | #include <QtCore/qpair.h> |
| 49 | |
| 50 | QT_BEGIN_NAMESPACE |
| 51 | |
| 52 | class QRadioData; |
| 53 | class QRadioTunerPrivate; |
| 54 | class Q_MULTIMEDIA_EXPORT QRadioTuner : public QMediaObject |
| 55 | { |
| 56 | Q_OBJECT |
| 57 | Q_PROPERTY(State state READ state NOTIFY stateChanged) |
| 58 | Q_PROPERTY(Band band READ band WRITE setBand NOTIFY bandChanged) |
| 59 | Q_PROPERTY(int frequency READ frequency WRITE setFrequency NOTIFY frequencyChanged) |
| 60 | Q_PROPERTY(bool stereo READ isStereo NOTIFY stereoStatusChanged) |
| 61 | Q_PROPERTY(StereoMode stereoMode READ stereoMode WRITE setStereoMode) |
| 62 | Q_PROPERTY(int signalStrength READ signalStrength NOTIFY signalStrengthChanged) |
| 63 | Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) |
| 64 | Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) |
| 65 | Q_PROPERTY(bool searching READ isSearching NOTIFY searchingChanged) |
| 66 | Q_PROPERTY(bool antennaConnected READ isAntennaConnected NOTIFY antennaConnectedChanged) |
| 67 | Q_PROPERTY(QRadioData *radioData READ radioData CONSTANT) |
| 68 | Q_ENUMS(State) |
| 69 | Q_ENUMS(Band) |
| 70 | Q_ENUMS(Error) |
| 71 | Q_ENUMS(StereoMode) |
| 72 | Q_ENUMS(SearchMode) |
| 73 | |
| 74 | public: |
| 75 | enum State { ActiveState, StoppedState }; |
| 76 | enum Band { AM, FM, SW, LW, FM2 }; |
| 77 | enum Error { NoError, ResourceError, OpenError, OutOfRangeError }; |
| 78 | enum StereoMode { ForceStereo, ForceMono, Auto }; |
| 79 | enum SearchMode { SearchFast, SearchGetStationId }; |
| 80 | |
| 81 | explicit QRadioTuner(QObject *parent = nullptr); |
| 82 | ~QRadioTuner(); |
| 83 | |
| 84 | QMultimedia::AvailabilityStatus availability() const override; |
| 85 | |
| 86 | State state() const; |
| 87 | |
| 88 | Band band() const; |
| 89 | |
| 90 | bool isBandSupported(Band b) const; |
| 91 | |
| 92 | int frequency() const; |
| 93 | int frequencyStep(Band band) const; |
| 94 | QPair<int,int> frequencyRange(Band band) const; |
| 95 | |
| 96 | bool isStereo() const; |
| 97 | void setStereoMode(QRadioTuner::StereoMode mode); |
| 98 | StereoMode stereoMode() const; |
| 99 | |
| 100 | int signalStrength() const; |
| 101 | |
| 102 | int volume() const; |
| 103 | bool isMuted() const; |
| 104 | |
| 105 | bool isSearching() const; |
| 106 | |
| 107 | bool isAntennaConnected() const; |
| 108 | |
| 109 | Error error() const; |
| 110 | QString errorString() const; |
| 111 | |
| 112 | QRadioData *radioData() const; |
| 113 | |
| 114 | public Q_SLOTS: |
| 115 | void searchForward(); |
| 116 | void searchBackward(); |
| 117 | void searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast); |
| 118 | void cancelSearch(); |
| 119 | |
| 120 | void setBand(Band band); |
| 121 | void setFrequency(int frequency); |
| 122 | |
| 123 | void setVolume(int volume); |
| 124 | void setMuted(bool muted); |
| 125 | |
| 126 | void start(); |
| 127 | void stop(); |
| 128 | |
| 129 | Q_SIGNALS: |
| 130 | void stateChanged(QRadioTuner::State state); |
| 131 | void bandChanged(QRadioTuner::Band band); |
| 132 | void frequencyChanged(int frequency); |
| 133 | void stereoStatusChanged(bool stereo); |
| 134 | void searchingChanged(bool searching); |
| 135 | void signalStrengthChanged(int signalStrength); |
| 136 | void volumeChanged(int volume); |
| 137 | void mutedChanged(bool muted); |
| 138 | void stationFound(int frequency, QString stationId); |
| 139 | void antennaConnectedChanged(bool connectionStatus); |
| 140 | |
| 141 | void error(QRadioTuner::Error error); |
| 142 | |
| 143 | private: |
| 144 | Q_DISABLE_COPY(QRadioTuner) |
| 145 | Q_DECLARE_PRIVATE(QRadioTuner) |
| 146 | }; |
| 147 | |
| 148 | QT_END_NAMESPACE |
| 149 | |
| 150 | Q_DECLARE_METATYPE(QRadioTuner::State) |
| 151 | Q_DECLARE_METATYPE(QRadioTuner::Band) |
| 152 | Q_DECLARE_METATYPE(QRadioTuner::Error) |
| 153 | Q_DECLARE_METATYPE(QRadioTuner::StereoMode) |
| 154 | Q_DECLARE_METATYPE(QRadioTuner::SearchMode) |
| 155 | |
| 156 | Q_MEDIA_ENUM_DEBUG(QRadioTuner, State) |
| 157 | Q_MEDIA_ENUM_DEBUG(QRadioTuner, Band) |
| 158 | Q_MEDIA_ENUM_DEBUG(QRadioTuner, Error) |
| 159 | Q_MEDIA_ENUM_DEBUG(QRadioTuner, StereoMode) |
| 160 | Q_MEDIA_ENUM_DEBUG(QRadioTuner, SearchMode) |
| 161 | |
| 162 | #endif // QRADIOPLAYER_H |
| 163 | |