qtmobility/plugins/multimedia/v4l/radio/v4lradiocontrol_maemo5.h
changeset 4 90517678cc4f
child 5 453da2cfceef
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 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 QTM_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     QtMedia::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 private slots:
       
   105     void search();
       
   106     void enableFMRX();
       
   107 
       
   108 private:
       
   109     bool initRadio();
       
   110     void setupHeadPhone();
       
   111     bool createGstPipeline();
       
   112     void callAmixer(const QString& target, const QString& value);
       
   113     int getEnumItemIndex(snd_ctl_t *handle, snd_ctl_elem_info_t *info, const  QString &value);
       
   114     int vol(snd_hctl_elem_t *elem) const;
       
   115 
       
   116 private:
       
   117     int fd;
       
   118 
       
   119     bool m_error;
       
   120     bool muted;
       
   121     bool stereo;
       
   122     bool low;
       
   123     bool available;
       
   124     int  tuners;
       
   125     int  step;
       
   126     int  sig;
       
   127     bool scanning;
       
   128     bool forward;
       
   129     QTimer* timer;
       
   130     QTimer* tickTimer;
       
   131     QRadioTuner::Band   currentBand;
       
   132     qint64 freqMin;
       
   133     qint64 freqMax;
       
   134     qint64 currentFreq;
       
   135 
       
   136     GstElement *pipeline;
       
   137 
       
   138     QDBusInterface* FMRXEnablerIFace;
       
   139 };
       
   140 
       
   141 #endif