mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
adding dv, raw1934, gnomevfs, rtp
Original commit message from CVS: adding dv, raw1934, gnomevfs, rtp
This commit is contained in:
parent
1c3d0eb6e8
commit
b0f5f9a941
11 changed files with 965 additions and 6 deletions
5
TODO
5
TODO
|
@ -31,3 +31,8 @@
|
|||
* make sidplay stuff ok, the source is on the net ;)
|
||||
|
||||
* fix xmms plugin, doesn't register atm
|
||||
|
||||
* arts and artsd need a good onceover
|
||||
|
||||
|
||||
* check if we can drop some of the AC_SUBST's for libs and cflags
|
||||
|
|
|
@ -545,6 +545,7 @@ dnl *** raw1394 ***
|
|||
translit(dnm, m, l) AM_CONDITIONAL(USE_RAW1394, true)
|
||||
GST_CHECK_FEATURE(RAW1394, [raw1394 library], dv1394src, [
|
||||
GST_CHECK_LIBHEADER(RAW1394, raw1934, raw1934_get_handle,, libraw1394/raw1394.h, RAW1394_LIBS="-raw1394")
|
||||
AC_SUBST(RAW1394_LIBS)
|
||||
])
|
||||
|
||||
dnl Check for librtp
|
||||
|
@ -1067,6 +1068,7 @@ ext/cdparanoia/Makefile
|
|||
ext/dvdread/Makefile
|
||||
ext/esd/Makefile
|
||||
ext/flac/Makefile
|
||||
ext/gnomevfs/Makefile
|
||||
ext/gsm/Makefile
|
||||
ext/hermes/Makefile
|
||||
ext/jpeg/Makefile
|
||||
|
@ -1074,6 +1076,8 @@ ext/lame/Makefile
|
|||
ext/mad/Makefile
|
||||
ext/mpeg2dec/Makefile
|
||||
ext/openquicktime/Makefile
|
||||
ext/raw1394/Makefile
|
||||
ext/rtp/Makefile
|
||||
ext/shout/Makefile
|
||||
ext/sdl/Makefile
|
||||
ext/vorbis/Makefile
|
||||
|
|
|
@ -34,6 +34,12 @@ else
|
|||
CDPARANOIA_DIR=
|
||||
endif
|
||||
|
||||
if USE_DV
|
||||
DV_DIR=dv
|
||||
else
|
||||
DV_DIR=
|
||||
endif
|
||||
|
||||
if USE_DVDREAD
|
||||
DVDREAD_DIR=dvdread
|
||||
else
|
||||
|
@ -64,6 +70,12 @@ else
|
|||
FLAC_DIR=
|
||||
endif
|
||||
|
||||
if USE_GNOME_VFS
|
||||
GNOME_VFS_DIR=gnomevfs
|
||||
else
|
||||
GNOME_VFS_DIR=
|
||||
endif
|
||||
|
||||
if USE_HERMES
|
||||
HERMES_DIR=hermes
|
||||
else
|
||||
|
@ -106,6 +118,12 @@ else
|
|||
OPENQUICKTIME_DIR=
|
||||
endif
|
||||
|
||||
if USE_RTP
|
||||
RTP_DIR=rtp
|
||||
else
|
||||
RTP_DIR=
|
||||
endif
|
||||
|
||||
if USE_SDL
|
||||
SDL_DIR=sdl
|
||||
else
|
||||
|
@ -131,12 +149,12 @@ XMMS_DIR=
|
|||
endif
|
||||
|
||||
SUBDIRS=$(A52_DIR) $(AALIB_DIR) $(ALSA_DIR) $(AUDIOFILE_DIR) \
|
||||
$(AVIFILE_DIR) $(CDPARANOIA_DIR) $(DVDREAD_DIR) $(ESD_DIR) \
|
||||
$(FESTIVAL_DIR) $(FLAC_DIR) $(GSM_DIR) $(HERMES_DIR) \
|
||||
$(AVIFILE_DIR) $(CDPARANOIA_DIR) $(DV_DIR) $(DVDREAD_DIR) $(ESD_DIR) \
|
||||
$(FESTIVAL_DIR) $(FLAC_DIR) $(GNOMEVFS_DIR) $(GSM_DIR) $(HERMES_DIR) \
|
||||
$(JPEG_DIR) $(LAME_DIR) $(MAD_DIR) $(MIKMOD_DIR) $(MPEG2DEC_DIR) \
|
||||
$(OPENQUICKTIME_DIR) $(SDL_DIR) $(SHOUT_DIR) $(VORBIS_DIR) \
|
||||
$(OPENQUICKTIME_DIR) $(RTP_DIR) $(SDL_DIR) $(SHOUT_DIR) $(VORBIS_DIR) \
|
||||
$(XMMS_DIR)
|
||||
|
||||
DIST_SUBDIRS=a52 aalib alsa avifile audiofile cdparanoia dvdread esd \
|
||||
festival flac gsm hermes jpeg lame mad mikmod mpeg2dec \
|
||||
openquicktime sdl shout vorbis xmms
|
||||
DIST_SUBDIRS=a52 aalib alsa avifile audiofile cdparanoia dv dvdread esd \
|
||||
festival flac gnomevfs gsm hermes jpeg lame mad mikmod mpeg2dec \
|
||||
openquicktime rtp sdl shout vorbis xmms
|
||||
|
|
11
ext/dv/Makefile.am
Normal file
11
ext/dv/Makefile.am
Normal file
|
@ -0,0 +1,11 @@
|
|||
plugindir = $(libdir)/gst
|
||||
|
||||
plugin_LTLIBRARIES = libgstdvdec.la
|
||||
|
||||
libdvdec_la_SOURCES = gstdvdec.c
|
||||
libdvdec_la_LIBADD = $(DV_LIBS)
|
||||
libdvdec_la_CFLAGS = $(GST_CFLAGS)
|
||||
|
||||
noinst_HEADERS = gstdvdec.h
|
||||
|
||||
EXTRA_DIST = NOTES
|
13
ext/dv/NOTES
Normal file
13
ext/dv/NOTES
Normal file
|
@ -0,0 +1,13 @@
|
|||
Packets come from 1394 480 bytes at a time. This is not a video segment
|
||||
length. This causes problems, since a packet boundary crossing a video
|
||||
segment can split a video segment if we lose an iso packet. We can
|
||||
recover from this, sorta, with significant changes to the parser. We have
|
||||
to deal with the idea that a) some macroblocks just don't exist (we have
|
||||
zero's for them) and b) when any of the 5 macroblocks doesn't exist, we
|
||||
can't do pass 3.
|
||||
|
||||
Since things are bitstream-based, we can deal with this, but we have to
|
||||
add a layer of code that tries to save time (maybe) by not decoding things
|
||||
that don't exist. Not sure how this is gonna work with the parse code
|
||||
being based on video segments, and not easily splittable into
|
||||
macroblock-level parsing (or is it?).
|
422
ext/dv/gstdvdec.c
Normal file
422
ext/dv/gstdvdec.c
Normal file
|
@ -0,0 +1,422 @@
|
|||
//#define RGB
|
||||
|
||||
/* Gnome-Streamer
|
||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* First, include the header file for the plugin, to bring in the
|
||||
* object definition and other useful things.
|
||||
*/
|
||||
#include "gstdvdec.h"
|
||||
|
||||
#define NTSC
|
||||
|
||||
#ifdef NTSC
|
||||
# define HEIGHT 480
|
||||
# define BUFFER 120000
|
||||
#else
|
||||
# define HEIGHT 576
|
||||
# define BUFFER 144000
|
||||
#endif
|
||||
|
||||
/* The ElementDetails structure gives a human-readable description
|
||||
* of the plugin, as well as author and version data.
|
||||
*/
|
||||
static GstElementDetails dvdec_details = {
|
||||
"DV (smpte314) decoder plugin",
|
||||
"Decoder/DV",
|
||||
"Uses libdv to decode DV video (libdv.sourceforge.net)",
|
||||
VERSION,
|
||||
"asdfasdf",
|
||||
"(C) 2001",
|
||||
};
|
||||
|
||||
/* These are the signals that this element can fire. They are zero-
|
||||
* based because the numbers themselves are private to the object.
|
||||
* LAST_SIGNAL is used for initialization of the signal array.
|
||||
*/
|
||||
enum {
|
||||
ASDF,
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
/* Arguments are identified the same way, but cannot be zero, so you
|
||||
* must leave the ARG_0 entry in as a placeholder.
|
||||
*/
|
||||
enum {
|
||||
ARG_0,
|
||||
/* FILL ME */
|
||||
};
|
||||
|
||||
/* The PadFactory structures describe what pads the element has or
|
||||
* can have. They can be quite complex, but for this dvdec plugin
|
||||
* they are rather simple.
|
||||
*/
|
||||
GST_PADTEMPLATE_FACTORY ( sink_temp,
|
||||
"sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_CAPS_NEW (
|
||||
"dv_dec_sink",
|
||||
"video/dv",
|
||||
"format", GST_PROPS_STRING ("NTSC")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
#ifdef RGB
|
||||
GST_PADTEMPLATE_FACTORY ( video_src_temp,
|
||||
"video",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_CAPS_NEW (
|
||||
"dv_dec_src",
|
||||
"video/raw",
|
||||
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('R','G','B',' ')),
|
||||
"bpp", GST_PROPS_INT(24),
|
||||
"depth", GST_PROPS_INT(24),
|
||||
"red_mask", GST_PROPS_INT(0x0000ff),
|
||||
"green_mask", GST_PROPS_INT(0x00ff00),
|
||||
"blue_mask", GST_PROPS_INT(0xff0000),
|
||||
"width", GST_PROPS_INT (720),
|
||||
"height", GST_PROPS_INT (HEIGHT)
|
||||
)
|
||||
)
|
||||
#else
|
||||
GST_PADTEMPLATE_FACTORY ( video_src_temp,
|
||||
"video",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_CAPS_NEW (
|
||||
"dv_dec_src",
|
||||
"video/raw",
|
||||
"format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2')),
|
||||
"width", GST_PROPS_INT (720),
|
||||
"height", GST_PROPS_INT (HEIGHT)
|
||||
)
|
||||
)
|
||||
#endif
|
||||
|
||||
GST_PADTEMPLATE_FACTORY ( audio_src_temp,
|
||||
"audio",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_CAPS_NEW (
|
||||
"arts_sample",
|
||||
"audio/raw",
|
||||
"format", GST_PROPS_STRING ("int"),
|
||||
"law", GST_PROPS_INT (0),
|
||||
"depth", GST_PROPS_INT (16),
|
||||
"width", GST_PROPS_INT (16),
|
||||
"signed", GST_PROPS_BOOLEAN (TRUE),
|
||||
"channels", GST_PROPS_INT (2),
|
||||
"endianness", GST_PROPS_INT (G_LITTLE_ENDIAN)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
/* A number of functon prototypes are given so we can refer to them later. */
|
||||
static void gst_dvdec_class_init (GstDVDecClass *klass);
|
||||
static void gst_dvdec_init (GstDVDec *dvdec);
|
||||
|
||||
static void gst_dvdec_loop (GstElement *element);
|
||||
|
||||
static void gst_dvdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
||||
static void gst_dvdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
||||
|
||||
/* The parent class pointer needs to be kept around for some object
|
||||
* operations.
|
||||
*/
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
/* This array holds the ids of the signals registered for this object.
|
||||
* The array indexes are based on the enum up above.
|
||||
*/
|
||||
static guint gst_dvdec_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
/* This function is used to register and subsequently return the type
|
||||
* identifier for this object class. On first invocation, it will
|
||||
* register the type, providing the name of the class, struct sizes,
|
||||
* and pointers to the various functions that define the class.
|
||||
*/
|
||||
GType
|
||||
gst_dvdec_get_type(void)
|
||||
{
|
||||
static GType dvdec_type = 0;
|
||||
|
||||
if (!dvdec_type) {
|
||||
static const GTypeInfo dvdec_info = {
|
||||
sizeof(GstDVDecClass), NULL, NULL,
|
||||
(GClassInitFunc)gst_dvdec_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(GstDVDec),
|
||||
0,
|
||||
(GInstanceInitFunc)gst_dvdec_init,
|
||||
};
|
||||
dvdec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstDVDec", &dvdec_info, 0);
|
||||
}
|
||||
return dvdec_type;
|
||||
}
|
||||
|
||||
/* In order to create an instance of an object, the class must be
|
||||
* initialized by this function. GObject will take care of running
|
||||
* it, based on the pointer to the function provided above.
|
||||
*/
|
||||
static void
|
||||
gst_dvdec_class_init (GstDVDecClass *klass)
|
||||
{
|
||||
/* Class pointers are needed to supply pointers to the private
|
||||
* implementations of parent class methods.
|
||||
*/
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
/* Since the dvdec class contains the parent classes, you can simply
|
||||
* cast the pointer to get access to the parent classes.
|
||||
*/
|
||||
gobject_class = (GObjectClass*)klass;
|
||||
gstelement_class = (GstElementClass*)klass;
|
||||
|
||||
/* The parent class is needed for class method overrides. */
|
||||
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
|
||||
|
||||
/* Here we add an argument to the object. This argument is an integer,
|
||||
* and can be both read and written.
|
||||
*/
|
||||
// g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ACTIVE,
|
||||
// g_param_spec_int("active","active","active",
|
||||
// G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME
|
||||
|
||||
/* Here we add a signal to the object. This is avery useless signal
|
||||
* called asdf. The signal will also pass a pointer to the listeners
|
||||
* which happens to be the dvdec element itself */
|
||||
gst_dvdec_signals[ASDF] =
|
||||
g_signal_new("asdf", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GstDVDecClass, asdf), NULL, NULL,
|
||||
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
|
||||
GST_TYPE_DVDEC);
|
||||
|
||||
/* The last thing is to provide the functions that implement get and set
|
||||
* of arguments.
|
||||
*/
|
||||
gobject_class->set_property = gst_dvdec_set_property;
|
||||
gobject_class->get_property = gst_dvdec_get_property;
|
||||
|
||||
|
||||
// table initialization, only do once
|
||||
dv_init();
|
||||
}
|
||||
|
||||
/* This function is responsible for initializing a specific instance of
|
||||
* the plugin.
|
||||
*/
|
||||
static void
|
||||
gst_dvdec_init(GstDVDec *dvdec)
|
||||
{
|
||||
dvdec->sinkpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET(sink_temp), "sink");
|
||||
gst_element_add_pad(GST_ELEMENT(dvdec),dvdec->sinkpad);
|
||||
|
||||
dvdec->videosrcpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET(video_src_temp), "video");
|
||||
//gst_pad_set_caps (dvdec->videosrcpad, gst_pad_get_padtemplate_caps (dvdec->videosrcpad));
|
||||
gst_element_add_pad(GST_ELEMENT(dvdec),dvdec->videosrcpad);
|
||||
|
||||
// dvdec->audiosrcpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET(audio_src_temp), "audio");
|
||||
// gst_pad_set_caps (dvdec->audiosrcpad, gst_pad_get_padtemplate_caps (dvdec->audiosrcpad));
|
||||
// gst_element_add_pad(GST_ELEMENT(dvdec),dvdec->audiosrcpad);
|
||||
|
||||
gst_element_set_loop_function (GST_ELEMENT(dvdec), gst_dvdec_loop);
|
||||
|
||||
dvdec->decoder = dv_decoder_new();
|
||||
dvdec->decoder->quality = DV_QUALITY_BEST;
|
||||
dvdec->inframe = g_malloc(BUFFER);
|
||||
dvdec->pool = NULL;
|
||||
dvdec->carryover = NULL;
|
||||
dvdec->remaining = 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gst_dvdec_loop (GstElement *element)
|
||||
{
|
||||
GstDVDec *dvdec;
|
||||
int needed;
|
||||
GstBuffer *buf;
|
||||
guint8 *outframe;
|
||||
guint8 *outframe_ptrs[3];
|
||||
gint outframe_pitches[3];
|
||||
|
||||
dvdec = GST_DVDEC (element);
|
||||
|
||||
do {
|
||||
// grab an input frame
|
||||
needed = BUFFER;
|
||||
if (dvdec->remaining > 0) {
|
||||
memcpy(&dvdec->inframe[BUFFER-needed],
|
||||
GST_BUFFER_DATA(dvdec->carryover)+(GST_BUFFER_SIZE(dvdec->carryover)-dvdec->remaining),
|
||||
dvdec->remaining);
|
||||
dvdec->remaining = 0;
|
||||
gst_buffer_unref(dvdec->carryover);
|
||||
}
|
||||
while (needed) {
|
||||
buf = gst_pad_pull(dvdec->sinkpad);
|
||||
if (needed < GST_BUFFER_SIZE(buf)) {
|
||||
memcpy(&dvdec->inframe[BUFFER-needed],GST_BUFFER_DATA(buf),needed);
|
||||
/***** NOTE: this is done because 1394src doesn't allow buffers to outlive the handler *****/
|
||||
dvdec->carryover = gst_buffer_copy(buf);
|
||||
dvdec->remaining = GST_BUFFER_SIZE(buf) - needed;
|
||||
needed = 0;
|
||||
} else {
|
||||
memcpy(&dvdec->inframe[BUFFER-needed],GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf));
|
||||
needed -= GST_BUFFER_SIZE(buf);
|
||||
}
|
||||
gst_buffer_unref(buf);
|
||||
}
|
||||
|
||||
if (!GST_PAD_CAPS (dvdec->videosrcpad)) {
|
||||
gst_pad_set_caps (dvdec->videosrcpad, gst_pad_get_padtemplate_caps (dvdec->videosrcpad));
|
||||
}
|
||||
|
||||
if (!dvdec->pool) {
|
||||
dvdec->pool = gst_pad_get_bufferpool (dvdec->videosrcpad);
|
||||
}
|
||||
|
||||
buf = NULL;
|
||||
if (dvdec->pool) {
|
||||
buf = gst_buffer_new_from_pool (dvdec->pool, 0, 0);
|
||||
}
|
||||
|
||||
if (!buf) {
|
||||
// allocate an output frame
|
||||
buf = gst_buffer_new();
|
||||
#ifdef RGB
|
||||
GST_BUFFER_SIZE(buf) = (720*HEIGHT)*3;
|
||||
#else
|
||||
GST_BUFFER_SIZE(buf) = (720*HEIGHT)*2;
|
||||
#endif
|
||||
GST_BUFFER_DATA(buf) = g_malloc(GST_BUFFER_SIZE(buf));
|
||||
outframe = GST_BUFFER_DATA(buf);
|
||||
} else {
|
||||
outframe = GST_BUFFER_DATA (buf);
|
||||
}
|
||||
|
||||
outframe_ptrs[0] = outframe;
|
||||
outframe_ptrs[1] = outframe_ptrs[0] + 720*HEIGHT;
|
||||
outframe_ptrs[2] = outframe_ptrs[1] + 360*HEIGHT;
|
||||
#ifdef RGB
|
||||
outframe_pitches[0] = 720*3;
|
||||
#else
|
||||
outframe_pitches[0] = 720*2; // huh?
|
||||
#endif
|
||||
outframe_pitches[1] = HEIGHT/2;
|
||||
outframe_pitches[2] = HEIGHT/2;
|
||||
|
||||
// now we start decoding the frame
|
||||
dv_parse_header(dvdec->decoder,dvdec->inframe);
|
||||
|
||||
#ifdef RGB
|
||||
dv_decode_full_frame(dvdec->decoder,dvdec->inframe,e_dv_color_rgb,outframe_ptrs,outframe_pitches);
|
||||
#else
|
||||
dv_decode_full_frame(dvdec->decoder,dvdec->inframe,e_dv_color_yuv,outframe_ptrs,outframe_pitches);
|
||||
#endif
|
||||
|
||||
gst_pad_push(dvdec->videosrcpad,buf);
|
||||
|
||||
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Arguments are part of the Gtk+ object system, and these functions
|
||||
* enable the element to respond to various arguments.
|
||||
*/
|
||||
static void
|
||||
gst_dvdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
GstDVDec *dvdec;
|
||||
|
||||
/* It's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_DVDEC(object));
|
||||
|
||||
/* Get a pointer of the right type. */
|
||||
dvdec = GST_DVDEC(object);
|
||||
|
||||
/* Check the argument id to see which argument we're setting. */
|
||||
switch (prop_id) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* The set function is simply the inverse of the get fuction. */
|
||||
static void
|
||||
gst_dvdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
GstDVDec *dvdec;
|
||||
|
||||
/* It's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_DVDEC(object));
|
||||
dvdec = GST_DVDEC(object);
|
||||
|
||||
switch (prop_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is the entry into the plugin itself. When the plugin loads,
|
||||
* this function is called to register everything that the plugin provides.
|
||||
*/
|
||||
static gboolean
|
||||
plugin_init (GModule *module, GstPlugin *plugin)
|
||||
{
|
||||
GstElementFactory *factory;
|
||||
|
||||
/* We need to create an ElementFactory for each element we provide.
|
||||
* This consists of the name of the element, the GType identifier,
|
||||
* and a pointer to the details structure at the top of the file.
|
||||
*/
|
||||
factory = gst_elementfactory_new("dvdec", GST_TYPE_DVDEC, &dvdec_details);
|
||||
g_return_val_if_fail(factory != NULL, FALSE);
|
||||
|
||||
/* The pad templates can be easily generated from the factories above,
|
||||
* and then added to the list of padtemplates for the elementfactory.
|
||||
* Note that the generated padtemplates are stored in static global
|
||||
* variables, for the gst_dvdec_init function to use later on.
|
||||
*/
|
||||
gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET(sink_temp));
|
||||
gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET(video_src_temp));
|
||||
gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET(audio_src_temp));
|
||||
|
||||
/* The very last thing is to register the elementfactory with the plugin. */
|
||||
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GstPluginDesc plugin_desc = {
|
||||
GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"dvdec",
|
||||
plugin_init
|
||||
};
|
||||
|
101
ext/dv/gstdvdec.h
Normal file
101
ext/dv/gstdvdec.h
Normal file
|
@ -0,0 +1,101 @@
|
|||
/* Gnome-Streamer
|
||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||
*
|
||||
* 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_DVDEC_H__
|
||||
#define __GST_DVDEC_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#include <libdv/dv.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/* This is the definition of the element's object structure. */
|
||||
typedef struct _GstDVDec GstDVDec;
|
||||
|
||||
/* The structure itself is derived from GstElement, as can be seen by the
|
||||
* fact that there's a complete instance of the GstElement structure at
|
||||
* the beginning of the object. This allows the element to be cast to
|
||||
* an Element or even an Object.
|
||||
*/
|
||||
struct _GstDVDec {
|
||||
GstElement element;
|
||||
|
||||
/* We need to keep track of our pads, so we do so here. */
|
||||
GstPad *sinkpad,*videosrcpad,*audiosrcpad;
|
||||
|
||||
guint8 *inframe; // here because we allocate it once, can't be on stack
|
||||
dv_decoder_t *decoder;
|
||||
GstBuffer *carryover;
|
||||
gint remaining;
|
||||
GstBufferPool *pool;
|
||||
};
|
||||
|
||||
/* The other half of the object is its class. The class also derives from
|
||||
* the same parent, though it must be the class structure this time.
|
||||
* Function pointers for polymophic methods and signals are placed in this
|
||||
* structure. */
|
||||
typedef struct _GstDVDecClass GstDVDecClass;
|
||||
|
||||
struct _GstDVDecClass {
|
||||
GstElementClass parent_class;
|
||||
|
||||
/* signals */
|
||||
void (*asdf) (GstElement *element, GstDVDec *dvdec);
|
||||
};
|
||||
|
||||
/* Five standard preprocessing macros are used in the Gtk+ object system.
|
||||
* The first uses the object's _get_type function to return the GType
|
||||
* of the object.
|
||||
*/
|
||||
#define GST_TYPE_DVDEC \
|
||||
(gst_dvdec_get_type())
|
||||
/* The second is a checking cast to the correct type. If the object passed
|
||||
* is not the right type, a warning will be generated on stderr.
|
||||
*/
|
||||
#define GST_DVDEC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DVDEC,GstDVDec))
|
||||
/* The third is a checking cast of the class instead of the object. */
|
||||
#define GST_DVDEC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DVDEC,GstDVDec))
|
||||
/* The last two simply check to see if the passed pointer is an object or
|
||||
* class of the correct type. */
|
||||
#define GST_IS_DVDEC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DVDEC))
|
||||
#define GST_IS_DVDEC_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DVDEC))
|
||||
|
||||
/* This is the only prototype needed, because it is used in the above
|
||||
* GST_TYPE_DVDEC macro.
|
||||
*/
|
||||
GType gst_dvdec_get_type(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif /* __GST_DVDEC_H__ */
|
8
ext/raw1394/Makefile.am
Normal file
8
ext/raw1394/Makefile.am
Normal file
|
@ -0,0 +1,8 @@
|
|||
plugindir = $(libdir)/gst
|
||||
|
||||
plugin_LTLIBRARIES = libgst1394.la
|
||||
|
||||
libgst1394_la_SOURCES = gst1394.c gstdv1394src.c
|
||||
libgst1394_la_LIBADD = $(raw1394_LIBS)
|
||||
|
||||
noinst_HEADERS = gstdv1394src.h
|
57
ext/raw1394/gst1394.c
Normal file
57
ext/raw1394/gst1394.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
|
||||
#include "dv1394src.h"
|
||||
|
||||
|
||||
static GstElementDetails gst_dv1394src_details = {
|
||||
"Firewire (1394) DV Source",
|
||||
"Source/1394/DV",
|
||||
"Source for DV video data from firewire port",
|
||||
VERSION,
|
||||
"Erik Walthinsen <omega@temple-baptist.com>",
|
||||
"(C) 2001",
|
||||
};
|
||||
|
||||
|
||||
static gboolean
|
||||
plugin_init (GModule *module, GstPlugin *plugin)
|
||||
{
|
||||
GstElementFactory *factory;
|
||||
|
||||
factory = gst_elementfactory_new("dv1394src",GST_TYPE_DV1394SRC,
|
||||
&gst_dv1394src_details);
|
||||
g_return_val_if_fail(factory != NULL, FALSE);
|
||||
|
||||
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GstPluginDesc plugin_desc = {
|
||||
GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"gst1394",
|
||||
plugin_init
|
||||
};
|
||||
|
245
ext/raw1394/gstdv1394src.c
Normal file
245
ext/raw1394/gstdv1394src.c
Normal file
|
@ -0,0 +1,245 @@
|
|||
/* Gnome-Streamer
|
||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include "gstdv1394src.h"
|
||||
|
||||
|
||||
/* Filter signals and args */
|
||||
enum {
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
ARG_0
|
||||
};
|
||||
|
||||
static GstPadTemplate*
|
||||
gst_dv1394src_factory (void)
|
||||
{
|
||||
static GstPadTemplate *template = NULL;
|
||||
|
||||
if (!template) {
|
||||
template = gst_padtemplate_new (
|
||||
"src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
gst_caps_new (
|
||||
"dv1394src",
|
||||
"video/dv",
|
||||
gst_props_new (
|
||||
"format", GST_PROPS_STRING ("NTSC"),
|
||||
NULL)),
|
||||
NULL);
|
||||
}
|
||||
return template;
|
||||
}
|
||||
|
||||
static void gst_dv1394src_class_init (GstDV1394SrcClass *klass);
|
||||
static void gst_dv1394src_init (GstDV1394Src *filter);
|
||||
|
||||
static void gst_dv1394src_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
||||
static void gst_dv1394src_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
||||
|
||||
static GstElementStateReturn gst_dv1394src_change_state (GstElement *element);
|
||||
|
||||
static GstBuffer * gst_dv1394src_get (GstPad *pad);
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
//static guint gst_filter_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GType
|
||||
gst_dv1394src_get_type(void) {
|
||||
static GType gst_dv1394src_type = 0;
|
||||
|
||||
if (!gst_dv1394src_type) {
|
||||
static const GTypeInfo gst_dv1394src_info = {
|
||||
sizeof(GstDV1394Src), NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)gst_dv1394src_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(GstDV1394Src),
|
||||
0,
|
||||
(GInstanceInitFunc)gst_dv1394src_init,
|
||||
};
|
||||
gst_dv1394src_type = g_type_register_static(GST_TYPE_ELEMENT, "DV1394Src", &gst_dv1394src_info, 0);
|
||||
}
|
||||
return gst_dv1394src_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_dv1394src_class_init (GstDV1394SrcClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
gobject_class = (GObjectClass*)klass;
|
||||
gstelement_class = (GstElementClass*)klass;
|
||||
|
||||
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
|
||||
|
||||
gobject_class->set_property = gst_dv1394src_set_property;
|
||||
gobject_class->get_property = gst_dv1394src_get_property;
|
||||
|
||||
gstelement_class->change_state = gst_dv1394src_change_state;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_dv1394src_init (GstDV1394Src *dv1394src)
|
||||
{
|
||||
dv1394src->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_pad_set_get_function (dv1394src->srcpad, gst_dv1394src_get);
|
||||
gst_element_add_pad (GST_ELEMENT (dv1394src), dv1394src->srcpad);
|
||||
|
||||
dv1394src->card = 0;
|
||||
dv1394src->port = 0;
|
||||
dv1394src->channel = 63;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_dv1394src_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
GstDV1394Src *filter;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_DV1394SRC(object));
|
||||
filter = GST_DV1394SRC(object);
|
||||
|
||||
switch (prop_id) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_dv1394src_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
GstDV1394Src *filter;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_DV1394SRC(object));
|
||||
filter = GST_DV1394SRC(object);
|
||||
|
||||
switch (prop_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
int gst_dv1394src_iso_receive(raw1394handle_t handle,int channel,size_t len,quadlet_t *data) {
|
||||
GstDV1394Src *dv1394src = GST_DV1394SRC (raw1394_get_userdata(handle));
|
||||
unsigned char *ptr = (unsigned char *)&data[3];
|
||||
GstBuffer *buf;
|
||||
|
||||
if (len > 16) {
|
||||
//fprintf(stderr,"section_type %d, dif_sequence %d, dif_block %d\n",ptr[0] >> 5,ptr[1] >> 4,ptr[2]);
|
||||
fprintf(stderr,".");
|
||||
if (((ptr[0] >> 5) == 0) &&
|
||||
((ptr[1] >> 4) == 0) && (ptr[2] == 0)) dv1394src->started = TRUE;
|
||||
if (dv1394src->started) {
|
||||
buf = gst_buffer_new();
|
||||
GST_BUFFER_DATA(buf) = ptr;
|
||||
GST_BUFFER_SIZE(buf) = 480;
|
||||
GST_BUFFER_OFFSET(buf) = 0;
|
||||
GST_BUFFER_FLAG_SET(buf,GST_BUFFER_DONTFREE);
|
||||
|
||||
dv1394src->buf = buf;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
int gst_dv1394src_bus_reset(raw1394handle_t handle) {
|
||||
GST_INFO_ELEMENT(0,GST_DV1394SRC(raw1394_get_userdata(handle)),"have bus reset");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GstBuffer *
|
||||
gst_dv1394src_get (GstPad *pad)
|
||||
{
|
||||
GstDV1394Src *dv1394src = GST_DV1394SRC (GST_PAD_PARENT(pad));
|
||||
|
||||
dv1394src->buf = NULL;
|
||||
while (dv1394src->buf == NULL)
|
||||
raw1394_loop_iterate(dv1394src->handle);
|
||||
|
||||
return dv1394src->buf;
|
||||
}
|
||||
|
||||
static GstElementStateReturn
|
||||
gst_dv1394src_change_state (GstElement *element)
|
||||
{
|
||||
GstDV1394Src *dv1394src;
|
||||
|
||||
g_return_val_if_fail (GST_IS_DV1394SRC (element), GST_STATE_FAILURE);
|
||||
dv1394src = GST_DV1394SRC (element);
|
||||
|
||||
switch (GST_STATE_TRANSITION (element)) {
|
||||
case GST_STATE_NULL_TO_READY:
|
||||
if ((dv1394src->handle = raw1394_get_handle()) == NULL) {
|
||||
GST_INFO_ELEMENT(0,dv1394src,"can't get raw1394 handle");
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
raw1394_set_userdata(dv1394src->handle,dv1394src);
|
||||
dv1394src->numcards = raw1394_get_port_info(dv1394src->handle,dv1394src->pinfo,16);
|
||||
if (dv1394src->numcards == 0) {
|
||||
GST_INFO_ELEMENT(0,dv1394src,"no cards available for raw1394");
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
if (dv1394src->pinfo[dv1394src->card].nodes <= 1) {
|
||||
GST_INFO_ELEMENT(0,dv1394src,"there are no nodes on the 1394 bus");
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
if (raw1394_set_port(dv1394src->handle,dv1394src->port) < 0) {
|
||||
GST_INFO_ELEMENT(0,dv1394src,"can't set 1394 port %d",dv1394src->port);
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
raw1394_set_iso_handler(dv1394src->handle,dv1394src->channel,gst_dv1394src_iso_receive);
|
||||
raw1394_set_bus_reset_handler(dv1394src->handle,gst_dv1394src_bus_reset);
|
||||
dv1394src->started = FALSE;
|
||||
GST_DEBUG(0,"successfully opened up 1394 connection");
|
||||
break;
|
||||
case GST_STATE_PAUSED_TO_PLAYING:
|
||||
if (raw1394_start_iso_rcv(dv1394src->handle,dv1394src->channel) < 0) {
|
||||
GST_INFO_ELEMENT(0,dv1394src,"can't start 1394 iso receive");
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
break;
|
||||
case GST_STATE_PLAYING_TO_PAUSED:
|
||||
raw1394_stop_iso_rcv(dv1394src->handle, dv1394src->channel);
|
||||
break;
|
||||
case GST_STATE_READY_TO_NULL:
|
||||
raw1394_destroy_handle(dv1394src->handle);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* if we haven't failed already, give the parent class a chance to ;-) */
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
|
||||
return GST_STATE_SUCCESS;
|
||||
}
|
75
ext/raw1394/gstdv1394src.h
Normal file
75
ext/raw1394/gstdv1394src.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/* Gnome-Streamer
|
||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||
*
|
||||
* 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_GST1394_H__
|
||||
#define __GST_GST1394_H__
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include <gst/gst.h>
|
||||
#include <libraw1394/raw1394.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#define GST_TYPE_DV1394SRC \
|
||||
(gst_dv1394src_get_type())
|
||||
#define GST_DV1394SRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DV1394SRC,GstDV1394Src))
|
||||
#define GST_DV1394SRC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DV1394SRC,GstDV1394Src))
|
||||
#define GST_IS_DV1394SRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DV1394SRC))
|
||||
#define GST_IS_DV1394SRC_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DV1394SRC))
|
||||
|
||||
typedef struct _GstDV1394Src GstDV1394Src;
|
||||
typedef struct _GstDV1394SrcClass GstDV1394SrcClass;
|
||||
|
||||
struct _GstDV1394Src {
|
||||
GstElement element;
|
||||
|
||||
GstPad *srcpad;
|
||||
|
||||
int numcards,numports;
|
||||
int card,port,channel;
|
||||
|
||||
struct raw1394_portinfo pinfo[16];
|
||||
raw1394handle_t handle;
|
||||
|
||||
gboolean started;
|
||||
GstBuffer *buf;
|
||||
};
|
||||
|
||||
struct _GstDV1394SrcClass {
|
||||
GstElementClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_dv1394src_get_type(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif /* __GST_GST1394_H__ */
|
Loading…
Reference in a new issue