Merge remote-tracking branch 'origin/stable' into dev
Change-Id: If52332b72560d21069e24cd31b13f08f33e1f406
This commit is contained in:
@@ -62,6 +62,10 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
DSCameraService::DSCameraService(QObject *parent):
|
||||
QMediaService(parent)
|
||||
#if defined(HAVE_WIDGETS)
|
||||
, m_viewFinderWidget(0)
|
||||
#endif
|
||||
, m_videoRenderer(0)
|
||||
{
|
||||
m_session = new DSCameraSession(this);
|
||||
|
||||
@@ -69,14 +73,8 @@ DSCameraService::DSCameraService(QObject *parent):
|
||||
|
||||
m_videoDevice = new DSVideoDeviceControl(m_session);
|
||||
|
||||
m_videoRenderer = new DSVideoRendererControl(m_session, this);
|
||||
|
||||
m_imageCapture = new DSImageCaptureControl(m_session);
|
||||
|
||||
#if defined(HAVE_WIDGETS)
|
||||
m_viewFinderWidget = new DSVideoWidgetControl(m_session);
|
||||
#endif
|
||||
|
||||
m_device = QByteArray("default");
|
||||
}
|
||||
|
||||
@@ -102,14 +100,23 @@ QMediaControl* DSCameraService::requestControl(const char *name)
|
||||
|
||||
#if defined(HAVE_WIDGETS)
|
||||
if (qstrcmp(name, QVideoWidgetControl_iid) == 0) {
|
||||
if (m_viewFinderWidget) {
|
||||
if (!m_viewFinderWidget && !m_videoRenderer) {
|
||||
m_viewFinderWidget = new DSVideoWidgetControl(m_session);
|
||||
return m_viewFinderWidget;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(qstrcmp(name,QVideoRendererControl_iid) == 0)
|
||||
return m_videoRenderer;
|
||||
if (qstrcmp(name,QVideoRendererControl_iid) == 0) {
|
||||
#if defined(HAVE_WIDGETS)
|
||||
if (!m_videoRenderer && !m_viewFinderWidget) {
|
||||
#else
|
||||
if (!m_videoRenderer) {
|
||||
#endif
|
||||
m_videoRenderer = new DSVideoRendererControl(m_session, this);
|
||||
return m_videoRenderer;
|
||||
}
|
||||
}
|
||||
|
||||
if (qstrcmp(name,QVideoDeviceSelectorControl_iid) == 0)
|
||||
return m_videoDevice;
|
||||
@@ -119,8 +126,19 @@ QMediaControl* DSCameraService::requestControl(const char *name)
|
||||
|
||||
void DSCameraService::releaseControl(QMediaControl *control)
|
||||
{
|
||||
Q_UNUSED(control)
|
||||
// Implemented as a singleton, so we do nothing.
|
||||
if (control == m_videoRenderer) {
|
||||
delete m_videoRenderer;
|
||||
m_videoRenderer = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(HAVE_WIDGETS)
|
||||
if (control == m_viewFinderWidget) {
|
||||
delete m_viewFinderWidget;
|
||||
m_viewFinderWidget = 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -52,9 +52,7 @@ class DSCameraControl;
|
||||
class DSCameraSession;
|
||||
class DSVideoOutputControl;
|
||||
class DSVideoDeviceControl;
|
||||
class DSVideoRendererControl;
|
||||
class DSImageCaptureControl;
|
||||
class DSVideoWidgetControl;
|
||||
|
||||
|
||||
class DSCameraService : public QMediaService
|
||||
@@ -73,10 +71,10 @@ private:
|
||||
DSCameraSession *m_session;
|
||||
DSVideoOutputControl *m_videoOutput;
|
||||
#if defined(HAVE_WIDGETS)
|
||||
DSVideoWidgetControl *m_viewFinderWidget;
|
||||
QMediaControl *m_viewFinderWidget;
|
||||
#endif
|
||||
DSVideoDeviceControl *m_videoDevice;
|
||||
DSVideoRendererControl *m_videoRenderer;
|
||||
QMediaControl *m_videoRenderer;
|
||||
DSImageCaptureControl *m_imageCapture;
|
||||
QByteArray m_device;
|
||||
};
|
||||
|
||||
@@ -595,7 +595,7 @@ void DSCameraSession::captureFrame()
|
||||
mutex.lock();
|
||||
|
||||
image = QImage(frames.at(0)->buffer,m_windowSize.width(),m_windowSize.height(),
|
||||
QImage::Format_RGB32).rgbSwapped().mirrored(true);
|
||||
QImage::Format_RGB32).mirrored(true);
|
||||
|
||||
QVideoFrame frame(image);
|
||||
frame.setStartTime(frames.at(0)->time);
|
||||
|
||||
@@ -1326,8 +1326,6 @@ void MFPlayerSession::start()
|
||||
switch (m_status) {
|
||||
case QMediaPlayer::EndOfMedia:
|
||||
m_varStart.hVal.QuadPart = 0;
|
||||
//since it must be loaded already, just fallthrough
|
||||
case QMediaPlayer::LoadedMedia:
|
||||
changeStatus(QMediaPlayer::BufferedMedia);
|
||||
return;
|
||||
}
|
||||
@@ -1911,10 +1909,12 @@ void MFPlayerSession::handleSessionEvent(IMFMediaEvent *sessionEvent)
|
||||
|
||||
switch (meType) {
|
||||
case MEBufferingStarted:
|
||||
changeStatus(QMediaPlayer::StalledMedia);
|
||||
changeStatus(m_status == QMediaPlayer::LoadedMedia ? QMediaPlayer::BufferingMedia : QMediaPlayer::StalledMedia);
|
||||
emit bufferStatusChanged(bufferStatus());
|
||||
break;
|
||||
case MEBufferingStopped:
|
||||
if (m_status == QMediaPlayer::BufferingMedia)
|
||||
stop(true);
|
||||
changeStatus(QMediaPlayer::BufferedMedia);
|
||||
emit bufferStatusChanged(bufferStatus());
|
||||
break;
|
||||
@@ -1979,6 +1979,16 @@ void MFPlayerSession::handleSessionEvent(IMFMediaEvent *sessionEvent)
|
||||
}
|
||||
}
|
||||
MFGetService(m_session, MFNETSOURCE_STATISTICS_SERVICE, IID_PPV_ARGS(&m_netsourceStatistics));
|
||||
|
||||
if (!m_netsourceStatistics || bufferStatus() == 100) {
|
||||
// If the source reader doesn't implement the statistics service, just set the status
|
||||
// to buffered, since there is no way to query the buffering progress...
|
||||
changeStatus(QMediaPlayer::BufferedMedia);
|
||||
} else {
|
||||
// Start to trigger buffering. Once enough buffering is done, the session will
|
||||
// be automatically stopped unless the user has explicitly started playback.
|
||||
start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user