DirectShow: Don't create the widget and renderer controls until requested.
Task-number: QTBUG-32282 Change-Id: If37ed4c35bcc2cc879f50d3b2ea3720b90603e9a Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
committed by
The Qt Project
parent
d599f7319a
commit
d8e56bc4b8
@@ -62,6 +62,10 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
DSCameraService::DSCameraService(QObject *parent):
|
DSCameraService::DSCameraService(QObject *parent):
|
||||||
QMediaService(parent)
|
QMediaService(parent)
|
||||||
|
#if defined(HAVE_WIDGETS)
|
||||||
|
, m_viewFinderWidget(0)
|
||||||
|
#endif
|
||||||
|
, m_videoRenderer(0)
|
||||||
{
|
{
|
||||||
m_session = new DSCameraSession(this);
|
m_session = new DSCameraSession(this);
|
||||||
|
|
||||||
@@ -69,14 +73,8 @@ DSCameraService::DSCameraService(QObject *parent):
|
|||||||
|
|
||||||
m_videoDevice = new DSVideoDeviceControl(m_session);
|
m_videoDevice = new DSVideoDeviceControl(m_session);
|
||||||
|
|
||||||
m_videoRenderer = new DSVideoRendererControl(m_session, this);
|
|
||||||
|
|
||||||
m_imageCapture = new DSImageCaptureControl(m_session);
|
m_imageCapture = new DSImageCaptureControl(m_session);
|
||||||
|
|
||||||
#if defined(HAVE_WIDGETS)
|
|
||||||
m_viewFinderWidget = new DSVideoWidgetControl(m_session);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_device = QByteArray("default");
|
m_device = QByteArray("default");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,14 +100,23 @@ QMediaControl* DSCameraService::requestControl(const char *name)
|
|||||||
|
|
||||||
#if defined(HAVE_WIDGETS)
|
#if defined(HAVE_WIDGETS)
|
||||||
if (qstrcmp(name, QVideoWidgetControl_iid) == 0) {
|
if (qstrcmp(name, QVideoWidgetControl_iid) == 0) {
|
||||||
if (m_viewFinderWidget) {
|
if (!m_viewFinderWidget && !m_videoRenderer) {
|
||||||
|
m_viewFinderWidget = new DSVideoWidgetControl(m_session);
|
||||||
return m_viewFinderWidget;
|
return m_viewFinderWidget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(qstrcmp(name,QVideoRendererControl_iid) == 0)
|
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;
|
return m_videoRenderer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (qstrcmp(name,QVideoDeviceSelectorControl_iid) == 0)
|
if (qstrcmp(name,QVideoDeviceSelectorControl_iid) == 0)
|
||||||
return m_videoDevice;
|
return m_videoDevice;
|
||||||
@@ -119,8 +126,19 @@ QMediaControl* DSCameraService::requestControl(const char *name)
|
|||||||
|
|
||||||
void DSCameraService::releaseControl(QMediaControl *control)
|
void DSCameraService::releaseControl(QMediaControl *control)
|
||||||
{
|
{
|
||||||
Q_UNUSED(control)
|
if (control == m_videoRenderer) {
|
||||||
// Implemented as a singleton, so we do nothing.
|
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
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ class DSCameraControl;
|
|||||||
class DSCameraSession;
|
class DSCameraSession;
|
||||||
class DSVideoOutputControl;
|
class DSVideoOutputControl;
|
||||||
class DSVideoDeviceControl;
|
class DSVideoDeviceControl;
|
||||||
class DSVideoRendererControl;
|
|
||||||
class DSImageCaptureControl;
|
class DSImageCaptureControl;
|
||||||
class DSVideoWidgetControl;
|
|
||||||
|
|
||||||
|
|
||||||
class DSCameraService : public QMediaService
|
class DSCameraService : public QMediaService
|
||||||
@@ -73,10 +71,10 @@ private:
|
|||||||
DSCameraSession *m_session;
|
DSCameraSession *m_session;
|
||||||
DSVideoOutputControl *m_videoOutput;
|
DSVideoOutputControl *m_videoOutput;
|
||||||
#if defined(HAVE_WIDGETS)
|
#if defined(HAVE_WIDGETS)
|
||||||
DSVideoWidgetControl *m_viewFinderWidget;
|
QMediaControl *m_viewFinderWidget;
|
||||||
#endif
|
#endif
|
||||||
DSVideoDeviceControl *m_videoDevice;
|
DSVideoDeviceControl *m_videoDevice;
|
||||||
DSVideoRendererControl *m_videoRenderer;
|
QMediaControl *m_videoRenderer;
|
||||||
DSImageCaptureControl *m_imageCapture;
|
DSImageCaptureControl *m_imageCapture;
|
||||||
QByteArray m_device;
|
QByteArray m_device;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user