qtmobility/plugins/multimedia/symbian/s60mediaserviceplugin.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
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 #include <QtCore/qstring.h>
       
    43 #include <QtCore/qdebug.h>
       
    44 
       
    45 #include "s60mediaserviceplugin.h"
       
    46 #if defined(TUNERLIBUSED) || defined(RADIOUTILITYLIBUSED) 
       
    47 #include "s60radiotunerservice.h"
       
    48 #endif
       
    49 #ifdef HAS_MEDIA_PLAYER
       
    50 #include "s60mediaplayerservice.h"
       
    51 #endif
       
    52 #include "s60audiocaptureservice.h"
       
    53 #ifdef QMEDIA_SYMBIAN_CAMERA
       
    54 #include "s60cameraservice.h"
       
    55 #endif
       
    56 
       
    57 
       
    58 QStringList S60MediaServicePlugin::keys() const
       
    59 {
       
    60     QStringList list;
       
    61 #if defined(TUNERLIBUSED) || defined(RADIOUTILITYLIBUSED)
       
    62     list << QLatin1String(Q_MEDIASERVICE_RADIO);
       
    63 #endif
       
    64 #ifdef QMEDIA_SYMBIAN_CAMERA
       
    65     list << QLatin1String(Q_MEDIASERVICE_CAMERA);
       
    66 #endif
       
    67 #ifdef HAS_MEDIA_PLAYER  
       
    68     list << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER);
       
    69 #endif
       
    70     list << QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE);
       
    71     return list;
       
    72 }
       
    73 
       
    74 QMediaService* S60MediaServicePlugin::create(QString const& key)
       
    75 {
       
    76 #ifdef QMEDIA_SYMBIAN_CAMERA
       
    77     if (key == QLatin1String(Q_MEDIASERVICE_CAMERA))
       
    78         return new S60CameraService;
       
    79 #endif
       
    80 #ifdef HAS_MEDIA_PLAYER
       
    81     if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER))
       
    82         return new S60MediaPlayerService;
       
    83 #endif
       
    84     if (key == QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE))
       
    85         return new S60AudioCaptureService;
       
    86     
       
    87 #if defined(TUNERLIBUSED) || defined(RADIOUTILITYLIBUSED) 
       
    88     if (key == QLatin1String(Q_MEDIASERVICE_RADIO)) 
       
    89         return new S60RadioTunerService;
       
    90 #endif
       
    91     
       
    92     return 0;
       
    93 }
       
    94 
       
    95 void S60MediaServicePlugin::release(QMediaService *service)
       
    96 {
       
    97     delete service;
       
    98 }
       
    99 
       
   100 QList<QByteArray> S60MediaServicePlugin::devices(const QByteArray &service) const
       
   101 {
       
   102 #ifdef QMEDIA_SYMBIAN_CAMERA
       
   103     if (service == Q_MEDIASERVICE_CAMERA) {
       
   104         if (m_cameraDevices.isEmpty())
       
   105             updateDevices();
       
   106 
       
   107         return m_cameraDevices;
       
   108     }
       
   109 #endif
       
   110     return QList<QByteArray>();
       
   111 }
       
   112 
       
   113 QString S60MediaServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
       
   114 {
       
   115 #ifdef QMEDIA_SYMBIAN_CAMERA
       
   116     if (service == Q_MEDIASERVICE_CAMERA) {
       
   117         if (m_cameraDevices.isEmpty())
       
   118             updateDevices();
       
   119 
       
   120         for (int i=0; i<m_cameraDevices.count(); i++)
       
   121             if (m_cameraDevices[i] == device)
       
   122                 return m_cameraDescriptions[i];
       
   123     }
       
   124 #endif
       
   125     return QString();
       
   126 }
       
   127 
       
   128 void S60MediaServicePlugin::updateDevices() const
       
   129 {
       
   130 #ifdef QMEDIA_SYMBIAN_CAMERA
       
   131     m_cameraDevices.clear();
       
   132     m_cameraDescriptions.clear();
       
   133     for (int i=0; i < S60CameraService::deviceCount(); i ++) {
       
   134         m_cameraDevices.append(S60CameraService::deviceName(i).toUtf8());
       
   135         m_cameraDescriptions.append(S60CameraService::deviceDescription(i));
       
   136     }
       
   137 #endif
       
   138 }
       
   139 
       
   140 Q_EXPORT_PLUGIN2(QtMobilityMultimediaEngine, S60MediaServicePlugin);