summaryrefslogtreecommitdiffstats
path: root/src/plugins/directshow/camera
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/directshow/camera')
-rw-r--r--src/plugins/directshow/camera/dscameracontrol.cpp2
-rw-r--r--src/plugins/directshow/camera/dscameracontrol.h6
-rw-r--r--src/plugins/directshow/camera/dscameraservice.cpp6
-rw-r--r--src/plugins/directshow/camera/dscameraservice.h6
-rw-r--r--src/plugins/directshow/camera/dscamerasession.cpp51
-rw-r--r--src/plugins/directshow/camera/dscamerasession.h37
-rw-r--r--src/plugins/directshow/camera/dsvideodevicecontrol.cpp6
-rw-r--r--src/plugins/directshow/camera/dsvideodevicecontrol.h4
-rw-r--r--src/plugins/directshow/camera/dsvideorenderer.cpp1
-rw-r--r--src/plugins/directshow/camera/dsvideorenderer.h4
10 files changed, 48 insertions, 75 deletions
diff --git a/src/plugins/directshow/camera/dscameracontrol.cpp b/src/plugins/directshow/camera/dscameracontrol.cpp
index 67971d1b5..3f60ec848 100644
--- a/src/plugins/directshow/camera/dscameracontrol.cpp
+++ b/src/plugins/directshow/camera/dscameracontrol.cpp
@@ -47,8 +47,6 @@ QT_BEGIN_NAMESPACE
DSCameraControl::DSCameraControl(QObject *parent)
: QCameraControl(parent)
- , m_state(QCamera::UnloadedState)
- , m_captureMode(QCamera::CaptureStillImage)
{
m_session = qobject_cast<DSCameraSession*>(parent);
connect(m_session, &DSCameraSession::statusChanged, this,
diff --git a/src/plugins/directshow/camera/dscameracontrol.h b/src/plugins/directshow/camera/dscameracontrol.h
index b9fb2766d..2087623d1 100644
--- a/src/plugins/directshow/camera/dscameracontrol.h
+++ b/src/plugins/directshow/camera/dscameracontrol.h
@@ -52,7 +52,7 @@ class DSCameraControl : public QCameraControl
{
Q_OBJECT
public:
- DSCameraControl(QObject *parent = 0);
+ DSCameraControl(QObject *parent = nullptr);
~DSCameraControl() override;
QCamera::State state() const override { return m_state; }
@@ -69,8 +69,8 @@ public:
private:
DSCameraSession *m_session;
- QCamera::State m_state;
- QCamera::CaptureModes m_captureMode;
+ QCamera::State m_state = QCamera::UnloadedState;
+ QCamera::CaptureModes m_captureMode = QCamera::CaptureStillImage;
};
QT_END_NAMESPACE
diff --git a/src/plugins/directshow/camera/dscameraservice.cpp b/src/plugins/directshow/camera/dscameraservice.cpp
index 8115ef385..ff488cf09 100644
--- a/src/plugins/directshow/camera/dscameraservice.cpp
+++ b/src/plugins/directshow/camera/dscameraservice.cpp
@@ -62,14 +62,12 @@ DSCameraService::DSCameraService(QObject *parent):
, m_session(new DSCameraSession(this))
, m_control(new DSCameraControl(m_session))
, m_videoDevice(new DSVideoDeviceControl(m_session))
- , m_videoRenderer(0)
, m_imageCapture(new DSImageCaptureControl(m_session))
, m_viewfinderSettings(new DSCameraViewfinderSettingsControl(m_session))
, m_imageProcessingControl(new DSCameraImageProcessingControl(m_session))
, m_exposureControl(new DirectShowCameraExposureControl(m_session))
, m_captureDestinationControl(new DirectShowCameraCaptureDestinationControl(m_session))
, m_captureBufferFormatControl(new DirectShowCameraCaptureBufferFormatControl)
- , m_videoProbeControl(nullptr)
, m_zoomControl(new DirectShowCameraZoomControl(m_session))
, m_imageEncoderControl(new DirectShowCameraImageEncoderControl(m_session))
{
@@ -140,14 +138,14 @@ QMediaControl* DSCameraService::requestControl(const char *name)
if (qstrcmp(name, QImageEncoderControl_iid) == 0)
return m_imageEncoderControl;
- return 0;
+ return nullptr;
}
void DSCameraService::releaseControl(QMediaControl *control)
{
if (control == m_videoRenderer) {
delete m_videoRenderer;
- m_videoRenderer = 0;
+ m_videoRenderer = nullptr;
return;
}
diff --git a/src/plugins/directshow/camera/dscameraservice.h b/src/plugins/directshow/camera/dscameraservice.h
index 9a8f745f6..6ea85b725 100644
--- a/src/plugins/directshow/camera/dscameraservice.h
+++ b/src/plugins/directshow/camera/dscameraservice.h
@@ -64,7 +64,7 @@ class DSCameraService : public QMediaService
Q_OBJECT
public:
- DSCameraService(QObject *parent = 0);
+ DSCameraService(QObject *parent = nullptr);
~DSCameraService() override;
QMediaControl* requestControl(const char *name) override;
@@ -74,14 +74,14 @@ private:
DSCameraSession *m_session;
DSCameraControl *m_control;
DSVideoDeviceControl *m_videoDevice;
- QMediaControl *m_videoRenderer;
+ QMediaControl *m_videoRenderer = nullptr;
DSImageCaptureControl *m_imageCapture;
DSCameraViewfinderSettingsControl *m_viewfinderSettings;
DSCameraImageProcessingControl *m_imageProcessingControl;
DirectShowCameraExposureControl *m_exposureControl;
DirectShowCameraCaptureDestinationControl *m_captureDestinationControl;
DirectShowCameraCaptureBufferFormatControl *m_captureBufferFormatControl;
- DirectShowVideoProbeControl *m_videoProbeControl;
+ DirectShowVideoProbeControl *m_videoProbeControl = nullptr;
DirectShowCameraZoomControl *m_zoomControl;
DirectShowCameraImageEncoderControl *m_imageEncoderControl;
};
diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp
index 267e7a9a4..a0c120816 100644
--- a/src/plugins/directshow/camera/dscamerasession.cpp
+++ b/src/plugins/directshow/camera/dscamerasession.cpp
@@ -58,23 +58,6 @@ QT_BEGIN_NAMESPACE
DSCameraSession::DSCameraSession(QObject *parent)
: QObject(parent)
- , m_graphBuilder(nullptr)
- , m_filterGraph(nullptr)
- , m_sourceDeviceName(QLatin1String("default"))
- , m_sourceFilter(nullptr)
- , m_needsHorizontalMirroring(false)
- , m_previewSampleGrabber(nullptr)
- , m_nullRendererFilter(nullptr)
- , m_previewStarted(false)
- , m_surface(nullptr)
- , m_previewPixelFormat(QVideoFrame::Format_Invalid)
- , m_stride(-1)
- , m_readyForCapture(false)
- , m_imageIdCounter(0)
- , m_currentImageId(-1)
- , m_captureDestinations(QCameraImageCapture::CaptureToFile)
- , m_videoProbeControl(nullptr)
- , m_status(QCamera::UnloadedStatus)
{
connect(this, &DSCameraSession::statusChanged,
this, &DSCameraSession::updateReadyForCapture);
@@ -284,7 +267,7 @@ void DSCameraSession::setImageProcessingParameter(
ImageProcessingParameterInfo>::iterator sourceValueInfo =
m_imageProcessingParametersInfos.find(resultingParameter);
- if (sourceValueInfo == m_imageProcessingParametersInfos.constEnd())
+ if (sourceValueInfo == m_imageProcessingParametersInfos.end())
return;
LONG sourceValue = 0;
@@ -464,7 +447,7 @@ bool DSCameraSession::startPreview()
QString errorString;
HRESULT hr = S_OK;
- IMediaControl* pControl = 0;
+ IMediaControl* pControl = nullptr;
if (!configurePreviewFormat()) {
errorString = tr("Failed to configure preview format");
@@ -516,7 +499,7 @@ bool DSCameraSession::stopPreview()
m_previewSampleGrabber->stop();
QString errorString;
- IMediaControl* pControl = 0;
+ IMediaControl* pControl = nullptr;
HRESULT hr = m_filterGraph->QueryInterface(IID_IMediaControl,
reinterpret_cast<void**>(&pControl));
if (FAILED(hr)) {
@@ -740,12 +723,12 @@ bool DSCameraSession::createFilterGraph()
pDevEnum->Release();
if (S_OK == hr) {
pEnum->Reset();
- IMalloc *mallocInterface = 0;
+ IMalloc *mallocInterface = nullptr;
CoGetMalloc(1, (LPMALLOC*)&mallocInterface);
//go through and find all video capture devices
while (pEnum->Next(1, &pMoniker, nullptr) == S_OK) {
- BSTR strName = 0;
+ BSTR strName = nullptr;
hr = pMoniker->GetDisplayName(nullptr, nullptr, &strName);
if (SUCCEEDED(hr)) {
QString output = QString::fromWCharArray(strName);
@@ -769,7 +752,7 @@ bool DSCameraSession::createFilterGraph()
pEnum->Reset();
// still have to loop to discard bind to storage failure case
while (pEnum->Next(1, &pMoniker, nullptr) == S_OK) {
- IPropertyBag *pPropBag = 0;
+ IPropertyBag *pPropBag = nullptr;
hr = pMoniker->BindToStorage(nullptr, nullptr, IID_IPropertyBag,
reinterpret_cast<void**>(&pPropBag));
@@ -780,17 +763,13 @@ bool DSCameraSession::createFilterGraph()
// No need to get the description, just grab it
- hr = pMoniker->BindToObject(0, 0, IID_IBaseFilter,
+ hr = pMoniker->BindToObject(nullptr, nullptr, IID_IBaseFilter,
reinterpret_cast<void**>(&m_sourceFilter));
pPropBag->Release();
pMoniker->Release();
- if (SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr))
break; // done, stop looping through
- }
- else
- {
- qWarning() << "Object bind failed";
- }
+ qWarning("Object bind failed");
}
}
}
@@ -898,7 +877,7 @@ bool DSCameraSession::configurePreviewFormat()
m_stride = DirectShowMediaType::bytesPerLine(m_previewSurfaceFormat);
HRESULT hr;
- IAMStreamConfig* pConfig = 0;
+ IAMStreamConfig* pConfig = nullptr;
hr = m_graphBuilder->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
m_sourceFilter, IID_IAMStreamConfig,
reinterpret_cast<void**>(&pConfig));
@@ -1064,21 +1043,21 @@ void DSCameraSession::updateSourceCapabilities()
AM_MEDIA_TYPE *pmt = nullptr;
VIDEOINFOHEADER *pvi = nullptr;
VIDEO_STREAM_CONFIG_CAPS scc;
- IAMStreamConfig* pConfig = 0;
+ IAMStreamConfig* pConfig = nullptr;
m_supportedViewfinderSettings.clear();
m_needsHorizontalMirroring = false;
m_supportedFormats.clear();
m_imageProcessingParametersInfos.clear();
- IAMVideoControl *pVideoControl = 0;
+ IAMVideoControl *pVideoControl = nullptr;
hr = m_graphBuilder->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
m_sourceFilter, IID_IAMVideoControl,
reinterpret_cast<void**>(&pVideoControl));
if (FAILED(hr)) {
qWarning() << "Failed to get the video control";
} else {
- IPin *pPin = 0;
+ IPin *pPin = nullptr;
if (!DirectShowUtils::getPin(m_sourceFilter, PINDIR_OUTPUT, &pPin, &hr)) {
qWarning() << "Failed to get the pin for the video control";
} else {
@@ -1130,12 +1109,12 @@ void DSCameraSession::updateSourceCapabilities()
QList<QCamera::FrameRateRange> frameRateRanges;
if (pVideoControl) {
- IPin *pPin = 0;
+ IPin *pPin = nullptr;
if (!DirectShowUtils::getPin(m_sourceFilter, PINDIR_OUTPUT, &pPin, &hr)) {
qWarning() << "Failed to get the pin for the video control";
} else {
long listSize = 0;
- LONGLONG *frameRates = 0;
+ LONGLONG *frameRates = nullptr;
SIZE size = { resolution.width(), resolution.height() };
hr = pVideoControl->GetFrameRateList(pPin, iIndex, size, &listSize, &frameRates);
if (hr == S_OK && listSize > 0 && frameRates) {
diff --git a/src/plugins/directshow/camera/dscamerasession.h b/src/plugins/directshow/camera/dscamerasession.h
index 18fc0cca7..5e7d026c2 100644
--- a/src/plugins/directshow/camera/dscamerasession.h
+++ b/src/plugins/directshow/camera/dscamerasession.h
@@ -84,7 +84,7 @@ class DSCameraSession : public QObject
{
Q_OBJECT
public:
- DSCameraSession(QObject *parent = 0);
+ DSCameraSession(QObject *parent = nullptr);
~DSCameraSession() override;
QCamera::Status status() const { return m_status; }
@@ -185,49 +185,48 @@ private:
QMutex m_presentMutex;
QMutex m_captureMutex;
- // Capture Graph
- ICaptureGraphBuilder2* m_graphBuilder;
- IGraphBuilder* m_filterGraph;
+ ICaptureGraphBuilder2* m_graphBuilder = nullptr;
+ IGraphBuilder* m_filterGraph = nullptr;
// Source (camera)
- QString m_sourceDeviceName;
- IBaseFilter* m_sourceFilter;
- bool m_needsHorizontalMirroring;
+ QString m_sourceDeviceName = QLatin1String("default");
+ IBaseFilter* m_sourceFilter = nullptr;
+ bool m_needsHorizontalMirroring = false;
QList<DirectShowMediaType> m_supportedFormats;
QList<QCameraViewfinderSettings> m_supportedViewfinderSettings;
DirectShowMediaType m_sourceFormat;
QMap<QCameraImageProcessingControl::ProcessingParameter, ImageProcessingParameterInfo> m_imageProcessingParametersInfos;
// Preview
- DirectShowSampleGrabber *m_previewSampleGrabber;
- IBaseFilter *m_nullRendererFilter;
+ DirectShowSampleGrabber *m_previewSampleGrabber = nullptr;
+ IBaseFilter *m_nullRendererFilter = nullptr;
QVideoFrame m_currentFrame;
- bool m_previewStarted;
- QAbstractVideoSurface* m_surface;
+ bool m_previewStarted = false;
+ QAbstractVideoSurface* m_surface = nullptr;
QVideoSurfaceFormat m_previewSurfaceFormat;
- QVideoFrame::PixelFormat m_previewPixelFormat;
+ QVideoFrame::PixelFormat m_previewPixelFormat = QVideoFrame::Format_RGB32;
QSize m_previewSize;
- int m_stride;
+ int m_stride = -1;
QCameraViewfinderSettings m_viewfinderSettings;
QCameraViewfinderSettings m_actualViewfinderSettings;
// Image capture
QString m_imageCaptureFileName;
QMediaStorageLocation m_fileNameGenerator;
- bool m_readyForCapture;
- int m_imageIdCounter;
- int m_currentImageId;
+ bool m_readyForCapture = false;
+ int m_imageIdCounter = 0;
+ int m_currentImageId = -1;
QVideoFrame m_capturedFrame;
- QCameraImageCapture::CaptureDestinations m_captureDestinations;
+ QCameraImageCapture::CaptureDestinations m_captureDestinations = QCameraImageCapture::CaptureToFile;
// Video probe
QMutex m_probeMutex;
- DirectShowVideoProbeControl *m_videoProbeControl;
+ DirectShowVideoProbeControl *m_videoProbeControl = nullptr;
QImageEncoderSettings m_imageEncoderSettings;
// Internal state
- QCamera::Status m_status;
+ QCamera::Status m_status = QCamera::UnloadedStatus;
QTimer m_deviceLostEventTimer;
QMap<QCameraImageProcessingControl::ProcessingParameter, QVariant> m_pendingImageProcessingParametrs;
diff --git a/src/plugins/directshow/camera/dsvideodevicecontrol.cpp b/src/plugins/directshow/camera/dsvideodevicecontrol.cpp
index 7285d0fb3..0f08154f1 100644
--- a/src/plugins/directshow/camera/dsvideodevicecontrol.cpp
+++ b/src/plugins/directshow/camera/dsvideodevicecontrol.cpp
@@ -143,10 +143,10 @@ void DSVideoDeviceControl::updateDevices()
pEnum->Reset();
// go through and find all video capture devices
IMoniker* pMoniker = nullptr;
- IMalloc *mallocInterface = 0;
+ IMalloc *mallocInterface = nullptr;
CoGetMalloc(1, (LPMALLOC*)&mallocInterface);
while (pEnum->Next(1, &pMoniker, nullptr) == S_OK) {
- BSTR strName = 0;
+ BSTR strName = nullptr;
hr = pMoniker->GetDisplayName(nullptr, nullptr, &strName);
if (SUCCEEDED(hr)) {
QString output(QString::fromWCharArray(strName));
@@ -162,7 +162,7 @@ void DSVideoDeviceControl::updateDevices()
// Find the description
VARIANT varName;
varName.vt = VT_BSTR;
- hr = pPropBag->Read(L"FriendlyName", &varName, 0);
+ hr = pPropBag->Read(L"FriendlyName", &varName, nullptr);
if (SUCCEEDED(hr)) {
output = QString::fromWCharArray(varName.bstrVal);
}
diff --git a/src/plugins/directshow/camera/dsvideodevicecontrol.h b/src/plugins/directshow/camera/dsvideodevicecontrol.h
index 7a7a0af1e..24a5b61a1 100644
--- a/src/plugins/directshow/camera/dsvideodevicecontrol.h
+++ b/src/plugins/directshow/camera/dsvideodevicecontrol.h
@@ -48,13 +48,13 @@ class DSCameraSession;
//QTM_USE_NAMESPACE
-typedef QPair<QByteArray, QString> DSVideoDeviceInfo;
+using DSVideoDeviceInfo = QPair<QByteArray, QString>;
class DSVideoDeviceControl : public QVideoDeviceSelectorControl
{
Q_OBJECT
public:
- DSVideoDeviceControl(QObject *parent = 0);
+ DSVideoDeviceControl(QObject *parent = nullptr);
int deviceCount() const override;
QString deviceName(int index) const override;
diff --git a/src/plugins/directshow/camera/dsvideorenderer.cpp b/src/plugins/directshow/camera/dsvideorenderer.cpp
index bf0aa2684..cde63af65 100644
--- a/src/plugins/directshow/camera/dsvideorenderer.cpp
+++ b/src/plugins/directshow/camera/dsvideorenderer.cpp
@@ -45,7 +45,6 @@ QT_BEGIN_NAMESPACE
DSVideoRendererControl::DSVideoRendererControl(DSCameraSession* session, QObject *parent)
:QVideoRendererControl(parent),
- m_surface(0),
m_session(session)
{
}
diff --git a/src/plugins/directshow/camera/dsvideorenderer.h b/src/plugins/directshow/camera/dsvideorenderer.h
index 3a4570b4c..a6a1f8103 100644
--- a/src/plugins/directshow/camera/dsvideorenderer.h
+++ b/src/plugins/directshow/camera/dsvideorenderer.h
@@ -50,7 +50,7 @@ class DSVideoRendererControl : public QVideoRendererControl
{
Q_OBJECT
public:
- DSVideoRendererControl(DSCameraSession* session, QObject *parent = 0);
+ DSVideoRendererControl(DSCameraSession* session, QObject *parent = nullptr);
~DSVideoRendererControl() override;
QAbstractVideoSurface *surface() const override;
@@ -59,7 +59,7 @@ public:
void setSession(DSCameraSession* session);
private:
- QAbstractVideoSurface* m_surface;
+ QAbstractVideoSurface* m_surface = nullptr;
DSCameraSession* m_session;
};