40 ****************************************************************************/ |
40 ****************************************************************************/ |
41 |
41 |
42 #include <QtCore/qdebug.h> |
42 #include <QtCore/qdebug.h> |
43 #include <QtCore/qmap.h> |
43 #include <QtCore/qmap.h> |
44 |
44 |
45 #include <qmediaservice.h> |
45 #include "qmediaservice.h" |
46 #include <qmediaserviceprovider.h> |
46 #include "qmediaserviceprovider.h" |
47 #include <qmediaserviceproviderplugin.h> |
47 #include "qmediaserviceproviderplugin.h" |
48 #include <qmediapluginloader_p.h> |
48 #include "qmediapluginloader_p.h" |
49 #include <qmediaplayer.h> |
49 #include "qmediaplayer.h" |
50 |
50 |
51 QTM_BEGIN_NAMESPACE |
51 QTM_BEGIN_NAMESPACE |
52 |
52 |
53 class QMediaServiceProviderHintPrivate : public QSharedData |
53 class QMediaServiceProviderHintPrivate : public QSharedData |
54 { |
54 { |
99 but playback should start without significant delay. |
99 but playback should start without significant delay. |
100 Such playback service can be used for beeps, ringtones, etc. |
100 Such playback service can be used for beeps, ringtones, etc. |
101 |
101 |
102 \value RecordingSupport |
102 \value RecordingSupport |
103 The service provides audio or video recording functions. |
103 The service provides audio or video recording functions. |
|
104 |
|
105 \value StreamPlayback |
|
106 The service is capable of playing QIODevice based streams. |
104 */ |
107 */ |
105 |
108 |
106 /*! |
109 /*! |
107 \enum QMediaServiceProviderHint::Type |
110 \enum QMediaServiceProviderHint::Type |
108 |
111 |
392 |
395 |
393 foreach(QObject *obj, instances) { |
396 foreach(QObject *obj, instances) { |
394 QMediaServiceSupportedFormatsInterface *iface = |
397 QMediaServiceSupportedFormatsInterface *iface = |
395 qobject_cast<QMediaServiceSupportedFormatsInterface*>(obj); |
398 qobject_cast<QMediaServiceSupportedFormatsInterface*>(obj); |
396 |
399 |
397 //if low latency playback was asked, skip services known |
400 |
398 //not to provide low latency playback |
401 if (flags) { |
399 if (flags & QMediaPlayer::LowLatency) { |
|
400 QMediaServiceFeaturesInterface *iface = |
402 QMediaServiceFeaturesInterface *iface = |
401 qobject_cast<QMediaServiceFeaturesInterface*>(obj); |
403 qobject_cast<QMediaServiceFeaturesInterface*>(obj); |
402 |
404 |
403 if (iface && !(iface->supportedFeatures(serviceType) & QMediaServiceProviderHint::LowLatencyPlayback)) |
405 if (iface) { |
404 continue; |
406 QMediaServiceProviderHint::Features features = iface->supportedFeatures(serviceType); |
|
407 |
|
408 //if low latency playback was asked, skip services known |
|
409 //not to provide low latency playback |
|
410 if ((flags & QMediaPlayer::LowLatency) && |
|
411 !(features & QMediaServiceProviderHint::LowLatencyPlayback)) |
|
412 continue; |
|
413 |
|
414 //the same for QIODevice based streams support |
|
415 if ((flags & QMediaPlayer::StreamPlayback) && |
|
416 !(features & QMediaServiceProviderHint::StreamPlayback)) |
|
417 continue; |
|
418 } |
405 } |
419 } |
406 |
420 |
407 if (iface) |
421 if (iface) |
408 supportEstimate = qMax(supportEstimate, iface->hasSupport(mimeType, codecs)); |
422 supportEstimate = qMax(supportEstimate, iface->hasSupport(mimeType, codecs)); |
409 else |
423 else |
410 allServicesProvideInterface = false; |
424 allServicesProvideInterface = false; |
411 } |
425 } |
412 |
426 |
413 //don't return PreferedService |
427 //don't return PreferredService |
414 supportEstimate = qMin(supportEstimate, QtMedia::ProbablySupported); |
428 supportEstimate = qMin(supportEstimate, QtMedia::ProbablySupported); |
415 |
429 |
416 //Return NotSupported only if no services are available of serviceType |
430 //Return NotSupported only if no services are available of serviceType |
417 //or all the services returned NotSupported, otherwise return at least MaybeSupported |
431 //or all the services returned NotSupported, otherwise return at least MaybeSupported |
418 if (!allServicesProvideInterface) |
432 if (!allServicesProvideInterface) |
429 |
443 |
430 foreach(QObject *obj, instances) { |
444 foreach(QObject *obj, instances) { |
431 QMediaServiceSupportedFormatsInterface *iface = |
445 QMediaServiceSupportedFormatsInterface *iface = |
432 qobject_cast<QMediaServiceSupportedFormatsInterface*>(obj); |
446 qobject_cast<QMediaServiceSupportedFormatsInterface*>(obj); |
433 |
447 |
434 // If low latency playback was asked for, skip MIME types from services known |
448 |
435 // not to provide low latency playback |
|
436 if (flags & QMediaPlayer::LowLatency) { |
449 if (flags & QMediaPlayer::LowLatency) { |
437 QMediaServiceFeaturesInterface *iface = |
450 QMediaServiceFeaturesInterface *iface = |
438 qobject_cast<QMediaServiceFeaturesInterface*>(obj); |
451 qobject_cast<QMediaServiceFeaturesInterface*>(obj); |
439 |
452 |
440 if (iface && !(iface->supportedFeatures(serviceType) & QMediaServiceProviderHint::LowLatencyPlayback)) |
453 if (iface) { |
441 continue; |
454 QMediaServiceProviderHint::Features features = iface->supportedFeatures(serviceType); |
|
455 |
|
456 // If low latency playback was asked for, skip MIME types from services known |
|
457 // not to provide low latency playback |
|
458 if ((flags & QMediaPlayer::LowLatency) && |
|
459 !(features & QMediaServiceProviderHint::LowLatencyPlayback)) |
|
460 continue; |
|
461 |
|
462 //the same for QIODevice based streams support |
|
463 if ((flags & QMediaPlayer::StreamPlayback) && |
|
464 !(features & QMediaServiceProviderHint::StreamPlayback)) |
|
465 continue; |
|
466 } |
442 } |
467 } |
443 |
468 |
444 if (iface) { |
469 if (iface) { |
445 supportedTypes << iface->supportedMimeTypes(); |
470 supportedTypes << iface->supportedMimeTypes(); |
446 } |
471 } |
561 Q_UNUSED(serviceType); |
586 Q_UNUSED(serviceType); |
562 Q_UNUSED(device); |
587 Q_UNUSED(device); |
563 return QString(); |
588 return QString(); |
564 } |
589 } |
565 |
590 |
|
591 |
|
592 #ifdef QT_BUILD_INTERNAL |
|
593 |
|
594 static QMediaServiceProvider *qt_defaultMediaServiceProvider = 0; |
|
595 |
|
596 /*! |
|
597 Sets a media service \a provider as the default. |
|
598 |
|
599 \internal |
|
600 */ |
|
601 void QMediaServiceProvider::setDefaultServiceProvider(QMediaServiceProvider *provider) |
|
602 { |
|
603 qt_defaultMediaServiceProvider = provider; |
|
604 } |
|
605 |
|
606 #endif |
|
607 |
566 /*! |
608 /*! |
567 Returns a default provider of media services. |
609 Returns a default provider of media services. |
568 */ |
610 */ |
569 QMediaServiceProvider *QMediaServiceProvider::defaultServiceProvider() |
611 QMediaServiceProvider *QMediaServiceProvider::defaultServiceProvider() |
570 { |
612 { |
|
613 #ifdef QT_BUILD_INTERNAL |
|
614 return qt_defaultMediaServiceProvider != 0 |
|
615 ? qt_defaultMediaServiceProvider |
|
616 : static_cast<QMediaServiceProvider *>(pluginProvider()); |
|
617 #else |
571 return pluginProvider(); |
618 return pluginProvider(); |
|
619 #endif |
572 } |
620 } |
573 |
621 |
574 /*! |
622 /*! |
575 \class QMediaServiceProviderPlugin |
623 \class QMediaServiceProviderPlugin |
576 \preliminary |
624 \preliminary |