summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Nicoletti <dantti12@gmail.com>2014-01-27 11:44:22 -0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-27 15:22:12 +0100
commit7451906b71e7271238ecf9446b7960ab2c647cc9 (patch)
tree33f50f34d38bf1624d176fa97c637307cc94bd84 /src
parentd26fcf043db5afba9c38653531794b6cf8f13e54 (diff)
Fix sending End Of Stream on gst plugin
When streaming to gst a typefind operation is performed which jumps around to find which codec the file provides, this fix the call to send an EOS before we try to read and not after which causes confusion to gst. Task-number: QTBUG-32963 Change-Id: I2658b6a4e960430c8ab422a3bee5e11956663116 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gsttools/qgstappsrc.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/gsttools/qgstappsrc.cpp b/src/gsttools/qgstappsrc.cpp
index c74639ef2..8917bda85 100644
--- a/src/gsttools/qgstappsrc.cpp
+++ b/src/gsttools/qgstappsrc.cpp
@@ -149,28 +149,29 @@ void QGstAppSrc::pushDataToAppSrc()
size = qMin(m_stream->bytesAvailable(), queueSize());
else
size = qMin(m_stream->bytesAvailable(), (qint64)m_dataRequestSize);
- void *data = g_malloc(size);
- GstBuffer* buffer = gst_app_buffer_new(data, size, g_free, data);
- buffer->offset = m_stream->pos();
- qint64 bytesRead = m_stream->read((char*)GST_BUFFER_DATA(buffer), size);
- buffer->offset_end = buffer->offset + bytesRead - 1;
-
- if (bytesRead > 0) {
- m_dataRequested = false;
- m_enoughData = false;
- GstFlowReturn ret = gst_app_src_push_buffer (GST_APP_SRC (element()), buffer);
- if (ret == GST_FLOW_ERROR) {
- qWarning()<<"appsrc: push buffer error";
- } else if (ret == GST_FLOW_WRONG_STATE) {
- qWarning()<<"appsrc: push buffer wrong state";
- } else if (ret == GST_FLOW_RESEND) {
- qWarning()<<"appsrc: push buffer resend";
- }
- }
- // After reading we might be all done
- if (m_stream->atEnd())
+ if (size) {
+ void *data = g_malloc(size);
+ GstBuffer* buffer = gst_app_buffer_new(data, size, g_free, data);
+ buffer->offset = m_stream->pos();
+ qint64 bytesRead = m_stream->read((char*)GST_BUFFER_DATA(buffer), size);
+ buffer->offset_end = buffer->offset + bytesRead - 1;
+
+ if (bytesRead > 0) {
+ m_dataRequested = false;
+ m_enoughData = false;
+ GstFlowReturn ret = gst_app_src_push_buffer (GST_APP_SRC (element()), buffer);
+ if (ret == GST_FLOW_ERROR) {
+ qWarning()<<"appsrc: push buffer error";
+ } else if (ret == GST_FLOW_WRONG_STATE) {
+ qWarning()<<"appsrc: push buffer wrong state";
+ } else if (ret == GST_FLOW_RESEND) {
+ qWarning()<<"appsrc: push buffer resend";
+ }
+ }
+ } else {
sendEOS();
+ }
} else if (m_stream->atEnd()) {
sendEOS();
}