summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-03-24 03:00:12 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-03-24 03:00:12 +0100
commit7142f2d83b5f838702dc11f9706abb51eb9898d7 (patch)
tree56fc6f44f79d2dacc96645bdbec78aeac1ea93c2 /src/plugins
parent2845e10810a50d6cba4f19a27cfefac10b06929a (diff)
parent58d83703d7d5435a74d59bdb906ca6a76b54f78f (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/audiocapture/audioencodercontrol.cpp13
-rw-r--r--src/plugins/directshow/camera/dscameracontrol.cpp2
-rw-r--r--src/plugins/directshow/camera/dscamerasession.cpp38
-rw-r--r--src/plugins/directshow/camera/dscamerasession.h2
-rw-r--r--src/plugins/directshow/player/directshowplayerservice.cpp5
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinlocks.cpp2
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinsession.cpp14
7 files changed, 50 insertions, 26 deletions
diff --git a/src/plugins/audiocapture/audioencodercontrol.cpp b/src/plugins/audiocapture/audioencodercontrol.cpp
index d8a83bf26..6fc519cef 100644
--- a/src/plugins/audiocapture/audioencodercontrol.cpp
+++ b/src/plugins/audiocapture/audioencodercontrol.cpp
@@ -54,13 +54,12 @@ static QAudioFormat audioSettingsToAudioFormat(const QAudioEncoderSettings &sett
fmt.setCodec(settings.codec());
fmt.setChannelCount(settings.channelCount());
fmt.setSampleRate(settings.sampleRate());
- if (settings.sampleRate() == 8000 && settings.bitRate() == 8000) {
- fmt.setSampleType(QAudioFormat::UnSignedInt);
- fmt.setSampleSize(8);
- } else {
- fmt.setSampleSize(16);
- fmt.setSampleType(QAudioFormat::SignedInt);
- }
+ int sampleSize = 16;
+ if (settings.bitRate() && settings.channelCount() && settings.sampleRate())
+ sampleSize = settings.bitRate() / settings.channelCount() / settings.sampleRate();
+ fmt.setSampleSize(sampleSize);
+ fmt.setSampleType(sampleSize == 8 ? QAudioFormat::UnSignedInt : QAudioFormat::SignedInt);
+
fmt.setByteOrder(QAudioDeviceInfo::defaultInputDevice().preferredFormat().byteOrder());
return fmt;
}
diff --git a/src/plugins/directshow/camera/dscameracontrol.cpp b/src/plugins/directshow/camera/dscameracontrol.cpp
index a6824976d..8d923da9f 100644
--- a/src/plugins/directshow/camera/dscameracontrol.cpp
+++ b/src/plugins/directshow/camera/dscameracontrol.cpp
@@ -53,6 +53,8 @@ DSCameraControl::DSCameraControl(QObject *parent)
m_session = qobject_cast<DSCameraSession*>(parent);
connect(m_session, SIGNAL(statusChanged(QCamera::Status)),
this, SIGNAL(statusChanged(QCamera::Status)));
+ connect(m_session, &DSCameraSession::cameraError,
+ this, &DSCameraControl::error);
}
DSCameraControl::~DSCameraControl()
diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp
index 9b642872a..ca3c47cb8 100644
--- a/src/plugins/directshow/camera/dscamerasession.cpp
+++ b/src/plugins/directshow/camera/dscamerasession.cpp
@@ -441,30 +441,33 @@ bool DSCameraSession::startPreview()
setStatus(QCamera::StartingStatus);
+ QString errorString;
HRESULT hr = S_OK;
IMediaControl* pControl = 0;
if (!configurePreviewFormat()) {
- qWarning() << "Failed to configure preview format";
+ errorString = tr("Failed to configure preview format");
goto failed;
}
- if (!connectGraph())
+ if (!connectGraph()) {
+ errorString = tr("Failed to connect graph");
goto failed;
+ }
if (m_surface)
m_surface->start(m_previewSurfaceFormat);
hr = m_filterGraph->QueryInterface(IID_IMediaControl, (void**)&pControl);
if (FAILED(hr)) {
- qWarning() << "failed to get stream control";
+ errorString = tr("Failed to get stream control");
goto failed;
}
hr = pControl->Run();
pControl->Release();
if (FAILED(hr)) {
- qWarning() << "failed to start";
+ errorString = tr("Failed to start");
goto failed;
}
@@ -477,7 +480,7 @@ failed:
if (m_surface && m_surface->isActive())
m_surface->stop();
disconnectGraph();
- setStatus(QCamera::LoadedStatus);
+ setError(QCamera::CameraError, errorString);
return false;
}
@@ -491,17 +494,18 @@ bool DSCameraSession::stopPreview()
if (m_previewSampleGrabber)
m_previewSampleGrabber->stop();
+ QString errorString;
IMediaControl* pControl = 0;
HRESULT hr = m_filterGraph->QueryInterface(IID_IMediaControl, (void**)&pControl);
if (FAILED(hr)) {
- qWarning() << "failed to get stream control";
+ errorString = tr("Failed to get stream control");
goto failed;
}
hr = pControl->Stop();
pControl->Release();
if (FAILED(hr)) {
- qWarning() << "failed to stop";
+ errorString = tr("Failed to stop");
goto failed;
}
@@ -514,10 +518,16 @@ bool DSCameraSession::stopPreview()
return true;
failed:
- setStatus(QCamera::ActiveStatus);
+ setError(QCamera::CameraError, errorString);
return false;
}
+void DSCameraSession::setError(int error, const QString &errorString)
+{
+ emit cameraError(error, errorString);
+ setStatus(QCamera::UnloadedStatus);
+}
+
void DSCameraSession::setStatus(QCamera::Status status)
{
if (m_status == status)
@@ -668,6 +678,7 @@ bool DSCameraSession::createFilterGraph()
// Previously containered in <qedit.h>.
static const CLSID cLSID_NullRenderer = { 0xC1F400A4, 0x3F08, 0x11d3, { 0x9F, 0x0B, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37 } };
+ QString errorString;
HRESULT hr;
IMoniker* pMoniker = NULL;
ICreateDevEnum* pDevEnum = NULL;
@@ -677,7 +688,7 @@ bool DSCameraSession::createFilterGraph()
hr = CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC,
IID_IGraphBuilder, (void**)&m_filterGraph);
if (FAILED(hr)) {
- qWarning() << "failed to create filter graph";
+ errorString = tr("Failed to create filter graph");
goto failed;
}
@@ -685,14 +696,14 @@ bool DSCameraSession::createFilterGraph()
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC,
IID_ICaptureGraphBuilder2, (void**)&m_graphBuilder);
if (FAILED(hr)) {
- qWarning() << "failed to create graph builder";
+ errorString = tr("Failed to create graph builder");
goto failed;
}
// Attach the filter graph to the capture graph
hr = m_graphBuilder->SetFiltergraph(m_filterGraph);
if (FAILED(hr)) {
- qWarning() << "failed to connect capture graph and filter graph";
+ errorString = tr("Failed to connect capture graph and filter graph");
goto failed;
}
@@ -762,7 +773,7 @@ bool DSCameraSession::createFilterGraph()
}
if (!m_sourceFilter) {
- qWarning() << "No capture device found";
+ errorString = tr("No capture device found");
goto failed;
}
@@ -779,7 +790,7 @@ bool DSCameraSession::createFilterGraph()
hr = CoCreateInstance(cLSID_NullRenderer, NULL, CLSCTX_INPROC,
IID_IBaseFilter, (void**)&m_nullRendererFilter);
if (FAILED(hr)) {
- qWarning() << "failed to create null renderer";
+ errorString = tr("Failed to create null renderer");
goto failed;
}
@@ -793,6 +804,7 @@ failed:
SAFE_RELEASE(m_nullRendererFilter);
SAFE_RELEASE(m_filterGraph);
SAFE_RELEASE(m_graphBuilder);
+ setError(QCamera::CameraError, errorString);
return false;
}
diff --git a/src/plugins/directshow/camera/dscamerasession.h b/src/plugins/directshow/camera/dscamerasession.h
index e28015534..07c3d9ef9 100644
--- a/src/plugins/directshow/camera/dscamerasession.h
+++ b/src/plugins/directshow/camera/dscamerasession.h
@@ -138,6 +138,7 @@ Q_SIGNALS:
void readyForCaptureChanged(bool);
void captureError(int id, int error, const QString &errorString);
void captureDestinationChanged(QCameraImageCapture::CaptureDestinations);
+ void cameraError(int error, const QString &errorString);
private Q_SLOTS:
void presentFrame();
@@ -176,6 +177,7 @@ private:
void updateSourceCapabilities();
bool configurePreviewFormat();
void updateImageProcessingParametersInfos();
+ void setError(int error, const QString &errorString);
// These static functions are used for scaling of adjustable parameters,
// which have the ranges from -1.0 to +1.0 in the QCameraImageProcessing API.
diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp
index 8ee5d67a1..63f738bbe 100644
--- a/src/plugins/directshow/player/directshowplayerservice.cpp
+++ b/src/plugins/directshow/player/directshowplayerservice.cpp
@@ -1071,8 +1071,11 @@ void DirectShowPlayerService::doSetRate(QMutexLocker *locker)
locker->relock();
if (!SUCCEEDED(hr)) {
+ qWarning("%s: Audio device or filter does not support rate: %.2f. " \
+ "Falling back to previous value.", __FUNCTION__, m_rate);
+
double rate = 0.0;
- m_rate = seeking->GetRate(&rate)
+ m_rate = SUCCEEDED(seeking->GetRate(&rate))
? rate
: 1.0;
}
diff --git a/src/plugins/gstreamer/camerabin/camerabinlocks.cpp b/src/plugins/gstreamer/camerabin/camerabinlocks.cpp
index 2ccc1b0bc..89be2ac5d 100644
--- a/src/plugins/gstreamer/camerabin/camerabinlocks.cpp
+++ b/src/plugins/gstreamer/camerabin/camerabinlocks.cpp
@@ -102,8 +102,6 @@ QCamera::LockStatus CameraBinLocks::lockStatus(QCamera::LockType lock) const
default:
return QCamera::Unlocked;
}
-
- return lock == QCamera::LockFocus ? m_focus->focusStatus() : QCamera::Unlocked;
}
void CameraBinLocks::searchAndLock(QCamera::LockTypes locks)
diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp
index 39f97e989..3bb6ebffb 100644
--- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp
+++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp
@@ -767,7 +767,11 @@ void CameraBinSession::setStateHelper(QCamera::State state)
void CameraBinSession::setError(int err, const QString &errorString)
{
- m_pendingState = QCamera::UnloadedState;
+ // Emit only first error
+ if (m_pendingState == QCamera::UnloadedState)
+ return;
+
+ setState(QCamera::UnloadedState);
emit error(err, errorString);
setStatus(QCamera::UnloadedStatus);
}
@@ -990,10 +994,14 @@ bool CameraBinSession::processBusMessage(const QGstreamerMessage &message)
if (err && err->message) {
message = QString::fromUtf8(err->message);
qWarning() << "CameraBin error:" << message;
+#if CAMERABIN_DEBUG
+ qWarning() << QString::fromUtf8(debug);
+#endif
}
- //only report error messager from camerabin
- if (GST_MESSAGE_SRC(gm) == GST_OBJECT_CAST(m_camerabin)) {
+ // Only report error messages from camerabin or video source
+ if (GST_MESSAGE_SRC(gm) == GST_OBJECT_CAST(m_camerabin)
+ || GST_MESSAGE_SRC(gm) == GST_OBJECT_CAST(m_videoSrc)) {
if (message.isEmpty())
message = tr("Camera error");