summaryrefslogtreecommitdiffstats
path: root/gst-libs/gst/app
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2007-03-03 09:06:06 +0000
committerDavid Schleef <ds@schleef.org>2007-03-03 09:06:06 +0000
commit6b355aa720a00409a4b49c2307d841979cea2e5d (patch)
treedba588aaf6fe4e05f224a06fc5e755ccd1d9fe98 /gst-libs/gst/app
parent50fdeffe760c39ca68ad4b83d678af0786970cbd (diff)
downloadgst-plugins-bad-6b355aa720a00409a4b49c2307d841979cea2e5d.tar.gz
gst-plugins-bad-6b355aa720a00409a4b49c2307d841979cea2e5d.tar.bz2
gst-plugins-bad-6b355aa720a00409a4b49c2307d841979cea2e5d.zip
gst-libs/gst/app/gstappsrc.*: Hacking to address issues in 413418.
Original commit message from CVS: * gst-libs/gst/app/gstappsrc.c: * gst-libs/gst/app/gstappsrc.h: Hacking to address issues in 413418.
Diffstat (limited to 'gst-libs/gst/app')
-rw-r--r--gst-libs/gst/app/gstappsrc.c66
-rw-r--r--gst-libs/gst/app/gstappsrc.h3
2 files changed, 64 insertions, 5 deletions
diff --git a/gst-libs/gst/app/gstappsrc.c b/gst-libs/gst/app/gstappsrc.c
index 1d5b45c6..d786424f 100644
--- a/gst-libs/gst/app/gstappsrc.c
+++ b/gst-libs/gst/app/gstappsrc.c
@@ -24,8 +24,6 @@
#include <gst/gst.h>
#include <gst/base/gstpushsrc.h>
-#include <unistd.h>
-#include <fcntl.h>
#include <string.h>
#include "gstappsrc.h"
@@ -100,9 +98,22 @@ gst_app_src_dispose (GObject * obj)
{
GstAppSrc *appsrc = GST_APP_SRC (obj);
- g_mutex_free (appsrc->mutex);
- g_cond_free (appsrc->cond);
- g_queue_free (appsrc->queue);
+ if (appsrc->caps) {
+ gst_caps_unref (appsrc->caps);
+ appsrc->caps = NULL;
+ }
+ if (appsrc->mutex) {
+ g_mutex_free (appsrc->mutex);
+ appsrc->mutex = NULL;
+ }
+ if (appsrc->cond) {
+ g_cond_free (appsrc->cond);
+ appsrc->cond = NULL;
+ }
+ if (appsrc->queue) {
+ g_queue_free (appsrc->queue);
+ appsrc->queue = NULL;
+ }
}
static void
@@ -187,6 +198,10 @@ gst_app_src_create (GstPushSrc * psrc, GstBuffer ** buf)
g_mutex_lock (appsrc->mutex);
while (1) {
+ if (appsrc->unlock) {
+ ret = GST_FLOW_WRONG_STATE;
+ break;
+ }
if (!g_queue_is_empty (appsrc->queue)) {
*buf = g_queue_pop_head (appsrc->queue);
@@ -216,9 +231,20 @@ gst_app_src_create (GstPushSrc * psrc, GstBuffer ** buf)
/* external API */
+/**
+ * gst_app_src_push_buffer:
+ * @appsrc:
+ * @buffer:
+ *
+ * Adds a buffer to the queue of buffers that the appsrc element will
+ * push to its source pad. This function takes ownership of the buffer.
+ */
void
gst_app_src_push_buffer (GstAppSrc * appsrc, GstBuffer * buffer)
{
+ g_return_if_fail (appsrc);
+ g_return_if_fail (GST_IS_APP_SRC (appsrc));
+
g_mutex_lock (appsrc->mutex);
g_queue_push_tail (appsrc->queue, buffer);
@@ -227,17 +253,37 @@ gst_app_src_push_buffer (GstAppSrc * appsrc, GstBuffer * buffer)
g_mutex_unlock (appsrc->mutex);
}
+/**
+ * gst_app_src_set_caps:
+ * @appsrc:
+ * @caps:
+ *
+ * Set the capabilities on the appsrc element. This function takes
+ * ownership of the caps structure.
+ */
void
gst_app_src_set_caps (GstAppSrc * appsrc, GstCaps * caps)
{
+ g_return_if_fail (appsrc);
+ g_return_if_fail (GST_IS_APP_SRC (appsrc));
+
gst_caps_replace (&appsrc->caps, caps);
}
+/**
+ * gst_app_src_flush:
+ * @appsrc:
+ *
+ * Flushes all queued buffers from the appsrc element.
+ */
void
gst_app_src_flush (GstAppSrc * appsrc)
{
GstBuffer *buffer;
+ g_return_if_fail (appsrc);
+ g_return_if_fail (GST_IS_APP_SRC (appsrc));
+
g_mutex_lock (appsrc->mutex);
while ((buffer = g_queue_pop_head (appsrc->queue))) {
@@ -249,9 +295,19 @@ gst_app_src_flush (GstAppSrc * appsrc)
g_mutex_unlock (appsrc->mutex);
}
+/**
+ * gst_app_src_end_of_stream:
+ * @appsrc:
+ *
+ * Indicates to the appsrc element that the last buffer queued in the
+ * element is the last buffer of the stream.
+ */
void
gst_app_src_end_of_stream (GstAppSrc * appsrc)
{
+ g_return_if_fail (appsrc);
+ g_return_if_fail (GST_IS_APP_SRC (appsrc));
+
g_mutex_lock (appsrc->mutex);
appsrc->end_of_stream = TRUE;
diff --git a/gst-libs/gst/app/gstappsrc.h b/gst-libs/gst/app/gstappsrc.h
index 48990bf9..617a20e2 100644
--- a/gst-libs/gst/app/gstappsrc.h
+++ b/gst-libs/gst/app/gstappsrc.h
@@ -23,6 +23,8 @@
#include <gst/gst.h>
#include <gst/base/gstpushsrc.h>
+G_BEGIN_DECLS
+
#define GST_TYPE_APP_SRC \
(gst_app_src_get_type())
#define GST_APP_SRC(obj) \
@@ -66,6 +68,7 @@ void gst_app_src_set_caps (GstAppSrc *appsrc, GstCaps *caps);
void gst_app_src_flush (GstAppSrc *appsrc);
void gst_app_src_end_of_stream (GstAppSrc *appsrc);
+G_END_DECLS
#endif