summaryrefslogtreecommitdiffstats
path: root/src/gsttools/qgstappsrc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gsttools/qgstappsrc.cpp')
-rw-r--r--src/gsttools/qgstappsrc.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/gsttools/qgstappsrc.cpp b/src/gsttools/qgstappsrc.cpp
index 561a96fc8..178e11805 100644
--- a/src/gsttools/qgstappsrc.cpp
+++ b/src/gsttools/qgstappsrc.cpp
@@ -147,23 +147,44 @@ void QGstAppSrc::pushDataToAppSrc()
size = qMin(m_stream->bytesAvailable(), (qint64)m_dataRequestSize);
if (size) {
- void *data = g_malloc(size);
- GstBuffer* buffer = gst_app_buffer_new(data, size, g_free, data);
+ GstBuffer* buffer = gst_buffer_new_and_alloc(size);
+
+#if GST_CHECK_VERSION(1,0,0)
+ GstMapInfo mapInfo;
+ gst_buffer_map(buffer, &mapInfo, GST_MAP_WRITE);
+ void* bufferData = mapInfo.data;
+#else
+ void* bufferData = GST_BUFFER_DATA(buffer);
+#endif
+
buffer->offset = m_stream->pos();
- qint64 bytesRead = m_stream->read((char*)GST_BUFFER_DATA(buffer), size);
+ qint64 bytesRead = m_stream->read((char*)bufferData, size);
buffer->offset_end = buffer->offset + bytesRead - 1;
+#if GST_CHECK_VERSION(1,0,0)
+ gst_buffer_unmap(buffer, &mapInfo);
+#endif
+
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";
+#if GST_CHECK_VERSION(1,0,0)
+ } else if (ret == GST_FLOW_FLUSHING) {
+ qWarning()<<"appsrc: push buffer wrong state";
+ }
+#else
} else if (ret == GST_FLOW_WRONG_STATE) {
qWarning()<<"appsrc: push buffer wrong state";
- } else if (ret == GST_FLOW_RESEND) {
+ }
+#endif
+#if GST_VERSION_MAJOR < 1
+ else if (ret == GST_FLOW_RESEND) {
qWarning()<<"appsrc: push buffer resend";
}
+#endif
}
} else {
sendEOS();