[ekiga] Use a GstAdapter in gstreamer's (video) input code: simpler for as good results
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Use a GstAdapter in gstreamer's (video) input code: simpler for as good results
- Date: Wed, 26 Sep 2012 19:43:08 +0000 (UTC)
commit eaa16e547699753fcb672df1a67e1497eeeb4bf1
Author: Julien Puydt <jpuydt free fr>
Date: Wed Sep 26 21:42:40 2012 +0200
Use a GstAdapter in gstreamer's (video) input code: simpler for as good results
Which still means bad results sometimes... but no crash.
plugins/gstreamer/gst-helper.cpp | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/plugins/gstreamer/gst-helper.cpp b/plugins/gstreamer/gst-helper.cpp
index 62db9a5..5c34867 100644
--- a/plugins/gstreamer/gst-helper.cpp
+++ b/plugins/gstreamer/gst-helper.cpp
@@ -38,6 +38,7 @@
#include "gst-helper.h"
#include "runtime.h"
+#include <gst/base/gstadapter.h>
#include <gst/app/gstappsrc.h>
#include <gst/app/gstappsink.h>
#include <gst/app/gstappbuffer.h>
@@ -47,6 +48,7 @@ struct gst_helper
GstElement* pipeline;
GstElement* active;
GstElement* volume;
+ GstAdapter* adapter;
};
@@ -55,6 +57,7 @@ gst_helper_new (const gchar* command)
{
g_message ("%s\t%s\n", __PRETTY_FUNCTION__, command);
gst_helper* self = g_new0 (gst_helper, 1);
+ self->adapter = gst_adapter_new ();
self->pipeline = gst_parse_launch (command, NULL);
(void)gst_element_set_state (self->pipeline, GST_STATE_PLAYING);
self->volume = gst_bin_get_by_name (GST_BIN (self->pipeline), "ekiga_volume");
@@ -69,6 +72,8 @@ static void
gst_helper_destroy (gst_helper* self)
{
gst_element_set_state (self->pipeline, GST_STATE_NULL);
+ gst_object_unref (self->adapter);
+ self->adapter = NULL;
g_object_unref (self->active);
self->active = NULL;
if (self->volume)
@@ -92,22 +97,17 @@ gst_helper_get_frame_data (gst_helper* self,
unsigned size,
unsigned& read)
{
- bool result = false;
GstBuffer* buffer = NULL;
- read = 0;
-
buffer = gst_app_sink_pull_buffer (GST_APP_SINK (self->active));
+ if (buffer != NULL)
+ gst_adapter_push (self->adapter, buffer);
- if (buffer != NULL) {
-
- read = MIN(GST_BUFFER_SIZE (buffer), size);
- memcpy (data, GST_BUFFER_DATA (buffer), read);
- gst_buffer_unref (buffer);
- result = true;
- }
+ read = MIN(size, gst_adapter_available (self->adapter));
+ gst_adapter_copy (self->adapter, (guint8*)data, 0, read);
+ gst_adapter_flush (self->adapter, read);
- return result;
+ return true;
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]