GStreamer: port to 1.0.
0.10 is still used by default. To enable GStreamer 1.0, pass GST_VERSION=1.0 to qmake for qtmultimedia.pro. Contributions from: Andrew den Exter <andrew.den.exter@qinetic.com.au> Ilya Smelykh <ilya@videoexpertsgroup.com> Jim Hodapp <jim.hodapp@canonical.com> Sergio Schvezov <sergio.schvezov@canonical.com> Change-Id: I72a46d1170a8794a149bdb5e20767afcc5b7587c Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
This commit is contained in:
committed by
Andrew den Exter
parent
7e3d69668e
commit
108dda7a90
@@ -37,32 +37,48 @@
|
||||
QGstreamerAudioProbeControl::QGstreamerAudioProbeControl(QObject *parent)
|
||||
: QMediaAudioProbeControl(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QGstreamerAudioProbeControl::~QGstreamerAudioProbeControl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QGstreamerAudioProbeControl::bufferProbed(GstBuffer* buffer)
|
||||
void QGstreamerAudioProbeControl::probeCaps(GstCaps *caps)
|
||||
{
|
||||
GstCaps* caps = gst_buffer_get_caps(buffer);
|
||||
if (!caps)
|
||||
return;
|
||||
|
||||
QAudioFormat format = QGstUtils::audioFormatForCaps(caps);
|
||||
gst_caps_unref(caps);
|
||||
if (!format.isValid())
|
||||
return;
|
||||
|
||||
QAudioBuffer audioBuffer = QAudioBuffer(QByteArray((const char*)buffer->data, buffer->size), format);
|
||||
QMutexLocker locker(&m_bufferMutex);
|
||||
m_format = format;
|
||||
}
|
||||
|
||||
{
|
||||
QMutexLocker locker(&m_bufferMutex);
|
||||
m_pendingBuffer = audioBuffer;
|
||||
QMetaObject::invokeMethod(this, "bufferProbed", Qt::QueuedConnection);
|
||||
bool QGstreamerAudioProbeControl::probeBuffer(GstBuffer *buffer)
|
||||
{
|
||||
qint64 position = GST_BUFFER_TIMESTAMP(buffer);
|
||||
position = position >= 0
|
||||
? position / G_GINT64_CONSTANT(1000) // microseconds
|
||||
: -1;
|
||||
|
||||
QByteArray data;
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
GstMapInfo info;
|
||||
if (gst_buffer_map(buffer, &info, GST_MAP_READ)) {
|
||||
data = QByteArray(reinterpret_cast<const char *>(info.data), info.size);
|
||||
gst_buffer_unmap(buffer, &info);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
data = QByteArray(reinterpret_cast<const char *>(buffer->data), buffer->size);
|
||||
#endif
|
||||
|
||||
QMutexLocker locker(&m_bufferMutex);
|
||||
if (m_format.isValid()) {
|
||||
if (!m_pendingBuffer.isValid())
|
||||
QMetaObject::invokeMethod(this, "bufferProbed", Qt::QueuedConnection);
|
||||
m_pendingBuffer = QAudioBuffer(data, m_format, position);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QGstreamerAudioProbeControl::bufferProbed()
|
||||
@@ -73,6 +89,7 @@ void QGstreamerAudioProbeControl::bufferProbed()
|
||||
if (!m_pendingBuffer.isValid())
|
||||
return;
|
||||
audioBuffer = m_pendingBuffer;
|
||||
m_pendingBuffer = QAudioBuffer();
|
||||
}
|
||||
emit audioBufferProbed(audioBuffer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user