Commit 80da1d40 authored by Nils Hasler's avatar Nils Hasler

removed private copy of gstappsink because appsink is now part of gstreamer base.

parent e7e72d24
......@@ -372,7 +372,7 @@ if(UNIX)
endif()
if(WITH_GSTREAMER)
CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER)
CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER_APP)
CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER)
CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER)
else()
set(HAVE_GSTREAMER FALSE)
......
......@@ -43,9 +43,6 @@
/* GStreamer multimedia framework */
#cmakedefine HAVE_GSTREAMER
/* GStreamer with gstappsink & gstappsrc */
#cmakedefine HAVE_GSTREAMER_APP
/* GTK+ 2.0 Thread support */
#cmakedefine HAVE_GTHREAD
......
......@@ -132,10 +132,6 @@ if(UNIX)
if(HAVE_GSTREAMER)
set(highgui_srcs ${highgui_srcs} src/cap_gstreamer.cpp)
if(NOT HAVE_GSTREAMER_APP)
set(highgui_srcs ${highgui_srcs} src/gstappsink.cpp)
set(highgui_hdrs ${highgui_hdrs} src/gstappsink.h)
endif()
endif()
if(HAVE_UNICAP)
......
......@@ -10,7 +10,7 @@
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2008, Nils Hasler, all rights reserved.
// Copyright (C) 2008, 2011, Nils Hasler, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -55,15 +55,10 @@
#include <map>
#include <gst/gst.h>
#include <gst/video/video.h>
#ifdef HAVE_GSTREAMER_APP
#include <gst/app/gstappsink.h>
#include <gst/app/gstappsrc.h>
#include <gst/riff/riff-media.h>
#else
#include "gstappsink.h"
#endif
#ifdef NDEBUG
#define CV_WARN(message)
#else
......@@ -168,28 +163,14 @@ bool CvCapture_GStreamer::grabFrame()
if(!pipeline)
return false;
if(gst_app_sink_is_eos(GST_APP_SINK(sink))) {
//printf("end of stream\n");
if(gst_app_sink_is_eos(GST_APP_SINK(sink)))
return false;
}
if(buffer)
gst_buffer_unref(buffer);
handleMessage();
#ifndef HAVE_GSTREAMER_APP
if(gst_app_sink_get_queue_length(GST_APP_SINK(sink)))
{
// printf("peeking buffer, %d buffers in queue\n",
buffer = gst_app_sink_peek_buffer(GST_APP_SINK(sink));
}
else
#endif
{
// printf("pulling buffer\n");
buffer = gst_app_sink_pull_buffer(GST_APP_SINK(sink));
// printf("pulled buffer %p\n", GST_BUFFER_DATA(buffer));
}
buffer = gst_app_sink_pull_buffer(GST_APP_SINK(sink));
if(!buffer)
return false;
......@@ -204,8 +185,6 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
if(!buffer)
return false;
// printf("retrieving buffer %p\n", GST_BUFFER_DATA(buffer));
if(!frame) {
gint height, width;
GstCaps *buff_caps = gst_buffer_get_caps(buffer);
......@@ -220,9 +199,9 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
gst_caps_unref(buff_caps);
}
// no need to memcpy, just use gstreamer's buffer :-)
frame->imageData = (char *)GST_BUFFER_DATA(buffer);
//memcpy (frame->imageData, GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE (buffer));
//gst_data_copy_into (frame->imageData,GST_BUFFER_DATA(buffer));
//gst_buffer_unref(buffer);
//buffer = 0;
return frame;
......@@ -270,7 +249,7 @@ void CvCapture_GStreamer::setFilter(const char *property, int type, int v1, int
else
caps = gst_caps_new_simple("video/x-raw-rgb", property, type, v1, v2, NULL);
} else {
printf("caps before setting %s\n", gst_caps_to_string(caps));
//printf("caps before setting %s\n", gst_caps_to_string(caps));
if(type == G_TYPE_INT)
gst_caps_set_simple(caps, "video/x-raw-rgb", property, type, v1, NULL);
else
......@@ -312,14 +291,6 @@ void CvCapture_GStreamer::newPad(GstElement *uridecodebin,
gst_object_unref (sinkpad);
}
// static int buffernum = 0;
// static GstFlowReturn newbuffer(GstAppSink *sink, gpointer data)
// {
// printf("new buffer %d\n", buffernum);
// buffernum++;
// return GST_FLOW_OK;
// }
bool CvCapture_GStreamer::open( int type, const char* filename )
{
close();
......@@ -347,11 +318,9 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
}
if(!gst_uri_is_valid(filename)) {
// printf("file '%s' is not uri\n", filename);
uri = realpath(filename, NULL);
stream=false;
if(uri) {
// printf("is file... ? %s\n", uri);
uri = g_filename_to_uri(uri, NULL, NULL);
if(!uri) {
CV_WARN("GStreamer: Error opening file\n");
......@@ -367,18 +336,14 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
return false;
}
stream = true;
// printf("created custom bin\n");
manualpipeline = true;
}
}
else {
// printf("file '%s' is uri\n", filename);
} else {
stream = true;
uri = g_strdup(filename);
}
if(!uridecodebin) {
// printf("creating uridecodebin\n");
uridecodebin = gst_element_factory_make ("uridecodebin", NULL);
g_object_set(G_OBJECT(uridecodebin),"uri",uri, NULL);
}
......@@ -387,22 +352,12 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
close();
return false;
}
// printf("Trying to connect to stream \n");
color = gst_element_factory_make("ffmpegcolorspace", NULL);
//printf("%sstreaming\n", stream ? "" : "not ");
#ifdef HAVE_GSTREAMER_APP
sink = gst_element_factory_make("appsink", NULL);
gst_app_sink_set_max_buffers (GST_APP_SINK(sink),1);
if (stream) {
gst_app_sink_set_drop (GST_APP_SINK(sink),true);
}
// GstAppSinkCallbacks cb = {0, 0, newbuffer, 0};
// gst_app_sink_set_callbacks(GST_APP_SINK(sink), &cb, 0, 0);
#else
sink = gst_element_factory_make("opencv-appsink", NULL);
#endif
gst_app_sink_set_max_buffers (GST_APP_SINK(sink), 1);
if(stream)
gst_app_sink_set_drop (GST_APP_SINK(sink), true);
GstCaps* caps= gst_caps_new_simple("video/x-raw-rgb",
"red_mask", G_TYPE_INT, 255,
"green_mask", G_TYPE_INT, 65280,
......@@ -413,14 +368,12 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
pipeline = gst_pipeline_new (NULL);
//printf("adding stuff to pipeline\n");
if(manualpipeline) {
// it is easier to link elements inside the same bin
gst_bin_add_many(GST_BIN(uridecodebin), color, sink, NULL);
// need the pipeline around the bin because bins don't know about timing
gst_bin_add(GST_BIN(pipeline), uridecodebin);
}
else {
} else {
gst_bin_add_many(GST_BIN(pipeline), uridecodebin, color, sink, NULL);
}
......@@ -428,11 +381,8 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
GstElement *e = gst_bin_get_by_name(GST_BIN(uridecodebin), "to-opencv");
if(e) {
if(!gst_element_link(e, color)) {
//printf("catching 'pad-added' for element 'to-opencv'\n");
g_signal_connect(e, "pad-added", G_CALLBACK(newPad), color);
}/* else {
printf("linked to-opencv -> color\n");
}*/
}
gst_object_unref(e);
} else {
CV_WARN("GStreamer: no element with 'name=to-opencv'\n");
......@@ -475,7 +425,7 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
return true;
}
#ifdef HAVE_GSTREAMER_APP
//
//
// gstreamer image sequence writer
......@@ -638,13 +588,7 @@ CvVideoWriter* cvCreateVideoWriter_GStreamer(const char* filename, int fourcc, d
delete wrt;
return false;
}
#else
CvVideoWriter* cvCreateVideoWriter_GStreamer(const char*, int, double, CvSize, int )
{
return false;
}
#endif
void CvCapture_GStreamer::close()
{
if(pipeline) {
......
This diff is collapsed.
/* GStreamer
* Copyright (C) 2007 David Schleef <ds@schleef.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef _GST_APP_SINK_H_
#define _GST_APP_SINK_H_
#include <gst/gst.h>
#include <gst/base/gstbasesink.h>
G_BEGIN_DECLS
#define GST_TYPE_APP_SINK \
(gst_app_sink_get_type())
#define GST_APP_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_APP_SINK,GstAppSink))
#define GST_APP_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_APP_SINK,GstAppSinkClass))
#define GST_IS_APP_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_APP_SINK))
#define GST_IS_APP_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_APP_SINK))
typedef struct _GstAppSink GstAppSink;
typedef struct _GstAppSinkClass GstAppSinkClass;
struct _GstAppSink
{
GstBaseSink basesink;
/*< private >*/
GstCaps *caps;
GCond *cond;
GMutex *mutex;
GQueue *queue;
GstBuffer *preroll;
gboolean started;
gboolean is_eos;
};
struct _GstAppSinkClass
{
GstBaseSinkClass basesink_class;
/* signals */
gboolean (*eos) (GstAppSink *sink);
gboolean (*new_preroll) (GstAppSink *sink);
gboolean (*new_buffer) (GstAppSink *sink);
/* actions */
GstBuffer * (*pull_preroll) (GstAppSink *sink);
GstBuffer * (*pull_buffer) (GstAppSink *sink);
};
GType gst_app_sink_get_type(void);
GST_DEBUG_CATEGORY_EXTERN (app_sink_debug);
void gst_app_sink_set_caps (GstAppSink *appsink, const GstCaps *caps);
GstCaps * gst_app_sink_get_caps (GstAppSink *appsink);
gboolean gst_app_sink_is_eos (GstAppSink *appsink);
GstBuffer * gst_app_sink_pull_preroll (GstAppSink *appsink);
GstBuffer * gst_app_sink_pull_buffer (GstAppSink *appsink);
GstBuffer * gst_app_sink_peek_buffer (GstAppSink *appsink);
guint gst_app_sink_get_queue_length (GstAppSink *appsink);
G_END_DECLS
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment