tests/auto/mediaobject/dummy/backend.cpp
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     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 test suite module of the Qt Toolkit.
       
     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 "audiooutput.h"
       
    43 #include "mediaobject.h"
       
    44 #include "videowidget.h"
       
    45 
       
    46 #include "backend.h"
       
    47 
       
    48 #include <QtCore/QSet>
       
    49 #include <QtCore/QVariant>
       
    50 #include <QtCore/QtPlugin>
       
    51 
       
    52 QT_BEGIN_NAMESPACE
       
    53 
       
    54 Q_EXPORT_PLUGIN2(phonon_dummy, Phonon::Dummy::Backend)
       
    55 
       
    56 namespace Phonon
       
    57 {
       
    58 namespace Dummy
       
    59 {
       
    60 
       
    61 Backend::Backend(QObject *parent, const QVariantList &)
       
    62         : QObject(parent)
       
    63 {
       
    64     qWarning()<<"Using TEST Phonon backend";
       
    65 }
       
    66 
       
    67 Backend::~Backend()
       
    68 {
       
    69 }
       
    70 
       
    71 /***
       
    72  * !reimp
       
    73  */
       
    74 QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList<QVariant> &args)
       
    75 {
       
    76     Q_UNUSED(args)
       
    77 
       
    78     switch (c) {
       
    79     case MediaObjectClass:
       
    80         return new MediaObject(this, parent);
       
    81 
       
    82     case AudioOutputClass: {
       
    83             AudioOutput *ao = new AudioOutput(this, parent);
       
    84             m_audioOutputs.append(ao);
       
    85             return ao;
       
    86         }
       
    87     case VideoWidgetClass: {
       
    88             QWidget *widget =  qobject_cast<QWidget*>(parent);
       
    89             return new VideoWidget(this, widget);
       
    90         }
       
    91     default:
       
    92         qWarning("createObject() : Backend object not available");
       
    93     }
       
    94     return 0;
       
    95 }
       
    96 
       
    97 /***
       
    98  * !reimp
       
    99  */
       
   100 QStringList Backend::availableMimeTypes() const
       
   101 {
       
   102     QStringList availableMimeTypes;
       
   103     // audio *.wav and *.mp3 files
       
   104     availableMimeTypes << QLatin1String("audio/x-mp3");
       
   105     availableMimeTypes << QLatin1String("audio/x-wav");
       
   106 
       
   107     // video *.ogv, *.mp4, *.avi (some)
       
   108 
       
   109     availableMimeTypes << QLatin1String("video/mpeg");
       
   110     availableMimeTypes << QLatin1String("video/ogg");
       
   111     availableMimeTypes << QLatin1String("video/mp4");
       
   112 
       
   113     return availableMimeTypes;
       
   114 }
       
   115 
       
   116 /***
       
   117  * !reimp
       
   118  */
       
   119 QList<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const
       
   120 {
       
   121     QList<int> list;
       
   122 
       
   123     if(type == Phonon::AudioOutputDeviceType)
       
   124         list.append(0);
       
   125 
       
   126     return list;
       
   127 }
       
   128 
       
   129 /***
       
   130  * !reimp
       
   131  */
       
   132 QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescriptionType type, int index) const
       
   133 {
       
   134     Q_UNUSED(index);
       
   135     QHash<QByteArray, QVariant> ret;
       
   136 
       
   137     if(type == Phonon::AudioOutputDeviceType)
       
   138         ret["name"] = QLatin1String("default audio device");
       
   139 
       
   140     return ret;
       
   141 }
       
   142 
       
   143 /***
       
   144  * !reimp
       
   145  */
       
   146 bool Backend::startConnectionChange(QSet<QObject *> objects)
       
   147 {
       
   148     Q_UNUSED(objects)
       
   149 
       
   150     return true;
       
   151 }
       
   152 
       
   153 /***
       
   154  * !reimp
       
   155  */
       
   156 bool Backend::connectNodes(QObject *source, QObject *sink)
       
   157 {
       
   158     Q_UNUSED(source)
       
   159     Q_UNUSED(sink)
       
   160 
       
   161     return true;
       
   162 }
       
   163 
       
   164 /***
       
   165  * !reimp
       
   166  */
       
   167 bool Backend::disconnectNodes(QObject *source, QObject *sink)
       
   168 {
       
   169     Q_UNUSED(source)
       
   170     Q_UNUSED(sink)
       
   171 
       
   172     return true;
       
   173 }
       
   174 
       
   175 /***
       
   176  * !reimp
       
   177  */
       
   178 bool Backend::endConnectionChange(QSet<QObject *> objects)
       
   179 {
       
   180     Q_UNUSED(objects)
       
   181 
       
   182     return true;
       
   183 }
       
   184 
       
   185 }
       
   186 }
       
   187 
       
   188 QT_END_NAMESPACE
       
   189 
       
   190 #include "moc_backend.cpp"