mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
rename dvdsrc to dvdreadsrc add libdvdnav support as dvdnavsrc plugin
Original commit message from CVS: rename dvdsrc to dvdreadsrc add libdvdnav support as dvdnavsrc plugin
This commit is contained in:
parent
9987beb5a5
commit
69bc511e38
10 changed files with 750 additions and 132 deletions
11
configure.ac
11
configure.ac
|
@ -372,11 +372,19 @@ GST_CHECK_FEATURE(DV, [dv library], dv, [
|
|||
|
||||
dnl *** dvdread ***
|
||||
translit(dnm, m, l) AM_CONDITIONAL(USE_DVDREAD, true)
|
||||
GST_CHECK_FEATURE(DVDREAD, [dvdread library], dvdsrc, [
|
||||
GST_CHECK_FEATURE(DVDREAD, [dvdread library], dvdreadsrc, [
|
||||
GST_CHECK_LIBHEADER(DVDREAD, dvdread, DVDOpen, , dvdread/dvd_reader.h, DVDREAD_LIBS="-ldvdread")
|
||||
AC_SUBST(DVDREAD_LIBS)
|
||||
])
|
||||
|
||||
dnl *** dvdnav ***
|
||||
translit(dnm, m, l) AM_CONDITIONAL(USE_DVDNAV, true)
|
||||
GST_CHECK_FEATURE(DVDNAV, [dvdnav library], dvdnavsrc, [
|
||||
translit(dnm, m, l) AC_SUBST(DVDNAV_LIBS)
|
||||
translit(dnm, m, l) AC_SUBST(DVDNAV_CFLAGS)
|
||||
GST_CHECK_CONFIGPROG(DVDNAV, dvdnav-config)
|
||||
])
|
||||
|
||||
dnl **** ESound ****
|
||||
translit(dnm, m, l) AM_CONDITIONAL(USE_ESD, true)
|
||||
GST_CHECK_FEATURE(ESD, [esound plugins], esdsink esdmon, [
|
||||
|
@ -831,6 +839,7 @@ ext/avifile/Makefile
|
|||
ext/cdparanoia/Makefile
|
||||
ext/dv/Makefile
|
||||
ext/dvdread/Makefile
|
||||
ext/dvdnav/Makefile
|
||||
ext/esd/Makefile
|
||||
ext/ffmpeg/Makefile
|
||||
ext/flac/Makefile
|
||||
|
|
|
@ -58,6 +58,12 @@ else
|
|||
DVDREAD_DIR=
|
||||
endif
|
||||
|
||||
if USE_DVDNAV
|
||||
DVDNAV_DIR=dvdnav
|
||||
else
|
||||
DVDNAV_DIR=
|
||||
endif
|
||||
|
||||
if USE_ESD
|
||||
ESD_DIR=esd
|
||||
else
|
||||
|
@ -213,7 +219,7 @@ endif
|
|||
SUBDIRS=$(A52DEC_DIR) $(AALIB_DIR) $(ALSA_DIR) \
|
||||
$(ARTS_DIR) $(ARTSC_DIR) $(AUDIOFILE_DIR) \
|
||||
$(AVIFILE_DIR) $(CDPARANOIA_DIR) $(DV_DIR) \
|
||||
$(DVDREAD_DIR) $(ESD_DIR) \
|
||||
$(DVDREAD_DIR) $(DVDNAV_DIR) $(ESD_DIR) \
|
||||
$(FLAC_DIR) $(GNOMEVFS_DIR) $(GSM_DIR) \
|
||||
$(HERMES_DIR) $(HTTP_DIR) $(JACK_DIR) $(JPEG_DIR) \
|
||||
$(LADSPA_DIR) $(LAME_DIR) $(LCS_DIR) \
|
||||
|
@ -226,7 +232,7 @@ DIST_SUBDIRS=\
|
|||
a52dec aalib alsa \
|
||||
arts artsd avifile \
|
||||
audiofile cdparanoia dv \
|
||||
dvdread esd ffmpeg \
|
||||
dvdread dvdnav esd ffmpeg \
|
||||
flac gnomevfs gsm \
|
||||
hermes http jack jpeg \
|
||||
ladspa lame lcs \
|
||||
|
|
12
ext/dvdnav/Makefile.am
Normal file
12
ext/dvdnav/Makefile.am
Normal file
|
@ -0,0 +1,12 @@
|
|||
plugindir = $(libdir)/gst
|
||||
|
||||
plugin_LTLIBRARIES = libgstdvdnavsrc.la
|
||||
|
||||
libgstdvdnavsrc_la_SOURCES = dvdnavsrc.c
|
||||
libgstdvdnavsrc_la_CFLAGS = $(GST_CFLAGS) $(DVDNAV_CFLAGS)
|
||||
libgstdvdnavsrc_la_LIBADD = $(DVDNAV_LIBS)
|
||||
libgstdvdnavsrc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||
|
||||
noinst_HEADERS = dvdnavsrc.h
|
||||
|
||||
EXTRA_DIST = README
|
5
ext/dvdnav/README
Normal file
5
ext/dvdnav/README
Normal file
|
@ -0,0 +1,5 @@
|
|||
Various Info
|
||||
============
|
||||
|
||||
http://members.aol.com/mpucoder/DVD/index.html
|
||||
http://dvd.sourceforge.net/
|
523
ext/dvdnav/dvdnavsrc.c
Normal file
523
ext/dvdnav/dvdnavsrc.c
Normal file
|
@ -0,0 +1,523 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2002 David I. Lehn <dlehn@users.sourceforge.net>
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <dvdnavsrc.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <dvdnav/dvdnav.h>
|
||||
|
||||
struct _DVDNavSrcPrivate {
|
||||
GstElement element;
|
||||
/* pads */
|
||||
GstPad *srcpad;
|
||||
|
||||
/* location */
|
||||
gchar *location;
|
||||
|
||||
gboolean new_seek;
|
||||
|
||||
int title, chapter, angle;
|
||||
dvdnav_t *dvdnav;
|
||||
};
|
||||
|
||||
|
||||
GstElementDetails dvdnavsrc_details = {
|
||||
"DVD Source",
|
||||
"Source/File/DVD",
|
||||
"Access a DVD with navigation features using libdvdnav",
|
||||
VERSION,
|
||||
"David I. Lehn <dlehn@users.sourceforge.net>",
|
||||
"(C) 2002",
|
||||
};
|
||||
|
||||
|
||||
/* DVDNavSrc signals and args */
|
||||
enum {
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
ARG_0,
|
||||
ARG_LOCATION,
|
||||
ARG_TITLE,
|
||||
ARG_CHAPTER,
|
||||
ARG_ANGLE
|
||||
};
|
||||
|
||||
|
||||
static void dvdnavsrc_class_init (DVDNavSrcClass *klass);
|
||||
static void dvdnavsrc_init (DVDNavSrc *dvdnavsrc);
|
||||
|
||||
static void dvdnavsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
||||
static void dvdnavsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
||||
|
||||
/*static GstBuffer * dvdnavsrc_get (GstPad *pad); */
|
||||
static void dvdnavsrc_loop (GstElement *element);
|
||||
/*static GstBuffer * dvdnavsrc_get_region (GstPad *pad,gulong offset,gulong size); */
|
||||
|
||||
static GstElementStateReturn dvdnavsrc_change_state (GstElement *element);
|
||||
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
/*static guint dvdnavsrc_signals[LAST_SIGNAL] = { 0 }; */
|
||||
|
||||
GType
|
||||
dvdnavsrc_get_type (void)
|
||||
{
|
||||
static GType dvdnavsrc_type = 0;
|
||||
|
||||
if (!dvdnavsrc_type) {
|
||||
static const GTypeInfo dvdnavsrc_info = {
|
||||
sizeof(DVDNavSrcClass), NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)dvdnavsrc_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(DVDNavSrc),
|
||||
0,
|
||||
(GInstanceInitFunc)dvdnavsrc_init,
|
||||
};
|
||||
dvdnavsrc_type = g_type_register_static (GST_TYPE_ELEMENT, "DVDNavSrc", &dvdnavsrc_info, 0);
|
||||
}
|
||||
return dvdnavsrc_type;
|
||||
}
|
||||
|
||||
static void
|
||||
dvdnavsrc_class_init (DVDNavSrcClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
gobject_class = (GObjectClass*)klass;
|
||||
gstelement_class = (GstElementClass*)klass;
|
||||
|
||||
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATION,
|
||||
g_param_spec_string("location","location","location",
|
||||
NULL, G_PARAM_READWRITE));
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TITLE,
|
||||
g_param_spec_int("title","title","title",
|
||||
1,99,1,G_PARAM_READWRITE));
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CHAPTER,
|
||||
g_param_spec_int("chapter","chapter","chapter",
|
||||
1,999,1,G_PARAM_READWRITE));
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ANGLE,
|
||||
g_param_spec_int("angle","angle","angle",
|
||||
1,9,1,G_PARAM_READWRITE));
|
||||
|
||||
gobject_class->set_property = GST_DEBUG_FUNCPTR(dvdnavsrc_set_property);
|
||||
gobject_class->get_property = GST_DEBUG_FUNCPTR(dvdnavsrc_get_property);
|
||||
|
||||
gstelement_class->change_state = dvdnavsrc_change_state;
|
||||
}
|
||||
|
||||
static void
|
||||
dvdnavsrc_init (DVDNavSrc *dvdnavsrc)
|
||||
{
|
||||
dvdnavsrc->priv = g_new(DVDNavSrcPrivate, 1);
|
||||
dvdnavsrc->priv->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (dvdnavsrc), dvdnavsrc->priv->srcpad);
|
||||
gst_element_set_loop_function (GST_ELEMENT(dvdnavsrc), GST_DEBUG_FUNCPTR(dvdnavsrc_loop));
|
||||
|
||||
dvdnavsrc->priv->location = g_strdup("/dev/dvd");
|
||||
dvdnavsrc->priv->new_seek = FALSE;
|
||||
dvdnavsrc->priv->title = 1;
|
||||
dvdnavsrc->priv->chapter = 1;
|
||||
dvdnavsrc->priv->angle = 1;
|
||||
}
|
||||
|
||||
/* FIXME: this code is not being used */
|
||||
#ifdef PLEASEFIXTHISCODE
|
||||
static void
|
||||
dvdnavsrc_destroy (DVDNavSrc *dvdnavsrc)
|
||||
{
|
||||
/* FIXME */
|
||||
g_print("FIXME\n");
|
||||
g_free(dvdnavsrc->priv);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
dvdnavsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
DVDNavSrc *src;
|
||||
DVDNavSrcPrivate *priv;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail (GST_IS_DVDNAVSRC (object));
|
||||
|
||||
src = DVDNAVSRC (object);
|
||||
priv = src->priv;
|
||||
|
||||
switch (prop_id) {
|
||||
case ARG_LOCATION:
|
||||
/* the element must be stopped in order to do this */
|
||||
/*g_return_if_fail(!GST_FLAG_IS_SET(src,GST_STATE_RUNNING)); */
|
||||
|
||||
if (priv->location)
|
||||
g_free (priv->location);
|
||||
/* clear the filename if we get a NULL (is that possible?) */
|
||||
if (g_value_get_string (value) == NULL)
|
||||
priv->location = g_strdup("/dev/dvd");
|
||||
/* otherwise set the new filename */
|
||||
else
|
||||
priv->location = g_strdup (g_value_get_string (value));
|
||||
break;
|
||||
case ARG_TITLE:
|
||||
priv->title = g_value_get_int (value);
|
||||
priv->new_seek = TRUE;
|
||||
break;
|
||||
case ARG_CHAPTER:
|
||||
priv->chapter = g_value_get_int (value);
|
||||
priv->new_seek = TRUE;
|
||||
break;
|
||||
case ARG_ANGLE:
|
||||
priv->angle = g_value_get_int (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
dvdnavsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
DVDNavSrc *src;
|
||||
DVDNavSrcPrivate *priv;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail (GST_IS_DVDNAVSRC (object));
|
||||
|
||||
src = DVDNAVSRC (object);
|
||||
priv = src->priv;
|
||||
|
||||
switch (prop_id) {
|
||||
case ARG_LOCATION:
|
||||
g_value_set_string (value, priv->location);
|
||||
break;
|
||||
case ARG_TITLE:
|
||||
g_value_set_int (value, priv->title);
|
||||
break;
|
||||
case ARG_CHAPTER:
|
||||
g_value_set_int (value, priv->chapter);
|
||||
break;
|
||||
case ARG_ANGLE:
|
||||
g_value_set_int (value, priv->angle);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_open(DVDNavSrcPrivate *priv, const gchar *location)
|
||||
{
|
||||
g_return_val_if_fail(priv != NULL, -1);
|
||||
g_return_val_if_fail(location != NULL, -1);
|
||||
|
||||
if (dvdnav_open ( &priv->dvdnav, (char*)location ) != DVDNAV_STATUS_OK) {
|
||||
fprintf( stderr, "dvdnav_open error: %s location: %s\n", dvdnav_err_to_string(priv->dvdnav), location);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_close(DVDNavSrcPrivate *priv)
|
||||
{
|
||||
g_return_val_if_fail(priv != NULL, -1);
|
||||
g_return_val_if_fail(priv->dvdnav != NULL, -1);
|
||||
|
||||
if (dvdnav_close ( priv->dvdnav ) != DVDNAV_STATUS_OK) {
|
||||
fprintf( stderr, "dvdnav_close error: %s\n", dvdnav_err_to_string(priv->dvdnav));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_seek(DVDNavSrcPrivate *priv, int title, int chapter, int angle)
|
||||
{
|
||||
int titles, programs, curangle, angles;
|
||||
|
||||
g_return_val_if_fail(priv != NULL, -1);
|
||||
g_return_val_if_fail(priv->dvdnav != NULL, -1);
|
||||
|
||||
/**
|
||||
* Make sure our title number is valid.
|
||||
*/
|
||||
if (dvdnav_get_number_of_titles (priv->dvdnav, &titles) != DVDNAV_STATUS_OK) {
|
||||
fprintf (stderr, "dvdnav_get_number_of_titles error: %s\n", dvdnav_err_to_string(priv->dvdnav));
|
||||
return -1;
|
||||
}
|
||||
fprintf (stderr, "There are %d titles on this DVD.\n", titles);
|
||||
if (title < 0 || title >= titles) {
|
||||
fprintf (stderr, "Invalid title %d.\n", title + 1);
|
||||
_close (priv);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure the chapter number is valid for this title.
|
||||
*/
|
||||
if (dvdnav_get_number_of_programs (priv->dvdnav, &programs) != DVDNAV_STATUS_OK) {
|
||||
fprintf( stderr, "dvdnav_get_number_of_programs error: %s\n", dvdnav_err_to_string(priv->dvdnav));
|
||||
return -1;
|
||||
}
|
||||
fprintf (stderr, "There are %d chapters in this title.\n", programs);
|
||||
if (chapter < 0 || chapter >= programs) {
|
||||
fprintf (stderr, "Invalid chapter %d\n", chapter + 1);
|
||||
_close (priv);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure the angle number is valid for this title.
|
||||
*/
|
||||
if (dvdnav_get_angle_info (priv->dvdnav, &curangle, &angles) != DVDNAV_STATUS_OK) {
|
||||
fprintf (stderr, "dvdnav_get_angle_info error: %s\n", dvdnav_err_to_string(priv->dvdnav));
|
||||
return -1;
|
||||
}
|
||||
fprintf (stderr, "There are %d angles in this title.\n", angles);
|
||||
if( angle < 0 || angle >= angles) {
|
||||
fprintf (stderr, "Invalid angle %d\n", angle + 1);
|
||||
_close (priv);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* We've got enough info, time to open the title set data.
|
||||
*/
|
||||
if (dvdnav_part_play (priv->dvdnav, title, chapter) != DVDNAV_STATUS_OK) {
|
||||
fprintf (stderr, "dvdnav_part_play error: %s\n", dvdnav_err_to_string(priv->dvdnav));
|
||||
return -1;
|
||||
}
|
||||
if (dvdnav_angle_change (priv->dvdnav, angle) != DVDNAV_STATUS_OK) {
|
||||
fprintf (stderr, "dvdnav_angle_change error: %s\n", dvdnav_err_to_string(priv->dvdnav));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
if (dvdnav_physical_audio_stream_change (priv->dvdnav, 0) != DVDNAV_STATUS_OK) {
|
||||
fprintf (stderr, "dvdnav_physical_audio_stream_change error: %s\n", dvdnav_err_to_string(priv->dvdnav));
|
||||
return -1;
|
||||
}
|
||||
if (dvdnav_logical_audio_stream_change (priv->dvdnav, 0) != DVDNAV_STATUS_OK) {
|
||||
fprintf (stderr, "dvdnav_logical_audio_stream_change error: %s\n", dvdnav_err_to_string(priv->dvdnav));
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
dvdnavsrc_loop (GstElement *element)
|
||||
{
|
||||
DVDNavSrc *dvdnavsrc;
|
||||
DVDNavSrcPrivate *priv;
|
||||
int done;
|
||||
|
||||
g_return_if_fail (element != NULL);
|
||||
g_return_if_fail (GST_IS_DVDNAVSRC (element));
|
||||
|
||||
dvdnavsrc = DVDNAVSRC (element);
|
||||
priv = dvdnavsrc->priv;
|
||||
g_return_if_fail (GST_FLAG_IS_SET (dvdnavsrc, DVDNAVSRC_OPEN));
|
||||
|
||||
done = 0;
|
||||
|
||||
while (!done) {
|
||||
int event, len;
|
||||
GstBuffer *buf;
|
||||
unsigned char *data;
|
||||
|
||||
/* allocate the space for the buffer data */
|
||||
data = g_malloc (DVD_VIDEO_LB_LEN);
|
||||
|
||||
if (dvdnav_get_next_block (priv->dvdnav, data, &event, &len) != DVDNAV_STATUS_OK) {
|
||||
fprintf (stderr, "dvdnav_get_next_block error: %s\n", dvdnav_err_to_string(priv->dvdnav));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case DVDNAV_BLOCK_OK:
|
||||
/* create the buffer */
|
||||
/* FIXME: should eventually use a bufferpool for this */
|
||||
buf = gst_buffer_new ();
|
||||
g_return_if_fail (buf);
|
||||
|
||||
GST_BUFFER_DATA (buf) = data;
|
||||
GST_BUFFER_SIZE (buf) = DVD_VIDEO_LB_LEN;
|
||||
gst_pad_push(priv->srcpad, buf);
|
||||
break;
|
||||
case DVDNAV_STOP:
|
||||
done = 1;
|
||||
gst_element_set_eos (GST_ELEMENT (dvdnavsrc));
|
||||
_close(priv);
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "dvdnavsrc event: %d\n", event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static GstBuffer *
|
||||
dvdnavsrc_get (GstPad *pad)
|
||||
{
|
||||
DVDNavSrc *dvdnavsrc;
|
||||
DVDNavSrcPrivate *priv;
|
||||
GstBuffer *buf;
|
||||
|
||||
g_return_val_if_fail (pad != NULL, NULL);
|
||||
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
|
||||
|
||||
dvdnavsrc = DVDNAVSRC (gst_pad_get_parent (pad));
|
||||
priv = dvdnavsrc->priv;
|
||||
g_return_val_if_fail (GST_FLAG_IS_SET (dvdnavsrc, DVDNAVSRC_OPEN),NULL);
|
||||
|
||||
/* create the buffer */
|
||||
/* FIXME: should eventually use a bufferpool for this */
|
||||
buf = gst_buffer_new ();
|
||||
g_return_val_if_fail (buf, NULL);
|
||||
|
||||
/* allocate the space for the buffer data */
|
||||
GST_BUFFER_DATA (buf) = g_malloc (1024 * DVD_VIDEO_LB_LEN);
|
||||
g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
|
||||
|
||||
if (priv->new_seek) {
|
||||
_seek(priv, priv->titleid, priv->chapid, priv->angle);
|
||||
}
|
||||
|
||||
/* read it in from the file */
|
||||
if (_read (priv, priv->angle, priv->new_seek, buf)) {
|
||||
gst_element_signal_eos (GST_ELEMENT (dvdnavsrc));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (priv->new_seek) {
|
||||
priv->new_seek = FALSE;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* open the file, necessary to go to RUNNING state */
|
||||
static gboolean
|
||||
dvdnavsrc_open_file (DVDNavSrc *src)
|
||||
{
|
||||
g_return_val_if_fail (src != NULL, FALSE);
|
||||
g_return_val_if_fail (GST_IS_DVDNAVSRC(src), FALSE);
|
||||
g_return_val_if_fail (!GST_FLAG_IS_SET (src, DVDNAVSRC_OPEN), FALSE);
|
||||
|
||||
if (_open(src->priv, src->priv->location))
|
||||
return FALSE;
|
||||
if (_seek(src->priv,
|
||||
src->priv->title,
|
||||
src->priv->chapter,
|
||||
src->priv->angle))
|
||||
return FALSE;
|
||||
|
||||
GST_FLAG_SET (src, DVDNAVSRC_OPEN);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* close the file */
|
||||
static void
|
||||
dvdnavsrc_close_file (DVDNavSrc *src)
|
||||
{
|
||||
g_return_if_fail (GST_FLAG_IS_SET (src, DVDNAVSRC_OPEN));
|
||||
|
||||
_close(src->priv);
|
||||
|
||||
GST_FLAG_UNSET (src, DVDNAVSRC_OPEN);
|
||||
}
|
||||
|
||||
static GstElementStateReturn
|
||||
dvdnavsrc_change_state (GstElement *element)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_DVDNAVSRC (element), GST_STATE_FAILURE);
|
||||
|
||||
GST_DEBUG (0,"gstdvdnavsrc: state pending %d", GST_STATE_PENDING (element));
|
||||
|
||||
/* if going down into NULL state, close the file if it's open */
|
||||
if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET (element, DVDNAVSRC_OPEN))
|
||||
dvdnavsrc_close_file (DVDNAVSRC (element));
|
||||
/* otherwise (READY or higher) we need to open the file */
|
||||
} else {
|
||||
if (!GST_FLAG_IS_SET (element, DVDNAVSRC_OPEN)) {
|
||||
if (!dvdnavsrc_open_file (DVDNAVSRC (element)))
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
plugin_init (GModule *module, GstPlugin *plugin)
|
||||
{
|
||||
GstElementFactory *factory;
|
||||
|
||||
/* create an elementfactory for the dvdnavsrc element */
|
||||
factory = gst_element_factory_new ("dvdnavsrc", GST_TYPE_DVDNAVSRC,
|
||||
&dvdnavsrc_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,
|
||||
"dvdnavsrc",
|
||||
plugin_init
|
||||
};
|
69
ext/dvdnav/dvdnavsrc.h
Normal file
69
ext/dvdnav/dvdnavsrc.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2002 David I. Lehn <dlehn@users.sourceforge.net>
|
||||
*
|
||||
* 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 __DVDNAVSRC_H__
|
||||
#define __DVDNAVSRC_H__
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GstElementDetails dvdnavsrc_details;
|
||||
|
||||
|
||||
#define GST_TYPE_DVDNAVSRC \
|
||||
(dvdnavsrc_get_type())
|
||||
#define DVDNAVSRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DVDNAVSRC,DVDNavSrc))
|
||||
#define DVDNAVSRC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DVDNAVSRC,DVDNavSrcClass))
|
||||
#define GST_IS_DVDNAVSRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DVDNAVSRC))
|
||||
#define GST_IS_DVDNAVSRC_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DVDNAVSRC))
|
||||
|
||||
/* NOTE: per-element flags start with 16 for now */
|
||||
typedef enum {
|
||||
DVDNAVSRC_OPEN = GST_ELEMENT_FLAG_LAST,
|
||||
|
||||
DVDNAVSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2,
|
||||
} DVDNavSrcFlags;
|
||||
|
||||
typedef struct _DVDNavSrc DVDNavSrc;
|
||||
typedef struct _DVDNavSrcPrivate DVDNavSrcPrivate;
|
||||
typedef struct _DVDNavSrcClass DVDNavSrcClass;
|
||||
|
||||
struct _DVDNavSrc {
|
||||
GstElement element;
|
||||
DVDNavSrcPrivate *priv;
|
||||
};
|
||||
|
||||
struct _DVDNavSrcClass {
|
||||
GstElementClass parent_class;
|
||||
};
|
||||
|
||||
GType dvdnavsrc_get_type(void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __DVDNAVSRC_H__ */
|
|
@ -1,16 +1,16 @@
|
|||
plugindir = $(libdir)/gst
|
||||
|
||||
plugin_LTLIBRARIES = libgstdvdsrc.la
|
||||
plugin_LTLIBRARIES = libgstdvdreadsrc.la
|
||||
|
||||
## FIXME: the extra option, what do we do with it ?
|
||||
## AM_CFLAGS = -D_LARGEFILE64_SOURCE $(LIBDVDREADCFLAGS)
|
||||
|
||||
libgstdvdsrc_la_SOURCES = dvdsrc.c
|
||||
libgstdvdsrc_la_CFLAGS = $(GST_CFLAGS)
|
||||
libgstdvdsrc_la_LIBADD = $(DVDREAD_LIBS)
|
||||
libgstdvdsrc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||
libgstdvdreadsrc_la_SOURCES = dvdreadsrc.c
|
||||
libgstdvdreadsrc_la_CFLAGS = $(GST_CFLAGS)
|
||||
libgstdvdreadsrc_la_LIBADD = $(DVDREAD_LIBS)
|
||||
libgstdvdreadsrc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||
|
||||
noinst_HEADERS = dvdsrc.h
|
||||
noinst_HEADERS = dvdreadsrc.h
|
||||
|
||||
# fix this
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ int main(int argc,char *argv[]) {
|
|||
pipeline = GST_PIPELINE(gst_pipeline_new("pipeline"));
|
||||
g_return_val_if_fail(pipeline != NULL, -1);
|
||||
|
||||
src = gst_element_factory_make("dvdsrc","src");
|
||||
src = gst_element_factory_make("dvdreadsrc","src");
|
||||
g_return_val_if_fail(src != NULL, -1);
|
||||
gtk_object_set(GTK_OBJECT(src),"location",argv[1],NULL);
|
||||
gtk_object_set(GTK_OBJECT(src),"title",atoi(argv[2]),NULL);
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include <linux/cdrom.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <dvdsrc.h>
|
||||
#include <dvdreadsrc.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
|||
#include <dvdread/nav_read.h>
|
||||
#include <dvdread/nav_print.h>
|
||||
|
||||
struct _DVDSrcPrivate {
|
||||
struct _DVDReadSrcPrivate {
|
||||
GstElement element;
|
||||
/* pads */
|
||||
GstPad *srcpad;
|
||||
|
@ -83,17 +83,17 @@ struct _DVDSrcPrivate {
|
|||
};
|
||||
|
||||
|
||||
GstElementDetails dvdsrc_details = {
|
||||
GstElementDetails dvdreadsrc_details = {
|
||||
"DVD Source",
|
||||
"Source/File/DVD",
|
||||
"Asynchronous read from encrypted DVD disk",
|
||||
"Access a DVD title/chapter/angle using libdvdread",
|
||||
VERSION,
|
||||
"Erik Walthinsen <omega@cse.ogi.edu>",
|
||||
"(C) 2001",
|
||||
};
|
||||
|
||||
|
||||
/* DVDSrc signals and args */
|
||||
/* DVDReadSrc signals and args */
|
||||
enum {
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
|
@ -108,45 +108,45 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void dvdsrc_class_init (DVDSrcClass *klass);
|
||||
static void dvdsrc_init (DVDSrc *dvdsrc);
|
||||
static void dvdreadsrc_class_init (DVDReadSrcClass *klass);
|
||||
static void dvdreadsrc_init (DVDReadSrc *dvdreadsrc);
|
||||
|
||||
static void dvdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
||||
static void dvdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
||||
static void dvdreadsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
||||
static void dvdreadsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
||||
|
||||
/*static GstBuffer * dvdsrc_get (GstPad *pad); */
|
||||
static void dvdsrc_loop (GstElement *element);
|
||||
/*static GstBuffer * dvdsrc_get_region (GstPad *pad,gulong offset,gulong size); */
|
||||
/*static GstBuffer * dvdreadsrc_get (GstPad *pad); */
|
||||
static void dvdreadsrc_loop (GstElement *element);
|
||||
/*static GstBuffer * dvdreadsrc_get_region (GstPad *pad,gulong offset,gulong size); */
|
||||
|
||||
static GstElementStateReturn dvdsrc_change_state (GstElement *element);
|
||||
static GstElementStateReturn dvdreadsrc_change_state (GstElement *element);
|
||||
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
/*static guint dvdsrc_signals[LAST_SIGNAL] = { 0 }; */
|
||||
/*static guint dvdreadsrc_signals[LAST_SIGNAL] = { 0 }; */
|
||||
|
||||
GType
|
||||
dvdsrc_get_type (void)
|
||||
dvdreadsrc_get_type (void)
|
||||
{
|
||||
static GType dvdsrc_type = 0;
|
||||
static GType dvdreadsrc_type = 0;
|
||||
|
||||
if (!dvdsrc_type) {
|
||||
static const GTypeInfo dvdsrc_info = {
|
||||
sizeof(DVDSrcClass), NULL,
|
||||
if (!dvdreadsrc_type) {
|
||||
static const GTypeInfo dvdreadsrc_info = {
|
||||
sizeof(DVDReadSrcClass), NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)dvdsrc_class_init,
|
||||
(GClassInitFunc)dvdreadsrc_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(DVDSrc),
|
||||
sizeof(DVDReadSrc),
|
||||
0,
|
||||
(GInstanceInitFunc)dvdsrc_init,
|
||||
(GInstanceInitFunc)dvdreadsrc_init,
|
||||
};
|
||||
dvdsrc_type = g_type_register_static (GST_TYPE_ELEMENT, "DVDSrc", &dvdsrc_info, 0);
|
||||
dvdreadsrc_type = g_type_register_static (GST_TYPE_ELEMENT, "DVDReadSrc", &dvdreadsrc_info, 0);
|
||||
}
|
||||
return dvdsrc_type;
|
||||
return dvdreadsrc_type;
|
||||
}
|
||||
|
||||
static void
|
||||
dvdsrc_class_init (DVDSrcClass *klass)
|
||||
dvdreadsrc_class_init (DVDReadSrcClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
|
@ -169,48 +169,48 @@ dvdsrc_class_init (DVDSrcClass *klass)
|
|||
g_param_spec_int("angle","angle","angle",
|
||||
0,G_MAXINT,0,G_PARAM_READWRITE));
|
||||
|
||||
gobject_class->set_property = GST_DEBUG_FUNCPTR(dvdsrc_set_property);
|
||||
gobject_class->get_property = GST_DEBUG_FUNCPTR(dvdsrc_get_property);
|
||||
gobject_class->set_property = GST_DEBUG_FUNCPTR(dvdreadsrc_set_property);
|
||||
gobject_class->get_property = GST_DEBUG_FUNCPTR(dvdreadsrc_get_property);
|
||||
|
||||
gstelement_class->change_state = dvdsrc_change_state;
|
||||
gstelement_class->change_state = dvdreadsrc_change_state;
|
||||
}
|
||||
|
||||
static void
|
||||
dvdsrc_init (DVDSrc *dvdsrc)
|
||||
dvdreadsrc_init (DVDReadSrc *dvdreadsrc)
|
||||
{
|
||||
dvdsrc->priv = g_new(DVDSrcPrivate, 1);
|
||||
dvdsrc->priv->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (dvdsrc), dvdsrc->priv->srcpad);
|
||||
gst_element_set_loop_function (GST_ELEMENT(dvdsrc), GST_DEBUG_FUNCPTR(dvdsrc_loop));
|
||||
dvdreadsrc->priv = g_new(DVDReadSrcPrivate, 1);
|
||||
dvdreadsrc->priv->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (dvdreadsrc), dvdreadsrc->priv->srcpad);
|
||||
gst_element_set_loop_function (GST_ELEMENT(dvdreadsrc), GST_DEBUG_FUNCPTR(dvdreadsrc_loop));
|
||||
|
||||
dvdsrc->priv->location = "/dev/dvd";
|
||||
dvdsrc->priv->new_seek = FALSE;
|
||||
dvdsrc->priv->title = 1;
|
||||
dvdsrc->priv->chapter = 1;
|
||||
dvdsrc->priv->angle = 1;
|
||||
dvdreadsrc->priv->location = g_strdup("/dev/dvd");
|
||||
dvdreadsrc->priv->new_seek = FALSE;
|
||||
dvdreadsrc->priv->title = 1;
|
||||
dvdreadsrc->priv->chapter = 1;
|
||||
dvdreadsrc->priv->angle = 1;
|
||||
}
|
||||
|
||||
/* FIXME: this code is not being used */
|
||||
#ifdef PLEASEFIXTHISCODE
|
||||
static void
|
||||
dvdsrc_destroy (DVDSrc *dvdsrc)
|
||||
dvdreadsrc_destroy (DVDReadSrc *dvdreadsrc)
|
||||
{
|
||||
/* FIXME */
|
||||
g_print("FIXME\n");
|
||||
g_free(dvdsrc->priv);
|
||||
g_free(dvdreadsrc->priv);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
dvdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
dvdreadsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
DVDSrc *src;
|
||||
DVDSrcPrivate *priv;
|
||||
DVDReadSrc *src;
|
||||
DVDReadSrcPrivate *priv;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail (GST_IS_DVDSRC (object));
|
||||
g_return_if_fail (GST_IS_DVDREADSRC (object));
|
||||
|
||||
src = DVDSRC (object);
|
||||
src = DVDREADSRC (object);
|
||||
priv = src->priv;
|
||||
|
||||
switch (prop_id) {
|
||||
|
@ -222,7 +222,7 @@ dvdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParam
|
|||
g_free (priv->location);
|
||||
/* clear the filename if we get a NULL (is that possible?) */
|
||||
if (g_value_get_string (value) == NULL)
|
||||
priv->location = "/dev/dvd";
|
||||
priv->location = g_strdup("/dev/dvd");
|
||||
/* otherwise set the new filename */
|
||||
else
|
||||
priv->location = g_strdup (g_value_get_string (value));
|
||||
|
@ -246,15 +246,15 @@ dvdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParam
|
|||
}
|
||||
|
||||
static void
|
||||
dvdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
dvdreadsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
DVDSrc *src;
|
||||
DVDSrcPrivate *priv;
|
||||
DVDReadSrc *src;
|
||||
DVDReadSrcPrivate *priv;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail (GST_IS_DVDSRC (object));
|
||||
g_return_if_fail (GST_IS_DVDREADSRC (object));
|
||||
|
||||
src = DVDSRC (object);
|
||||
src = DVDREADSRC (object);
|
||||
priv = src->priv;
|
||||
|
||||
switch (prop_id) {
|
||||
|
@ -288,7 +288,7 @@ is_nav_pack( unsigned char *buffer )
|
|||
}
|
||||
|
||||
static int
|
||||
_open(DVDSrcPrivate *priv, const gchar *location)
|
||||
_open(DVDReadSrcPrivate *priv, const gchar *location)
|
||||
{
|
||||
g_return_val_if_fail(priv != NULL, -1);
|
||||
g_return_val_if_fail(location != NULL, -1);
|
||||
|
@ -319,7 +319,7 @@ _open(DVDSrcPrivate *priv, const gchar *location)
|
|||
}
|
||||
|
||||
static int
|
||||
_close(DVDSrcPrivate *priv)
|
||||
_close(DVDReadSrcPrivate *priv)
|
||||
{
|
||||
ifoClose( priv->vts_file );
|
||||
ifoClose( priv->vmg_file );
|
||||
|
@ -329,7 +329,7 @@ _close(DVDSrcPrivate *priv)
|
|||
}
|
||||
|
||||
static int
|
||||
_seek(DVDSrcPrivate *priv, int title, int chapter, int angle)
|
||||
_seek(DVDReadSrcPrivate *priv, int title, int chapter, int angle)
|
||||
{
|
||||
/**
|
||||
* Make sure our title number is valid.
|
||||
|
@ -414,17 +414,17 @@ _seek(DVDSrcPrivate *priv, int title, int chapter, int angle)
|
|||
}
|
||||
|
||||
static void
|
||||
dvdsrc_loop (GstElement *element)
|
||||
dvdreadsrc_loop (GstElement *element)
|
||||
{
|
||||
DVDSrc *dvdsrc;
|
||||
DVDSrcPrivate *priv;
|
||||
DVDReadSrc *dvdreadsrc;
|
||||
DVDReadSrcPrivate *priv;
|
||||
|
||||
g_return_if_fail (element != NULL);
|
||||
g_return_if_fail (GST_IS_DVDSRC (element));
|
||||
g_return_if_fail (GST_IS_DVDREADSRC (element));
|
||||
|
||||
dvdsrc = DVDSRC (element);
|
||||
priv = dvdsrc->priv;
|
||||
g_return_if_fail (GST_FLAG_IS_SET (dvdsrc, DVDSRC_OPEN));
|
||||
dvdreadsrc = DVDREADSRC (element);
|
||||
priv = dvdreadsrc->priv;
|
||||
g_return_if_fail (GST_FLAG_IS_SET (dvdreadsrc, DVDREADSRC_OPEN));
|
||||
|
||||
/**
|
||||
* Playback by cell in this pgc, starting at the cell for our chapter.
|
||||
|
@ -482,7 +482,7 @@ dvdsrc_loop (GstElement *element)
|
|||
if( len == 0 ) {
|
||||
fprintf( stderr, "Read failed for block %d\n", priv->cur_pack );
|
||||
_close(priv);
|
||||
gst_element_set_eos (GST_ELEMENT (dvdsrc));
|
||||
gst_element_set_eos (GST_ELEMENT (dvdreadsrc));
|
||||
return;
|
||||
}
|
||||
assert( is_nav_pack( data ) );
|
||||
|
@ -534,7 +534,7 @@ dvdsrc_loop (GstElement *element)
|
|||
fprintf( stderr, "Read failed for %d blocks at %d\n",
|
||||
cur_output_size, priv->cur_pack );
|
||||
_close(priv);
|
||||
gst_element_set_eos (GST_ELEMENT (dvdsrc));
|
||||
gst_element_set_eos (GST_ELEMENT (dvdreadsrc));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -547,7 +547,7 @@ dvdsrc_loop (GstElement *element)
|
|||
|
||||
#if 0
|
||||
static int
|
||||
_read(DVDSrcPrivate *priv, int angle, int new_seek, GstBuffer *buf)
|
||||
_read(DVDReadSrcPrivate *priv, int angle, int new_seek, GstBuffer *buf)
|
||||
{
|
||||
unsigned char *data;
|
||||
|
||||
|
@ -668,18 +668,18 @@ _read(DVDSrcPrivate *priv, int angle, int new_seek, GstBuffer *buf)
|
|||
}
|
||||
|
||||
static GstBuffer *
|
||||
dvdsrc_get (GstPad *pad)
|
||||
dvdreadsrc_get (GstPad *pad)
|
||||
{
|
||||
DVDSrc *dvdsrc;
|
||||
DVDSrcPrivate *priv;
|
||||
DVDReadSrc *dvdreadsrc;
|
||||
DVDReadSrcPrivate *priv;
|
||||
GstBuffer *buf;
|
||||
|
||||
g_return_val_if_fail (pad != NULL, NULL);
|
||||
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
|
||||
|
||||
dvdsrc = DVDSRC (gst_pad_get_parent (pad));
|
||||
priv = dvdsrc->priv;
|
||||
g_return_val_if_fail (GST_FLAG_IS_SET (dvdsrc, DVDSRC_OPEN),NULL);
|
||||
dvdreadsrc = DVDREADSRC (gst_pad_get_parent (pad));
|
||||
priv = dvdreadsrc->priv;
|
||||
g_return_val_if_fail (GST_FLAG_IS_SET (dvdreadsrc, DVDREADSRC_OPEN),NULL);
|
||||
|
||||
/* create the buffer */
|
||||
/* FIXME: should eventually use a bufferpool for this */
|
||||
|
@ -696,7 +696,7 @@ dvdsrc_get (GstPad *pad)
|
|||
|
||||
/* read it in from the file */
|
||||
if (_read (priv, priv->angle, priv->new_seek, buf)) {
|
||||
gst_element_signal_eos (GST_ELEMENT (dvdsrc));
|
||||
gst_element_signal_eos (GST_ELEMENT (dvdreadsrc));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -710,11 +710,11 @@ dvdsrc_get (GstPad *pad)
|
|||
|
||||
/* open the file, necessary to go to RUNNING state */
|
||||
static gboolean
|
||||
dvdsrc_open_file (DVDSrc *src)
|
||||
dvdreadsrc_open_file (DVDReadSrc *src)
|
||||
{
|
||||
g_return_val_if_fail (src != NULL, FALSE);
|
||||
g_return_val_if_fail (GST_IS_DVDSRC(src), FALSE);
|
||||
g_return_val_if_fail (!GST_FLAG_IS_SET (src, DVDSRC_OPEN), FALSE);
|
||||
g_return_val_if_fail (GST_IS_DVDREADSRC(src), FALSE);
|
||||
g_return_val_if_fail (!GST_FLAG_IS_SET (src, DVDREADSRC_OPEN), FALSE);
|
||||
|
||||
if (_open(src->priv, src->priv->location))
|
||||
return FALSE;
|
||||
|
@ -724,37 +724,37 @@ dvdsrc_open_file (DVDSrc *src)
|
|||
src->priv->angle))
|
||||
return FALSE;
|
||||
|
||||
GST_FLAG_SET (src, DVDSRC_OPEN);
|
||||
GST_FLAG_SET (src, DVDREADSRC_OPEN);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* close the file */
|
||||
static void
|
||||
dvdsrc_close_file (DVDSrc *src)
|
||||
dvdreadsrc_close_file (DVDReadSrc *src)
|
||||
{
|
||||
g_return_if_fail (GST_FLAG_IS_SET (src, DVDSRC_OPEN));
|
||||
g_return_if_fail (GST_FLAG_IS_SET (src, DVDREADSRC_OPEN));
|
||||
|
||||
_close(src->priv);
|
||||
|
||||
GST_FLAG_UNSET (src, DVDSRC_OPEN);
|
||||
GST_FLAG_UNSET (src, DVDREADSRC_OPEN);
|
||||
}
|
||||
|
||||
static GstElementStateReturn
|
||||
dvdsrc_change_state (GstElement *element)
|
||||
dvdreadsrc_change_state (GstElement *element)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_DVDSRC (element), GST_STATE_FAILURE);
|
||||
g_return_val_if_fail (GST_IS_DVDREADSRC (element), GST_STATE_FAILURE);
|
||||
|
||||
GST_DEBUG (0,"gstdisksrc: state pending %d", GST_STATE_PENDING (element));
|
||||
GST_DEBUG (0,"gstdvdreadsrc: state pending %d", GST_STATE_PENDING (element));
|
||||
|
||||
/* if going down into NULL state, close the file if it's open */
|
||||
if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET (element, DVDSRC_OPEN))
|
||||
dvdsrc_close_file (DVDSRC (element));
|
||||
if (GST_FLAG_IS_SET (element, DVDREADSRC_OPEN))
|
||||
dvdreadsrc_close_file (DVDREADSRC (element));
|
||||
/* otherwise (READY or higher) we need to open the file */
|
||||
} else {
|
||||
if (!GST_FLAG_IS_SET (element, DVDSRC_OPEN)) {
|
||||
if (!dvdsrc_open_file (DVDSRC (element)))
|
||||
if (!GST_FLAG_IS_SET (element, DVDREADSRC_OPEN)) {
|
||||
if (!dvdreadsrc_open_file (DVDREADSRC (element)))
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -771,9 +771,9 @@ plugin_init (GModule *module, GstPlugin *plugin)
|
|||
{
|
||||
GstElementFactory *factory;
|
||||
|
||||
/* create an elementfactory for the dvdsrc element */
|
||||
factory = gst_element_factory_new ("dvdsrc", GST_TYPE_DVDSRC,
|
||||
&dvdsrc_details);
|
||||
/* create an elementfactory for the dvdreadsrc element */
|
||||
factory = gst_element_factory_new ("dvdreadsrc", GST_TYPE_DVDREADSRC,
|
||||
&dvdreadsrc_details);
|
||||
g_return_val_if_fail (factory != NULL, FALSE);
|
||||
|
||||
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
||||
|
@ -784,7 +784,7 @@ plugin_init (GModule *module, GstPlugin *plugin)
|
|||
GstPluginDesc plugin_desc = {
|
||||
GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"dvdsrc",
|
||||
"dvdreadsrc",
|
||||
plugin_init
|
||||
};
|
||||
|
|
@ -18,58 +18,52 @@
|
|||
*/
|
||||
|
||||
|
||||
#ifndef __DVDSRC_H__
|
||||
#define __DVDSRC_H__
|
||||
#ifndef __DVDREADSRC_H__
|
||||
#define __DVDREADSRC_H__
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GstElementDetails dvdreadsrc_details;
|
||||
|
||||
|
||||
GstElementDetails dvdsrc_details;
|
||||
|
||||
|
||||
#define GST_TYPE_DVDSRC \
|
||||
(dvdsrc_get_type())
|
||||
#define DVDSRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DVDSRC,DVDSrc))
|
||||
#define DVDSRC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DVDSRC,DVDSrcClass))
|
||||
#define GST_IS_DVDSRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DVDSRC))
|
||||
#define GST_IS_DVDSRC_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DVDSRC))
|
||||
#define GST_TYPE_DVDREADSRC \
|
||||
(dvdreadsrc_get_type())
|
||||
#define DVDREADSRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DVDREADSRC,DVDReadSrc))
|
||||
#define DVDREADSRC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DVDREADSRC,DVDReadSrcClass))
|
||||
#define GST_IS_DVDREADSRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DVDREADSRC))
|
||||
#define GST_IS_DVDREADSRC_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DVDREADSRC))
|
||||
|
||||
/* NOTE: per-element flags start with 16 for now */
|
||||
typedef enum {
|
||||
DVDSRC_OPEN = GST_ELEMENT_FLAG_LAST,
|
||||
DVDREADSRC_OPEN = GST_ELEMENT_FLAG_LAST,
|
||||
|
||||
DVDSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2,
|
||||
} DVDSrcFlags;
|
||||
DVDREADSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2,
|
||||
} DVDReadSrcFlags;
|
||||
|
||||
typedef struct _DVDSrc DVDSrc;
|
||||
typedef struct _DVDSrcPrivate DVDSrcPrivate;
|
||||
typedef struct _DVDSrcClass DVDSrcClass;
|
||||
typedef struct _DVDReadSrc DVDReadSrc;
|
||||
typedef struct _DVDReadSrcPrivate DVDReadSrcPrivate;
|
||||
typedef struct _DVDReadSrcClass DVDReadSrcClass;
|
||||
|
||||
struct _DVDSrc {
|
||||
struct _DVDReadSrc {
|
||||
GstElement element;
|
||||
DVDSrcPrivate *priv;
|
||||
DVDReadSrcPrivate *priv;
|
||||
};
|
||||
|
||||
struct _DVDSrcClass {
|
||||
struct _DVDReadSrcClass {
|
||||
GstElementClass parent_class;
|
||||
};
|
||||
|
||||
GType dvdsrc_get_type(void);
|
||||
GType dvdreadsrc_get_type(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif /* __DVDSRC_H__ */
|
||||
#endif /* __DVDREADSRC_H__ */
|
Loading…
Reference in a new issue