Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I25197ccc930730be363f8f65624d7fa10c1d33e9
This commit is contained in:
@@ -8,13 +8,13 @@ QT = core multimedia-private gui-private
|
||||
|
||||
unix:!maemo*:contains(QT_CONFIG, alsa) {
|
||||
DEFINES += HAVE_ALSA
|
||||
LIBS += \
|
||||
LIBS_PRIVATE += \
|
||||
-lasound
|
||||
}
|
||||
|
||||
CONFIG += link_pkgconfig
|
||||
|
||||
PKGCONFIG += \
|
||||
PKGCONFIG_PRIVATE += \
|
||||
gstreamer-0.10 \
|
||||
gstreamer-base-0.10 \
|
||||
gstreamer-interfaces-0.10 \
|
||||
@@ -22,11 +22,11 @@ PKGCONFIG += \
|
||||
gstreamer-video-0.10 \
|
||||
gstreamer-pbutils-0.10
|
||||
|
||||
maemo*:PKGCONFIG +=gstreamer-plugins-bad-0.10
|
||||
maemo*: PKGCONFIG_PRIVATE +=gstreamer-plugins-bad-0.10
|
||||
|
||||
config_resourcepolicy {
|
||||
DEFINES += HAVE_RESOURCE_POLICY
|
||||
PKGCONFIG += libresourceqt5
|
||||
PKGCONFIG_PRIVATE += libresourceqt5
|
||||
}
|
||||
|
||||
# Header files must go inside source directory of a module
|
||||
@@ -79,24 +79,24 @@ qtHaveModule(widgets) {
|
||||
}
|
||||
|
||||
maemo6 {
|
||||
PKGCONFIG += qmsystem2
|
||||
PKGCONFIG_PRIVATE += qmsystem2
|
||||
|
||||
contains(QT_CONFIG, opengles2):qtHaveModule(widgets) {
|
||||
PRIVATE_HEADERS += qgstreamergltexturerenderer_p.h
|
||||
SOURCES += qgstreamergltexturerenderer.cpp
|
||||
QT += opengl
|
||||
LIBS += -lEGL -lgstmeegointerfaces-0.10
|
||||
LIBS_PRIVATE += -lEGL -lgstmeegointerfaces-0.10
|
||||
}
|
||||
}
|
||||
|
||||
config_gstreamer_appsrc {
|
||||
PKGCONFIG += gstreamer-app-0.10
|
||||
PKGCONFIG_PRIVATE += gstreamer-app-0.10
|
||||
PRIVATE_HEADERS += qgstappsrc_p.h
|
||||
SOURCES += qgstappsrc.cpp
|
||||
|
||||
DEFINES += HAVE_GST_APPSRC
|
||||
|
||||
LIBS += -lgstapp-0.10
|
||||
LIBS_PRIVATE += -lgstapp-0.10
|
||||
}
|
||||
|
||||
HEADERS += $$PRIVATE_HEADERS
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
module QtAudioEngine
|
||||
plugin declarative_audioengine
|
||||
typeinfo plugins.qmltypes
|
||||
classname QAudioEngineDeclarativeModule
|
||||
@@ -1,4 +1,6 @@
|
||||
module QtMultimedia
|
||||
plugin declarative_multimedia
|
||||
classname QMultimediaDeclarativeModule
|
||||
typeinfo plugins.qmltypes
|
||||
Video 5.0 Video.qml
|
||||
classname QMultimediaDeclarativeModule
|
||||
|
||||
@@ -44,14 +44,14 @@ win32 {
|
||||
SOURCES += audio/qaudiodeviceinfo_win32_p.cpp \
|
||||
audio/qaudiooutput_win32_p.cpp \
|
||||
audio/qaudioinput_win32_p.cpp
|
||||
LIBS += -lwinmm -lstrmiids -lole32 -loleaut32
|
||||
LIBS_PRIVATE += -lwinmm -lstrmiids -lole32 -loleaut32
|
||||
}
|
||||
|
||||
unix:!mac {
|
||||
config_pulseaudio {
|
||||
DEFINES += QT_NO_AUDIO_BACKEND
|
||||
CONFIG += link_pkgconfig
|
||||
PKGCONFIG += libpulse
|
||||
PKGCONFIG_PRIVATE += libpulse
|
||||
|
||||
DEFINES += QT_MULTIMEDIA_PULSEAUDIO
|
||||
PRIVATE_HEADERS += audio/qsoundeffect_pulse_p.h
|
||||
|
||||
@@ -236,10 +236,9 @@ void QSoundEffectPrivate::play()
|
||||
setStatus(QSoundEffect::Null);
|
||||
return;
|
||||
}
|
||||
setPlaying(true);
|
||||
if (d->m_audioOutput && d->m_audioOutput->state() == QAudio::StoppedState && d->m_sampleReady)
|
||||
d->m_audioOutput->start(d);
|
||||
|
||||
setPlaying(true);
|
||||
}
|
||||
|
||||
void QSoundEffectPrivate::stop()
|
||||
|
||||
@@ -2,7 +2,7 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
|
||||
|
||||
project = QtMultimedia
|
||||
description = Qt Multimedia Documentation
|
||||
url = http://qt-project.org/doc/qt-$QT_VER/qtmultimedia
|
||||
url = http://qt-project.org/doc/qt-$QT_VER
|
||||
version = $QT_VERSION
|
||||
|
||||
# The following parameters are for creating a qhp file, the qhelpgenerator
|
||||
|
||||
@@ -60,11 +60,16 @@ ANDROID_LIB_DEPENDENCIES = \
|
||||
lib/libQt5MultimediaQuick_p.so:Qt5Quick
|
||||
ANDROID_BUNDLED_FILES += \
|
||||
lib/libQt5MultimediaQuick_p.so
|
||||
ANDROID_PERMISSIONS += \
|
||||
android.permission.CAMERA \
|
||||
android.permission.RECORD_AUDIO
|
||||
ANDROID_FEATURES += \
|
||||
android.hardware.camera
|
||||
MODULE_PLUGIN_TYPES = \
|
||||
mediaservice \
|
||||
audio \
|
||||
video/videonode
|
||||
|
||||
win32:LIBS += -luuid
|
||||
win32: LIBS_PRIVATE += -luuid
|
||||
|
||||
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
|
||||
|
||||
@@ -2,7 +2,7 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
|
||||
|
||||
project = QtMultimediaWidgets
|
||||
description = Qt Multimedia Widgets Documentation
|
||||
url = http://qt-project.org/doc/qt-$QT_VER/qtmultimediawidgets
|
||||
url = http://qt-project.org/doc/qt-$QT_VER
|
||||
version = $QT_VERSION
|
||||
|
||||
# The following parameters are for creating a qhp file, the qhelpgenerator
|
||||
|
||||
@@ -35,7 +35,7 @@ maemo6 {
|
||||
|
||||
SOURCES += qgraphicsvideoitem_maemo6.cpp
|
||||
|
||||
LIBS += -lX11
|
||||
LIBS_PRIVATE += -lX11
|
||||
} else {
|
||||
SOURCES += qgraphicsvideoitem.cpp
|
||||
}
|
||||
|
||||
@@ -159,7 +159,6 @@ public class QtAndroidMediaPlayer extends MediaPlayer
|
||||
public void onCompletion(final MediaPlayer mp)
|
||||
{
|
||||
onMediaPlayerInfoNative(MEDIA_PLAYER_FINISHED, 0, mID);
|
||||
reset();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -191,9 +190,9 @@ public class QtAndroidMediaPlayer extends MediaPlayer
|
||||
@Override
|
||||
public void onPrepared(final MediaPlayer mp)
|
||||
{
|
||||
mPreparing = false;
|
||||
onMediaPlayerInfoNative(MEDIA_PLAYER_READY, 0, mID);
|
||||
onMediaPlayerInfoNative(MEDIA_PLAYER_DURATION, getDuration(), mID);
|
||||
mPreparing = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -238,6 +238,10 @@ void QAndroidCameraFocusControl::updateFocusZones(QCameraFocusZone::FocusZoneSta
|
||||
return;
|
||||
|
||||
QSize viewportSize = m_session->camera()->previewSize();
|
||||
|
||||
if (!viewportSize.isValid())
|
||||
return;
|
||||
|
||||
QSizeF focusSize(50.f / viewportSize.width(), 50.f / viewportSize.height());
|
||||
float x = qBound(qreal(0),
|
||||
m_actualFocusPoint.x() - (focusSize.width() / 2),
|
||||
|
||||
@@ -52,6 +52,41 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class DataVideoBuffer : public QAbstractVideoBuffer
|
||||
{
|
||||
public:
|
||||
DataVideoBuffer(const QByteArray &d)
|
||||
: QAbstractVideoBuffer(NoHandle)
|
||||
, data(d)
|
||||
, mode(NotMapped)
|
||||
{ }
|
||||
|
||||
MapMode mapMode() const { return mode; }
|
||||
|
||||
uchar *map(MapMode m, int *numBytes, int *bytesPerLine)
|
||||
{
|
||||
if (mode != NotMapped || m == NotMapped)
|
||||
return 0;
|
||||
|
||||
mode = m;
|
||||
|
||||
if (numBytes)
|
||||
*numBytes = data.size();
|
||||
|
||||
if (bytesPerLine)
|
||||
*bytesPerLine = -1;
|
||||
|
||||
return reinterpret_cast<uchar *>(data.data());
|
||||
}
|
||||
|
||||
void unmap() { mode = NotMapped; }
|
||||
|
||||
private:
|
||||
QByteArray data;
|
||||
MapMode mode;
|
||||
};
|
||||
|
||||
|
||||
QAndroidCameraSession::QAndroidCameraSession(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_selectedCamera(0)
|
||||
@@ -205,8 +240,11 @@ void QAndroidCameraSession::adjustViewfinderSize(const QSize &captureSize, bool
|
||||
|
||||
QSize viewfinderResolution = m_camera->previewSize();
|
||||
const qreal aspectRatio = qreal(captureSize.width()) / qreal(captureSize.height());
|
||||
if (qFuzzyCompare(aspectRatio, qreal(viewfinderResolution.width()) / qreal(viewfinderResolution.height())))
|
||||
if (viewfinderResolution.isValid() &&
|
||||
qFuzzyCompare(aspectRatio,
|
||||
qreal(viewfinderResolution.width()) / viewfinderResolution.height())) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QSize> previewSizes = m_camera->getSupportedPreviewSizes();
|
||||
for (int i = previewSizes.count() - 1; i >= 0; --i) {
|
||||
@@ -270,6 +308,7 @@ void QAndroidCameraSession::stopPreview()
|
||||
JMultimediaUtils::enableOrientationListener(false);
|
||||
|
||||
m_camera->stopPreview();
|
||||
m_camera->setPreviewSize(QSize());
|
||||
if (m_videoOutput)
|
||||
m_videoOutput->stop();
|
||||
m_previewStarted = false;
|
||||
@@ -459,6 +498,7 @@ void QAndroidCameraSession::onCameraPictureCaptured(const QByteArray &data)
|
||||
QtConcurrent::run(this, &QAndroidCameraSession::processCapturedImage,
|
||||
m_currentImageCaptureId,
|
||||
data,
|
||||
m_imageSettings.resolution(),
|
||||
m_captureDestination,
|
||||
m_currentImageCaptureFileName);
|
||||
}
|
||||
@@ -473,6 +513,7 @@ void QAndroidCameraSession::onCameraPictureCaptured(const QByteArray &data)
|
||||
|
||||
void QAndroidCameraSession::processCapturedImage(int id,
|
||||
const QByteArray &data,
|
||||
const QSize &resolution,
|
||||
QCameraImageCapture::CaptureDestinations dest,
|
||||
const QString &fileName)
|
||||
{
|
||||
@@ -505,16 +546,8 @@ void QAndroidCameraSession::processCapturedImage(int id,
|
||||
}
|
||||
|
||||
if (dest & QCameraImageCapture::CaptureToBuffer) {
|
||||
QImage image;
|
||||
const bool ok = image.loadFromData(data, "JPG");
|
||||
|
||||
if (ok) {
|
||||
QVideoFrame frame(image);
|
||||
emit imageAvailable(id, frame);
|
||||
} else {
|
||||
emit imageCaptureError(id, QCameraImageCapture::FormatError,
|
||||
tr("Could not load JPEG data from captured image"));
|
||||
}
|
||||
QVideoFrame frame(new DataVideoBuffer(data), resolution, QVideoFrame::Format_Jpeg);
|
||||
emit imageAvailable(id, frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -127,6 +127,7 @@ private:
|
||||
void processPreviewImage(int id, const QByteArray &data);
|
||||
void processCapturedImage(int id,
|
||||
const QByteArray &data,
|
||||
const QSize &resolution,
|
||||
QCameraImageCapture::CaptureDestinations dest,
|
||||
const QString &fileName);
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ void QAndroidMediaPlayerControl::onMediaPlayerInfo(qint32 what, qint32 extra)
|
||||
Q_EMIT positionChanged(extra);
|
||||
break;
|
||||
case JMediaPlayer::MEDIA_PLAYER_FINISHED:
|
||||
setState(QMediaPlayer::StoppedState);
|
||||
stop();
|
||||
setMediaStatus(QMediaPlayer::EndOfMedia);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -261,8 +261,10 @@ void JCamera::setPreviewSize(const QSize &size)
|
||||
|
||||
m_previewSize = size;
|
||||
|
||||
m_parameters.callMethod<void>("setPreviewSize", "(II)V", size.width(), size.height());
|
||||
applyParameters();
|
||||
if (m_previewSize.isValid()) {
|
||||
m_parameters.callMethod<void>("setPreviewSize", "(II)V", size.width(), size.height());
|
||||
applyParameters();
|
||||
}
|
||||
|
||||
emit previewSizeChanged();
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
TARGET = qtmedia_blackberry
|
||||
QT += multimedia-private gui-private
|
||||
|
||||
PLUGIN_TYPE=mediaservice
|
||||
PLUGIN_CLASS_NAME = BbServicePlugin
|
||||
load(qt_plugin)
|
||||
|
||||
LIBS += -lscreen
|
||||
|
||||
HEADERS += bbserviceplugin.h
|
||||
SOURCES += bbserviceplugin.cpp
|
||||
|
||||
include(common/common.pri)
|
||||
|
||||
include(camera/camera.pri)
|
||||
|
||||
include(mediaplayer/mediaplayer.pri)
|
||||
|
||||
OTHER_FILES += blackberry_mediaservice.json
|
||||
@@ -1,21 +0,0 @@
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/bbmediaplayercontrol.h \
|
||||
$$PWD/bbmediaplayerservice.h \
|
||||
$$PWD/bbmetadata.h \
|
||||
$$PWD/bbmetadatareadercontrol.h \
|
||||
$$PWD/bbplayervideorenderercontrol.h \
|
||||
$$PWD/bbutil.h \
|
||||
$$PWD/bbvideowindowcontrol.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/bbmediaplayercontrol.cpp \
|
||||
$$PWD/bbmediaplayerservice.cpp \
|
||||
$$PWD/bbmetadata.cpp \
|
||||
$$PWD/bbmetadatareadercontrol.cpp \
|
||||
$$PWD/bbplayervideorenderercontrol.cpp \
|
||||
$$PWD/bbutil.cpp \
|
||||
$$PWD/bbvideowindowcontrol.cpp
|
||||
|
||||
LIBS += -lmmrndclient -lstrm
|
||||
@@ -389,86 +389,86 @@ void DirectShowMetaDataControl::updateGraph(IFilterGraph2 *graph, IBaseFilter *s
|
||||
if (FAILED(pStore->GetValue(key, &var)))
|
||||
continue;
|
||||
|
||||
if (key == PKEY_Author) {
|
||||
if (IsEqualPropertyKey(key, PKEY_Author)) {
|
||||
m_metadata.insert(QMediaMetaData::Author, convertValue(var));
|
||||
} else if (key == PKEY_Title) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Title)) {
|
||||
m_metadata.insert(QMediaMetaData::Title, convertValue(var));
|
||||
} else if (key == PKEY_Media_SubTitle) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Media_SubTitle)) {
|
||||
m_metadata.insert(QMediaMetaData::SubTitle, convertValue(var));
|
||||
} else if (key == PKEY_ParentalRating) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_ParentalRating)) {
|
||||
m_metadata.insert(QMediaMetaData::ParentalRating, convertValue(var));
|
||||
} else if (key == PKEY_Comment) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Comment)) {
|
||||
m_metadata.insert(QMediaMetaData::Description, convertValue(var));
|
||||
} else if (key == PKEY_Copyright) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Copyright)) {
|
||||
m_metadata.insert(QMediaMetaData::Copyright, convertValue(var));
|
||||
} else if (key == PKEY_Media_ProviderStyle) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Media_ProviderStyle)) {
|
||||
m_metadata.insert(QMediaMetaData::Genre, convertValue(var));
|
||||
} else if (key == PKEY_Media_Year) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Media_Year)) {
|
||||
m_metadata.insert(QMediaMetaData::Year, convertValue(var));
|
||||
} else if (key == PKEY_Media_DateEncoded) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Media_DateEncoded)) {
|
||||
m_metadata.insert(QMediaMetaData::Date, convertValue(var));
|
||||
} else if (key == PKEY_Rating) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Rating)) {
|
||||
m_metadata.insert(QMediaMetaData::UserRating,
|
||||
int((convertValue(var).toUInt() - 1) / qreal(98) * 100));
|
||||
} else if (key == PKEY_Keywords) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Keywords)) {
|
||||
m_metadata.insert(QMediaMetaData::Keywords, convertValue(var));
|
||||
} else if (key == PKEY_Language) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Language)) {
|
||||
m_metadata.insert(QMediaMetaData::Language, convertValue(var));
|
||||
} else if (key == PKEY_Media_Publisher) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Media_Publisher)) {
|
||||
m_metadata.insert(QMediaMetaData::Publisher, convertValue(var));
|
||||
} else if (key == PKEY_Media_Duration) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Media_Duration)) {
|
||||
m_metadata.insert(QMediaMetaData::Duration,
|
||||
(convertValue(var).toLongLong() + 10000) / 10000);
|
||||
} else if (key == PKEY_Audio_EncodingBitrate) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Audio_EncodingBitrate)) {
|
||||
m_metadata.insert(QMediaMetaData::AudioBitRate, convertValue(var));
|
||||
} else if (key == PKEY_Media_AverageLevel) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Media_AverageLevel)) {
|
||||
m_metadata.insert(QMediaMetaData::AverageLevel, convertValue(var));
|
||||
} else if (key == PKEY_Audio_ChannelCount) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Audio_ChannelCount)) {
|
||||
m_metadata.insert(QMediaMetaData::ChannelCount, convertValue(var));
|
||||
} else if (key == PKEY_Audio_PeakValue) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Audio_PeakValue)) {
|
||||
m_metadata.insert(QMediaMetaData::PeakValue, convertValue(var));
|
||||
} else if (key == PKEY_Audio_SampleRate) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Audio_SampleRate)) {
|
||||
m_metadata.insert(QMediaMetaData::SampleRate, convertValue(var));
|
||||
} else if (key == PKEY_Music_AlbumTitle) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Music_AlbumTitle)) {
|
||||
m_metadata.insert(QMediaMetaData::AlbumTitle, convertValue(var));
|
||||
} else if (key == PKEY_Music_AlbumArtist) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Music_AlbumArtist)) {
|
||||
m_metadata.insert(QMediaMetaData::AlbumArtist, convertValue(var));
|
||||
} else if (key == PKEY_Music_Artist) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Music_Artist)) {
|
||||
m_metadata.insert(QMediaMetaData::ContributingArtist, convertValue(var));
|
||||
} else if (key == PKEY_Music_Composer) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Music_Composer)) {
|
||||
m_metadata.insert(QMediaMetaData::Composer, convertValue(var));
|
||||
} else if (key == PKEY_Music_Conductor) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Music_Conductor)) {
|
||||
m_metadata.insert(QMediaMetaData::Conductor, convertValue(var));
|
||||
} else if (key == PKEY_Music_Lyrics) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Music_Lyrics)) {
|
||||
m_metadata.insert(QMediaMetaData::Lyrics, convertValue(var));
|
||||
} else if (key == PKEY_Music_Mood) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Music_Mood)) {
|
||||
m_metadata.insert(QMediaMetaData::Mood, convertValue(var));
|
||||
} else if (key == PKEY_Music_TrackNumber) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Music_TrackNumber)) {
|
||||
m_metadata.insert(QMediaMetaData::TrackNumber, convertValue(var));
|
||||
} else if (key == PKEY_Music_Genre) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Music_Genre)) {
|
||||
m_metadata.insert(QMediaMetaData::Genre, convertValue(var));
|
||||
} else if (key == PKEY_ThumbnailStream) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_ThumbnailStream)) {
|
||||
m_metadata.insert(QMediaMetaData::ThumbnailImage, convertValue(var));
|
||||
} else if (key == PKEY_Video_FrameHeight) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Video_FrameHeight)) {
|
||||
QSize res;
|
||||
res.setHeight(convertValue(var).toUInt());
|
||||
if (SUCCEEDED(pStore->GetValue(PKEY_Video_FrameWidth, &var)))
|
||||
res.setWidth(convertValue(var).toUInt());
|
||||
m_metadata.insert(QMediaMetaData::Resolution, res);
|
||||
} else if (key == PKEY_Video_HorizontalAspectRatio) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Video_HorizontalAspectRatio)) {
|
||||
QSize aspectRatio;
|
||||
aspectRatio.setWidth(convertValue(var).toUInt());
|
||||
if (SUCCEEDED(pStore->GetValue(PKEY_Video_VerticalAspectRatio, &var)))
|
||||
aspectRatio.setHeight(convertValue(var).toUInt());
|
||||
m_metadata.insert(QMediaMetaData::PixelAspectRatio, aspectRatio);
|
||||
} else if (key == PKEY_Video_FrameRate) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Video_FrameRate)) {
|
||||
m_metadata.insert(QMediaMetaData::VideoFrameRate,
|
||||
convertValue(var).toReal() / 1000);
|
||||
} else if (key == PKEY_Video_EncodingBitrate) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Video_EncodingBitrate)) {
|
||||
m_metadata.insert(QMediaMetaData::VideoBitRate, convertValue(var));
|
||||
} else if (key == PKEY_Video_Director) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Video_Director)) {
|
||||
m_metadata.insert(QMediaMetaData::Director, convertValue(var));
|
||||
} else if (key == PKEY_Media_Writer) {
|
||||
} else if (IsEqualPropertyKey(key, PKEY_Media_Writer)) {
|
||||
m_metadata.insert(QMediaMetaData::Writer, convertValue(var));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,15 +9,15 @@ TEMPLATE = subdirs
|
||||
SUBDIRS += m3u
|
||||
|
||||
android {
|
||||
SUBDIRS += android
|
||||
}
|
||||
|
||||
blackberry {
|
||||
SUBDIRS += blackberry
|
||||
SUBDIRS += android opensles
|
||||
}
|
||||
|
||||
qnx {
|
||||
SUBDIRS += audiocapture qnx
|
||||
SUBDIRS += qnx audiocapture
|
||||
}
|
||||
|
||||
qnx:!blackberry {
|
||||
SUBDIRS += qnx-audio
|
||||
}
|
||||
|
||||
win32 {
|
||||
@@ -52,10 +52,6 @@ mac:!simulator {
|
||||
!ios: SUBDIRS += qt7
|
||||
}
|
||||
|
||||
config_opensles {
|
||||
SUBDIRS += opensles
|
||||
}
|
||||
|
||||
config_resourcepolicy {
|
||||
SUBDIRS += resourcepolicy
|
||||
}
|
||||
|
||||
3
src/plugins/qnx-audio/qnx-audio.pro
Normal file
3
src/plugins/qnx-audio/qnx-audio.pro
Normal file
@@ -0,0 +1,3 @@
|
||||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS = audio
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
#include "bbcameraservice.h"
|
||||
#include "bbvideodeviceselectorcontrol.h"
|
||||
#include "bbmediaplayerservice.h"
|
||||
#include "mmrenderermediaplayerservice.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@@ -58,7 +58,7 @@ QMediaService *BbServicePlugin::create(const QString &key)
|
||||
return new BbCameraService();
|
||||
|
||||
if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER))
|
||||
return new BbMediaPlayerService();
|
||||
return new MmRendererMediaPlayerService();
|
||||
|
||||
return 0;
|
||||
}
|
||||
258
src/plugins/qnx/camera/bbcameralockscontrol.cpp
Normal file
258
src/plugins/qnx/camera/bbcameralockscontrol.cpp
Normal file
@@ -0,0 +1,258 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Research In Motion
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "bbcameralockscontrol.h"
|
||||
|
||||
#include "bbcamerasession.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
BbCameraLocksControl::BbCameraLocksControl(BbCameraSession *session, QObject *parent)
|
||||
: QCameraLocksControl(parent)
|
||||
, m_session(session)
|
||||
, m_locksApplyMode(IndependentMode)
|
||||
, m_focusLockStatus(QCamera::Unlocked)
|
||||
, m_exposureLockStatus(QCamera::Unlocked)
|
||||
, m_whiteBalanceLockStatus(QCamera::Unlocked)
|
||||
, m_currentLockTypes(QCamera::NoLock)
|
||||
, m_supportedLockTypes(QCamera::NoLock)
|
||||
{
|
||||
connect(m_session, SIGNAL(cameraOpened()), SLOT(cameraOpened()));
|
||||
connect(m_session, SIGNAL(focusStatusChanged(int)), SLOT(focusStatusChanged(int)));
|
||||
}
|
||||
|
||||
QCamera::LockTypes BbCameraLocksControl::supportedLocks() const
|
||||
{
|
||||
return (QCamera::LockFocus | QCamera::LockExposure | QCamera::LockWhiteBalance);
|
||||
}
|
||||
|
||||
QCamera::LockStatus BbCameraLocksControl::lockStatus(QCamera::LockType lock) const
|
||||
{
|
||||
if (!m_supportedLockTypes.testFlag(lock) || (m_session->handle() == CAMERA_HANDLE_INVALID))
|
||||
return QCamera::Locked;
|
||||
|
||||
switch (lock) {
|
||||
case QCamera::LockExposure:
|
||||
return m_exposureLockStatus;
|
||||
case QCamera::LockWhiteBalance:
|
||||
return m_whiteBalanceLockStatus;
|
||||
case QCamera::LockFocus:
|
||||
return m_focusLockStatus;
|
||||
default:
|
||||
return QCamera::Locked;
|
||||
}
|
||||
}
|
||||
|
||||
void BbCameraLocksControl::searchAndLock(QCamera::LockTypes locks)
|
||||
{
|
||||
if (m_session->handle() == CAMERA_HANDLE_INVALID)
|
||||
return;
|
||||
|
||||
// filter out unsupported locks
|
||||
locks &= m_supportedLockTypes;
|
||||
|
||||
m_currentLockTypes |= locks;
|
||||
|
||||
uint32_t lockModes = CAMERA_3A_NONE;
|
||||
|
||||
switch (m_locksApplyMode) {
|
||||
case IndependentMode:
|
||||
if (m_currentLockTypes & QCamera::LockExposure)
|
||||
lockModes |= CAMERA_3A_AUTOEXPOSURE;
|
||||
if (m_currentLockTypes & QCamera::LockWhiteBalance)
|
||||
lockModes |= CAMERA_3A_AUTOWHITEBALANCE;
|
||||
if (m_currentLockTypes & QCamera::LockFocus)
|
||||
lockModes |= CAMERA_3A_AUTOFOCUS;
|
||||
break;
|
||||
case FocusExposureBoundMode:
|
||||
if ((m_currentLockTypes & QCamera::LockExposure) || (m_currentLockTypes & QCamera::LockFocus))
|
||||
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS);
|
||||
break;
|
||||
case AllBoundMode:
|
||||
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOWHITEBALANCE);
|
||||
break;
|
||||
case FocusOnlyMode:
|
||||
lockModes = CAMERA_3A_AUTOFOCUS;
|
||||
break;
|
||||
}
|
||||
|
||||
const camera_error_t result = camera_set_3a_lock(m_session->handle(), lockModes);
|
||||
|
||||
if (result != CAMERA_EOK) {
|
||||
qWarning() << "Unable to set lock modes:" << result;
|
||||
} else {
|
||||
if (lockModes & CAMERA_3A_AUTOFOCUS) {
|
||||
// handled by focusStatusChanged()
|
||||
}
|
||||
|
||||
if (lockModes & CAMERA_3A_AUTOEXPOSURE) {
|
||||
m_exposureLockStatus = QCamera::Locked;
|
||||
emit lockStatusChanged(QCamera::LockExposure, QCamera::Locked, QCamera::LockAcquired);
|
||||
}
|
||||
|
||||
if (lockModes & CAMERA_3A_AUTOWHITEBALANCE) {
|
||||
m_whiteBalanceLockStatus = QCamera::Locked;
|
||||
emit lockStatusChanged(QCamera::LockWhiteBalance, QCamera::Locked, QCamera::LockAcquired);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BbCameraLocksControl::unlock(QCamera::LockTypes locks)
|
||||
{
|
||||
// filter out unsupported locks
|
||||
locks &= m_supportedLockTypes;
|
||||
|
||||
m_currentLockTypes &= ~locks;
|
||||
|
||||
uint32_t lockModes = CAMERA_3A_NONE;
|
||||
|
||||
switch (m_locksApplyMode) {
|
||||
case IndependentMode:
|
||||
if (m_currentLockTypes & QCamera::LockExposure)
|
||||
lockModes |= CAMERA_3A_AUTOEXPOSURE;
|
||||
if (m_currentLockTypes & QCamera::LockWhiteBalance)
|
||||
lockModes |= CAMERA_3A_AUTOWHITEBALANCE;
|
||||
if (m_currentLockTypes & QCamera::LockFocus)
|
||||
lockModes |= CAMERA_3A_AUTOFOCUS;
|
||||
break;
|
||||
case FocusExposureBoundMode:
|
||||
if ((m_currentLockTypes & QCamera::LockExposure) || (m_currentLockTypes & QCamera::LockFocus))
|
||||
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS);
|
||||
break;
|
||||
case AllBoundMode:
|
||||
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOWHITEBALANCE);
|
||||
break;
|
||||
case FocusOnlyMode:
|
||||
lockModes = CAMERA_3A_AUTOFOCUS;
|
||||
break;
|
||||
}
|
||||
|
||||
const camera_error_t result = camera_set_3a_lock(m_session->handle(), lockModes);
|
||||
|
||||
if (result != CAMERA_EOK) {
|
||||
qWarning() << "Unable to set lock modes:" << result;
|
||||
} else {
|
||||
if (locks.testFlag(QCamera::LockFocus)) {
|
||||
// handled by focusStatusChanged()
|
||||
}
|
||||
|
||||
if (locks.testFlag(QCamera::LockExposure)) {
|
||||
m_exposureLockStatus = QCamera::Unlocked;
|
||||
emit lockStatusChanged(QCamera::LockExposure, QCamera::Unlocked, QCamera::UserRequest);
|
||||
}
|
||||
|
||||
if (locks.testFlag(QCamera::LockWhiteBalance)) {
|
||||
m_whiteBalanceLockStatus = QCamera::Unlocked;
|
||||
emit lockStatusChanged(QCamera::LockWhiteBalance, QCamera::Unlocked, QCamera::UserRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BbCameraLocksControl::cameraOpened()
|
||||
{
|
||||
// retrieve information about lock apply modes
|
||||
int supported = 0;
|
||||
uint32_t modes[20];
|
||||
|
||||
const camera_error_t result = camera_get_3a_lock_modes(m_session->handle(), 20, &supported, modes);
|
||||
|
||||
if (result == CAMERA_EOK) {
|
||||
// see API documentation of camera_get_3a_lock_modes for explanation of case discrimination below
|
||||
if (supported == 4) {
|
||||
m_locksApplyMode = IndependentMode;
|
||||
} else if (supported == 3) {
|
||||
m_locksApplyMode = FocusExposureBoundMode;
|
||||
} else if (supported == 2) {
|
||||
if (modes[0] == (CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOWHITEBALANCE))
|
||||
m_locksApplyMode = AllBoundMode;
|
||||
else
|
||||
m_locksApplyMode = FocusOnlyMode;
|
||||
}
|
||||
}
|
||||
|
||||
// retrieve information about supported lock types
|
||||
m_supportedLockTypes = QCamera::NoLock;
|
||||
|
||||
if (camera_has_feature(m_session->handle(), CAMERA_FEATURE_AUTOFOCUS))
|
||||
m_supportedLockTypes |= QCamera::LockFocus;
|
||||
|
||||
if (camera_has_feature(m_session->handle(), CAMERA_FEATURE_AUTOEXPOSURE))
|
||||
m_supportedLockTypes |= QCamera::LockExposure;
|
||||
|
||||
if (camera_has_feature(m_session->handle(), CAMERA_FEATURE_AUTOWHITEBALANCE))
|
||||
m_supportedLockTypes |= QCamera::LockWhiteBalance;
|
||||
|
||||
m_focusLockStatus = QCamera::Unlocked;
|
||||
m_exposureLockStatus = QCamera::Unlocked;
|
||||
m_whiteBalanceLockStatus = QCamera::Unlocked;
|
||||
}
|
||||
|
||||
void BbCameraLocksControl::focusStatusChanged(int value)
|
||||
{
|
||||
const camera_focusstate_t focusState = static_cast<camera_focusstate_t>(value);
|
||||
|
||||
switch (focusState) {
|
||||
case CAMERA_FOCUSSTATE_NONE:
|
||||
m_focusLockStatus = QCamera::Unlocked;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::UserRequest);
|
||||
break;
|
||||
case CAMERA_FOCUSSTATE_WAITING:
|
||||
case CAMERA_FOCUSSTATE_SEARCHING:
|
||||
m_focusLockStatus = QCamera::Searching;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Searching, QCamera::UserRequest);
|
||||
break;
|
||||
case CAMERA_FOCUSSTATE_FAILED:
|
||||
m_focusLockStatus = QCamera::Unlocked;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockFailed);
|
||||
break;
|
||||
case CAMERA_FOCUSSTATE_LOCKED:
|
||||
m_focusLockStatus = QCamera::Locked;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Locked, QCamera::LockAcquired);
|
||||
break;
|
||||
case CAMERA_FOCUSSTATE_SCENECHANGE:
|
||||
m_focusLockStatus = QCamera::Unlocked;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockTemporaryLost);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
@@ -51,6 +51,14 @@ class BbCameraLocksControl : public QCameraLocksControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum LocksApplyMode
|
||||
{
|
||||
IndependentMode,
|
||||
FocusExposureBoundMode,
|
||||
AllBoundMode,
|
||||
FocusOnlyMode
|
||||
};
|
||||
|
||||
explicit BbCameraLocksControl(BbCameraSession *session, QObject *parent = 0);
|
||||
|
||||
QCamera::LockTypes supportedLocks() const Q_DECL_OVERRIDE;
|
||||
@@ -58,8 +66,19 @@ public:
|
||||
void searchAndLock(QCamera::LockTypes locks) Q_DECL_OVERRIDE;
|
||||
void unlock(QCamera::LockTypes locks) Q_DECL_OVERRIDE;
|
||||
|
||||
private Q_SLOTS:
|
||||
void cameraOpened();
|
||||
void focusStatusChanged(int value);
|
||||
|
||||
private:
|
||||
BbCameraSession *m_session;
|
||||
|
||||
LocksApplyMode m_locksApplyMode;
|
||||
QCamera::LockStatus m_focusLockStatus;
|
||||
QCamera::LockStatus m_exposureLockStatus;
|
||||
QCamera::LockStatus m_whiteBalanceLockStatus;
|
||||
QCamera::LockTypes m_currentLockTypes;
|
||||
QCamera::LockTypes m_supportedLockTypes;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
@@ -131,8 +131,6 @@ BbCameraSession::BbCameraSession(QObject *parent)
|
||||
, m_captureImageDriveMode(QCameraImageCapture::SingleImageCapture)
|
||||
, m_lastImageCaptureId(0)
|
||||
, m_captureDestination(QCameraImageCapture::CaptureToFile)
|
||||
, m_locksApplyMode(IndependentMode)
|
||||
, m_focusLockStatus(QCamera::Unlocked)
|
||||
, m_videoState(QMediaRecorder::StoppedState)
|
||||
, m_videoStatus(QMediaRecorder::LoadedStatus)
|
||||
, m_handle(CAMERA_HANDLE_INVALID)
|
||||
@@ -175,10 +173,8 @@ void BbCameraSession::setState(QCamera::State state)
|
||||
}
|
||||
} else if (state == QCamera::ActiveState) {
|
||||
if (openCamera()) {
|
||||
applyConfiguration();
|
||||
if (startViewFinder()) {
|
||||
m_state = state;
|
||||
}
|
||||
QMetaObject::invokeMethod(this, "applyConfiguration", Qt::QueuedConnection);
|
||||
m_state = state;
|
||||
}
|
||||
}
|
||||
} else if (previousState == QCamera::LoadedState) {
|
||||
@@ -186,10 +182,8 @@ void BbCameraSession::setState(QCamera::State state)
|
||||
closeCamera();
|
||||
m_state = state;
|
||||
} else if (state == QCamera::ActiveState) {
|
||||
applyConfiguration();
|
||||
if (startViewFinder()) {
|
||||
m_state = state;
|
||||
}
|
||||
QMetaObject::invokeMethod(this, "applyConfiguration", Qt::QueuedConnection);
|
||||
m_state = state;
|
||||
}
|
||||
} else if (previousState == QCamera::ActiveState) {
|
||||
if (state == QCamera::LoadedState) {
|
||||
@@ -458,95 +452,6 @@ void BbCameraSession::setImageSettings(const QImageEncoderSettings &settings)
|
||||
m_imageEncoderSettings.setCodec(QLatin1String("jpeg"));
|
||||
}
|
||||
|
||||
QCamera::LockTypes BbCameraSession::supportedLocks() const
|
||||
{
|
||||
if (m_locksApplyMode == FocusOnlyMode)
|
||||
return QCamera::LockFocus;
|
||||
else
|
||||
return (QCamera::LockExposure | QCamera::LockWhiteBalance | QCamera::LockFocus);
|
||||
}
|
||||
|
||||
QCamera::LockStatus BbCameraSession::lockStatus(QCamera::LockType lock) const
|
||||
{
|
||||
switch (lock) {
|
||||
case QCamera::LockExposure:
|
||||
return QCamera::Unlocked;
|
||||
case QCamera::LockWhiteBalance:
|
||||
return QCamera::Unlocked;
|
||||
case QCamera::LockFocus:
|
||||
return m_focusLockStatus;
|
||||
default:
|
||||
return QCamera::Unlocked;
|
||||
}
|
||||
}
|
||||
|
||||
void BbCameraSession::searchAndLock(QCamera::LockTypes locks)
|
||||
{
|
||||
m_currentLockTypes |= locks;
|
||||
|
||||
uint32_t lockModes = CAMERA_3A_NONE;
|
||||
|
||||
switch (m_locksApplyMode) {
|
||||
case IndependentMode:
|
||||
if (m_currentLockTypes & QCamera::LockExposure)
|
||||
lockModes |= CAMERA_3A_AUTOEXPOSURE;
|
||||
if (m_currentLockTypes & QCamera::LockWhiteBalance)
|
||||
lockModes |= CAMERA_3A_AUTOWHITEBALANCE;
|
||||
if (m_currentLockTypes & QCamera::LockFocus)
|
||||
lockModes |= CAMERA_3A_AUTOFOCUS;
|
||||
break;
|
||||
case FocusExposureBoundMode:
|
||||
if ((m_currentLockTypes & QCamera::LockExposure) || (m_currentLockTypes & QCamera::LockFocus))
|
||||
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS);
|
||||
break;
|
||||
case AllBoundMode:
|
||||
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOWHITEBALANCE);
|
||||
break;
|
||||
case FocusOnlyMode:
|
||||
lockModes = CAMERA_3A_AUTOFOCUS;
|
||||
break;
|
||||
}
|
||||
|
||||
const camera_error_t result = camera_set_3a_lock(m_handle, lockModes);
|
||||
|
||||
if (result != CAMERA_EOK) {
|
||||
qWarning() << "Unable to set lock modes:" << result;
|
||||
}
|
||||
}
|
||||
|
||||
void BbCameraSession::unlock(QCamera::LockTypes locks)
|
||||
{
|
||||
m_currentLockTypes &= ~locks;
|
||||
|
||||
uint32_t lockModes = CAMERA_3A_NONE;
|
||||
|
||||
switch (m_locksApplyMode) {
|
||||
case IndependentMode:
|
||||
if (m_currentLockTypes & QCamera::LockExposure)
|
||||
lockModes |= CAMERA_3A_AUTOEXPOSURE;
|
||||
if (m_currentLockTypes & QCamera::LockWhiteBalance)
|
||||
lockModes |= CAMERA_3A_AUTOWHITEBALANCE;
|
||||
if (m_currentLockTypes & QCamera::LockFocus)
|
||||
lockModes |= CAMERA_3A_AUTOFOCUS;
|
||||
break;
|
||||
case FocusExposureBoundMode:
|
||||
if ((m_currentLockTypes & QCamera::LockExposure) || (m_currentLockTypes & QCamera::LockFocus))
|
||||
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS);
|
||||
break;
|
||||
case AllBoundMode:
|
||||
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOWHITEBALANCE);
|
||||
break;
|
||||
case FocusOnlyMode:
|
||||
lockModes = CAMERA_3A_AUTOFOCUS;
|
||||
break;
|
||||
}
|
||||
|
||||
const camera_error_t result = camera_set_3a_lock(m_handle, lockModes);
|
||||
|
||||
if (result != CAMERA_EOK)
|
||||
qWarning() << "Unable to set lock modes:" << result;
|
||||
}
|
||||
|
||||
QUrl BbCameraSession::outputLocation() const
|
||||
{
|
||||
return QUrl::fromLocalFile(m_videoOutputLocation);
|
||||
@@ -647,13 +552,15 @@ void BbCameraSession::applyVideoSettings()
|
||||
|
||||
const QByteArray windowGroupId = m_windowGrabber->windowGroupId();
|
||||
|
||||
const int rotationAngle = (360 - m_nativeCameraOrientation);
|
||||
|
||||
camera_error_t result = CAMERA_EOK;
|
||||
result = camera_set_videovf_property(m_handle,
|
||||
CAMERA_IMGPROP_WIN_GROUPID, windowGroupId.data(),
|
||||
CAMERA_IMGPROP_WIN_ID, windowId.data(),
|
||||
CAMERA_IMGPROP_WIDTH, viewfinderResolution.width(),
|
||||
CAMERA_IMGPROP_HEIGHT, viewfinderResolution.height(),
|
||||
CAMERA_IMGPROP_ROTATION, 360 - m_nativeCameraOrientation);
|
||||
CAMERA_IMGPROP_ROTATION, rotationAngle);
|
||||
|
||||
if (result != CAMERA_EOK) {
|
||||
qWarning() << "Unable to apply video viewfinder settings:" << result;
|
||||
@@ -693,9 +600,11 @@ void BbCameraSession::applyVideoSettings()
|
||||
cameraAudioCodec = CAMERA_AUDIOCODEC_AAC;
|
||||
else if (audioCodec == QLatin1String("raw"))
|
||||
cameraAudioCodec = CAMERA_AUDIOCODEC_RAW;
|
||||
|
||||
result = camera_set_video_property(m_handle,
|
||||
CAMERA_IMGPROP_WIDTH, resolution.width(),
|
||||
CAMERA_IMGPROP_HEIGHT, resolution.height(),
|
||||
CAMERA_IMGPROP_ROTATION, rotationAngle,
|
||||
CAMERA_IMGPROP_VIDEOCODEC, cameraVideoCodec,
|
||||
CAMERA_IMGPROP_AUDIOCODEC, cameraAudioCodec);
|
||||
#else
|
||||
@@ -832,37 +741,6 @@ void BbCameraSession::imageCaptured(int requestId, const QImage &rawImage, const
|
||||
}
|
||||
}
|
||||
|
||||
void BbCameraSession::handleFocusStatusChanged(int value)
|
||||
{
|
||||
const camera_focusstate_t focusState = static_cast<camera_focusstate_t>(value);
|
||||
|
||||
switch (focusState) {
|
||||
case CAMERA_FOCUSSTATE_NONE:
|
||||
case CAMERA_FOCUSSTATE_WAITING:
|
||||
m_focusLockStatus = QCamera::Unlocked;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::UserRequest);
|
||||
break;
|
||||
case CAMERA_FOCUSSTATE_SEARCHING:
|
||||
m_focusLockStatus = QCamera::Searching;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Searching, QCamera::UserRequest);
|
||||
break;
|
||||
case CAMERA_FOCUSSTATE_FAILED:
|
||||
m_focusLockStatus = QCamera::Unlocked;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockFailed);
|
||||
break;
|
||||
case CAMERA_FOCUSSTATE_LOCKED:
|
||||
m_focusLockStatus = QCamera::Locked;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Locked, QCamera::LockAcquired);
|
||||
break;
|
||||
case CAMERA_FOCUSSTATE_SCENECHANGE:
|
||||
m_focusLockStatus = QCamera::Unlocked;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockTemporaryLost);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BbCameraSession::handleVideoRecordingPaused()
|
||||
{
|
||||
//TODO: implement once BB10 API supports pausing a video
|
||||
@@ -952,6 +830,8 @@ bool BbCameraSession::openCamera()
|
||||
m_status = QCamera::LoadedStatus;
|
||||
emit statusChanged(m_status);
|
||||
|
||||
emit cameraOpened();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -985,7 +865,7 @@ static void viewFinderStatusCallback(camera_handle_t handle, camera_devstatus_t
|
||||
|
||||
if (status == CAMERA_STATUS_FOCUS_CHANGE) {
|
||||
BbCameraSession *session = static_cast<BbCameraSession*>(context);
|
||||
QMetaObject::invokeMethod(session, "handleFocusStatusChanged", Qt::QueuedConnection, Q_ARG(int, value));
|
||||
QMetaObject::invokeMethod(session, "focusStatusChanged", Qt::QueuedConnection, Q_ARG(int, value));
|
||||
return;
|
||||
}
|
||||
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||
@@ -1016,28 +896,6 @@ bool BbCameraSession::startViewFinder()
|
||||
return false;
|
||||
}
|
||||
|
||||
// retrieve information about lock apply modes
|
||||
{
|
||||
int supported = 0;
|
||||
uint32_t modes[20];
|
||||
|
||||
const camera_error_t result = camera_get_3a_lock_modes(m_handle, 20, &supported, modes);
|
||||
|
||||
if (result == CAMERA_EOK) {
|
||||
// see API documentation of camera_get_3a_lock_modes for explanation of case discrimination below
|
||||
if (supported == 4) {
|
||||
m_locksApplyMode = IndependentMode;
|
||||
} else if (supported == 3) {
|
||||
m_locksApplyMode = FocusExposureBoundMode;
|
||||
} else if (supported == 2) {
|
||||
if (modes[0] == (CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOWHITEBALANCE))
|
||||
m_locksApplyMode = AllBoundMode;
|
||||
else
|
||||
m_locksApplyMode = FocusOnlyMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const int angle = m_orientationHandler->orientation();
|
||||
|
||||
const QSize rotatedSize = ((angle == 0 || angle == 180) ? viewfinderResolution
|
||||
@@ -1163,6 +1021,8 @@ void BbCameraSession::applyConfiguration()
|
||||
} else if (m_captureMode & QCamera::CaptureVideo) {
|
||||
applyVideoSettings();
|
||||
}
|
||||
|
||||
startViewFinder();
|
||||
}
|
||||
|
||||
static void videoRecordingStatusCallback(camera_handle_t handle, camera_devstatus_t status, uint16_t value, void *context)
|
||||
@@ -105,20 +105,6 @@ public:
|
||||
QImageEncoderSettings imageSettings() const;
|
||||
void setImageSettings(const QImageEncoderSettings &settings);
|
||||
|
||||
// locks control
|
||||
enum LocksApplyMode
|
||||
{
|
||||
IndependentMode,
|
||||
FocusExposureBoundMode,
|
||||
AllBoundMode,
|
||||
FocusOnlyMode
|
||||
};
|
||||
|
||||
QCamera::LockTypes supportedLocks() const;
|
||||
QCamera::LockStatus lockStatus(QCamera::LockType lock) const;
|
||||
void searchAndLock(QCamera::LockTypes locks);
|
||||
void unlock(QCamera::LockTypes locks);
|
||||
|
||||
// media recorder control
|
||||
QUrl outputLocation() const;
|
||||
bool setOutputLocation(const QUrl &location);
|
||||
@@ -157,9 +143,6 @@ Q_SIGNALS:
|
||||
// capture destination control
|
||||
void captureDestinationChanged(QCameraImageCapture::CaptureDestinations destination);
|
||||
|
||||
// locks control
|
||||
void lockStatusChanged(QCamera::LockType type, QCamera::LockStatus status, QCamera::LockChangeReason reason);
|
||||
|
||||
// media recorder control
|
||||
void videoStateChanged(QMediaRecorder::State state);
|
||||
void videoStatusChanged(QMediaRecorder::Status status);
|
||||
@@ -167,22 +150,24 @@ Q_SIGNALS:
|
||||
void actualLocationChanged(const QUrl &location);
|
||||
void videoError(int error, const QString &errorString);
|
||||
|
||||
void cameraOpened();
|
||||
void focusStatusChanged(int status);
|
||||
|
||||
private slots:
|
||||
void updateReadyForCapture();
|
||||
void imageCaptured(int, const QImage&, const QString&);
|
||||
void handleFocusStatusChanged(int);
|
||||
void handleVideoRecordingPaused();
|
||||
void handleVideoRecordingResumed();
|
||||
void deviceOrientationChanged(int);
|
||||
void handleCameraPowerUp();
|
||||
void viewfinderFrameGrabbed(const QImage &image);
|
||||
void applyConfiguration();
|
||||
|
||||
private:
|
||||
bool openCamera();
|
||||
void closeCamera();
|
||||
bool startViewFinder();
|
||||
void stopViewFinder();
|
||||
void applyConfiguration();
|
||||
bool startVideoRecording();
|
||||
void stopVideoRecording();
|
||||
|
||||
@@ -210,10 +195,6 @@ private:
|
||||
|
||||
QImageEncoderSettings m_imageEncoderSettings;
|
||||
|
||||
LocksApplyMode m_locksApplyMode;
|
||||
QCamera::LockStatus m_focusLockStatus;
|
||||
QCamera::LockTypes m_currentLockTypes;
|
||||
|
||||
QString m_videoOutputLocation;
|
||||
QMediaRecorder::State m_videoState;
|
||||
QMediaRecorder::Status m_videoStatus;
|
||||
@@ -47,7 +47,10 @@
|
||||
#include <QImage>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
|
||||
#ifdef Q_OS_BLACKBERRY
|
||||
#include <bps/event.h>
|
||||
#include <bps/screen.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -232,40 +235,55 @@ void WindowGrabber::resume()
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
bool WindowGrabber::nativeEventFilter(const QByteArray&, void *message, long*)
|
||||
bool WindowGrabber::handleScreenEvent(screen_event_t screen_event)
|
||||
{
|
||||
|
||||
int eventType;
|
||||
if (screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &eventType) != 0) {
|
||||
qWarning() << "WindowGrabber: Failed to query screen event type";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (eventType != SCREEN_EVENT_CREATE)
|
||||
return false;
|
||||
|
||||
screen_window_t window = 0;
|
||||
if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0) {
|
||||
qWarning() << "WindowGrabber: Failed to query window property";
|
||||
return false;
|
||||
}
|
||||
|
||||
const int maxIdStrLength = 128;
|
||||
char idString[maxIdStrLength];
|
||||
if (screen_get_window_property_cv(window, SCREEN_PROPERTY_ID_STRING, maxIdStrLength, idString) != 0) {
|
||||
qWarning() << "WindowGrabber: Failed to query window ID string";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_windowId == idString) {
|
||||
m_window = window;
|
||||
start();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WindowGrabber::nativeEventFilter(const QByteArray &eventType, void *message, long*)
|
||||
{
|
||||
#ifdef Q_OS_BLACKBERRY
|
||||
Q_UNUSED(eventType)
|
||||
bps_event_t * const event = static_cast<bps_event_t *>(message);
|
||||
|
||||
if (event && bps_event_get_domain(event) == screen_get_domain()) {
|
||||
const screen_event_t screen_event = screen_event_get_event(event);
|
||||
|
||||
int eventType;
|
||||
if (screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &eventType) != 0) {
|
||||
qWarning() << "WindowGrabber: Failed to query screen event type";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (eventType != SCREEN_EVENT_CREATE)
|
||||
return false;
|
||||
|
||||
screen_window_t window = 0;
|
||||
if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0) {
|
||||
qWarning() << "WindowGrabber: Failed to query window property";
|
||||
return false;
|
||||
}
|
||||
|
||||
const int maxIdStrLength = 128;
|
||||
char idString[maxIdStrLength];
|
||||
if (screen_get_window_property_cv(window, SCREEN_PROPERTY_ID_STRING, maxIdStrLength, idString) != 0) {
|
||||
qWarning() << "WindowGrabber: Failed to query window ID string";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_windowId == idString) {
|
||||
m_window = window;
|
||||
start();
|
||||
}
|
||||
return handleScreenEvent(screen_event);
|
||||
}
|
||||
#else
|
||||
if (eventType == "screen_event_t") {
|
||||
const screen_event_t event = static_cast<screen_event_t>(message);
|
||||
return handleScreenEvent(event);
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -69,6 +69,8 @@ public:
|
||||
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
|
||||
|
||||
bool handleScreenEvent(screen_event_t event);
|
||||
|
||||
QByteArray windowGroupId() const;
|
||||
|
||||
signals:
|
||||
117
src/plugins/qnx/mediaplayer/bpsmediaplayercontrol.cpp
Normal file
117
src/plugins/qnx/mediaplayer/bpsmediaplayercontrol.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Research In Motion
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "bpsmediaplayercontrol.h"
|
||||
#include "mmrenderervideowindowcontrol.h"
|
||||
|
||||
#include <bps/mmrenderer.h>
|
||||
#include <bps/screen.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
BpsMediaPlayerControl::BpsMediaPlayerControl(QObject *parent)
|
||||
: MmRendererMediaPlayerControl(parent),
|
||||
m_eventMonitor(0)
|
||||
{
|
||||
openConnection();
|
||||
}
|
||||
|
||||
BpsMediaPlayerControl::~BpsMediaPlayerControl()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void BpsMediaPlayerControl::startMonitoring(int contextId, const QString &contextName)
|
||||
{
|
||||
m_eventMonitor = mmrenderer_request_events(contextName.toLatin1().constData(), 0, contextId);
|
||||
if (!m_eventMonitor) {
|
||||
qDebug() << "Unable to request multimedia events";
|
||||
emit error(0, "Unable to request multimedia events");
|
||||
}
|
||||
}
|
||||
|
||||
void BpsMediaPlayerControl::stopMonitoring()
|
||||
{
|
||||
if (m_eventMonitor) {
|
||||
mmrenderer_stop_events(m_eventMonitor);
|
||||
m_eventMonitor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool BpsMediaPlayerControl::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
|
||||
{
|
||||
Q_UNUSED(result)
|
||||
Q_UNUSED(eventType)
|
||||
|
||||
bps_event_t * const event = static_cast<bps_event_t *>(message);
|
||||
if (!event ||
|
||||
(bps_event_get_domain(event) != mmrenderer_get_domain() &&
|
||||
bps_event_get_domain(event) != screen_get_domain()))
|
||||
return false;
|
||||
|
||||
if (event && bps_event_get_domain(event) == screen_get_domain()) {
|
||||
const screen_event_t screen_event = screen_event_get_event(event);
|
||||
if (MmRendererVideoWindowControl *control = videoWindowControl())
|
||||
control->screenEventHandler(screen_event);
|
||||
}
|
||||
|
||||
if (bps_event_get_domain(event) == mmrenderer_get_domain()) {
|
||||
if (bps_event_get_code(event) == MMRENDERER_STATE_CHANGE) {
|
||||
const mmrenderer_state_t newState = mmrenderer_event_get_state(event);
|
||||
if (newState == MMR_STOPPED) {
|
||||
handleMmStopped();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bps_event_get_code(event) == MMRENDERER_STATUS_UPDATE) {
|
||||
const qint64 newPosition = QString::fromLatin1(mmrenderer_event_get_position(event)).toLongLong();
|
||||
handleMmStatusUpdate(newPosition);
|
||||
|
||||
const QString bufferStatus = QString::fromLatin1(mmrenderer_event_get_bufferlevel(event));
|
||||
setMmBufferStatus(bufferStatus);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
@@ -38,38 +38,29 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "bbcameralockscontrol.h"
|
||||
#ifndef BPSMEDIAPLAYERCONTROL_H
|
||||
#define BPSMEDIAPLAYERCONTROL_H
|
||||
|
||||
#include "bbcamerasession.h"
|
||||
#include "mmrenderermediaplayercontrol.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
BbCameraLocksControl::BbCameraLocksControl(BbCameraSession *session, QObject *parent)
|
||||
: QCameraLocksControl(parent)
|
||||
, m_session(session)
|
||||
class BpsMediaPlayerControl Q_DECL_FINAL : public MmRendererMediaPlayerControl
|
||||
{
|
||||
connect(m_session, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)),
|
||||
this, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
|
||||
}
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BpsMediaPlayerControl(QObject *parent = 0);
|
||||
~BpsMediaPlayerControl();
|
||||
|
||||
QCamera::LockTypes BbCameraLocksControl::supportedLocks() const
|
||||
{
|
||||
return m_session->supportedLocks();
|
||||
}
|
||||
void startMonitoring(int contextId, const QString &contextName) Q_DECL_OVERRIDE;
|
||||
void stopMonitoring() Q_DECL_OVERRIDE;
|
||||
|
||||
QCamera::LockStatus BbCameraLocksControl::lockStatus(QCamera::LockType lock) const
|
||||
{
|
||||
return m_session->lockStatus(lock);
|
||||
}
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
|
||||
|
||||
void BbCameraLocksControl::searchAndLock(QCamera::LockTypes locks)
|
||||
{
|
||||
m_session->searchAndLock(locks);
|
||||
}
|
||||
|
||||
void BbCameraLocksControl::unlock(QCamera::LockTypes locks)
|
||||
{
|
||||
m_session->unlock(locks);
|
||||
}
|
||||
private:
|
||||
mmrenderer_monitor_t *m_eventMonitor;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
31
src/plugins/qnx/mediaplayer/mediaplayer.pri
Normal file
31
src/plugins/qnx/mediaplayer/mediaplayer.pri
Normal file
@@ -0,0 +1,31 @@
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/mmrenderermediaplayercontrol.h \
|
||||
$$PWD/mmrenderermediaplayerservice.h \
|
||||
$$PWD/mmrenderermetadata.h \
|
||||
$$PWD/mmrenderermetadatareadercontrol.h \
|
||||
$$PWD/mmrendererplayervideorenderercontrol.h \
|
||||
$$PWD/mmrendererutil.h \
|
||||
$$PWD/mmrenderervideowindowcontrol.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/mmrenderermediaplayercontrol.cpp \
|
||||
$$PWD/mmrenderermediaplayerservice.cpp \
|
||||
$$PWD/mmrenderermetadata.cpp \
|
||||
$$PWD/mmrenderermetadatareadercontrol.cpp \
|
||||
$$PWD/mmrendererplayervideorenderercontrol.cpp \
|
||||
$$PWD/mmrendererutil.cpp \
|
||||
$$PWD/mmrenderervideowindowcontrol.cpp
|
||||
|
||||
LIBS += -lmmrndclient -lstrm
|
||||
|
||||
blackberry {
|
||||
HEADERS += $$PWD/bpsmediaplayercontrol.h
|
||||
SOURCES += $$PWD/bpsmediaplayercontrol.cpp
|
||||
} else {
|
||||
HEADERS += $$PWD/ppsmediaplayercontrol.h
|
||||
SOURCES += $$PWD/ppsmediaplayercontrol.cpp
|
||||
QT += core-private
|
||||
LIBS += -lpps
|
||||
}
|
||||
@@ -38,19 +38,18 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "bbmediaplayercontrol.h"
|
||||
#include "bbmetadatareadercontrol.h"
|
||||
#include "bbplayervideorenderercontrol.h"
|
||||
#include "bbutil.h"
|
||||
#include "bbvideowindowcontrol.h"
|
||||
#include "mmrenderermediaplayercontrol.h"
|
||||
#include "mmrenderermetadatareadercontrol.h"
|
||||
#include "mmrendererplayervideorenderercontrol.h"
|
||||
#include "mmrendererutil.h"
|
||||
#include "mmrenderervideowindowcontrol.h"
|
||||
#include <QtCore/qabstracteventdispatcher.h>
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtCore/qdir.h>
|
||||
#include <QtCore/qfileinfo.h>
|
||||
#include <QtCore/quuid.h>
|
||||
#include <mm/renderer.h>
|
||||
#include <bps/mmrenderer.h>
|
||||
#include <bps/screen.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/strm.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -59,7 +58,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
static int idCounter = 0;
|
||||
|
||||
BbMediaPlayerControl::BbMediaPlayerControl(QObject *parent)
|
||||
MmRendererMediaPlayerControl::MmRendererMediaPlayerControl(QObject *parent)
|
||||
: QMediaPlayerControl(parent),
|
||||
m_connection(0),
|
||||
m_context(0),
|
||||
@@ -69,7 +68,6 @@ BbMediaPlayerControl::BbMediaPlayerControl(QObject *parent)
|
||||
m_muted(false),
|
||||
m_rate(1),
|
||||
m_id(-1),
|
||||
m_eventMonitor(0),
|
||||
m_position(0),
|
||||
m_mediaStatus(QMediaPlayer::NoMedia),
|
||||
m_playAfterMediaLoaded(false),
|
||||
@@ -81,10 +79,9 @@ BbMediaPlayerControl::BbMediaPlayerControl(QObject *parent)
|
||||
m_loadingTimer.setInterval(0);
|
||||
connect(&m_loadingTimer, SIGNAL(timeout()), this, SLOT(continueLoadMedia()));
|
||||
QCoreApplication::eventDispatcher()->installNativeEventFilter(this);
|
||||
openConnection();
|
||||
}
|
||||
|
||||
BbMediaPlayerControl::~BbMediaPlayerControl()
|
||||
void MmRendererMediaPlayerControl::destroy()
|
||||
{
|
||||
stop();
|
||||
detach();
|
||||
@@ -92,7 +89,7 @@ BbMediaPlayerControl::~BbMediaPlayerControl()
|
||||
QCoreApplication::eventDispatcher()->removeNativeEventFilter(this);
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::openConnection()
|
||||
void MmRendererMediaPlayerControl::openConnection()
|
||||
{
|
||||
m_connection = mmr_connect(NULL);
|
||||
if (!m_connection) {
|
||||
@@ -101,7 +98,7 @@ void BbMediaPlayerControl::openConnection()
|
||||
}
|
||||
|
||||
m_id = idCounter++;
|
||||
m_contextName = QString("BbMediaPlayerControl_%1_%2").arg(m_id)
|
||||
m_contextName = QString("MmRendererMediaPlayerControl_%1_%2").arg(m_id)
|
||||
.arg(QCoreApplication::applicationPid());
|
||||
m_context = mmr_context_create(m_connection, m_contextName.toLatin1(),
|
||||
0, S_IRWXU|S_IRWXG|S_IRWXO);
|
||||
@@ -111,19 +108,41 @@ void BbMediaPlayerControl::openConnection()
|
||||
return;
|
||||
}
|
||||
|
||||
m_eventMonitor = mmrenderer_request_events(m_contextName.toLatin1(), 0, m_id);
|
||||
if (!m_eventMonitor) {
|
||||
qDebug() << "Unable to request multimedia events";
|
||||
emit error(0, "Unable to request multimedia events");
|
||||
startMonitoring(m_id, m_contextName);
|
||||
}
|
||||
|
||||
void MmRendererMediaPlayerControl::handleMmStatusUpdate(qint64 newPosition)
|
||||
{
|
||||
// Prevent spurious position change events from overriding our own position, for example
|
||||
// when setting the position to 0 in stop().
|
||||
// Also, don't change the position while we're loading the media, as then play() would
|
||||
// set a wrong initial position.
|
||||
if (m_state != QMediaPlayer::PlayingState ||
|
||||
m_mediaStatus == QMediaPlayer::LoadingMedia ||
|
||||
m_mediaStatus == QMediaPlayer::NoMedia ||
|
||||
m_mediaStatus == QMediaPlayer::InvalidMedia)
|
||||
return;
|
||||
|
||||
setMmPosition(newPosition);
|
||||
}
|
||||
|
||||
void MmRendererMediaPlayerControl::handleMmStopped()
|
||||
{
|
||||
// Only react to stop events that happen when the end of the stream is reached and
|
||||
// playback is stopped because of this.
|
||||
// Ignore other stop event sources, souch as calling mmr_stop() ourselves and
|
||||
// mmr_input_attach().
|
||||
if (m_stopEventsToIgnore > 0) {
|
||||
--m_stopEventsToIgnore;
|
||||
} else {
|
||||
setMediaStatus(QMediaPlayer::EndOfMedia);
|
||||
stopInternal(IgnoreMmRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::closeConnection()
|
||||
void MmRendererMediaPlayerControl::closeConnection()
|
||||
{
|
||||
if (m_eventMonitor) {
|
||||
mmrenderer_stop_events(m_eventMonitor);
|
||||
m_eventMonitor = 0;
|
||||
}
|
||||
stopMonitoring();
|
||||
|
||||
if (m_context) {
|
||||
mmr_context_destroy(m_context);
|
||||
@@ -137,7 +156,7 @@ void BbMediaPlayerControl::closeConnection()
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray BbMediaPlayerControl::resourcePathForUrl(const QUrl &url)
|
||||
QByteArray MmRendererMediaPlayerControl::resourcePathForUrl(const QUrl &url)
|
||||
{
|
||||
// If this is a local file, mmrenderer expects the file:// prefix and an absolute path.
|
||||
// We treat URLs without scheme as local files, most likely someone just forgot to set the
|
||||
@@ -173,7 +192,7 @@ QByteArray BbMediaPlayerControl::resourcePathForUrl(const QUrl &url)
|
||||
}
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::attach()
|
||||
void MmRendererMediaPlayerControl::attach()
|
||||
{
|
||||
// Should only be called in detached state
|
||||
Q_ASSERT(m_audioId == -1 && !m_inputAttached && m_tempMediaFileName.isEmpty());
|
||||
@@ -219,7 +238,7 @@ void BbMediaPlayerControl::attach()
|
||||
emit bufferStatusChanged(m_bufferStatus);
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::detach()
|
||||
void MmRendererMediaPlayerControl::detach()
|
||||
{
|
||||
if (m_context) {
|
||||
if (m_inputAttached) {
|
||||
@@ -243,27 +262,27 @@ void BbMediaPlayerControl::detach()
|
||||
m_loadingTimer.stop();
|
||||
}
|
||||
|
||||
QMediaPlayer::State BbMediaPlayerControl::state() const
|
||||
QMediaPlayer::State MmRendererMediaPlayerControl::state() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
QMediaPlayer::MediaStatus BbMediaPlayerControl::mediaStatus() const
|
||||
QMediaPlayer::MediaStatus MmRendererMediaPlayerControl::mediaStatus() const
|
||||
{
|
||||
return m_mediaStatus;
|
||||
}
|
||||
|
||||
qint64 BbMediaPlayerControl::duration() const
|
||||
qint64 MmRendererMediaPlayerControl::duration() const
|
||||
{
|
||||
return m_metaData.duration();
|
||||
}
|
||||
|
||||
qint64 BbMediaPlayerControl::position() const
|
||||
qint64 MmRendererMediaPlayerControl::position() const
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setPosition(qint64 position)
|
||||
void MmRendererMediaPlayerControl::setPosition(qint64 position)
|
||||
{
|
||||
if (m_position != position) {
|
||||
m_position = position;
|
||||
@@ -277,12 +296,12 @@ void BbMediaPlayerControl::setPosition(qint64 position)
|
||||
}
|
||||
}
|
||||
|
||||
int BbMediaPlayerControl::volume() const
|
||||
int MmRendererMediaPlayerControl::volume() const
|
||||
{
|
||||
return m_volume;
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setVolumeInternal(int newVolume)
|
||||
void MmRendererMediaPlayerControl::setVolumeInternal(int newVolume)
|
||||
{
|
||||
if (!m_context)
|
||||
return;
|
||||
@@ -296,7 +315,7 @@ void BbMediaPlayerControl::setVolumeInternal(int newVolume)
|
||||
}
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setPlaybackRateInternal(qreal rate)
|
||||
void MmRendererMediaPlayerControl::setPlaybackRateInternal(qreal rate)
|
||||
{
|
||||
if (!m_context)
|
||||
return;
|
||||
@@ -306,7 +325,7 @@ void BbMediaPlayerControl::setPlaybackRateInternal(qreal rate)
|
||||
emitMmError("mmr_speed_set failed");
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setPositionInternal(qint64 position)
|
||||
void MmRendererMediaPlayerControl::setPositionInternal(qint64 position)
|
||||
{
|
||||
if (!m_context)
|
||||
return;
|
||||
@@ -317,7 +336,7 @@ void BbMediaPlayerControl::setPositionInternal(qint64 position)
|
||||
}
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setMediaStatus(QMediaPlayer::MediaStatus status)
|
||||
void MmRendererMediaPlayerControl::setMediaStatus(QMediaPlayer::MediaStatus status)
|
||||
{
|
||||
if (m_mediaStatus != status) {
|
||||
m_mediaStatus = status;
|
||||
@@ -325,7 +344,7 @@ void BbMediaPlayerControl::setMediaStatus(QMediaPlayer::MediaStatus status)
|
||||
}
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setState(QMediaPlayer::State state)
|
||||
void MmRendererMediaPlayerControl::setState(QMediaPlayer::State state)
|
||||
{
|
||||
if (m_state != state) {
|
||||
if (m_videoRendererControl) {
|
||||
@@ -342,7 +361,7 @@ void BbMediaPlayerControl::setState(QMediaPlayer::State state)
|
||||
}
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::stopInternal(StopCommand stopCommand)
|
||||
void MmRendererMediaPlayerControl::stopInternal(StopCommand stopCommand)
|
||||
{
|
||||
if (m_state != QMediaPlayer::StoppedState) {
|
||||
|
||||
@@ -360,7 +379,7 @@ void BbMediaPlayerControl::stopInternal(StopCommand stopCommand)
|
||||
}
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setVolume(int volume)
|
||||
void MmRendererMediaPlayerControl::setVolume(int volume)
|
||||
{
|
||||
const int newVolume = qBound(0, volume, 100);
|
||||
if (m_volume != newVolume) {
|
||||
@@ -371,12 +390,12 @@ void BbMediaPlayerControl::setVolume(int volume)
|
||||
}
|
||||
}
|
||||
|
||||
bool BbMediaPlayerControl::isMuted() const
|
||||
bool MmRendererMediaPlayerControl::isMuted() const
|
||||
{
|
||||
return m_muted;
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setMuted(bool muted)
|
||||
void MmRendererMediaPlayerControl::setMuted(bool muted)
|
||||
{
|
||||
if (m_muted != muted) {
|
||||
m_muted = muted;
|
||||
@@ -385,38 +404,38 @@ void BbMediaPlayerControl::setMuted(bool muted)
|
||||
}
|
||||
}
|
||||
|
||||
int BbMediaPlayerControl::bufferStatus() const
|
||||
int MmRendererMediaPlayerControl::bufferStatus() const
|
||||
{
|
||||
return m_bufferStatus;
|
||||
}
|
||||
|
||||
bool BbMediaPlayerControl::isAudioAvailable() const
|
||||
bool MmRendererMediaPlayerControl::isAudioAvailable() const
|
||||
{
|
||||
return m_metaData.hasAudio();
|
||||
}
|
||||
|
||||
bool BbMediaPlayerControl::isVideoAvailable() const
|
||||
bool MmRendererMediaPlayerControl::isVideoAvailable() const
|
||||
{
|
||||
return m_metaData.hasVideo();
|
||||
}
|
||||
|
||||
bool BbMediaPlayerControl::isSeekable() const
|
||||
bool MmRendererMediaPlayerControl::isSeekable() const
|
||||
{
|
||||
return m_metaData.isSeekable();
|
||||
}
|
||||
|
||||
QMediaTimeRange BbMediaPlayerControl::availablePlaybackRanges() const
|
||||
QMediaTimeRange MmRendererMediaPlayerControl::availablePlaybackRanges() const
|
||||
{
|
||||
// We can't get this information from the mmrenderer API yet, so pretend we can seek everywhere
|
||||
return QMediaTimeRange(0, m_metaData.duration());
|
||||
}
|
||||
|
||||
qreal BbMediaPlayerControl::playbackRate() const
|
||||
qreal MmRendererMediaPlayerControl::playbackRate() const
|
||||
{
|
||||
return m_rate;
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setPlaybackRate(qreal rate)
|
||||
void MmRendererMediaPlayerControl::setPlaybackRate(qreal rate)
|
||||
{
|
||||
if (m_rate != rate) {
|
||||
m_rate = rate;
|
||||
@@ -425,18 +444,18 @@ void BbMediaPlayerControl::setPlaybackRate(qreal rate)
|
||||
}
|
||||
}
|
||||
|
||||
QMediaContent BbMediaPlayerControl::media() const
|
||||
QMediaContent MmRendererMediaPlayerControl::media() const
|
||||
{
|
||||
return m_media;
|
||||
}
|
||||
|
||||
const QIODevice *BbMediaPlayerControl::mediaStream() const
|
||||
const QIODevice *MmRendererMediaPlayerControl::mediaStream() const
|
||||
{
|
||||
// Always 0, we don't support QIODevice streams
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setMedia(const QMediaContent &media, QIODevice *stream)
|
||||
void MmRendererMediaPlayerControl::setMedia(const QMediaContent &media, QIODevice *stream)
|
||||
{
|
||||
Q_UNUSED(stream); // not supported
|
||||
|
||||
@@ -460,7 +479,7 @@ void BbMediaPlayerControl::setMedia(const QMediaContent &media, QIODevice *strea
|
||||
}
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::continueLoadMedia()
|
||||
void MmRendererMediaPlayerControl::continueLoadMedia()
|
||||
{
|
||||
attach();
|
||||
updateMetaData();
|
||||
@@ -468,7 +487,17 @@ void BbMediaPlayerControl::continueLoadMedia()
|
||||
play();
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::play()
|
||||
QString MmRendererMediaPlayerControl::contextName() const
|
||||
{
|
||||
return m_contextName;
|
||||
}
|
||||
|
||||
MmRendererVideoWindowControl *MmRendererMediaPlayerControl::videoWindowControl() const
|
||||
{
|
||||
return m_videoWindowControl;
|
||||
}
|
||||
|
||||
void MmRendererMediaPlayerControl::play()
|
||||
{
|
||||
if (m_playAfterMediaLoaded)
|
||||
m_playAfterMediaLoaded = false;
|
||||
@@ -513,7 +542,7 @@ void BbMediaPlayerControl::play()
|
||||
setState( QMediaPlayer::PlayingState);
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::pause()
|
||||
void MmRendererMediaPlayerControl::pause()
|
||||
{
|
||||
if (m_state == QMediaPlayer::PlayingState) {
|
||||
setPlaybackRateInternal(0);
|
||||
@@ -521,94 +550,53 @@ void BbMediaPlayerControl::pause()
|
||||
}
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::stop()
|
||||
void MmRendererMediaPlayerControl::stop()
|
||||
{
|
||||
stopInternal(StopMmRenderer);
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setVideoRendererControl(BbPlayerVideoRendererControl *videoControl)
|
||||
MmRendererPlayerVideoRendererControl *MmRendererMediaPlayerControl::videoRendererControl() const
|
||||
{
|
||||
return m_videoRendererControl;
|
||||
}
|
||||
|
||||
void MmRendererMediaPlayerControl::setVideoRendererControl(MmRendererPlayerVideoRendererControl *videoControl)
|
||||
{
|
||||
m_videoRendererControl = videoControl;
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setVideoWindowControl(BbVideoWindowControl *videoControl)
|
||||
void MmRendererMediaPlayerControl::setVideoWindowControl(MmRendererVideoWindowControl *videoControl)
|
||||
{
|
||||
m_videoWindowControl = videoControl;
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::setMetaDataReaderControl(BbMetaDataReaderControl *metaDataReaderControl)
|
||||
void MmRendererMediaPlayerControl::setMetaDataReaderControl(MmRendererMetaDataReaderControl *metaDataReaderControl)
|
||||
{
|
||||
m_metaDataReaderControl = metaDataReaderControl;
|
||||
}
|
||||
|
||||
bool BbMediaPlayerControl::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
|
||||
void MmRendererMediaPlayerControl::setMmPosition(qint64 newPosition)
|
||||
{
|
||||
Q_UNUSED(eventType);
|
||||
Q_UNUSED(result);
|
||||
|
||||
bps_event_t * const event = static_cast<bps_event_t *>(message);
|
||||
if (!event ||
|
||||
(bps_event_get_domain(event) != mmrenderer_get_domain() &&
|
||||
bps_event_get_domain(event) != screen_get_domain()))
|
||||
return false;
|
||||
|
||||
if (m_videoWindowControl)
|
||||
m_videoWindowControl->bpsEventHandler(event);
|
||||
|
||||
if (bps_event_get_domain(event) == mmrenderer_get_domain()) {
|
||||
if (bps_event_get_code(event) == MMRENDERER_STATE_CHANGE) {
|
||||
const mmrenderer_state_t newState = mmrenderer_event_get_state(event);
|
||||
if (newState == MMR_STOPPED) {
|
||||
|
||||
// Only react to stop events that happen when the end of the stream is reached and
|
||||
// playback is stopped because of this.
|
||||
// Ignore other stop event sources, souch as calling mmr_stop() ourselves and
|
||||
// mmr_input_attach().
|
||||
if (m_stopEventsToIgnore > 0) {
|
||||
--m_stopEventsToIgnore;
|
||||
} else {
|
||||
setMediaStatus(QMediaPlayer::EndOfMedia);
|
||||
stopInternal(IgnoreMmRenderer);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bps_event_get_code(event) == MMRENDERER_STATUS_UPDATE) {
|
||||
|
||||
// Prevent spurious position change events from overriding our own position, for example
|
||||
// when setting the position to 0 in stop().
|
||||
// Also, don't change the position while we're loading the media, as then play() would
|
||||
// set a wrong initial position.
|
||||
if (m_state != QMediaPlayer::PlayingState ||
|
||||
m_mediaStatus == QMediaPlayer::LoadingMedia ||
|
||||
m_mediaStatus == QMediaPlayer::NoMedia ||
|
||||
m_mediaStatus == QMediaPlayer::InvalidMedia)
|
||||
return false;
|
||||
|
||||
const qint64 newPosition = QString::fromLatin1(mmrenderer_event_get_position(event)).toLongLong();
|
||||
if (newPosition != 0 && newPosition != m_position) {
|
||||
m_position = newPosition;
|
||||
emit positionChanged(m_position);
|
||||
}
|
||||
|
||||
const QString bufferStatus = QString::fromLatin1(mmrenderer_event_get_bufferlevel(event));
|
||||
const int slashPos = bufferStatus.indexOf('/');
|
||||
if (slashPos != -1) {
|
||||
const int fill = bufferStatus.left(slashPos).toInt();
|
||||
const int capacity = bufferStatus.mid(slashPos + 1).toInt();
|
||||
if (capacity != 0) {
|
||||
m_bufferStatus = fill / static_cast<float>(capacity) * 100.0f;
|
||||
emit bufferStatusChanged(m_bufferStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newPosition != 0 && newPosition != m_position) {
|
||||
m_position = newPosition;
|
||||
emit positionChanged(m_position);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::updateMetaData()
|
||||
void MmRendererMediaPlayerControl::setMmBufferStatus(const QString &bufferStatus)
|
||||
{
|
||||
const int slashPos = bufferStatus.indexOf('/');
|
||||
if (slashPos != -1) {
|
||||
const int fill = bufferStatus.left(slashPos).toInt();
|
||||
const int capacity = bufferStatus.mid(slashPos + 1).toInt();
|
||||
if (capacity != 0) {
|
||||
m_bufferStatus = fill / static_cast<float>(capacity) * 100.0f;
|
||||
emit bufferStatusChanged(m_bufferStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MmRendererMediaPlayerControl::updateMetaData()
|
||||
{
|
||||
if (m_mediaStatus == QMediaPlayer::LoadedMedia)
|
||||
m_metaData.parse(m_contextName);
|
||||
@@ -628,7 +616,7 @@ void BbMediaPlayerControl::updateMetaData()
|
||||
emit seekableChanged(m_metaData.isSeekable());
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::emitMmError(const QString &msg)
|
||||
void MmRendererMediaPlayerControl::emitMmError(const QString &msg)
|
||||
{
|
||||
int errorCode = MMR_ERROR_NONE;
|
||||
const QString errorMessage = mmErrorMessage(msg, m_context, &errorCode);
|
||||
@@ -636,7 +624,7 @@ void BbMediaPlayerControl::emitMmError(const QString &msg)
|
||||
emit error(errorCode, errorMessage);
|
||||
}
|
||||
|
||||
void BbMediaPlayerControl::emitPError(const QString &msg)
|
||||
void MmRendererMediaPlayerControl::emitPError(const QString &msg)
|
||||
{
|
||||
const QString errorMessage = QString("%1: %2").arg(msg).arg(strerror(errno));
|
||||
qDebug() << errorMessage;
|
||||
@@ -38,32 +38,30 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef BBMEDIAPLAYERCONTROL_H
|
||||
#define BBMEDIAPLAYERCONTROL_H
|
||||
#ifndef MMRENDERERMEDIAPLAYERCONTROL_H
|
||||
#define MMRENDERERMEDIAPLAYERCONTROL_H
|
||||
|
||||
#include "bbmetadata.h"
|
||||
#include "mmrenderermetadata.h"
|
||||
#include <qmediaplayercontrol.h>
|
||||
#include <QtCore/qabstractnativeeventfilter.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
#include <QtCore/qtimer.h>
|
||||
|
||||
struct bps_event_t;
|
||||
typedef struct mmr_connection mmr_connection_t;
|
||||
typedef struct mmr_context mmr_context_t;
|
||||
typedef struct mmrenderer_monitor mmrenderer_monitor_t;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class BbMetaDataReaderControl;
|
||||
class BbPlayerVideoRendererControl;
|
||||
class BbVideoWindowControl;
|
||||
class MmRendererMetaDataReaderControl;
|
||||
class MmRendererPlayerVideoRendererControl;
|
||||
class MmRendererVideoWindowControl;
|
||||
|
||||
class BbMediaPlayerControl : public QMediaPlayerControl, public QAbstractNativeEventFilter
|
||||
class MmRendererMediaPlayerControl : public QMediaPlayerControl, public QAbstractNativeEventFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BbMediaPlayerControl(QObject *parent = 0);
|
||||
~BbMediaPlayerControl();
|
||||
explicit MmRendererMediaPlayerControl(QObject *parent = 0);
|
||||
|
||||
QMediaPlayer::State state() const Q_DECL_OVERRIDE;
|
||||
|
||||
@@ -100,25 +98,39 @@ public:
|
||||
void pause() Q_DECL_OVERRIDE;
|
||||
void stop() Q_DECL_OVERRIDE;
|
||||
|
||||
void setVideoRendererControl(BbPlayerVideoRendererControl *videoControl);
|
||||
void setVideoWindowControl(BbVideoWindowControl *videoControl);
|
||||
void setMetaDataReaderControl(BbMetaDataReaderControl *metaDataReaderControl);
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
|
||||
MmRendererPlayerVideoRendererControl *videoRendererControl() const;
|
||||
void setVideoRendererControl(MmRendererPlayerVideoRendererControl *videoControl);
|
||||
|
||||
MmRendererVideoWindowControl *videoWindowControl() const;
|
||||
void setVideoWindowControl(MmRendererVideoWindowControl *videoControl);
|
||||
void setMetaDataReaderControl(MmRendererMetaDataReaderControl *metaDataReaderControl);
|
||||
|
||||
protected:
|
||||
virtual void startMonitoring(int contextId, const QString &contextName) = 0;
|
||||
virtual void stopMonitoring() = 0;
|
||||
|
||||
QString contextName() const;
|
||||
void openConnection();
|
||||
void emitMmError(const QString &msg);
|
||||
void emitPError(const QString &msg);
|
||||
void setMmPosition(qint64 newPosition);
|
||||
void setMmBufferStatus(const QString &bufferStatus);
|
||||
void handleMmStopped();
|
||||
void handleMmStatusUpdate(qint64 position);
|
||||
|
||||
// must be called from subclass dtors (calls virtual function stopMonitoring())
|
||||
void destroy();
|
||||
|
||||
private Q_SLOTS:
|
||||
void continueLoadMedia();
|
||||
|
||||
private:
|
||||
QByteArray resourcePathForUrl(const QUrl &url);
|
||||
void openConnection();
|
||||
void closeConnection();
|
||||
void attach();
|
||||
void detach();
|
||||
void updateMetaData();
|
||||
|
||||
void emitMmError(const QString &msg);
|
||||
void emitPError(const QString &msg);
|
||||
|
||||
// All these set the specified value to the backend, but neither emit changed signals
|
||||
// nor change the member value.
|
||||
void setVolumeInternal(int newVolume);
|
||||
@@ -140,12 +152,11 @@ private:
|
||||
int m_volume;
|
||||
bool m_muted;
|
||||
qreal m_rate;
|
||||
QPointer<BbPlayerVideoRendererControl> m_videoRendererControl;
|
||||
QPointer<BbVideoWindowControl> m_videoWindowControl;
|
||||
QPointer<BbMetaDataReaderControl> m_metaDataReaderControl;
|
||||
BbMetaData m_metaData;
|
||||
QPointer<MmRendererPlayerVideoRendererControl> m_videoRendererControl;
|
||||
QPointer<MmRendererVideoWindowControl> m_videoWindowControl;
|
||||
QPointer<MmRendererMetaDataReaderControl> m_metaDataReaderControl;
|
||||
MmRendererMetaData m_metaData;
|
||||
int m_id;
|
||||
mmrenderer_monitor_t *m_eventMonitor;
|
||||
qint64 m_position;
|
||||
QMediaPlayer::MediaStatus m_mediaStatus;
|
||||
bool m_playAfterMediaLoaded;
|
||||
@@ -38,17 +38,25 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "bbmediaplayerservice.h"
|
||||
#include "mmrenderermediaplayerservice.h"
|
||||
|
||||
#include "bbmediaplayercontrol.h"
|
||||
#include "bbmetadatareadercontrol.h"
|
||||
#include "bbplayervideorenderercontrol.h"
|
||||
#include "bbutil.h"
|
||||
#include "bbvideowindowcontrol.h"
|
||||
#include "mmrenderermediaplayercontrol.h"
|
||||
#include "mmrenderermetadatareadercontrol.h"
|
||||
#include "mmrendererplayervideorenderercontrol.h"
|
||||
#include "mmrendererutil.h"
|
||||
#include "mmrenderervideowindowcontrol.h"
|
||||
|
||||
#ifdef Q_OS_BLACKBERRY
|
||||
#include "bpsmediaplayercontrol.h"
|
||||
typedef BpsMediaPlayerControl PlatformSpecificMediaPlayerControl;
|
||||
#else
|
||||
#include "ppsmediaplayercontrol.h"
|
||||
typedef PpsMediaPlayerControl PlatformSpecificMediaPlayerControl;
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
BbMediaPlayerService::BbMediaPlayerService(QObject *parent)
|
||||
MmRendererMediaPlayerService::MmRendererMediaPlayerService(QObject *parent)
|
||||
: QMediaService(parent),
|
||||
m_videoRendererControl(0),
|
||||
m_videoWindowControl(0),
|
||||
@@ -59,7 +67,7 @@ BbMediaPlayerService::BbMediaPlayerService(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
BbMediaPlayerService::~BbMediaPlayerService()
|
||||
MmRendererMediaPlayerService::~MmRendererMediaPlayerService()
|
||||
{
|
||||
// Someone should have called releaseControl(), but better be safe
|
||||
delete m_videoRendererControl;
|
||||
@@ -68,18 +76,18 @@ BbMediaPlayerService::~BbMediaPlayerService()
|
||||
delete m_metaDataReaderControl;
|
||||
}
|
||||
|
||||
QMediaControl *BbMediaPlayerService::requestControl(const char *name)
|
||||
QMediaControl *MmRendererMediaPlayerService::requestControl(const char *name)
|
||||
{
|
||||
if (qstrcmp(name, QMediaPlayerControl_iid) == 0) {
|
||||
if (!m_mediaPlayerControl) {
|
||||
m_mediaPlayerControl = new BbMediaPlayerControl();
|
||||
m_mediaPlayerControl = new PlatformSpecificMediaPlayerControl;
|
||||
updateControls();
|
||||
}
|
||||
return m_mediaPlayerControl;
|
||||
}
|
||||
else if (qstrcmp(name, QMetaDataReaderControl_iid) == 0) {
|
||||
if (!m_metaDataReaderControl) {
|
||||
m_metaDataReaderControl = new BbMetaDataReaderControl();
|
||||
m_metaDataReaderControl = new MmRendererMetaDataReaderControl();
|
||||
updateControls();
|
||||
}
|
||||
return m_metaDataReaderControl;
|
||||
@@ -98,14 +106,14 @@ QMediaControl *BbMediaPlayerService::requestControl(const char *name)
|
||||
}
|
||||
|
||||
if (!m_videoRendererControl) {
|
||||
m_videoRendererControl = new BbPlayerVideoRendererControl();
|
||||
m_videoRendererControl = new MmRendererPlayerVideoRendererControl();
|
||||
updateControls();
|
||||
}
|
||||
return m_videoRendererControl;
|
||||
}
|
||||
else if (qstrcmp(name, QVideoWindowControl_iid) == 0) {
|
||||
if (!m_videoWindowControl) {
|
||||
m_videoWindowControl = new BbVideoWindowControl();
|
||||
m_videoWindowControl = new MmRendererVideoWindowControl();
|
||||
updateControls();
|
||||
}
|
||||
return m_videoWindowControl;
|
||||
@@ -113,7 +121,7 @@ QMediaControl *BbMediaPlayerService::requestControl(const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BbMediaPlayerService::releaseControl(QMediaControl *control)
|
||||
void MmRendererMediaPlayerService::releaseControl(QMediaControl *control)
|
||||
{
|
||||
if (control == m_videoRendererControl)
|
||||
m_videoRendererControl = 0;
|
||||
@@ -126,7 +134,7 @@ void BbMediaPlayerService::releaseControl(QMediaControl *control)
|
||||
delete control;
|
||||
}
|
||||
|
||||
void BbMediaPlayerService::updateControls()
|
||||
void MmRendererMediaPlayerService::updateControls()
|
||||
{
|
||||
if (m_videoRendererControl && m_mediaPlayerControl)
|
||||
m_mediaPlayerControl->setVideoRendererControl(m_videoRendererControl);
|
||||
@@ -38,25 +38,25 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef BBMEDIAPLAYERSERVICE_H
|
||||
#define BBMEDIAPLAYERSERVICE_H
|
||||
#ifndef MMRENDERERMEDIAPLAYERSERVICE_H
|
||||
#define MMRENDERERMEDIAPLAYERSERVICE_H
|
||||
|
||||
#include <qmediaservice.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class BbMediaPlayerControl;
|
||||
class BbMetaDataReaderControl;
|
||||
class BbPlayerVideoRendererControl;
|
||||
class BbVideoWindowControl;
|
||||
class MmRendererMediaPlayerControl;
|
||||
class MmRendererMetaDataReaderControl;
|
||||
class MmRendererPlayerVideoRendererControl;
|
||||
class MmRendererVideoWindowControl;
|
||||
|
||||
class BbMediaPlayerService : public QMediaService
|
||||
class MmRendererMediaPlayerService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BbMediaPlayerService(QObject *parent = 0);
|
||||
~BbMediaPlayerService();
|
||||
explicit MmRendererMediaPlayerService(QObject *parent = 0);
|
||||
~MmRendererMediaPlayerService();
|
||||
|
||||
QMediaControl *requestControl(const char *name) Q_DECL_OVERRIDE;
|
||||
void releaseControl(QMediaControl *control) Q_DECL_OVERRIDE;
|
||||
@@ -64,10 +64,10 @@ public:
|
||||
private:
|
||||
void updateControls();
|
||||
|
||||
QPointer<BbPlayerVideoRendererControl> m_videoRendererControl;
|
||||
QPointer<BbVideoWindowControl> m_videoWindowControl;
|
||||
QPointer<BbMediaPlayerControl> m_mediaPlayerControl;
|
||||
QPointer<BbMetaDataReaderControl> m_metaDataReaderControl;
|
||||
QPointer<MmRendererPlayerVideoRendererControl> m_videoRendererControl;
|
||||
QPointer<MmRendererVideoWindowControl> m_videoWindowControl;
|
||||
QPointer<MmRendererMediaPlayerControl> m_mediaPlayerControl;
|
||||
QPointer<MmRendererMetaDataReaderControl> m_metaDataReaderControl;
|
||||
|
||||
bool m_appHasDrmPermission : 1;
|
||||
bool m_appHasDrmPermissionChecked : 1;
|
||||
@@ -38,7 +38,7 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "bbmetadata.h"
|
||||
#include "mmrenderermetadata.h"
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qfile.h>
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
BbMetaData::BbMetaData()
|
||||
MmRendererMetaData::MmRendererMetaData()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
@@ -64,14 +64,14 @@ static const char * trackKey = "md_title_track";
|
||||
static const char * widthKey = "md_video_width";
|
||||
static const char * heightKey = "md_video_height";
|
||||
static const char * mediaTypeKey = "md_title_mediatype";
|
||||
static const char * pixelWidthKey = "md_video_pixel_height";
|
||||
static const char * pixelHeightKey = "md_video_pixel_width";
|
||||
static const char * pixelWidthKey = "md_video_pixel_width";
|
||||
static const char * pixelHeightKey = "md_video_pixel_height";
|
||||
static const char * seekableKey = "md_title_seekable";
|
||||
|
||||
static const int mediaTypeAudioFlag = 4;
|
||||
static const int mediaTypeVideoFlag = 2;
|
||||
|
||||
bool BbMetaData::parse(const QString &contextName)
|
||||
bool MmRendererMetaData::parse(const QString &contextName)
|
||||
{
|
||||
clear();
|
||||
QString fileName =
|
||||
@@ -138,7 +138,7 @@ bool BbMetaData::parse(const QString &contextName)
|
||||
return true;
|
||||
}
|
||||
|
||||
void BbMetaData::clear()
|
||||
void MmRendererMetaData::clear()
|
||||
{
|
||||
m_duration = 0;
|
||||
m_height = 0;
|
||||
@@ -158,7 +158,7 @@ void BbMetaData::clear()
|
||||
m_track = 0;
|
||||
}
|
||||
|
||||
qlonglong BbMetaData::duration() const
|
||||
qlonglong MmRendererMetaData::duration() const
|
||||
{
|
||||
return m_duration;
|
||||
}
|
||||
@@ -173,17 +173,17 @@ qlonglong BbMetaData::duration() const
|
||||
// is 600x200, which will cause the video to be displayed in an aspect ratio of 3:1 instead of 3:2,
|
||||
// and therefore look correct.
|
||||
|
||||
int BbMetaData::height() const
|
||||
int MmRendererMetaData::height() const
|
||||
{
|
||||
return m_height * m_pixelHeight;
|
||||
}
|
||||
|
||||
int BbMetaData::width() const
|
||||
int MmRendererMetaData::width() const
|
||||
{
|
||||
return m_width * m_pixelWidth;
|
||||
}
|
||||
|
||||
bool BbMetaData::hasVideo() const
|
||||
bool MmRendererMetaData::hasVideo() const
|
||||
{
|
||||
// By default, assume no video if we can't extract the information
|
||||
if (m_mediaType == -1)
|
||||
@@ -192,7 +192,7 @@ bool BbMetaData::hasVideo() const
|
||||
return (m_mediaType & mediaTypeVideoFlag);
|
||||
}
|
||||
|
||||
bool BbMetaData::hasAudio() const
|
||||
bool MmRendererMetaData::hasAudio() const
|
||||
{
|
||||
// By default, assume audio only if we can't extract the information
|
||||
if (m_mediaType == -1)
|
||||
@@ -201,37 +201,37 @@ bool BbMetaData::hasAudio() const
|
||||
return (m_mediaType & mediaTypeAudioFlag);
|
||||
}
|
||||
|
||||
QString BbMetaData::title() const
|
||||
QString MmRendererMetaData::title() const
|
||||
{
|
||||
return m_title;
|
||||
}
|
||||
|
||||
bool BbMetaData::isSeekable() const
|
||||
bool MmRendererMetaData::isSeekable() const
|
||||
{
|
||||
return m_seekable;
|
||||
}
|
||||
|
||||
QString BbMetaData::artist() const
|
||||
QString MmRendererMetaData::artist() const
|
||||
{
|
||||
return m_artist;
|
||||
}
|
||||
|
||||
QString BbMetaData::comment() const
|
||||
QString MmRendererMetaData::comment() const
|
||||
{
|
||||
return m_comment;
|
||||
}
|
||||
|
||||
QString BbMetaData::genre() const
|
||||
QString MmRendererMetaData::genre() const
|
||||
{
|
||||
return m_genre;
|
||||
}
|
||||
|
||||
int BbMetaData::year() const
|
||||
int MmRendererMetaData::year() const
|
||||
{
|
||||
return m_year;
|
||||
}
|
||||
|
||||
QString BbMetaData::mediaType() const
|
||||
QString MmRendererMetaData::mediaType() const
|
||||
{
|
||||
if (hasVideo())
|
||||
return QLatin1String("video");
|
||||
@@ -241,27 +241,27 @@ QString BbMetaData::mediaType() const
|
||||
return QString();
|
||||
}
|
||||
|
||||
int BbMetaData::audioBitRate() const
|
||||
int MmRendererMetaData::audioBitRate() const
|
||||
{
|
||||
return m_audioBitRate;
|
||||
}
|
||||
|
||||
int BbMetaData::sampleRate() const
|
||||
int MmRendererMetaData::sampleRate() const
|
||||
{
|
||||
return m_sampleRate;
|
||||
}
|
||||
|
||||
QString BbMetaData::album() const
|
||||
QString MmRendererMetaData::album() const
|
||||
{
|
||||
return m_album;
|
||||
}
|
||||
|
||||
int BbMetaData::track() const
|
||||
int MmRendererMetaData::track() const
|
||||
{
|
||||
return m_track;
|
||||
}
|
||||
|
||||
QSize BbMetaData::resolution() const
|
||||
QSize MmRendererMetaData::resolution() const
|
||||
{
|
||||
return QSize(width(), height());
|
||||
}
|
||||
@@ -38,8 +38,8 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef BBMETADATA_H
|
||||
#define BBMETADATA_H
|
||||
#ifndef MMRENDERERMETADATA_H
|
||||
#define MMRENDERERMETADATA_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore/QSize>
|
||||
@@ -47,10 +47,10 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class BbMetaData
|
||||
class MmRendererMetaData
|
||||
{
|
||||
public:
|
||||
BbMetaData();
|
||||
MmRendererMetaData();
|
||||
bool parse(const QString &contextName);
|
||||
void clear();
|
||||
|
||||
@@ -38,22 +38,22 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "bbmetadatareadercontrol.h"
|
||||
#include "mmrenderermetadatareadercontrol.h"
|
||||
#include <QtMultimedia/qmediametadata.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
BbMetaDataReaderControl::BbMetaDataReaderControl(QObject *parent)
|
||||
MmRendererMetaDataReaderControl::MmRendererMetaDataReaderControl(QObject *parent)
|
||||
: QMetaDataReaderControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool BbMetaDataReaderControl::isMetaDataAvailable() const
|
||||
bool MmRendererMetaDataReaderControl::isMetaDataAvailable() const
|
||||
{
|
||||
return !availableMetaData().isEmpty();
|
||||
}
|
||||
|
||||
QVariant BbMetaDataReaderControl::metaData(const QString &key) const
|
||||
QVariant MmRendererMetaDataReaderControl::metaData(const QString &key) const
|
||||
{
|
||||
if (key == QMediaMetaData::Title)
|
||||
return m_metaData.title();
|
||||
@@ -83,7 +83,7 @@ QVariant BbMetaDataReaderControl::metaData(const QString &key) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QStringList BbMetaDataReaderControl::availableMetaData() const
|
||||
QStringList MmRendererMetaDataReaderControl::availableMetaData() const
|
||||
{
|
||||
QStringList metaData;
|
||||
|
||||
@@ -115,9 +115,9 @@ QStringList BbMetaDataReaderControl::availableMetaData() const
|
||||
return metaData;
|
||||
}
|
||||
|
||||
void BbMetaDataReaderControl::setMetaData(const BbMetaData &data)
|
||||
void MmRendererMetaDataReaderControl::setMetaData(const MmRendererMetaData &data)
|
||||
{
|
||||
const BbMetaData oldMetaData = m_metaData;
|
||||
const MmRendererMetaData oldMetaData = m_metaData;
|
||||
const bool oldMetaDataAvailable = isMetaDataAvailable();
|
||||
|
||||
m_metaData = data;
|
||||
@@ -38,29 +38,29 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef BBMETADATAREADERCONTROL_H
|
||||
#define BBMETADATAREADERCONTROL_H
|
||||
#ifndef MMRENDERERMETADATAREADERCONTROL_H
|
||||
#define MMRENDERERMETADATAREADERCONTROL_H
|
||||
|
||||
#include "bbmetadata.h"
|
||||
#include "mmrenderermetadata.h"
|
||||
#include <qmetadatareadercontrol.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class BbMetaDataReaderControl : public QMetaDataReaderControl
|
||||
class MmRendererMetaDataReaderControl : public QMetaDataReaderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BbMetaDataReaderControl(QObject *parent = 0);
|
||||
explicit MmRendererMetaDataReaderControl(QObject *parent = 0);
|
||||
|
||||
bool isMetaDataAvailable() const Q_DECL_OVERRIDE;
|
||||
|
||||
QVariant metaData(const QString &key) const Q_DECL_OVERRIDE;
|
||||
QStringList availableMetaData() const Q_DECL_OVERRIDE;
|
||||
|
||||
void setMetaData(const BbMetaData &data);
|
||||
void setMetaData(const MmRendererMetaData &data);
|
||||
|
||||
private:
|
||||
BbMetaData m_metaData;
|
||||
MmRendererMetaData m_metaData;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
@@ -39,7 +39,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "bbplayervideorenderercontrol.h"
|
||||
#include "mmrendererplayervideorenderercontrol.h"
|
||||
|
||||
#include "windowgrabber.h"
|
||||
|
||||
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
static int winIdCounter = 0;
|
||||
|
||||
BbPlayerVideoRendererControl::BbPlayerVideoRendererControl(QObject *parent)
|
||||
MmRendererPlayerVideoRendererControl::MmRendererPlayerVideoRendererControl(QObject *parent)
|
||||
: QVideoRendererControl(parent)
|
||||
, m_windowGrabber(new WindowGrabber(this))
|
||||
, m_context(0)
|
||||
@@ -62,40 +62,40 @@ BbPlayerVideoRendererControl::BbPlayerVideoRendererControl(QObject *parent)
|
||||
connect(m_windowGrabber, SIGNAL(frameGrabbed(QImage)), SLOT(frameGrabbed(QImage)));
|
||||
}
|
||||
|
||||
BbPlayerVideoRendererControl::~BbPlayerVideoRendererControl()
|
||||
MmRendererPlayerVideoRendererControl::~MmRendererPlayerVideoRendererControl()
|
||||
{
|
||||
detachDisplay();
|
||||
}
|
||||
|
||||
QAbstractVideoSurface *BbPlayerVideoRendererControl::surface() const
|
||||
QAbstractVideoSurface *MmRendererPlayerVideoRendererControl::surface() const
|
||||
{
|
||||
return m_surface;
|
||||
}
|
||||
|
||||
void BbPlayerVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
|
||||
void MmRendererPlayerVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
|
||||
{
|
||||
m_surface = QPointer<QAbstractVideoSurface>(surface);
|
||||
}
|
||||
|
||||
void BbPlayerVideoRendererControl::attachDisplay(mmr_context_t *context)
|
||||
void MmRendererPlayerVideoRendererControl::attachDisplay(mmr_context_t *context)
|
||||
{
|
||||
if (m_videoId != -1) {
|
||||
qWarning() << "BbPlayerVideoRendererControl: Video output already attached!";
|
||||
qWarning() << "MmRendererPlayerVideoRendererControl: Video output already attached!";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context) {
|
||||
qWarning() << "BbPlayerVideoRendererControl: No media player context!";
|
||||
qWarning() << "MmRendererPlayerVideoRendererControl: No media player context!";
|
||||
return;
|
||||
}
|
||||
|
||||
const QByteArray windowGroupId = m_windowGrabber->windowGroupId();
|
||||
if (windowGroupId.isEmpty()) {
|
||||
qWarning() << "BbPlayerVideoRendererControl: Unable to find window group";
|
||||
qWarning() << "MmRendererPlayerVideoRendererControl: Unable to find window group";
|
||||
return;
|
||||
}
|
||||
|
||||
const QString windowName = QStringLiteral("BbPlayerVideoRendererControl_%1_%2")
|
||||
const QString windowName = QStringLiteral("MmRendererPlayerVideoRendererControl_%1_%2")
|
||||
.arg(winIdCounter++)
|
||||
.arg(QCoreApplication::applicationPid());
|
||||
|
||||
@@ -115,7 +115,7 @@ void BbPlayerVideoRendererControl::attachDisplay(mmr_context_t *context)
|
||||
m_context = context;
|
||||
}
|
||||
|
||||
void BbPlayerVideoRendererControl::detachDisplay()
|
||||
void MmRendererPlayerVideoRendererControl::detachDisplay()
|
||||
{
|
||||
m_windowGrabber->stop();
|
||||
|
||||
@@ -129,17 +129,17 @@ void BbPlayerVideoRendererControl::detachDisplay()
|
||||
m_videoId = -1;
|
||||
}
|
||||
|
||||
void BbPlayerVideoRendererControl::pause()
|
||||
void MmRendererPlayerVideoRendererControl::pause()
|
||||
{
|
||||
m_windowGrabber->pause();
|
||||
}
|
||||
|
||||
void BbPlayerVideoRendererControl::resume()
|
||||
void MmRendererPlayerVideoRendererControl::resume()
|
||||
{
|
||||
m_windowGrabber->resume();
|
||||
}
|
||||
|
||||
void BbPlayerVideoRendererControl::frameGrabbed(const QImage &frame)
|
||||
void MmRendererPlayerVideoRendererControl::frameGrabbed(const QImage &frame)
|
||||
{
|
||||
if (m_surface) {
|
||||
if (!m_surface->isActive()) {
|
||||
@@ -38,26 +38,25 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef BBPLAYERVIDEORENDERERCONTROL_H
|
||||
#define BBPLAYERVIDEORENDERERCONTROL_H
|
||||
#ifndef MMRENDERERPLAYERVIDEORENDERERCONTROL_H
|
||||
#define MMRENDERERPLAYERVIDEORENDERERCONTROL_H
|
||||
|
||||
#include <QPointer>
|
||||
#include <qabstractvideosurface.h>
|
||||
#include <qvideorenderercontrol.h>
|
||||
|
||||
typedef struct mmr_context mmr_context_t;
|
||||
struct bps_event_t;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class WindowGrabber;
|
||||
|
||||
class BbPlayerVideoRendererControl : public QVideoRendererControl
|
||||
class MmRendererPlayerVideoRendererControl : public QVideoRendererControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BbPlayerVideoRendererControl(QObject *parent = 0);
|
||||
~BbPlayerVideoRendererControl();
|
||||
explicit MmRendererPlayerVideoRendererControl(QObject *parent = 0);
|
||||
~MmRendererPlayerVideoRendererControl();
|
||||
|
||||
QAbstractVideoSurface *surface() const Q_DECL_OVERRIDE;
|
||||
void setSurface(QAbstractVideoSurface *surface) Q_DECL_OVERRIDE;
|
||||
@@ -38,7 +38,7 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "bbutil.h"
|
||||
#include "mmrendererutil.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
@@ -38,8 +38,8 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef BBUTIL_H
|
||||
#define BBUTIL_H
|
||||
#ifndef MMRENDERERUTIL_H
|
||||
#define MMRENDERERUTIL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
@@ -38,21 +38,20 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "bbvideowindowcontrol.h"
|
||||
#include "bbutil.h"
|
||||
#include "mmrenderervideowindowcontrol.h"
|
||||
#include "mmrendererutil.h"
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtGui/qguiapplication.h>
|
||||
#include <QtGui/qpa/qplatformnativeinterface.h>
|
||||
#include <QtGui/qscreen.h>
|
||||
#include <QtGui/qwindow.h>
|
||||
#include <mm/renderer.h>
|
||||
#include <bps/screen.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static int winIdCounter = 0;
|
||||
|
||||
BbVideoWindowControl::BbVideoWindowControl(QObject *parent)
|
||||
MmRendererVideoWindowControl::MmRendererVideoWindowControl(QObject *parent)
|
||||
: QVideoWindowControl(parent),
|
||||
m_videoId(-1),
|
||||
m_winId(0),
|
||||
@@ -67,26 +66,26 @@ BbVideoWindowControl::BbVideoWindowControl(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
BbVideoWindowControl::~BbVideoWindowControl()
|
||||
MmRendererVideoWindowControl::~MmRendererVideoWindowControl()
|
||||
{
|
||||
}
|
||||
|
||||
WId BbVideoWindowControl::winId() const
|
||||
WId MmRendererVideoWindowControl::winId() const
|
||||
{
|
||||
return m_winId;
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::setWinId(WId id)
|
||||
void MmRendererVideoWindowControl::setWinId(WId id)
|
||||
{
|
||||
m_winId = id;
|
||||
}
|
||||
|
||||
QRect BbVideoWindowControl::displayRect() const
|
||||
QRect MmRendererVideoWindowControl::displayRect() const
|
||||
{
|
||||
return m_displayRect ;
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::setDisplayRect(const QRect &rect)
|
||||
void MmRendererVideoWindowControl::setDisplayRect(const QRect &rect)
|
||||
{
|
||||
if (m_displayRect != rect) {
|
||||
m_displayRect = rect;
|
||||
@@ -94,12 +93,12 @@ void BbVideoWindowControl::setDisplayRect(const QRect &rect)
|
||||
}
|
||||
}
|
||||
|
||||
bool BbVideoWindowControl::isFullScreen() const
|
||||
bool MmRendererVideoWindowControl::isFullScreen() const
|
||||
{
|
||||
return m_fullscreen;
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::setFullScreen(bool fullScreen)
|
||||
void MmRendererVideoWindowControl::setFullScreen(bool fullScreen)
|
||||
{
|
||||
if (m_fullscreen != fullScreen) {
|
||||
m_fullscreen = fullScreen;
|
||||
@@ -108,32 +107,32 @@ void BbVideoWindowControl::setFullScreen(bool fullScreen)
|
||||
}
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::repaint()
|
||||
void MmRendererVideoWindowControl::repaint()
|
||||
{
|
||||
// Nothing we can or should do here
|
||||
}
|
||||
|
||||
QSize BbVideoWindowControl::nativeSize() const
|
||||
QSize MmRendererVideoWindowControl::nativeSize() const
|
||||
{
|
||||
return QSize(m_metaData.width(), m_metaData.height());
|
||||
}
|
||||
|
||||
Qt::AspectRatioMode BbVideoWindowControl::aspectRatioMode() const
|
||||
Qt::AspectRatioMode MmRendererVideoWindowControl::aspectRatioMode() const
|
||||
{
|
||||
return m_aspectRatioMode;
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode)
|
||||
void MmRendererVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode)
|
||||
{
|
||||
m_aspectRatioMode = mode;
|
||||
}
|
||||
|
||||
int BbVideoWindowControl::brightness() const
|
||||
int MmRendererVideoWindowControl::brightness() const
|
||||
{
|
||||
return m_brightness;
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::setBrightness(int brightness)
|
||||
void MmRendererVideoWindowControl::setBrightness(int brightness)
|
||||
{
|
||||
if (m_brightness != brightness) {
|
||||
m_brightness = brightness;
|
||||
@@ -142,12 +141,12 @@ void BbVideoWindowControl::setBrightness(int brightness)
|
||||
}
|
||||
}
|
||||
|
||||
int BbVideoWindowControl::contrast() const
|
||||
int MmRendererVideoWindowControl::contrast() const
|
||||
{
|
||||
return m_contrast;
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::setContrast(int contrast)
|
||||
void MmRendererVideoWindowControl::setContrast(int contrast)
|
||||
{
|
||||
if (m_contrast != contrast) {
|
||||
m_contrast = contrast;
|
||||
@@ -156,12 +155,12 @@ void BbVideoWindowControl::setContrast(int contrast)
|
||||
}
|
||||
}
|
||||
|
||||
int BbVideoWindowControl::hue() const
|
||||
int MmRendererVideoWindowControl::hue() const
|
||||
{
|
||||
return m_hue;
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::setHue(int hue)
|
||||
void MmRendererVideoWindowControl::setHue(int hue)
|
||||
{
|
||||
if (m_hue != hue) {
|
||||
m_hue = hue;
|
||||
@@ -170,12 +169,12 @@ void BbVideoWindowControl::setHue(int hue)
|
||||
}
|
||||
}
|
||||
|
||||
int BbVideoWindowControl::saturation() const
|
||||
int MmRendererVideoWindowControl::saturation() const
|
||||
{
|
||||
return m_saturation;
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::setSaturation(int saturation)
|
||||
void MmRendererVideoWindowControl::setSaturation(int saturation)
|
||||
{
|
||||
if (m_saturation != saturation) {
|
||||
m_saturation = saturation;
|
||||
@@ -184,40 +183,44 @@ void BbVideoWindowControl::setSaturation(int saturation)
|
||||
}
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::attachDisplay(mmr_context_t *context)
|
||||
void MmRendererVideoWindowControl::attachDisplay(mmr_context_t *context)
|
||||
{
|
||||
if (m_videoId != -1) {
|
||||
qDebug() << "BbVideoWindowControl: Video output already attached!";
|
||||
qDebug() << "MmRendererVideoWindowControl: Video output already attached!";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context) {
|
||||
qDebug() << "BbVideoWindowControl: No media player context!";
|
||||
qDebug() << "MmRendererVideoWindowControl: No media player context!";
|
||||
return;
|
||||
}
|
||||
|
||||
QWindow * const window = findWindow(m_winId);
|
||||
QWindow *window = findWindow(m_winId);
|
||||
if (!window) {
|
||||
qDebug() << "BbVideoWindowControl: No video window!";
|
||||
qDebug() << "MmRendererVideoWindowControl: No video window!";
|
||||
return;
|
||||
}
|
||||
|
||||
QPlatformNativeInterface * const nativeInterface = QGuiApplication::platformNativeInterface();
|
||||
if (!nativeInterface) {
|
||||
qDebug() << "BbVideoWindowControl: Unable to get platform native interface";
|
||||
qDebug() << "MmRendererVideoWindowControl: Unable to get platform native interface";
|
||||
return;
|
||||
}
|
||||
|
||||
const char * const groupNameData = static_cast<const char *>(
|
||||
nativeInterface->nativeResourceForWindow("windowGroup", window));
|
||||
if (!groupNameData) {
|
||||
qDebug() << "BbVideoWindowControl: Unable to find window group for window" << window;
|
||||
qDebug() << "MmRendererVideoWindowControl: Unable to find window group for window" << window;
|
||||
return;
|
||||
}
|
||||
|
||||
const QString groupName = QString::fromLatin1(groupNameData);
|
||||
m_windowName = QString("BbVideoWindowControl_%1_%2").arg(winIdCounter++)
|
||||
m_windowName = QString("MmRendererVideoWindowControl_%1_%2").arg(winIdCounter++)
|
||||
.arg(QCoreApplication::applicationPid());
|
||||
|
||||
nativeInterface->setWindowProperty(window->handle(),
|
||||
QStringLiteral("mmRendererWindowName"), m_windowName);
|
||||
|
||||
// Start with an invisible window. If it would be visible right away, it would be at the wrong
|
||||
// position, and we can only change the position once we get the window handle.
|
||||
const QString videoDeviceUrl =
|
||||
@@ -237,7 +240,7 @@ void BbVideoWindowControl::attachDisplay(mmr_context_t *context)
|
||||
updateSaturation();
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::updateVideoPosition()
|
||||
void MmRendererVideoWindowControl::updateVideoPosition()
|
||||
{
|
||||
QWindow * const window = findWindow(m_winId);
|
||||
if (m_context && m_videoId != -1 && window) {
|
||||
@@ -303,7 +306,7 @@ void BbVideoWindowControl::updateVideoPosition()
|
||||
}
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::updateBrightness()
|
||||
void MmRendererVideoWindowControl::updateBrightness()
|
||||
{
|
||||
if (m_window != 0) {
|
||||
const int backendValue = m_brightness * 2.55f;
|
||||
@@ -312,7 +315,7 @@ void BbVideoWindowControl::updateBrightness()
|
||||
}
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::updateContrast()
|
||||
void MmRendererVideoWindowControl::updateContrast()
|
||||
{
|
||||
if (m_window != 0) {
|
||||
const int backendValue = m_contrast * 1.27f;
|
||||
@@ -321,7 +324,7 @@ void BbVideoWindowControl::updateContrast()
|
||||
}
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::updateHue()
|
||||
void MmRendererVideoWindowControl::updateHue()
|
||||
{
|
||||
if (m_window != 0) {
|
||||
const int backendValue = m_hue * 1.27f;
|
||||
@@ -330,7 +333,7 @@ void BbVideoWindowControl::updateHue()
|
||||
}
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::updateSaturation()
|
||||
void MmRendererVideoWindowControl::updateSaturation()
|
||||
{
|
||||
if (m_window != 0) {
|
||||
const int backendValue = m_saturation * 1.27f;
|
||||
@@ -339,7 +342,7 @@ void BbVideoWindowControl::updateSaturation()
|
||||
}
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::detachDisplay()
|
||||
void MmRendererVideoWindowControl::detachDisplay()
|
||||
{
|
||||
if (m_context && m_videoId != -1)
|
||||
mmr_output_detach(m_context, m_videoId);
|
||||
@@ -355,7 +358,7 @@ void BbVideoWindowControl::detachDisplay()
|
||||
m_saturation = 0;
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::setMetaData(const BbMetaData &metaData)
|
||||
void MmRendererVideoWindowControl::setMetaData(const MmRendererMetaData &metaData)
|
||||
{
|
||||
m_metaData = metaData;
|
||||
emit nativeSizeChanged();
|
||||
@@ -364,47 +367,43 @@ void BbVideoWindowControl::setMetaData(const BbMetaData &metaData)
|
||||
updateVideoPosition();
|
||||
}
|
||||
|
||||
void BbVideoWindowControl::bpsEventHandler(bps_event_t *event)
|
||||
void MmRendererVideoWindowControl::screenEventHandler(const screen_event_t &screen_event)
|
||||
{
|
||||
if (event && bps_event_get_domain(event) == screen_get_domain()) {
|
||||
const screen_event_t screen_event = screen_event_get_event(event);
|
||||
int eventType;
|
||||
if (screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &eventType) != 0) {
|
||||
perror("MmRendererVideoWindowControl: Failed to query screen event type");
|
||||
return;
|
||||
}
|
||||
|
||||
int eventType;
|
||||
if (screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &eventType) != 0) {
|
||||
perror("BbVideoWindowControl: Failed to query screen event type");
|
||||
if (eventType != SCREEN_EVENT_CREATE)
|
||||
return;
|
||||
|
||||
screen_window_t window = 0;
|
||||
if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0) {
|
||||
perror("MmRendererVideoWindowControl: Failed to query window property");
|
||||
return;
|
||||
}
|
||||
|
||||
const int maxIdStrLength = 128;
|
||||
char idString[maxIdStrLength];
|
||||
if (screen_get_window_property_cv(window, SCREEN_PROPERTY_ID_STRING, maxIdStrLength, idString) != 0) {
|
||||
perror("MmRendererVideoWindowControl: Failed to query window ID string");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_windowName == idString) {
|
||||
m_window = window;
|
||||
updateVideoPosition();
|
||||
|
||||
const int visibleFlag = 1;
|
||||
if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_VISIBLE, &visibleFlag) != 0) {
|
||||
perror("MmRendererVideoWindowControl: Failed to make window visible");
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventType != SCREEN_EVENT_CREATE)
|
||||
return;
|
||||
|
||||
screen_window_t window = 0;
|
||||
if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0) {
|
||||
perror("BbVideoWindowControl: Failed to query window property");
|
||||
return;
|
||||
}
|
||||
|
||||
const int maxIdStrLength = 128;
|
||||
char idString[maxIdStrLength];
|
||||
if (screen_get_window_property_cv(window, SCREEN_PROPERTY_ID_STRING, maxIdStrLength, idString) != 0) {
|
||||
perror("BbVideoWindowControl: Failed to query window ID string");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_windowName == idString) {
|
||||
m_window = window;
|
||||
updateVideoPosition();
|
||||
|
||||
const int visibleFlag = 1;
|
||||
if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_VISIBLE, &visibleFlag) != 0) {
|
||||
perror("BbVideoWindowControl: Failed to make window visible");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWindow *BbVideoWindowControl::findWindow(WId id) const
|
||||
QWindow *MmRendererVideoWindowControl::findWindow(WId id) const
|
||||
{
|
||||
Q_FOREACH (QWindow *window, QGuiApplication::allWindows())
|
||||
if (window->winId() == id)
|
||||
@@ -38,24 +38,23 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef BBVIDEOWINDOWCONTROL_H
|
||||
#define BBVIDEOWINDOWCONTROL_H
|
||||
#ifndef MMRENDERERVIDEOWINDOWCONTROL_H
|
||||
#define MMRENDERERVIDEOWINDOWCONTROL_H
|
||||
|
||||
#include "bbmetadata.h"
|
||||
#include "mmrenderermetadata.h"
|
||||
#include <qvideowindowcontrol.h>
|
||||
#include <screen/screen.h>
|
||||
|
||||
typedef struct mmr_context mmr_context_t;
|
||||
struct bps_event_t;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class BbVideoWindowControl : public QVideoWindowControl
|
||||
class MmRendererVideoWindowControl : public QVideoWindowControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BbVideoWindowControl(QObject *parent = 0);
|
||||
~BbVideoWindowControl();
|
||||
explicit MmRendererVideoWindowControl(QObject *parent = 0);
|
||||
~MmRendererVideoWindowControl();
|
||||
|
||||
WId winId() const Q_DECL_OVERRIDE;
|
||||
void setWinId(WId id) Q_DECL_OVERRIDE;
|
||||
@@ -90,8 +89,8 @@ public:
|
||||
//
|
||||
void detachDisplay();
|
||||
void attachDisplay(mmr_context_t *context);
|
||||
void setMetaData(const BbMetaData &metaData);
|
||||
void bpsEventHandler(bps_event_t *event);
|
||||
void setMetaData(const MmRendererMetaData &metaData);
|
||||
void screenEventHandler(const screen_event_t &event);
|
||||
|
||||
private:
|
||||
QWindow *findWindow(WId id) const;
|
||||
@@ -106,7 +105,7 @@ private:
|
||||
QRect m_displayRect;
|
||||
mmr_context_t *m_context;
|
||||
bool m_fullscreen;
|
||||
BbMetaData m_metaData;
|
||||
MmRendererMetaData m_metaData;
|
||||
Qt::AspectRatioMode m_aspectRatioMode;
|
||||
QString m_windowName;
|
||||
screen_window_t m_window;
|
||||
199
src/plugins/qnx/mediaplayer/ppsmediaplayercontrol.cpp
Normal file
199
src/plugins/qnx/mediaplayer/ppsmediaplayercontrol.cpp
Normal file
@@ -0,0 +1,199 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Research In Motion
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "ppsmediaplayercontrol.h"
|
||||
#include "mmrenderervideowindowcontrol.h"
|
||||
|
||||
#include <QtCore/qfile.h>
|
||||
#include <QtCore/qsocketnotifier.h>
|
||||
#include <QtCore/private/qcore_unix_p.h>
|
||||
|
||||
#include <screen/screen.h>
|
||||
#include <sys/pps.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
PpsMediaPlayerControl::PpsMediaPlayerControl(QObject *parent)
|
||||
: MmRendererMediaPlayerControl(parent),
|
||||
m_ppsStatusNotifier(0),
|
||||
m_ppsStatusFd(-1),
|
||||
m_ppsStateNotifier(0),
|
||||
m_ppsStateFd(-1)
|
||||
, m_previouslySeenState("STOPPED")
|
||||
{
|
||||
openConnection();
|
||||
}
|
||||
|
||||
PpsMediaPlayerControl::~PpsMediaPlayerControl()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void PpsMediaPlayerControl::startMonitoring(int, const QString &contextName)
|
||||
{
|
||||
const QString ppsContextPath = QStringLiteral("/pps/services/multimedia/renderer/context/%1/").arg(contextName);
|
||||
const QString ppsStatusPath = ppsContextPath + QStringLiteral("/status");
|
||||
|
||||
Q_ASSERT(m_ppsStatusFd == -1);
|
||||
errno = 0;
|
||||
m_ppsStatusFd = qt_safe_open(QFile::encodeName(ppsStatusPath).constData(), O_RDONLY);
|
||||
if (m_ppsStatusFd == -1) {
|
||||
emitPError(QStringLiteral("Unable to open %1: %2").arg(ppsStatusPath, qt_error_string(errno)));
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(!m_ppsStatusNotifier);
|
||||
m_ppsStatusNotifier = new QSocketNotifier(m_ppsStatusFd, QSocketNotifier::Read);
|
||||
connect(m_ppsStatusNotifier, SIGNAL(activated(int)), this, SLOT(ppsReadyRead(int)));
|
||||
|
||||
|
||||
const QString ppsStatePath = ppsContextPath + QStringLiteral("/state");
|
||||
|
||||
Q_ASSERT(m_ppsStateFd == -1);
|
||||
errno = 0;
|
||||
m_ppsStateFd = qt_safe_open(QFile::encodeName(ppsStatePath).constData(), O_RDONLY);
|
||||
if (m_ppsStateFd == -1) {
|
||||
emitPError(QStringLiteral("Unable to open %1: %2").arg(ppsStatePath, qt_error_string(errno)));
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(!m_ppsStateNotifier);
|
||||
m_ppsStateNotifier = new QSocketNotifier(m_ppsStateFd, QSocketNotifier::Read);
|
||||
connect(m_ppsStateNotifier, SIGNAL(activated(int)), this, SLOT(ppsReadyRead(int)));
|
||||
|
||||
//ensure we receive any initial state
|
||||
ppsReadyRead(m_ppsStatusFd);
|
||||
ppsReadyRead(m_ppsStateFd);
|
||||
}
|
||||
|
||||
void PpsMediaPlayerControl::stopMonitoring()
|
||||
{
|
||||
|
||||
if (m_ppsStatusFd != -1) {
|
||||
::close(m_ppsStatusFd);
|
||||
m_ppsStatusFd = -1;
|
||||
}
|
||||
|
||||
delete m_ppsStatusNotifier;
|
||||
m_ppsStatusNotifier = 0;
|
||||
|
||||
if (m_ppsStateFd != -1) {
|
||||
::close(m_ppsStateFd);
|
||||
m_ppsStateFd = -1;
|
||||
}
|
||||
|
||||
delete m_ppsStateNotifier;
|
||||
m_ppsStateNotifier = 0;
|
||||
}
|
||||
|
||||
bool PpsMediaPlayerControl::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
|
||||
{
|
||||
Q_UNUSED(result)
|
||||
if (eventType == "screen_event_t") {
|
||||
screen_event_t event = static_cast<screen_event_t>(message);
|
||||
if (MmRendererVideoWindowControl *control = videoWindowControl())
|
||||
control->screenEventHandler(event);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void PpsMediaPlayerControl::ppsReadyRead(int fd)
|
||||
{
|
||||
Q_ASSERT(fd == m_ppsStateFd || fd == m_ppsStatusFd);
|
||||
const int bufferSize = 2048;
|
||||
char buffer[bufferSize];
|
||||
const ssize_t nread = qt_safe_read(fd, buffer, bufferSize - 1);
|
||||
if (nread < 0) {
|
||||
//TODO emit error?
|
||||
}
|
||||
|
||||
if (nread == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// nread is the real space necessary, not the amount read.
|
||||
if (static_cast<size_t>(nread) > bufferSize - 1) {
|
||||
//TODO emit error?
|
||||
qCritical("BBMediaPlayerControl: PPS buffer size too short; need %u.", nread + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
buffer[nread] = 0;
|
||||
|
||||
pps_decoder_t decoder;
|
||||
|
||||
if (pps_decoder_initialize(&decoder, buffer) != PPS_DECODER_OK) {
|
||||
//TODO emit error?
|
||||
qCritical("Could not initialize pps_decoder");
|
||||
pps_decoder_cleanup(&decoder);
|
||||
return;
|
||||
}
|
||||
|
||||
pps_decoder_push(&decoder, 0);
|
||||
|
||||
const char *value = 0;
|
||||
if (pps_decoder_get_string(&decoder, "bufferlevel", &value) == PPS_DECODER_OK) {
|
||||
setMmBufferStatus(QString::fromLatin1(value));
|
||||
}
|
||||
|
||||
if (pps_decoder_get_string(&decoder, "state", &value) == PPS_DECODER_OK) {
|
||||
const QByteArray state = value;
|
||||
if (state != m_previouslySeenState && state == "STOPPED")
|
||||
handleMmStopped();
|
||||
m_previouslySeenState = state;
|
||||
}
|
||||
|
||||
if (pps_decoder_get_string(&decoder, "position", &value) == PPS_DECODER_OK) {
|
||||
const QByteArray valueBa = QByteArray(value);
|
||||
bool ok;
|
||||
const qint64 position = valueBa.toLongLong(&ok);
|
||||
if (!ok) {
|
||||
qCritical("Could not parse position from '%s'", valueBa.constData());
|
||||
} else {
|
||||
setMmPosition(position);
|
||||
}
|
||||
}
|
||||
|
||||
pps_decoder_cleanup(&decoder);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
75
src/plugins/qnx/mediaplayer/ppsmediaplayercontrol.h
Normal file
75
src/plugins/qnx/mediaplayer/ppsmediaplayercontrol.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Research In Motion
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef PPSMEDIAPLAYERCONTROL_H
|
||||
#define PPSMEDIAPLAYERCONTROL_H
|
||||
|
||||
#include "mmrenderermediaplayercontrol.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QSocketNotifier;
|
||||
|
||||
class PpsMediaPlayerControl Q_DECL_FINAL : public MmRendererMediaPlayerControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PpsMediaPlayerControl(QObject *parent = 0);
|
||||
~PpsMediaPlayerControl();
|
||||
|
||||
void startMonitoring(int contextId, const QString &contextName) Q_DECL_OVERRIDE;
|
||||
void stopMonitoring() Q_DECL_OVERRIDE;
|
||||
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
|
||||
|
||||
private Q_SLOTS:
|
||||
void ppsReadyRead(int fd);
|
||||
|
||||
private:
|
||||
QSocketNotifier *m_ppsStatusNotifier;
|
||||
int m_ppsStatusFd;
|
||||
QSocketNotifier *m_ppsStateNotifier;
|
||||
int m_ppsStateFd;
|
||||
QByteArray m_previouslySeenState;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user