qtmobility/src/multimedia/qmediaserviceprovider.cpp
changeset 14 6fbed849b4f4
parent 11 06b8e2af4411
child 15 1f895d8a5b2b
equal deleted inserted replaced
11:06b8e2af4411 14:6fbed849b4f4
    81 
    81 
    82 /*!
    82 /*!
    83     \class QMediaServiceProviderHint
    83     \class QMediaServiceProviderHint
    84     \preliminary
    84     \preliminary
    85     \brief The QMediaServiceProviderHint class describes what is required of a QMediaService.
    85     \brief The QMediaServiceProviderHint class describes what is required of a QMediaService.
    86     
    86 
    87     \ingroup multimedia-serv
    87     \ingroup multimedia
    88 
    88 
    89     The QMediaServiceProvider class uses hints to select an appropriate media service.
    89     The QMediaServiceProvider class uses hints to select an appropriate media service.
    90 */
    90 */
    91 
    91 
    92 /*!
    92 /*!
   258     return d->features;
   258     return d->features;
   259 }
   259 }
   260 
   260 
   261 
   261 
   262 Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, loader,
   262 Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, loader,
   263         (QMediaServiceProviderFactoryInterface_iid, QLatin1String("/mediaservice"), Qt::CaseInsensitive))
   263         (QMediaServiceProviderFactoryInterface_iid, QLatin1String("mediaservice"), Qt::CaseInsensitive))
   264 
   264 
   265 
   265 
   266 class QPluginServiceProvider : public QMediaServiceProvider
   266 class QPluginServiceProvider : public QMediaServiceProvider
   267 {
   267 {
   268     QMap<QMediaService*, QMediaServiceProviderPlugin*> pluginMap;
   268     QMap<QMediaService*, QMediaServiceProviderPlugin*> pluginMap;
   334                         }
   334                         }
   335                     }
   335                     }
   336                 }
   336                 }
   337                 break;
   337                 break;
   338             case QMediaServiceProviderHint::ContentType: {
   338             case QMediaServiceProviderHint::ContentType: {
   339                     QtMediaServices::SupportEstimate estimate = QtMediaServices::NotSupported;
   339                     QtMultimedia::SupportEstimate estimate = QtMultimedia::NotSupported;
   340                     foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) {
   340                     foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) {
   341                         QtMediaServices::SupportEstimate currentEstimate = QtMediaServices::MaybeSupported;
   341                         QtMultimedia::SupportEstimate currentEstimate = QtMultimedia::MaybeSupported;
   342                         QMediaServiceSupportedFormatsInterface *iface =
   342                         QMediaServiceSupportedFormatsInterface *iface =
   343                                 qobject_cast<QMediaServiceSupportedFormatsInterface*>(currentPlugin);
   343                                 qobject_cast<QMediaServiceSupportedFormatsInterface*>(currentPlugin);
   344 
   344 
   345                         if (iface)
   345                         if (iface)
   346                             currentEstimate = iface->hasSupport(hint.mimeType(), hint.codecs());
   346                             currentEstimate = iface->hasSupport(hint.mimeType(), hint.codecs());
   347 
   347 
   348                         if (currentEstimate > estimate) {
   348                         if (currentEstimate > estimate) {
   349                             estimate = currentEstimate;
   349                             estimate = currentEstimate;
   350                             plugin = currentPlugin;
   350                             plugin = currentPlugin;
   351 
   351 
   352                             if (currentEstimate == QtMediaServices::PreferredService)
   352                             if (currentEstimate == QtMultimedia::PreferredService)
   353                                 break;
   353                                 break;
   354                         }
   354                         }
   355                     }
   355                     }
   356                 }
   356                 }
   357                 break;
   357                 break;
   378             if (plugin != 0)
   378             if (plugin != 0)
   379                 plugin->release(service);
   379                 plugin->release(service);
   380         }
   380         }
   381     }
   381     }
   382 
   382 
   383     QtMediaServices::SupportEstimate hasSupport(const QByteArray &serviceType,
   383     QtMultimedia::SupportEstimate hasSupport(const QByteArray &serviceType,
   384                                      const QString &mimeType,
   384                                      const QString &mimeType,
   385                                      const QStringList& codecs,
   385                                      const QStringList& codecs,
   386                                      int flags) const
   386                                      int flags) const
   387     {
   387     {
   388         QList<QObject*> instances = loader()->instances(serviceType);
   388         QList<QObject*> instances = loader()->instances(serviceType);
   389 
   389 
   390         if (instances.isEmpty())
   390         if (instances.isEmpty())
   391             return QtMediaServices::NotSupported;
   391             return QtMultimedia::NotSupported;
   392 
   392 
   393         bool allServicesProvideInterface = true;
   393         bool allServicesProvideInterface = true;
   394         QtMediaServices::SupportEstimate supportEstimate = QtMediaServices::NotSupported;
   394         QtMultimedia::SupportEstimate supportEstimate = QtMultimedia::NotSupported;
   395 
   395 
   396         foreach(QObject *obj, instances) {
   396         foreach(QObject *obj, instances) {
   397             QMediaServiceSupportedFormatsInterface *iface =
   397             QMediaServiceSupportedFormatsInterface *iface =
   398                     qobject_cast<QMediaServiceSupportedFormatsInterface*>(obj);
   398                     qobject_cast<QMediaServiceSupportedFormatsInterface*>(obj);
   399 
   399 
   423             else
   423             else
   424                 allServicesProvideInterface = false;
   424                 allServicesProvideInterface = false;
   425         }
   425         }
   426 
   426 
   427         //don't return PreferredService
   427         //don't return PreferredService
   428         supportEstimate = qMin(supportEstimate, QtMediaServices::ProbablySupported);
   428         supportEstimate = qMin(supportEstimate, QtMultimedia::ProbablySupported);
   429 
   429 
   430         //Return NotSupported only if no services are available of serviceType
   430         //Return NotSupported only if no services are available of serviceType
   431         //or all the services returned NotSupported, otherwise return at least MaybeSupported
   431         //or all the services returned NotSupported, otherwise return at least MaybeSupported
   432         if (!allServicesProvideInterface)
   432         if (!allServicesProvideInterface)
   433             supportEstimate = qMax(QtMediaServices::MaybeSupported, supportEstimate);
   433             supportEstimate = qMax(QtMultimedia::MaybeSupported, supportEstimate);
   434 
   434 
   435         return supportEstimate;
   435         return supportEstimate;
   436     }
   436     }
   437 
   437 
   438     QStringList supportedMimeTypes(const QByteArray &serviceType, int flags) const
   438     QStringList supportedMimeTypes(const QByteArray &serviceType, int flags) const
   518 */
   518 */
   519 
   519 
   520 /*!
   520 /*!
   521     \fn QMediaServiceProvider::requestService(const QByteArray &type, const QMediaServiceProviderHint &hint)
   521     \fn QMediaServiceProvider::requestService(const QByteArray &type, const QMediaServiceProviderHint &hint)
   522 
   522 
   523     Requests an instance of a \a type service which best matches the given \a hint.
   523     Requests an instance of a \a type service which best matches the given \a
   524 
   524     hint.
   525     Returns a pointer to the requested service, or a null pointer if there is no suitable service.
   525 
   526 
   526     Returns a pointer to the requested service, or a null pointer if there is
   527     The returned service must be released with releaseService when it is finished with.
   527     no suitable service.
       
   528 
       
   529     The returned service must be released with releaseService when it is
       
   530     finished with.
   528 */
   531 */
   529 
   532 
   530 /*!
   533 /*!
   531     \fn QMediaServiceProvider::releaseService(QMediaService *service)
   534     \fn QMediaServiceProvider::releaseService(QMediaService *service)
   532 
   535 
   533     Releases a media \a service requested with requestService().
   536     Releases a media \a service requested with requestService().
   534 */
   537 */
   535 
   538 
   536 /*!
   539 /*!
   537     \fn QtMediaServices::SupportEstimate QMediaServiceProvider::hasSupport(const QByteArray &serviceType, const QString &mimeType, const QStringList& codecs, int flags) const
   540     \fn QtMultimedia::SupportEstimate QMediaServiceProvider::hasSupport(const QByteArray &serviceType, const QString &mimeType, const QStringList& codecs, int flags) const
   538 
   541 
   539     Returns how confident a media service provider is that is can provide a \a serviceType
   542     Returns how confident a media service provider is that is can provide a \a
   540     service that is able to play media of a specific \a mimeType that is encoded using the listed
   543     serviceType service that is able to play media of a specific \a mimeType
   541     \a codecs while adhearing to constraints identified in \a flags.
   544     that is encoded using the listed \a codecs while adhering to constraints
   542 */
   545     identified in \a flags.
   543 QtMediaServices::SupportEstimate QMediaServiceProvider::hasSupport(const QByteArray &serviceType,
   546 */
       
   547 QtMultimedia::SupportEstimate QMediaServiceProvider::hasSupport(const QByteArray &serviceType,
   544                                                         const QString &mimeType,
   548                                                         const QString &mimeType,
   545                                                         const QStringList& codecs,
   549                                                         const QStringList& codecs,
   546                                                         int flags) const
   550                                                         int flags) const
   547 {
   551 {
   548     Q_UNUSED(serviceType);
   552     Q_UNUSED(serviceType);
   549     Q_UNUSED(mimeType);
   553     Q_UNUSED(mimeType);
   550     Q_UNUSED(codecs);
   554     Q_UNUSED(codecs);
   551     Q_UNUSED(flags);
   555     Q_UNUSED(flags);
   552 
   556 
   553     return QtMediaServices::MaybeSupported;
   557     return QtMultimedia::MaybeSupported;
   554 }
   558 }
   555 
   559 
   556 /*!
   560 /*!
   557     \fn QStringList QMediaServiceProvider::supportedMimeTypes(const QByteArray &serviceType, int flags) const
   561     \fn QStringList QMediaServiceProvider::supportedMimeTypes(const QByteArray &serviceType, int flags) const
   558 
   562 
   559     Returns a list of MIME types supported by the service provider for the specified \a serviceType.
   563     Returns a list of MIME types supported by the service provider for the
   560 
   564     specified \a serviceType.
   561     The resultant list is restricted to MIME types which can be supported given the constraints in \a flags.
   565 
       
   566     The resultant list is restricted to MIME types which can be supported given
       
   567     the constraints in \a flags.
   562 */
   568 */
   563 QStringList QMediaServiceProvider::supportedMimeTypes(const QByteArray &serviceType, int flags) const
   569 QStringList QMediaServiceProvider::supportedMimeTypes(const QByteArray &serviceType, int flags) const
   564 {
   570 {
   565     Q_UNUSED(serviceType);
   571     Q_UNUSED(serviceType);
   566     Q_UNUSED(flags);
   572     Q_UNUSED(flags);
   576     Q_UNUSED(service);
   582     Q_UNUSED(service);
   577     return QList<QByteArray>();
   583     return QList<QByteArray>();
   578 }
   584 }
   579 
   585 
   580 /*!
   586 /*!
   581     Returns the description of \a device related to \a serviceType,
   587     Returns the description of \a device related to \a serviceType, suitable for use by
   582     suitable to be displayed to user.
   588     an application for display.
   583 */
   589 */
   584 QString QMediaServiceProvider::deviceDescription(const QByteArray &serviceType, const QByteArray &device)
   590 QString QMediaServiceProvider::deviceDescription(const QByteArray &serviceType, const QByteArray &device)
   585 {
   591 {
   586     Q_UNUSED(serviceType);
   592     Q_UNUSED(serviceType);
   587     Q_UNUSED(device);
   593     Q_UNUSED(device);
   624     \preliminary
   630     \preliminary
   625     \brief The QMediaServiceProviderPlugin class interface provides an interface for QMediaService
   631     \brief The QMediaServiceProviderPlugin class interface provides an interface for QMediaService
   626     plug-ins.
   632     plug-ins.
   627 
   633 
   628     A media service provider plug-in may implement one or more of
   634     A media service provider plug-in may implement one or more of
   629     QMediaServiceSupportedFormatsInterface, QMediaServiceSupportedDevicesInterface,
   635     QMediaServiceSupportedFormatsInterface,
   630     and QMediaServiceFeaturesInterface to identify the features it supports.
   636     QMediaServiceSupportedDevicesInterface, and QMediaServiceFeaturesInterface
       
   637     to identify the features it supports.
   631 */
   638 */
   632 
   639 
   633 /*!
   640 /*!
   634     \fn QMediaServiceProviderPlugin::keys() const
   641     \fn QMediaServiceProviderPlugin::keys() const
   635 
   642 
   666 */
   673 */
   667 
   674 
   668 /*!
   675 /*!
   669     \fn QMediaServiceSupportedFormatsInterface::hasSupport(const QString &mimeType, const QStringList& codecs) const
   676     \fn QMediaServiceSupportedFormatsInterface::hasSupport(const QString &mimeType, const QStringList& codecs) const
   670 
   677 
   671     Returns the level of support a media service plug-in has for a \a mimeType and set of \a codecs.
   678     Returns the level of support a media service plug-in has for a \a mimeType
       
   679     and set of \a codecs.
   672 */
   680 */
   673 
   681 
   674 /*!
   682 /*!
   675     \fn QMediaServiceSupportedFormatsInterface::supportedMimeTypes() const
   683     \fn QMediaServiceSupportedFormatsInterface::supportedMimeTypes() const
   676 
   684