summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/directshow/camera/dscamerasession.cpp4
-rw-r--r--src/plugins/directshow/camera/dscamerasession.h2
-rw-r--r--src/plugins/directshow/common/directshowsamplegrabber.cpp8
-rw-r--r--src/plugins/directshow/common/directshowsamplegrabber.h2
-rw-r--r--src/plugins/directshow/player/directshowplayerservice.cpp9
-rw-r--r--src/plugins/directshow/player/directshowplayerservice.h4
6 files changed, 13 insertions, 16 deletions
diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp
index 3f1187ba..55ab868c 100644
--- a/src/plugins/directshow/camera/dscamerasession.cpp
+++ b/src/plugins/directshow/camera/dscamerasession.cpp
@@ -529,12 +529,10 @@ int DSCameraSession::captureImage(const QString &fileName)
return m_imageIdCounter;
}
-void DSCameraSession::onFrameAvailable(double time, quint8 *buffer, long len)
+void DSCameraSession::onFrameAvailable(double time, const QByteArray &data)
{
// !!! Not called on the main thread
Q_UNUSED(time);
- // Deep copy, the data might be modified or freed after the callback returns
- QByteArray data(reinterpret_cast<const char *>(buffer), len);
m_presentMutex.lock();
diff --git a/src/plugins/directshow/camera/dscamerasession.h b/src/plugins/directshow/camera/dscamerasession.h
index 6b6cb49b..90407f49 100644
--- a/src/plugins/directshow/camera/dscamerasession.h
+++ b/src/plugins/directshow/camera/dscamerasession.h
@@ -156,7 +156,7 @@ private:
void setStatus(QCamera::Status status);
- void onFrameAvailable(double time, quint8 *buffer, long len);
+ void onFrameAvailable(double time, const QByteArray &data);
void saveCapturedImage(int id, const QImage &image, const QString &path);
bool createFilterGraph();
diff --git a/src/plugins/directshow/common/directshowsamplegrabber.cpp b/src/plugins/directshow/common/directshowsamplegrabber.cpp
index b33c3cfc..fb95370c 100644
--- a/src/plugins/directshow/common/directshowsamplegrabber.cpp
+++ b/src/plugins/directshow/common/directshowsamplegrabber.cpp
@@ -99,9 +99,11 @@ public:
STDMETHODIMP BufferCB(double time, BYTE *buffer, long bufferLen)
{
- if (m_grabber)
- Q_EMIT m_grabber->bufferAvailable(time, buffer, bufferLen);
-
+ if (m_grabber) {
+ // Deep copy, the data might be modified or freed after the callback returns
+ QByteArray data(reinterpret_cast<const char *>(buffer), bufferLen);
+ Q_EMIT m_grabber->bufferAvailable(time, data);
+ }
return S_OK;
}
diff --git a/src/plugins/directshow/common/directshowsamplegrabber.h b/src/plugins/directshow/common/directshowsamplegrabber.h
index edabae2d..a9b72fcd 100644
--- a/src/plugins/directshow/common/directshowsamplegrabber.h
+++ b/src/plugins/directshow/common/directshowsamplegrabber.h
@@ -75,7 +75,7 @@ public:
Q_SIGNALS:
void sampleAvailable(double time, IMediaSample *sample);
- void bufferAvailable(double time, quint8 *buffer, long len);
+ void bufferAvailable(double time, const QByteArray &data);
private:
IBaseFilter *m_filter;
diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp
index 2f959b23..9cbb6296 100644
--- a/src/plugins/directshow/player/directshowplayerservice.cpp
+++ b/src/plugins/directshow/player/directshowplayerservice.cpp
@@ -1453,7 +1453,7 @@ void DirectShowPlayerService::videoOutputChanged()
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers")
-void DirectShowPlayerService::onAudioBufferAvailable(double time, quint8 *buffer, long len)
+void DirectShowPlayerService::onAudioBufferAvailable(double time, const QByteArray &data)
{
QMutexLocker locker(&m_mutex);
if (!m_audioProbeControl || !m_audioSampleGrabber)
@@ -1497,18 +1497,16 @@ void DirectShowPlayerService::onAudioBufferAvailable(double time, quint8 *buffer
format.setSampleType(QAudioFormat::SignedInt);
const quint64 startTime = quint64(time * 1000.);
- QAudioBuffer audioBuffer(QByteArray(reinterpret_cast<const char *>(buffer), len),
+ QAudioBuffer audioBuffer(data,
format,
startTime);
Q_EMIT m_audioProbeControl->audioBufferProbed(audioBuffer);
}
-void DirectShowPlayerService::onVideoBufferAvailable(double time, quint8 *buffer, long len)
+void DirectShowPlayerService::onVideoBufferAvailable(double time, const QByteArray &data)
{
Q_UNUSED(time);
- Q_UNUSED(buffer);
- Q_UNUSED(len);
QMutexLocker locker(&m_mutex);
if (!m_videoProbeControl || !m_videoSampleGrabber)
@@ -1536,7 +1534,6 @@ void DirectShowPlayerService::onVideoBufferAvailable(double time, quint8 *buffer
const QSize &size = videoFormat.frameSize();
const int bytesPerLine = DirectShowMediaType::bytesPerLine(videoFormat);
- QByteArray data(reinterpret_cast<const char *>(buffer), len);
QVideoFrame frame(new QMemoryVideoBuffer(data, bytesPerLine),
size,
format);
diff --git a/src/plugins/directshow/player/directshowplayerservice.h b/src/plugins/directshow/player/directshowplayerservice.h
index 676d88fb..01d05449 100644
--- a/src/plugins/directshow/player/directshowplayerservice.h
+++ b/src/plugins/directshow/player/directshowplayerservice.h
@@ -106,8 +106,8 @@ protected:
private Q_SLOTS:
void videoOutputChanged();
- void onAudioBufferAvailable(double time, quint8 *buffer, long len);
- void onVideoBufferAvailable(double time, quint8 *buffer, long len);
+ void onAudioBufferAvailable(double time, const QByteArray &data);
+ void onVideoBufferAvailable(double time, const QByteArray &data);
private:
void releaseGraph();