summaryrefslogtreecommitdiff
path: root/src/input
diff options
context:
space:
mode:
Diffstat (limited to 'src/input')
-rw-r--r--src/input/Makefile.am9
-rw-r--r--src/input/base64.c131
-rw-r--r--src/input/base64.h91
-rw-r--r--src/input/http_helper.c26
-rw-r--r--src/input/http_helper.h24
-rw-r--r--src/input/input_cdda.c93
-rw-r--r--src/input/input_dvb.c70
-rw-r--r--src/input/input_dvd.c25
-rw-r--r--src/input/input_file.c52
-rw-r--r--src/input/input_gnome_vfs.c10
-rw-r--r--src/input/input_http.c24
-rw-r--r--src/input/input_mms.c6
-rw-r--r--src/input/input_net.c16
-rw-r--r--src/input/input_plugin.h420
-rw-r--r--src/input/input_pnm.c8
-rw-r--r--src/input/input_pvr.c152
-rw-r--r--src/input/input_rtp.c6
-rw-r--r--src/input/input_rtsp.c8
-rw-r--r--src/input/input_smb.c8
-rw-r--r--src/input/input_stdin_fifo.c6
-rw-r--r--src/input/input_v4l.c35
-rw-r--r--src/input/input_vcd.c6
-rw-r--r--src/input/libdvdnav/dvd_reader.c2
-rw-r--r--src/input/libreal/asmrp.c2
-rw-r--r--src/input/libreal/real.c13
-rw-r--r--src/input/libreal/rmff.c130
-rw-r--r--src/input/libreal/rmff.h16
-rw-r--r--src/input/libreal/sdpplin.c7
-rw-r--r--src/input/librtsp/rtsp.c61
-rw-r--r--src/input/librtsp/rtsp.h10
-rw-r--r--src/input/librtsp/rtsp_session.c28
-rw-r--r--src/input/media_helper.h2
-rw-r--r--src/input/mms.c12
-rw-r--r--src/input/mms.h2
-rw-r--r--src/input/mmsh.c8
-rw-r--r--src/input/mmsh.h2
-rw-r--r--src/input/net_buf_ctrl.c27
-rw-r--r--src/input/net_buf_ctrl.h8
-rw-r--r--src/input/pnm.c16
-rw-r--r--src/input/pnm.h2
-rw-r--r--src/input/sha1.c6
-rw-r--r--src/input/sha1.h2
-rw-r--r--src/input/vcd/xine-extra.h6
-rw-r--r--src/input/vcd/xineplug_inp_vcd.c10
44 files changed, 478 insertions, 1120 deletions
diff --git a/src/input/Makefile.am b/src/input/Makefile.am
index ed32ad7c5..ca7e6dabd 100644
--- a/src/input/Makefile.am
+++ b/src/input/Makefile.am
@@ -19,7 +19,6 @@ SUBDIRS += libdvdnav
endif
-xineinclude_HEADERS = input_plugin.h
noinst_HEADERS = net_buf_ctrl.h mms.h mmsh.h pnm.h media_helper.h http_helper.h
@@ -113,21 +112,21 @@ xineplug_inp_dvb_la_CPPFLAGS = $(AM_CPPFLAGS) $(XDG_BASEDIR_CPPFLAGS)
xineplug_inp_rtsp_la_SOURCES = input_rtsp.c net_buf_ctrl.c
xineplug_inp_rtsp_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS) $(LTLIBINTL) libreal/libreal.la librtsp/librtsp.la
-xineplug_inp_cdda_la_SOURCES = input_cdda.c media_helper.c sha1.c sha1.h base64.c base64.h
+xineplug_inp_cdda_la_SOURCES = input_cdda.c media_helper.c sha1.c sha1.h
xineplug_inp_cdda_la_DEPS = $(XDG_BASEDIR_DEPS)
xineplug_inp_cdda_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) $(XDG_BASEDIR_LIBS)
xineplug_inp_cdda_la_CPPFLAGS = $(AM_CPPFLAGS) $(XDG_BASEDIR_CPPFLAGS)
xineplug_inp_v4l_la_SOURCES = input_v4l.c
-xineplug_inp_v4l_la_LIBADD = $(ALSA_LIBS) $(XINE_LIB) $(LTLIBINTL)
+xineplug_inp_v4l_la_LIBADD = $(XINE_LIB) $(ALSA_LIBS) $(LTLIBINTL)
xineplug_inp_v4l_la_CFLAGS = $(AM_CFLAGS) $(ALSA_CFLAGS)
xineplug_inp_gnome_vfs_la_SOURCES = input_gnome_vfs.c net_buf_ctrl.c
-xineplug_inp_gnome_vfs_la_LIBADD = $(GNOME_VFS_LIBS) $(XINE_LIB) $(PTHREAD_LIBS) $(LTLIBINTL)
+xineplug_inp_gnome_vfs_la_LIBADD = $(XINE_LIB) $(GNOME_VFS_LIBS) $(PTHREAD_LIBS) $(LTLIBINTL)
xineplug_inp_gnome_vfs_la_CFLAGS = $(AM_CFLAGS) $(GNOME_VFS_CFLAGS)
xineplug_inp_smb_la_SOURCES = input_smb.c
-xineplug_inp_smb_la_LIBADD = $(LIBSMBCLIENT_LIBS) $(XINE_LIB) $(LTLIBINTL)
+xineplug_inp_smb_la_LIBADD = $(XINE_LIB) $(LIBSMBCLIENT_LIBS) $(LTLIBINTL)
xineplug_inp_pvr_la_SOURCES = input_pvr.c
xineplug_inp_pvr_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS) $(LTLIBINTL)
diff --git a/src/input/base64.c b/src/input/base64.c
deleted file mode 100644
index ffb039802..000000000
--- a/src/input/base64.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2000 Robert Kaye
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * Base64 encoding modified for Musicbrainz
- * relicensed under the GNU General Public License for use in xine-lib
- */
-/* --------------------------------------------------------------------------
-
- MusicBrainz -- The Internet music metadatabase
-
- Copyright (C) 2000 Robert Kaye
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
-
-----------------------------------------------------------------------------*/
-/*
- * Program: RFC-822 routines (originally from SMTP)
- *
- * Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
- *
- * Date: 27 July 1988
- * Last Edited: 10 September 1998
- *
- * Sponsorship: The original version of this work was developed in the
- * Symbolic Systems Resources Group of the Knowledge Systems
- * Laboratory at Stanford University in 1987-88, and was funded
- * by the Biomedical Research Technology Program of the National
- * Institutes of Health under grant number RR-00785.
- *
- * Original version Copyright 1988 by The Leland Stanford Junior University
- * Copyright 1998 by the University of Washington
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notices appear in all copies and that both the
- * above copyright notices and this permission notice appear in supporting
- * documentation, and that the name of the University of Washington or The
- * Leland Stanford Junior University not be used in advertising or publicity
- * pertaining to distribution of the software without specific, written prior
- * permission. This software is made available "as is", and
- * THE UNIVERSITY OF WASHINGTON AND THE LELAND STANFORD JUNIOR UNIVERSITY
- * DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS SOFTWARE,
- * INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF
- * WASHINGTON OR THE LELAND STANFORD JUNIOR UNIVERSITY BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <ctype.h>
-#include <stdio.h>
-#include <time.h>
-#include <stdlib.h>
-
-#include "base64.h"
-
-
-/* NOTE: This is not true RFC822 anymore. The use of the characters
- '/', '+', and '=' is no bueno when the ID will be used as part of a URL.
- '_', '.', and '-' have been used instead
-*/
-
-/* Convert binary contents to BASE64
- * Accepts: source
- * length of source
- * pointer to return destination length
- * Returns: destination as BASE64
- */
-
-unsigned char *rfc822_binary (void *src,unsigned long srcl,unsigned long *len)
-{
- unsigned char *ret,*d;
- unsigned char *s = (unsigned char *) src;
- char *v = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._";
- unsigned long i = ((srcl + 2) / 3) * 4;
- *len = i += 2 * ((i / 60) + 1);
- d = ret = (unsigned char *) malloc ((size_t) ++i);
- for (i = 0; srcl; s += 3) { /* process tuplets */
- *d++ = v[s[0] >> 2]; /* byte 1: high 6 bits (1) */
- /* byte 2: low 2 bits (1), high 4 bits (2) */
- *d++ = v[((s[0] << 4) + (--srcl ? (s[1] >> 4) : 0)) & 0x3f];
- /* byte 3: low 4 bits (2), high 2 bits (3) */
- *d++ = srcl ? v[((s[1] << 2) + (--srcl ? (s[2] >> 6) : 0)) & 0x3f] : '-';
- /* byte 4: low 6 bits (3) */
- *d++ = srcl ? v[s[2] & 0x3f] : '-';
- if (srcl) srcl--; /* count third character if processed */
- if ((++i) == 15) { /* output 60 characters? */
- i = 0; /* restart line break count, insert CRLF */
- *d++ = '\015'; *d++ = '\012';
- }
- }
- *d = '\0'; /* tie off string */
-
- return ret; /* return the resulting string */
-}
diff --git a/src/input/base64.h b/src/input/base64.h
deleted file mode 100644
index 5cc94d7f0..000000000
--- a/src/input/base64.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2000 Robert Kaye
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * Base64 encoding modified for Musicbrainz
- * relicensed under the GNU General Public License for use in xine-lib
- */
-/* --------------------------------------------------------------------------
-
- MusicBrainz -- The Internet music metadatabase
-
- Copyright (C) 2000 Robert Kaye
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
-
-----------------------------------------------------------------------------*/
-/*
- * Program: RFC-822 routines (originally from SMTP)
- *
- * Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
- *
- * Date: 27 July 1988
- * Last Edited: 10 September 1998
- *
- * Sponsorship: The original version of this work was developed in the
- * Symbolic Systems Resources Group of the Knowledge Systems
- * Laboratory at Stanford University in 1987-88, and was funded
- * by the Biomedical Research Technology Program of the National
- * Institutes of Health under grant number RR-00785.
- *
- * Original version Copyright 1988 by The Leland Stanford Junior University
- * Copyright 1998 by the University of Washington
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notices appear in all copies and that both the
- * above copyright notices and this permission notice appear in supporting
- * documentation, and that the name of the University of Washington or The
- * Leland Stanford Junior University not be used in advertising or publicity
- * pertaining to distribution of the software without specific, written prior
- * permission. This software is made available "as is", and
- * THE UNIVERSITY OF WASHINGTON AND THE LELAND STANFORD JUNIOR UNIVERSITY
- * DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS SOFTWARE,
- * INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF
- * WASHINGTON OR THE LELAND STANFORD JUNIOR UNIVERSITY BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef BASE64_H
-#define BASE64_H
-
-unsigned char *rfc822_binary (void *src,unsigned long srcl,unsigned long *len);
-
-#endif
diff --git a/src/input/http_helper.c b/src/input/http_helper.c
index 4883763b0..f4950a084 100644
--- a/src/input/http_helper.c
+++ b/src/input/http_helper.c
@@ -26,7 +26,7 @@
#include <string.h>
-#include "xine_internal.h"
+#include <xine/xine_internal.h>
#include "http_helper.h"
int _x_parse_url (char *url, char **proto, char** host, int *port,
@@ -220,30 +220,6 @@ error:
return 0;
}
-char *_x_canonicalise_url (const char *base, const char *url) {
-
- size_t base_length;
- char *cut, *ret;
-
- if ((cut = strstr (url, "://")))
- return strdup (url);
-
- cut = strstr (base, "://");
- if (url[0] == '/') {
- /* absolute - base up to first '/' after "://", then url */
- cut = strchr (cut + 3, '/');
- }
- else {
- /* relative - base up to & inc. last '/', then url */
- cut = strrchr (cut, '/');
- if (cut)
- ++cut;
- }
- base_length = cut ? (size_t)(cut - base) : strlen (base);
- ret = malloc (base_length + strlen (url) + 1);
- sprintf (ret, "%.*s%s", (int)base_length, base, url);
- return ret;
-}
#ifdef TEST_URL
/*
diff --git a/src/input/http_helper.h b/src/input/http_helper.h
index 3ce3f2b7c..9baa05235 100644
--- a/src/input/http_helper.h
+++ b/src/input/http_helper.h
@@ -43,6 +43,28 @@ int _x_parse_url (char *url, char **proto, char** host, int *port,
* return:
* the canonicalised URL (caller must free() it)
*/
-char *_x_canonicalise_url (const char *base, const char *url);
+static inline char *_x_canonicalise_url (const char *base, const char *url) {
+
+ size_t base_length;
+ char *cut, *ret;
+
+ if ((cut = strstr (url, "://")))
+ return strdup (url);
+
+ cut = strstr (base, "://");
+ if (url[0] == '/') {
+ /* absolute - base up to first '/' after "://", then url */
+ cut = strchr (cut + 3, '/');
+ }
+ else {
+ /* relative - base up to & inc. last '/', then url */
+ cut = strrchr (cut, '/');
+ if (cut)
+ ++cut;
+ }
+ base_length = cut ? (size_t)(cut - base) : strlen (base);
+ asprintf (&ret, "%.*s%s", (int)base_length, base, url);
+ return ret;
+}
#endif /* HTTP_HELPER_H */
diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c
index df4617e22..64495c433 100644
--- a/src/input/input_cdda.c
+++ b/src/input/input_cdda.c
@@ -65,11 +65,11 @@
*/
#include "sha1.h"
-#include "base64.h"
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#include "media_helper.h"
+#include "base64.h"
#if defined(__sun)
#define DEFAULT_CDDA_DEVICE "/vol/dev/aliases/cdrom0"
@@ -422,10 +422,9 @@ static int read_cdrom_toc(int fd, cdrom_toc *toc) {
toc->total_tracks = toc->last_track - toc->first_track + 1;
/* allocate space for the toc entries */
- toc->toc_entries =
- (cdrom_toc_entry *)malloc(toc->total_tracks * sizeof(cdrom_toc_entry));
+ toc->toc_entries = calloc(toc->total_tracks, sizeof(cdrom_toc_entry));
if (!toc->toc_entries) {
- perror("malloc");
+ perror("calloc");
return -1;
}
@@ -533,10 +532,9 @@ static int read_cdrom_toc(int fd, cdrom_toc *toc) {
toc->total_tracks = toc->last_track - toc->first_track + 1;
/* allocate space for the toc entries */
- toc->toc_entries =
- (cdrom_toc_entry *)malloc(toc->total_tracks * sizeof(cdrom_toc_entry));
+ toc->toc_entries = calloc(toc->total_tracks, sizeof(cdrom_toc_entry));
if (!toc->toc_entries) {
- perror("malloc");
+ perror("calloc");
return -1;
}
@@ -646,10 +644,9 @@ static int read_cdrom_toc(int fd, cdrom_toc *toc) {
toc->total_tracks = toc->last_track - toc->first_track + 1;
/* allocate space for the toc entries */
- toc->toc_entries =
- (cdrom_toc_entry *)malloc(toc->total_tracks * sizeof(cdrom_toc_entry));
+ toc->toc_entries = calloc(toc->total_tracks, sizeof(cdrom_toc_entry));
if (!toc->toc_entries) {
- perror("malloc");
+ perror("calloc");
return -1;
}
@@ -839,10 +836,9 @@ static int read_cdrom_toc(cdda_input_plugin_t *this_gen, cdrom_toc *toc) {
/* allocate space for the toc entries */
- toc->toc_entries =
- (cdrom_toc_entry *)malloc(toc->total_tracks * sizeof(cdrom_toc_entry));
+ toc->toc_entries = calloc(toc->total_tracks, sizeof(cdrom_toc_entry));
if (!toc->toc_entries) {
- perror("malloc");
+ perror("calloc");
return -1;
}
@@ -991,7 +987,7 @@ static int parse_url (char *urlbuf, char** host, int *port) {
#endif
static int XINE_FORMAT_PRINTF(4, 5)
-network_command( xine_stream_t *stream, int socket, char *data_buf, char *msg, ...)
+network_command( xine_stream_t *stream, int socket, void *data_buf, const char *msg, ...)
{
char buf[_BUFSIZ];
va_list args;
@@ -1040,13 +1036,13 @@ network_command( xine_stream_t *stream, int socket, char *data_buf, char *msg, .
#ifndef WIN32
-static int network_connect(xine_stream_t *stream, char *url )
+static int network_connect(xine_stream_t *stream, const char *_url )
{
char *host;
int port;
int fd;
- url = strdup(url);
+ char *url = strdup(_url);
parse_url(url, &host, &port);
if( !host || !strlen(host) || !port )
@@ -1085,10 +1081,9 @@ static int network_read_cdrom_toc(xine_stream_t *stream, int fd, cdrom_toc *toc)
toc->total_tracks = toc->last_track - toc->first_track + 1;
/* allocate space for the toc entries */
- toc->toc_entries =
- (cdrom_toc_entry *)malloc(toc->total_tracks * sizeof(cdrom_toc_entry));
+ toc->toc_entries = calloc(toc->total_tracks, sizeof(cdrom_toc_entry));
if (!toc->toc_entries) {
- perror("malloc");
+ perror("calloc");
return -1;
}
@@ -1288,42 +1283,27 @@ static void _cdda_mkdir_safe(xine_t *xine, char *path) {
}
/*
- * Make recursive directory creation
+ * Make recursive directory creation (given an absolute pathname)
*/
-static void _cdda_mkdir_recursive_safe(xine_t *xine, char *path) {
- char *p, *pp;
- char buf[XINE_PATH_MAX + XINE_NAME_MAX + 1];
- char buf2[XINE_PATH_MAX + XINE_NAME_MAX + 1];
-
- if(path == NULL)
+static void _cdda_mkdir_recursive_safe (xine_t *xine, char *path)
+{
+ if (!path)
return;
- memset(&buf, 0, sizeof(buf));
- memset(&buf2, 0, sizeof(buf2));
-
- snprintf(buf, sizeof(buf), "%s", path);
- pp = buf;
- while((p = xine_strsep(&pp, "/")) != NULL) {
- if(p && strlen(p)) {
-
-#ifdef WIN32
- if (*buf2 != '\0') {
-#endif
-
- int size = strlen(buf2);
- snprintf(buf2 + size, sizeof(buf2) - size, "/%s", p);
+ char buf[strlen (path) + 1];
+ strcpy (buf, path);
+ char *p = strchr (buf, '/') ? : buf;
-#ifdef WIN32
- }
- else {
- snprintf(buf2, sizeof(buf2), "%s", p);
- }
-
-#endif /* WIN32 */
-
- _cdda_mkdir_safe(xine, buf2);
- }
- }
+ do
+ {
+ while (*p++ == '/') /**/;
+ p = strchr (p, '/');
+ if (p)
+ *p = 0;
+ _cdda_mkdir_safe (xine, buf);
+ if (p)
+ *p = '/';
+ } while (p);
}
/*
@@ -1443,7 +1423,6 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) {
while((pdir = readdir(dir)) != NULL) {
char discid[9];
- memset(&discid, 0, sizeof(discid));
snprintf(discid, sizeof(discid), "%08lx", this->cddb.disc_id);
if(!strcasecmp(pdir->d_name, discid)) {
@@ -1649,7 +1628,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) {
this->cddb.fd = _cdda_cddb_socket_open(this);
if(this->cddb.fd >= 0) {
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
- _("input_cdda: successfuly connected to cddb server '%s:%d'.\n"),
+ _("input_cdda: successfully connected to cddb server '%s:%d'.\n"),
this->cddb.server, this->cddb.port);
}
else {
@@ -1957,7 +1936,7 @@ static void _cdda_cdindex(cdda_input_plugin_t *this, cdrom_toc *toc) {
sha_final(digest, &sha);
- base64 = rfc822_binary(digest, 20, &size);
+ base64 = _x_rfc822_binary(digest, 20, &size);
base64[size] = 0;
_x_meta_info_set_utf8(this->stream, XINE_META_INFO_CDINDEX_DISCID, base64);
diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c
index a998d274b..07aefc362 100644
--- a/src/input/input_dvb.c
+++ b/src/input/input_dvb.c
@@ -113,9 +113,9 @@
#define LOG_READS
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#include "net_buf_ctrl.h"
#define BUFSIZE 16384
@@ -234,9 +234,8 @@ typedef struct {
int adapter_num;
- char frontend_device[100];
- char dvr_device[100];
- char demux_device[100];
+ char *dvr_device;
+ char *demux_device;
struct dmx_pes_filter_params pesFilterParams[MAX_FILTERS];
struct dmx_pes_filter_params subFilterParams[MAX_SUBTITLES];
@@ -291,7 +290,7 @@ typedef struct {
xine_t *xine;
- char *mrls[5];
+ const char *mrls[5];
int numchannels;
@@ -359,7 +358,7 @@ typedef struct {
} dvb_input_plugin_t;
typedef struct {
- char *name;
+ const char *name;
int value;
} Param;
@@ -432,7 +431,7 @@ static const Param transmissionmode_list [] = {
};
-time_t dvb_mjdtime (char *buf);
+static time_t dvb_mjdtime (uint8_t *buf);
static void load_epg_data(dvb_input_plugin_t *this);
static void show_eit(dvb_input_plugin_t *this);
@@ -491,7 +490,7 @@ static int find_descriptor(uint8_t tag, const unsigned char *buf, int descriptor
/* Extract UTC time and date encoded in modified julian date format and return it as a time_t.
*/
-time_t dvb_mjdtime (char *buf)
+static time_t dvb_mjdtime (uint8_t *buf)
{
int i;
unsigned int year, month, day, hour, min, sec;
@@ -548,9 +547,10 @@ static void tuner_dispose(tuner_t * this)
for (x = 0; x < MAX_SUBTITLES; x++)
if (this->fd_subfilter[x] >= 0)
close(this->fd_subfilter[x]);
-
- if(this)
- free(this);
+
+ free(this->dvr_device);
+ free(this->demux_device);
+ free(this);
}
@@ -560,10 +560,9 @@ static tuner_t *tuner_init(xine_t * xine, int adapter)
tuner_t *this;
int x;
int test_video;
- char *video_device=xine_xmalloc(200);
+ char *video_device = NULL;
+ char *frontend_device = NULL;
- _x_assert(video_device != NULL);
-
this = (tuner_t *) xine_xmalloc(sizeof(tuner_t));
_x_assert(this != NULL);
@@ -576,21 +575,24 @@ static tuner_t *tuner_init(xine_t * xine, int adapter)
this->xine = xine;
this->adapter_num = adapter;
- snprintf(this->frontend_device,100,"/dev/dvb/adapter%i/frontend0",this->adapter_num);
- snprintf(this->demux_device,100,"/dev/dvb/adapter%i/demux0",this->adapter_num);
- snprintf(this->dvr_device,100,"/dev/dvb/adapter%i/dvr0",this->adapter_num);
- snprintf(video_device,100,"/dev/dvb/adapter%i/video0",this->adapter_num);
-
- if ((this->fd_frontend = open(this->frontend_device, O_RDWR)) < 0) {
+ asprintf(&this->demux_device,"/dev/dvb/adapter%i/demux0",this->adapter_num);
+ asprintf(&this->dvr_device,"/dev/dvb/adapter%i/dvr0",this->adapter_num);
+ asprintf(&video_device,"/dev/dvb/adapter%i/video0",this->adapter_num);
+
+ asprintf(&frontend_device,"/dev/dvb/adapter%i/frontend0",this->adapter_num);
+ if ((this->fd_frontend = open(frontend_device, O_RDWR)) < 0) {
xprintf(this->xine, XINE_VERBOSITY_DEBUG, "FRONTEND DEVICE: %s\n", strerror(errno));
tuner_dispose(this);
- return NULL;
+ this = NULL;
+ goto exit;
}
+ free(frontend_device); frontend_device = NULL;
if ((ioctl(this->fd_frontend, FE_GET_INFO, &this->feinfo)) < 0) {
xprintf(this->xine, XINE_VERBOSITY_DEBUG, "FE_GET_INFO: %s\n", strerror(errno));
tuner_dispose(this);
- return NULL;
+ this = NULL;
+ goto exit;
}
for (x = 0; x < MAX_FILTERS; x++) {
@@ -598,7 +600,8 @@ static tuner_t *tuner_init(xine_t * xine, int adapter)
if (this->fd_pidfilter[x] < 0) {
xprintf(this->xine, XINE_VERBOSITY_DEBUG, "DEMUX DEVICE PIDfilter: %s\n", strerror(errno));
tuner_dispose(this);
- return NULL;
+ this = NULL;
+ goto exit;
}
}
for (x = 0; x < MAX_SUBTITLES; x++) {
@@ -630,7 +633,9 @@ static tuner_t *tuner_init(xine_t * xine, int adapter)
close(test_video);
}
+ exit:
free(video_device);
+ free(frontend_device);
return this;
}
@@ -1203,8 +1208,8 @@ static void parse_pmt(dvb_input_plugin_t *this, const unsigned char *buf, int se
static void dvb_parse_si(dvb_input_plugin_t *this) {
- char *tmpbuffer;
- char *bufptr;
+ uint8_t *tmpbuffer;
+ uint8_t *bufptr;
int service_id;
int result;
int section_len;
@@ -1403,8 +1408,8 @@ static void load_epg_data(dvb_input_plugin_t *this)
int section_len = 0;
unsigned int service_id=-1;
int n;
- char *eit = NULL;
- char *foo = NULL;
+ uint8_t *eit = NULL;
+ uint8_t *foo = NULL;
char *seen_channels = NULL;
int text_len;
struct pollfd fd;
@@ -1591,7 +1596,7 @@ static void load_epg_data(dvb_input_plugin_t *this)
case 0x54: { /* Content Descriptor, riveting stuff */
int content_bits = getbits(eit, 8, 4);
- char *content[] = {
+ static const char *const content[] = {
"UNKNOWN","MOVIE","NEWS","ENTERTAINMENT","SPORT",
"CHILDRENS","MUSIC","ARTS/CULTURE","CURRENT AFFAIRS",
"EDUCATIONAL","INFOTAINMENT","SPECIAL","COMEDY","DRAMA",
@@ -2476,7 +2481,7 @@ static void ts_rewrite_packets (dvb_input_plugin_t *this, unsigned char * origin
static off_t dvb_plugin_read (input_plugin_t *this_gen,
void *buf_gen, off_t len) {
dvb_input_plugin_t *this = (dvb_input_plugin_t *) this_gen;
- char *buf = (char *)buf_gen;
+ uint8_t *buf = buf_gen;
off_t n=0, total=0;
int have_mutex=0;
@@ -2491,9 +2496,6 @@ static off_t dvb_plugin_read (input_plugin_t *this_gen,
"input_dvb: reading %" PRIdMAX " bytes...\n", (intmax_t)len);
#endif
-#ifndef DVB_NO_BUFFERING
- nbc_check_buffers (this->nbc);
-#endif
/* protect against channel changes */
have_mutex = pthread_mutex_lock(&this->channel_change_mutex);
total=0;
diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c
index 446b7c778..02017956e 100644
--- a/src/input/input_dvd.c
+++ b/src/input/input_dvd.c
@@ -85,9 +85,9 @@
#endif
/* Xine includes */
-#include "xineutils.h"
-#include "buffer.h"
-#include "xine_internal.h"
+#include <xine/xineutils.h>
+#include <xine/buffer.h>
+#include <xine/xine_internal.h>
#include "media_helper.h"
/* Print debug messages? */
@@ -225,7 +225,7 @@ typedef struct {
int32_t region;
int32_t play_single_chapter;
- char *filelist[MAX_DIR_ENTRIES];
+ const char *filelist[MAX_DIR_ENTRIES];
} dvd_input_class_t;
@@ -332,7 +332,7 @@ static void send_mouse_enter_leave_event(dvd_input_plugin_t *this, int direction
this->mouse_in = !this->mouse_in;
if(direction != this->mouse_in) {
- const xine_spu_button_t spu_event = {
+ xine_spu_button_t spu_event = {
.direction = direction,
.button = this->mouse_buttonN
};
@@ -1374,10 +1374,7 @@ check_solaris_vold_device(dvd_input_class_t *this)
(volume_action = getenv("VOLUME_ACTION")) != NULL &&
strcmp(volume_action, "insert") == 0) {
- device = malloc(strlen(volume_device) + strlen(volume_name) + 2);
- if (device == NULL)
- return;
- sprintf(device, "%s/%s", volume_device, volume_name);
+ asprintf(&device, "%s/%s", volume_device, volume_name);
if (stat(device, &stb) != 0 || !S_ISCHR(stb.st_mode)) {
free(device);
return;
@@ -1624,12 +1621,12 @@ static int dvd_plugin_open (input_plugin_t *this_gen) {
static input_plugin_t *dvd_class_get_instance (input_class_t *class_gen, xine_stream_t *stream, const char *data) {
dvd_input_plugin_t *this;
dvd_input_class_t *class = (dvd_input_class_t*)class_gen;
- static char *handled_mrl = "dvd:/";
+ static const char handled_mrl[] = "dvd:/";
trace_print("Called\n");
/* Check we can handle this MRL */
- if (strncasecmp (data, handled_mrl, strlen(handled_mrl) ) != 0)
+ if (strncasecmp (data, handled_mrl, sizeof(handled_mrl)-1 ) != 0)
return NULL;
this = (dvd_input_plugin_t *) xine_xmalloc (sizeof (dvd_input_plugin_t));
@@ -1743,9 +1740,9 @@ static void *init_class (xine_t *xine, void *data) {
dvd_input_class_t *this;
config_values_t *config = xine->config;
void *dvdcss;
- static const char *skip_modes[] = {"skip program", "skip part", "skip title", NULL};
- static const char *seek_modes[] = {"seek in program chain", "seek in program", NULL};
- static const char *play_single_chapter_modes[] = {"entire dvd", "one chapter", NULL};
+ static const char *const skip_modes[] = {"skip program", "skip part", "skip title", NULL};
+ static const char *const seek_modes[] = {"seek in program chain", "seek in program", NULL};
+ static const char *const play_single_chapter_modes[] = {"entire dvd", "one chapter", NULL};
trace_print("Called\n");
#ifdef INPUT_DEBUG
diff --git a/src/input/input_file.c b/src/input/input_file.c
index 1916a71e4..2fe3925ea 100644
--- a/src/input/input_file.c
+++ b/src/input/input_file.c
@@ -44,10 +44,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/input_plugin.h>
#define MAXFILES 65535
@@ -337,7 +337,7 @@ static int file_plugin_open (input_plugin_t *this_gen ) {
lprintf("file_plugin_open\n");
- if (strncasecmp (this->mrl, "file:", 5) == 0)
+ if (strncasecmp (this->mrl, "file:/", 6) == 0)
{
if (strncasecmp (this->mrl, "file://localhost/", 16) == 0)
filename = decode_uri(&(this->mrl[16]));
@@ -347,43 +347,27 @@ static int file_plugin_open (input_plugin_t *this_gen ) {
filename = decode_uri(&(this->mrl[5]));
}
else
- filename = decode_uri(this->mrl);
+ filename = strdup(this->mrl); /* NEVER unescape plain file names! */
this->fh = open (filename, O_RDONLY|O_BINARY);
-
- free(filename);
if (this->fh == -1) {
- /* try again without unescaping; such MRLs might be invalid,
- * but we are a nice software */
- if (strncasecmp (this->mrl, "file:", 5) == 0)
- {
- if (strncasecmp (this->mrl, "file://localhost/", 16) == 0)
- this->fh = open(&this->mrl[16], O_RDONLY|O_BINARY);
- else if (strncasecmp (this->mrl, "file://127.0.0.1/", 16) == 0)
- this->fh = open(&this->mrl[16], O_RDONLY|O_BINARY);
- else
- this->fh = open(&this->mrl[5], O_RDONLY|O_BINARY);
+ if (errno == EACCES) {
+ _x_message(this->stream, XINE_MSG_PERMISSION_ERROR, this->mrl, NULL);
+ xine_log (this->stream->xine, XINE_LOG_MSG,
+ _("input_file: Permission denied: >%s<\n"), this->mrl);
+ } else if (errno == ENOENT) {
+ _x_message(this->stream, XINE_MSG_FILE_NOT_FOUND, this->mrl, NULL);
+ xine_log (this->stream->xine, XINE_LOG_MSG,
+ _("input_file: File not found: >%s<\n"), this->mrl);
}
- else
- this->fh = open(this->mrl, O_RDONLY|O_BINARY);
-
- if (this->fh == -1) {
- if (errno == EACCES) {
- _x_message(this->stream, XINE_MSG_PERMISSION_ERROR, this->mrl, NULL);
- xine_log (this->stream->xine, XINE_LOG_MSG,
- _("input_file: Permission denied: >%s<\n"), this->mrl);
- return -1;
- } else if (errno == ENOENT) {
- _x_message(this->stream, XINE_MSG_FILE_NOT_FOUND, this->mrl, NULL);
- xine_log (this->stream->xine, XINE_LOG_MSG,
- _("input_file: File not found: >%s<\n"), this->mrl);
- }
- return -1;
- }
+ free(filename);
+ return -1;
}
+ free(filename);
+
#ifdef HAVE_MMAP
this->mmap_on = 0;
this->mmap_base = NULL;
diff --git a/src/input/input_gnome_vfs.c b/src/input/input_gnome_vfs.c
index 71a4ada85..7fb2d8b00 100644
--- a/src/input/input_gnome_vfs.c
+++ b/src/input/input_gnome_vfs.c
@@ -24,9 +24,9 @@
#include "config.h"
#endif
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#include "net_buf_ctrl.h"
#include <libgnomevfs/gnome-vfs.h>
@@ -200,7 +200,7 @@ gnomevfs_plugin_get_length (input_plugin_t *this_gen)
static uint32_t
gnomevfs_plugin_get_blocksize (input_plugin_t *this_gen)
{
- return 32 * 1024;
+ return 8 * 1024;
}
static const char*
@@ -291,7 +291,7 @@ gnomevfs_klass_dispose (input_class_t *this_gen)
g_free (this);
}
-static const char *const ignore_scheme[] = { "cdda", "file", "http" };
+static const char ignore_scheme[][8] = { "cdda", "file", "http" };
static input_plugin_t *
gnomevfs_klass_get_instance (input_class_t *klass_gen, xine_stream_t *stream,
diff --git a/src/input/input_http.c b/src/input/input_http.c
index 38658b161..c2836affe 100644
--- a/src/input/input_http.c
+++ b/src/input/input_http.c
@@ -46,9 +46,9 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#include "net_buf_ctrl.h"
#include "http_helper.h"
@@ -77,11 +77,7 @@ typedef struct {
off_t contentlength;
char buf[BUFSIZE];
- char proxybuf[BUFSIZE];
- char auth[BUFSIZE];
- char proxyauth[BUFSIZE];
-
char preview[MAX_PREVIEW_SIZE];
off_t preview_size;
@@ -232,7 +228,7 @@ static int _x_use_proxy(http_input_class_t *this, const char *host) {
}
static int http_plugin_basicauth (const char *user, const char *password, char* dest, int len) {
- static char *enctable="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+ static const char enctable[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
char *tmp;
char *sptr;
char *dptr;
@@ -249,7 +245,7 @@ static int http_plugin_basicauth (const char *user, const char *password, char*
if (len < enclen)
return -1;
- tmp = malloc (sizeof(char) * (totlen + 1));
+ tmp = malloc (totlen + 1);
strcpy (tmp, user);
strcat (tmp, ":");
if (password != NULL)
@@ -667,6 +663,8 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
int use_proxy;
int proxyport;
int mpegurl_redirect = 0;
+ char auth[BUFSIZE];
+ char proxyauth[BUFSIZE];
use_proxy = this_class->proxyhost && strlen(this_class->proxyhost);
@@ -674,7 +672,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
if (this_class->proxyuser && strlen(this_class->proxyuser)) {
if (http_plugin_basicauth (this_class->proxyuser,
this_class->proxypassword,
- this->proxyauth, BUFSIZE)) {
+ proxyauth, BUFSIZE)) {
_x_message(this->stream, XINE_MSG_CONNECTION_REFUSED, "proxy error", NULL);
return 0;
}
@@ -693,7 +691,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
this->port = DEFAULT_HTTP_PORT;
if (this->user && strlen(this->user)) {
- if (http_plugin_basicauth (this->user, this->password, this->auth, BUFSIZE)) {
+ if (http_plugin_basicauth (this->user, this->password, auth, BUFSIZE)) {
_x_message(this->stream, XINE_MSG_CONNECTION_REFUSED, "basic auth error", NULL);
return -1;
}
@@ -776,12 +774,12 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
buflen = strlen(this->buf);
if (this_class->proxyuser && strlen(this_class->proxyuser)) {
snprintf (this->buf + buflen, BUFSIZE - buflen,
- "Proxy-Authorization: Basic %s\015\012", this->proxyauth);
+ "Proxy-Authorization: Basic %s\015\012", proxyauth);
buflen = strlen(this->buf);
}
if (this->user && strlen(this->user)) {
snprintf (this->buf + buflen, BUFSIZE - buflen,
- "Authorization: Basic %s\015\012", this->auth);
+ "Authorization: Basic %s\015\012", auth);
buflen = strlen(this->buf);
}
diff --git a/src/input/input_mms.c b/src/input/input_mms.c
index 0b9e6c7f2..0287e0060 100644
--- a/src/input/input_mms.c
+++ b/src/input/input_mms.c
@@ -41,9 +41,9 @@
*/
#include "bswap.h"
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#include "mms.h"
#include "mmsh.h"
diff --git a/src/input/input_net.c b/src/input/input_net.c
index 7a52f670d..8a4874203 100644
--- a/src/input/input_net.c
+++ b/src/input/input_net.c
@@ -66,9 +66,9 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#include "net_buf_ctrl.h"
#define NET_BS_LEN 2324
@@ -412,6 +412,8 @@ static int net_plugin_open (input_plugin_t *this_gen ) {
char *filename;
char *pptr;
int port = 7658;
+ int toread = MAX_PREVIEW_SIZE;
+ int trycount = 0;
filename = this->host_port;
pptr=strrchr(filename, ':');
@@ -430,11 +432,15 @@ static int net_plugin_open (input_plugin_t *this_gen ) {
/*
* fill preview buffer
*/
+ while ((toread > 0) && (trycount < 10)) {
#ifndef WIN32
- this->preview_size = read (this->fh, this->preview, MAX_PREVIEW_SIZE);
+ this->preview_size += read (this->fh, this->preview + this->preview_size, toread);
#else
- this->preview_size = recv (this->fh, this->preview, MAX_PREVIEW_SIZE, 0);
+ this->preview_size += recv (this->fh, this->preview + this->preview_size, toread, 0);
#endif
+ trycount++;
+ toread = MAX_PREVIEW_SIZE - this->preview_size;
+ }
this->curpos = 0;
diff --git a/src/input/input_plugin.h b/src/input/input_plugin.h
deleted file mode 100644
index 2917721c9..000000000
--- a/src/input/input_plugin.h
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * Copyright (C) 2000-2004 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- */
-
-#ifndef HAVE_INPUT_PLUGIN_H
-#define HAVE_INPUT_PLUGIN_H
-
-#include <sys/types.h>
-
-#ifdef XINE_COMPILE
-# include <inttypes.h>
-# include "xineutils.h"
-# include "buffer.h"
-# include "configfile.h"
-#else
-# include <xine/os_types.h>
-# include <xine/xineutils.h>
-# include <xine/buffer.h>
-# include <xine/configfile.h>
-#endif
-
-#define INPUT_PLUGIN_IFACE_VERSION 18
-
-typedef struct input_class_s input_class_t ;
-typedef struct input_plugin_s input_plugin_t;
-
-struct input_class_s {
-
- /*
- * create a new instance of this plugin class
- * return NULL if the plugin does'nt handle the given mrl
- */
- input_plugin_t* (*get_instance) (input_class_t *this, xine_stream_t *stream, const char *mrl);
-
- /**
- * @brief short human readable identifier for this plugin class
- */
- const char *identifier;
-
- /**
- * @brief human readable (verbose = 1 line) description for this plugin class
- *
- * The description is passed to gettext() to internationalise.
- */
- const char *description;
-
- /**
- * @brief Optional non-standard catalog to use with dgettext() for description.
- */
- const char *textdomain;
-
- /*
- * ls function, optional: may be NULL
- * return value: NULL => filename is a file, **char=> filename is a dir
- */
- xine_mrl_t ** (*get_dir) (input_class_t *this, const char *filename, int *nFiles);
-
- /*
- * generate autoplay list, optional: may be NULL
- * return value: list of MRLs
- */
- char ** (*get_autoplay_list) (input_class_t *this, int *num_files);
-
- /*
- * close down, free all resources
- */
- void (*dispose) (input_class_t *this);
-
- /*
- * eject/load the media (if possible), optional: may be NULL
- *
- * returns 0 for temporary failures
- */
- int (*eject_media) (input_class_t *this);
-};
-
-#define default_input_class_dispose (void (*) (input_class_t *this))free
-
-struct input_plugin_s {
-
- /*
- * open the stream
- * return 0 if an error occured
- */
- int (*open) (input_plugin_t *this);
-
- /*
- * return capabilities of the current playable entity. See
- * get_current_pos below for a description of a "playable entity"
- * Capabilities a created by "OR"ing a mask of constants listed
- * below which start "INPUT_CAP".
- *
- * depending on the values set, some of the functions below
- * will or will not get called or should (not) be able to
- * do certain tasks.
- *
- * for example if INPUT_CAP_SEEKABLE is set,
- * the seek() function is expected to work fully at any time.
- * however, if the flag is not set, the seek() function should
- * make a best-effort attempt to seek, e.g. at least
- * relative forward seeking should work.
- */
- uint32_t (*get_capabilities) (input_plugin_t *this);
-
- /*
- * read nlen bytes, return number of bytes read
- * Should block until some bytes available for read;
- * a return value of 0 indicates no data available
- */
- off_t (*read) (input_plugin_t *this, void *buf, off_t nlen);
-
-
- /*
- * read one block, return newly allocated block (or NULL on failure)
- * for blocked input sources len must be == blocksize
- * the fifo parameter is only used to get access to the buffer_pool_alloc function
- */
- buf_element_t *(*read_block)(input_plugin_t *this, fifo_buffer_t *fifo, off_t len);
-
-
- /*
- * seek position, return new position
- *
- * if seeking failed, -1 is returned
- */
- off_t (*seek) (input_plugin_t *this, off_t offset, int origin);
-
-
- /*
- * seek to time position, return new position
- * time_offset is given in miliseconds
- *
- * if seeking failed, -1 is returned
- *
- * note: only SEEK_SET (0) is currently supported as origin
- * note: may be NULL is not supported
- */
- off_t (*seek_time) (input_plugin_t *this, int time_offset, int origin);
-
-
- /*
- * get current position in stream.
- *
- */
- off_t (*get_current_pos) (input_plugin_t *this);
-
-
- /*
- * get current time position in stream in miliseconds.
- *
- * note: may be NULL is not supported
- */
- int (*get_current_time) (input_plugin_t *this);
-
-
- /*
- * return number of bytes in the next playable entity or -1 if the
- * input is unlimited, as would be the case in a network stream.
- *
- * A "playable entity" tends to be the entities listed in a playback
- * list or the units on which playback control generally works on.
- * It might be the number of bytes in a VCD "segment" or "track" (if
- * the track has no "entry" subdivisions), or the number of bytes in
- * a PS (Program Segment or "Chapter") of a DVD. If there are no
- * subdivisions of the input medium and it is considered one
- * indivisible entity, it would be the byte count of that entity;
- * for example, the length in bytes of an MPEG file.
-
- * This length information is used, for example when in setting the
- * absolute or relative play position or possibly calculating the
- * bit rate.
- */
- off_t (*get_length) (input_plugin_t *this);
-
-
- /*
- * return block size in bytes of next complete playable entity (if
- * supported, 0 otherwise). See the description above under
- * get_length for a description of a "complete playable entity".
- *
- * this block size is only used for mpeg streams stored on
- * a block oriented storage media, e.g. DVDs and VCDs, to speed
- * up the demuxing process. only set this (and the INPUT_CAP_BLOCK
- * flag) if this is the case for your input plugin.
- *
- * make this function simply return 0 if unsure.
- */
-
- uint32_t (*get_blocksize) (input_plugin_t *this);
-
-
- /*
- * return current MRL
- */
- const char * (*get_mrl) (input_plugin_t *this);
-
-
- /*
- * request optional data from input plugin.
- */
- int (*get_optional_data) (input_plugin_t *this, void *data, int data_type);
-
-
- /*
- * close stream, free instance resources
- */
- void (*dispose) (input_plugin_t *this);
-
- /*
- * "backward" link to input plugin class struct
- */
-
- input_class_t *input_class;
-
- void *node; /* used by plugin loader */
-
-};
-
-/*
- * possible capabilites an input plugin can have:
- */
-#define INPUT_CAP_NOCAP 0x00000000
-
-/*
- * INPUT_CAP_SEEKABLE:
- * seek () works reliably.
- * even for plugins that do not have this flag set
- * it is a good idea to implement the seek() function
- * in a "best effort" style anyway, so at least
- * throw away data for network streams when seeking forward
- */
-
-#define INPUT_CAP_SEEKABLE 0x00000001
-
-/*
- * INPUT_CAP_BLOCK:
- * means more or less that a block device sits behind
- * this input plugin. get_blocksize must be implemented.
- * will be used for fast and efficient demuxing of
- * mpeg streams (demux_mpeg_block).
- */
-
-#define INPUT_CAP_BLOCK 0x00000002
-
-/*
- * INPUT_CAP_AUDIOLANG:
- * INPUT_CAP_SPULANG:
- * input plugin knows something about audio/spu languages,
- * e.g. knows that audio stream #0 is english,
- * audio stream #1 is german, ...
- * *((int *)data) will provide the requested channel number
- * and awaits the language back in (char *)data
- */
-
-#define INPUT_CAP_AUDIOLANG 0x00000008
-#define INPUT_CAP_SPULANG 0x00000010
-
-/*
- * INPUT_CAP_PREVIEW:
- * get_optional_data can handle INPUT_OPTIONAL_DATA_PREVIEW
- * so a non-seekable stream plugin can povide the first
- * few bytes for demuxers to look at them and decide wheter
- * they can handle the stream or not. the preview data must
- * be buffered and delivered again through subsequent
- * read() calls.
- * caller must provide a buffer allocated with at least
- * MAX_PREVIEW_SIZE bytes.
- */
-
-#define INPUT_CAP_PREVIEW 0x00000040
-
-/*
- * INPUT_CAP_CHAPTERS:
- * The media streams provided by this plugin have an internal
- * structure dividing it into segments usable for navigation.
- * For those plugins, the behaviour of the skip button in UIs
- * should be changed from "next MRL" to "next chapter" by
- * sending XINE_EVENT_INPUT_NEXT.
- */
-
-#define INPUT_CAP_CHAPTERS 0x00000080
-
-/*
- * INPUT_CAP_RIP_FORBIDDEN:
- * means that rip/disk saving must not be used.
- * (probably at author's request)
- */
-
-#define INPUT_CAP_RIP_FORBIDDEN 0x00000100
-
-
-#define INPUT_IS_SEEKABLE(input) (((input)->get_capabilities(input) & INPUT_CAP_SEEKABLE) != 0)
-
-#define INPUT_OPTIONAL_UNSUPPORTED 0
-#define INPUT_OPTIONAL_SUCCESS 1
-
-#define INPUT_OPTIONAL_DATA_AUDIOLANG 2
-#define INPUT_OPTIONAL_DATA_SPULANG 3
-#define INPUT_OPTIONAL_DATA_PREVIEW 7
-
-#define MAX_MRL_ENTRIES 255
-#define MAX_PREVIEW_SIZE 4096
-
-/* Types of mrls returned by get_dir() */
-#define mrl_unknown (0 << 0)
-#define mrl_dvd (1 << 0)
-#define mrl_vcd (1 << 1)
-#define mrl_net (1 << 2)
-#define mrl_rtp (1 << 3)
-#define mrl_stdin (1 << 4)
-#define mrl_cda (1 << 5)
-#define mrl_file (1 << 6)
-#define mrl_file_fifo (1 << 7)
-#define mrl_file_chardev (1 << 8)
-#define mrl_file_directory (1 << 9)
-#define mrl_file_blockdev (1 << 10)
-#define mrl_file_normal (1 << 11)
-#define mrl_file_symlink (1 << 12)
-#define mrl_file_sock (1 << 13)
-#define mrl_file_exec (1 << 14)
-#define mrl_file_backup (1 << 15)
-#define mrl_file_hidden (1 << 16)
-
-/*
- * Freeing/zeroing all of entries of given mrl.
- */
-#define MRL_ZERO(m) { \
- if((m)) { \
- if((m)->origin) \
- free((m)->origin); \
- if((m)->mrl) \
- free((m)->mrl); \
- if((m)->link) \
- free((m)->link); \
- (m)->origin = NULL; \
- (m)->mrl = NULL; \
- (m)->link = NULL; \
- (m)->type = 0; \
- (m)->size = (off_t) 0; \
- } \
-}
-
-/*
- * Duplicate two mrls entries (s = source, d = destination).
- */
-#define MRL_DUPLICATE(s, d) { \
- _x_assert((s) != NULL); \
- _x_assert((d) != NULL); \
- \
- if((s)->origin) { \
- if((d)->origin) { \
- (d)->origin = (char *) realloc((d)->origin, strlen((s)->origin) + 1); \
- sprintf((d)->origin, "%s", (s)->origin); \
- } \
- else \
- (d)->origin = strdup((s)->origin); \
- } \
- else \
- (d)->origin = NULL; \
- \
- if((s)->mrl) { \
- if((d)->mrl) { \
- (d)->mrl = (char *) realloc((d)->mrl, strlen((s)->mrl) + 1); \
- sprintf((d)->mrl, "%s", (s)->mrl); \
- } \
- else \
- (d)->mrl = strdup((s)->mrl); \
- } \
- else \
- (d)->mrl = NULL; \
- \
- if((s)->link) { \
- if((d)->link) { \
- (d)->link = (char *) realloc((d)->link, strlen((s)->link) + 1); \
- sprintf((d)->link, "%s", (s)->link); \
- } \
- else \
- (d)->link = strdup((s)->link); \
- } \
- else \
- (d)->link = NULL; \
- \
- (d)->type = (s)->type; \
- (d)->size = (s)->size; \
-}
-
-/*
- * Duplicate two arrays of mrls (s = source, d = destination).
- */
-#define MRLS_DUPLICATE(s, d) { \
- int i = 0; \
- \
- _x_assert((s) != NULL); \
- _x_assert((d) != NULL); \
- \
- while((s) != NULL) { \
- d[i] = (xine_mrl_t *) malloc(sizeof(xine_mrl_t)); \
- MRL_DUPLICATE(s[i], d[i]); \
- i++; \
- } \
-}
-
-
-#endif
diff --git a/src/input/input_pnm.c b/src/input/input_pnm.c
index 3bc026b69..e11e3b361 100644
--- a/src/input/input_pnm.c
+++ b/src/input/input_pnm.c
@@ -41,9 +41,9 @@
*/
#include "bswap.h"
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#include "pnm.h"
#include "net_buf_ctrl.h"
@@ -83,8 +83,6 @@ static off_t pnm_plugin_read (input_plugin_t *this_gen,
lprintf ("pnm_plugin_read: %"PRId64" bytes ...\n", len);
- nbc_check_buffers (this->nbc);
-
n = pnm_read (this->pnm, buf, len);
this->curpos += n;
diff --git a/src/input/input_pvr.c b/src/input/input_pvr.c
index ac7c5f2f0..740d51665 100644
--- a/src/input/input_pvr.c
+++ b/src/input/input_pvr.c
@@ -108,10 +108,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/input_plugin.h>
#define PVR_DEVICE "/dev/video0"
@@ -511,10 +511,7 @@ static char *make_temp_name(pvr_input_plugin_t *this, int page) {
char *filename;
- int size = strlen(this->tmp_prefix)+PVR_FILENAME_SIZE;
- filename = malloc(size);
-
- snprintf(filename, size, PVR_FILENAME, this->tmp_prefix, this->session, page);
+ asprintf(&filename, PVR_FILENAME, this->tmp_prefix, this->session, page);
return filename;
}
@@ -527,12 +524,9 @@ static char *make_base_save_name(int channel, time_t tm) {
struct tm rec_time;
char *filename;
- int size = SAVE_BASE_FILENAME_SIZE;
- filename = malloc(size);
-
localtime_r(&tm, &rec_time);
- snprintf(filename, size, SAVE_BASE_FILENAME,
+ asprintf(&filename, SAVE_BASE_FILENAME,
channel, rec_time.tm_mon+1, rec_time.tm_mday,
rec_time.tm_year+1900, rec_time.tm_hour, rec_time.tm_min,
rec_time.tm_sec);
@@ -546,10 +540,7 @@ static char *make_save_name(pvr_input_plugin_t *this, char *base, int page) {
char *filename;
- int size = strlen(this->save_prefix)+strlen(base)+SAVE_FILENAME_SIZE;
- filename = malloc(size);
-
- snprintf(filename, size, SAVE_FILENAME, this->save_prefix, base, page);
+ asprintf(&filename, SAVE_FILENAME, this->save_prefix, base, page);
return filename;
}
@@ -988,69 +979,92 @@ static void pvr_event_handler (pvr_input_plugin_t *this) {
/* make sure we are not paused */
_x_set_speed(this->stream, XINE_SPEED_NORMAL);
- if( v4l2_data->session_id != this->session ) {
- /* if session changes -> closes the old one */
- pthread_mutex_lock(&this->lock);
- pvr_finish_recording(this);
- time(&this->start_time);
- this->show_time = this->start_time;
- this->session = v4l2_data->session_id;
- this->new_session = 1;
- this->pvr_play_paused = 0;
- this->scr_tunning = 0;
- pvrscr_speed_tunning(this->scr, 1.0 );
- pvr_break_rec_page(this);
- pthread_mutex_unlock(&this->lock);
- _x_demux_flush_engine (this->stream);
- } else {
- /* no session change, break the page and store a new show_time */
- pthread_mutex_lock(&this->lock);
- pvr_break_rec_page(this);
- this->show_page = this->rec_page;
- pthread_mutex_unlock(&this->lock);
- time(&this->show_time);
+ if ( v4l2_data->session_id != -1) {
+ if( v4l2_data->session_id != this->session ) {
+ /* if session changes -> closes the old one */
+ pthread_mutex_lock(&this->lock);
+ pvr_finish_recording(this);
+ time(&this->start_time);
+ this->show_time = this->start_time;
+ this->session = v4l2_data->session_id;
+ this->new_session = 1;
+ this->pvr_play_paused = 0;
+ this->scr_tunning = 0;
+ pvrscr_speed_tunning(this->scr, 1.0 );
+ pvr_break_rec_page(this);
+ pthread_mutex_unlock(&this->lock);
+ _x_demux_flush_engine (this->stream);
+ } else {
+ /* no session change, break the page and store a new show_time */
+ pthread_mutex_lock(&this->lock);
+ pvr_break_rec_page(this);
+ this->show_page = this->rec_page;
+ pthread_mutex_unlock(&this->lock);
+ time(&this->show_time);
+ }
}
-
- if( (v4l2_data->input != -1 && v4l2_data->input != this->input) ||
- (v4l2_data->channel != -1 && v4l2_data->channel != this->channel) ||
- (v4l2_data->frequency != -1 && v4l2_data->frequency != this->frequency) ) {
- struct v4l2_frequency vf;
+ pthread_mutex_lock(&this->dev_lock);
+
+ /* change input */
+ if (v4l2_data->input != -1 && v4l2_data->input != this->input) {
this->input = v4l2_data->input;
+
+ /* as of ivtv 0.10.6: must close and reopen to set input */
+ close(this->dev_fd);
+ this->dev_fd = open (this->class->devname, O_RDWR);
+ if (this->dev_fd < 0) {
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "input_pvr: error opening device %s\n", this->class->devname );
+ } else {
+ if( ioctl(this->dev_fd, VIDIOC_S_INPUT, &this->input) == 0 ) {
+ lprintf("Tuner Input set to:%d\n", v4l2_data->input);
+ } else {
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "input_pvr: error setting v4l2 input\n");
+ }
+ }
+ }
+
+ /* change channel */
+ if (v4l2_data->channel != -1 && v4l2_data->channel != this->channel) {
+ lprintf("change channel to:%d\n", v4l2_data->channel);
this->channel = v4l2_data->channel;
+ }
+
+ /* change frequency */
+ if (v4l2_data->frequency != -1 && v4l2_data->frequency != this->frequency) {
+ double freq = (double)v4l2_data->frequency / 1000.0;
+ struct v4l2_frequency vf;
+ struct v4l2_tuner vt;
+ double fac = 16;
+
+ memset(&vf, 0, sizeof(vf));
+ memset(&vt, 0, sizeof(vt));
+
this->frequency = v4l2_data->frequency;
- lprintf("switching to input:%d chan:%d freq:%.2f\n",
- v4l2_data->input,
- v4l2_data->channel,
- (float)v4l2_data->frequency * 62.5);
-
- pthread_mutex_lock(&this->dev_lock);
- if( ioctl(this->dev_fd, VIDIOC_S_INPUT, &this->input) )
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "input_pvr: error setting v4l2 input\n");
-
- vf.frequency = this->frequency;
+ if (ioctl(this->dev_fd, VIDIOC_G_TUNER, &vt) == 0) {
+ fac = (vt.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16;
+ }
+
vf.tuner = 0;
- if( ioctl(this->dev_fd, VIDIOC_S_FREQUENCY, &vf) )
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "input_pvr: error setting v4l2 frequency\n");
+ vf.type = vt.type;
+ vf.frequency = (__u32)(freq * fac);
- /* workaround an ivtv bug where stream gets bad mpeg2 artifacts
- * after changing inputs. reopening the device fixes it.
- */
- close(this->dev_fd);
- this->dev_fd = open (this->class->devname, O_RDWR);
- if (this->dev_fd == -1) {
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "input_pvr: error opening device %s\n", this->class->devname );
- return;
+ if (ioctl(this->dev_fd, VIDIOC_S_FREQUENCY, &vf) == 0) {
+ lprintf("Tuner Frequency set to %d (%f.3 MHz)\n", vf.frequency, vf.frequency / fac);
+ } else {
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "input_pvr: error setting v4l2 frequency\n");
}
- pthread_mutex_unlock(&this->dev_lock);
-
- /* FIXME: also flush the device */
- /* _x_demux_flush_engine(this->stream); */
}
+
+ pthread_mutex_unlock(&this->dev_lock);
+
+ /* FIXME: also flush the device */
+ /* _x_demux_flush_engine(this->stream); */
+
break;
diff --git a/src/input/input_rtp.c b/src/input/input_rtp.c
index c3abf4bf5..33183e555 100644
--- a/src/input/input_rtp.c
+++ b/src/input/input_rtp.c
@@ -91,9 +91,9 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#include "net_buf_ctrl.h"
#ifdef __GNUC__
diff --git a/src/input/input_rtsp.c b/src/input/input_rtsp.c
index 690507d88..e2b1bae99 100644
--- a/src/input/input_rtsp.c
+++ b/src/input/input_rtsp.c
@@ -41,9 +41,9 @@
*/
#include "bswap.h"
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#include "librtsp/rtsp_session.h"
#include "net_buf_ctrl.h"
@@ -83,8 +83,6 @@ static off_t rtsp_plugin_read (input_plugin_t *this_gen,
lprintf ("rtsp_plugin_read: %"PRId64" bytes ...\n", len);
- nbc_check_buffers (this->nbc);
-
n = rtsp_session_read (this->rtsp, buf, len);
this->curpos += n;
diff --git a/src/input/input_smb.c b/src/input/input_smb.c
index 8bbbfdfe5..44fa96bfd 100644
--- a/src/input/input_smb.c
+++ b/src/input/input_smb.c
@@ -23,10 +23,10 @@
#include "config.h"
#endif
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/input_plugin.h>
#include <libsmbclient.h>
#include <sys/types.h>
diff --git a/src/input/input_stdin_fifo.c b/src/input/input_stdin_fifo.c
index e28a8d0c3..d67954ea8 100644
--- a/src/input/input_stdin_fifo.c
+++ b/src/input/input_stdin_fifo.c
@@ -36,9 +36,9 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#include "net_buf_ctrl.h"
#define BUFSIZE 1024
diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c
index ff9ea87d0..df0e0e48b 100644
--- a/src/input/input_v4l.c
+++ b/src/input/input_v4l.c
@@ -88,9 +88,9 @@ static char *log_line_prefix()
}
#endif
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#define NUM_FRAMES 15
@@ -110,12 +110,15 @@ static const resolution_t resolutions[] = {
{ 160, 120 }
};
-static char *tv_standard_names[] = { "PAL", "NTSC", "SECAM", NULL };
-static int tv_standard_values[] = { VIDEO_MODE_PAL, VIDEO_MODE_NTSC, VIDEO_MODE_SECAM };
+static const char *const tv_standard_names[] = { "PAL", "NTSC", "SECAM", NULL };
+static const int tv_standard_values[] = { VIDEO_MODE_PAL, VIDEO_MODE_NTSC, VIDEO_MODE_SECAM };
#define NUM_RESOLUTIONS (sizeof(resolutions)/sizeof(resolutions[0]))
-#define RADIO_DEV "/dev/v4l/radio0"
-#define VIDEO_DEV "/dev/v4l/video0"
+#define RADIO_DEV "/dev/radio0"
+#define VIDEO_DEV "/dev/video0"
+#ifdef HAVE_ALSA
+#define AUDIO_DEV "plughw:0,0"
+#endif
#if !defined(NDELAY) && defined(O_NDELAY)
#define FNDELAY O_NDELAY
@@ -913,7 +916,7 @@ static int open_video_capture_device(v4l_input_plugin_t *this)
if (ret < 0) {
close (this->video_fd);
this->video_fd = -1;
- lprintf("Grab: no colorspace format found\n");
+ lprintf("Grab: no colour space format found\n");
return 0;
}
else
@@ -1732,6 +1735,9 @@ static input_plugin_t *v4l_class_get_instance (input_class_t *cls_gen,
{
/* v4l_input_class_t *cls = (v4l_input_class_t *) cls_gen; */
v4l_input_plugin_t *this;
+#ifdef HAVE_ALSA
+ cfg_entry_t *entry;
+#endif
char *mrl = strdup(data);
/* Example mrl: v4l:/Television/62500 */
@@ -1752,13 +1758,14 @@ static input_plugin_t *v4l_class_get_instance (input_class_t *cls_gen,
this->event_queue = NULL;
this->scr = NULL;
#ifdef HAVE_ALSA
- this->pcm_name = NULL;
this->pcm_data = NULL;
this->pcm_hwparams = NULL;
/* Audio */
this->pcm_stream = SND_PCM_STREAM_CAPTURE;
- this->pcm_name = strdup("plughw:0,0");
+ entry = this->stream->xine->config->lookup_entry(this->stream->xine->config,
+ "media.video4linux.audio_device");
+ this->pcm_name = strdup (entry->str_value);
this->audio_capture = 1;
#endif
this->rate = 44100;
@@ -1928,6 +1935,14 @@ static void *init_video_class (xine_t *xine, void *data)
_("Selects the TV standard of the input signals. "
"Either: PAL, NTSC and SECAM. "), 20, NULL, NULL);
+#ifdef HAVE_ALSA
+ config->register_filename (config, "media.video4linux.audio_device",
+ AUDIO_DEV, 0,
+ _("v4l ALSA audio input device"),
+ _("The name of the audio device which corresponds "
+ "to your Video4Linux video device."),
+ 10, NULL, NULL);
+#endif
return this;
}
diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c
index 14a924a2a..4b624a9e7 100644
--- a/src/input/input_vcd.c
+++ b/src/input/input_vcd.c
@@ -45,9 +45,9 @@
#error "you need to add cdrom / VCD support for your platform to input_vcd and configure.in"
#endif
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#include "media_helper.h"
#if defined(__sun)
diff --git a/src/input/libdvdnav/dvd_reader.c b/src/input/libdvdnav/dvd_reader.c
index 200a1dbec..c15a5c3f5 100644
--- a/src/input/libdvdnav/dvd_reader.c
+++ b/src/input/libdvdnav/dvd_reader.c
@@ -70,7 +70,7 @@ static inline int _private_gettimeofday( struct timeval *tv, void *tz )
#include <mntent.h>
#endif
-#include "compat.h"
+#include <xine/compat.h>
#include "dvd_udf.h"
#include "dvd_input.h"
#include "dvd_reader.h"
diff --git a/src/input/libreal/asmrp.c b/src/input/libreal/asmrp.c
index f7206b583..9fc7a3867 100644
--- a/src/input/libreal/asmrp.c
+++ b/src/input/libreal/asmrp.c
@@ -43,7 +43,7 @@
*/
#include "asmrp.h"
-#include "xineutils.h"
+#include <xine/xineutils.h>
#define ASMRP_SYM_NONE 0
#define ASMRP_SYM_EOF 1
diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c
index 9ea65d9df..078b12757 100644
--- a/src/input/libreal/real.c
+++ b/src/input/libreal/real.c
@@ -33,8 +33,8 @@
#include "real.h"
#include "asmrp.h"
#include "sdpplin.h"
-#include "xine_internal.h"
-#include "xineutils.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
#include "bswap.h"
#define XOR_TABLE_LEN 37
@@ -316,14 +316,13 @@ void real_calc_response_and_checksum (char *response, char *chksum, char *challe
int ch_len, resp_len;
int i;
char *ptr;
- char buf[128];
+ char buf[128] = { 0, };
/* initialize return values */
memset(response, 0, 64);
memset(chksum, 0, 34);
/* initialize buffer */
- memset(buf, 0, 128);
ptr=buf;
_X_BE_32C(ptr, 0xa1e9149d);
ptr+=4;
@@ -353,10 +352,10 @@ void real_calc_response_and_checksum (char *response, char *chksum, char *challe
calc_response_string (response, buf);
/* add tail */
- resp_len = strlen (response);
- strcpy (&response[resp_len], "01d0a8e3");
+ strcat(response, "01d0a8e3");
/* calculate checksum */
+ resp_len = strlen (response);
for (i=0; i<resp_len/4; i++)
chksum[i] = response[i*4];
}
@@ -660,7 +659,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid
lprintf("Stream description size: %i\n", size);
- description = malloc(sizeof(char)*(size+1));
+ description = calloc(size+1, sizeof(char));
if( rtsp_read_data(rtsp_session, description, size) <= 0) {
xine_buffer_free(buf);
diff --git a/src/input/libreal/rmff.c b/src/input/libreal/rmff.c
index 159b81ee6..1600e967a 100644
--- a/src/input/libreal/rmff.c
+++ b/src/input/libreal/rmff.c
@@ -27,7 +27,7 @@
#define LOG
*/
-#include "xineutils.h"
+#include <xine/xineutils.h>
#include "bswap.h"
#include "rmff.h"
@@ -35,9 +35,13 @@
* writes header data to a buffer
*/
-static void rmff_dump_fileheader(rmff_fileheader_t *fileheader, char *buffer) {
+static int rmff_dump_fileheader(rmff_fileheader_t *fileheader, uint8_t *buffer, int bufsize) {
+
+ if (!fileheader) return 0;
+
+ if (bufsize < RMFF_FILEHEADER_SIZE)
+ return -1;
- if (!fileheader) return;
fileheader->object_id=_X_BE_32(&fileheader->object_id);
fileheader->size=_X_BE_32(&fileheader->size);
fileheader->object_version=_X_BE_16(&fileheader->object_version);
@@ -53,11 +57,17 @@ static void rmff_dump_fileheader(rmff_fileheader_t *fileheader, char *buffer) {
fileheader->file_version=_X_BE_32(&fileheader->file_version);
fileheader->num_headers=_X_BE_32(&fileheader->num_headers);
fileheader->object_id=_X_BE_32(&fileheader->object_id);
+
+ return RMFF_FILEHEADER_SIZE;
}
-static void rmff_dump_prop(rmff_prop_t *prop, char *buffer) {
+static int rmff_dump_prop(rmff_prop_t *prop, uint8_t *buffer, int bufsize) {
+
+ if (!prop) return 0;
+
+ if (bufsize < RMFF_PROPHEADER_SIZE)
+ return -1;
- if (!prop) return;
prop->object_id=_X_BE_32(&prop->object_id);
prop->size=_X_BE_32(&prop->size);
prop->object_version=_X_BE_16(&prop->object_version);
@@ -93,13 +103,19 @@ static void rmff_dump_prop(rmff_prop_t *prop, char *buffer) {
prop->num_streams=_X_BE_16(&prop->num_streams);
prop->flags=_X_BE_16(&prop->flags);
prop->object_id=_X_BE_32(&prop->object_id);
+
+ return RMFF_PROPHEADER_SIZE;
}
-static void rmff_dump_mdpr(rmff_mdpr_t *mdpr, char *buffer) {
+static int rmff_dump_mdpr(rmff_mdpr_t *mdpr, uint8_t *buffer, int bufsize) {
int s1, s2, s3;
- if (!mdpr) return;
+ if (!mdpr) return 0;
+
+ if (bufsize < RMFF_MDPRHEADER_SIZE + mdpr->type_specific_len + mdpr->stream_name_size + mdpr->mime_type_size)
+ return -1;
+
mdpr->object_id=_X_BE_32(&mdpr->object_id);
mdpr->size=_X_BE_32(&mdpr->size);
mdpr->object_version=_X_BE_16(&mdpr->object_version);
@@ -141,13 +157,19 @@ static void rmff_dump_mdpr(rmff_mdpr_t *mdpr, char *buffer) {
mdpr->duration=_X_BE_32(&mdpr->duration);
mdpr->object_id=_X_BE_32(&mdpr->object_id);
+ return RMFF_MDPRHEADER_SIZE + s1 + s2 + s3;
}
-static void rmff_dump_cont(rmff_cont_t *cont, char *buffer) {
+static int rmff_dump_cont(rmff_cont_t *cont, uint8_t *buffer, int bufsize) {
int p;
- if (!cont) return;
+ if (!cont) return 0;
+
+ if (bufsize < RMFF_CONTHEADER_SIZE + cont->title_len + cont->author_len +
+ cont->copyright_len + cont->comment_len)
+ return -1;
+
cont->object_id=_X_BE_32(&cont->object_id);
cont->size=_X_BE_32(&cont->size);
cont->object_version=_X_BE_16(&cont->object_version);
@@ -181,11 +203,18 @@ static void rmff_dump_cont(rmff_cont_t *cont, char *buffer) {
cont->size=_X_BE_32(&cont->size);
cont->object_version=_X_BE_16(&cont->object_version);
cont->object_id=_X_BE_32(&cont->object_id);
+
+ return RMFF_CONTHEADER_SIZE + cont->title_len + cont->author_len +
+ cont->copyright_len + cont->comment_len;
}
-static void rmff_dump_dataheader(rmff_data_t *data, char *buffer) {
+static int rmff_dump_dataheader(rmff_data_t *data, uint8_t *buffer, int bufsize) {
+
+ if (!data) return 0;
+
+ if (bufsize < RMFF_DATAHEADER_SIZE)
+ return -1;
- if (!data) return;
data->object_id=_X_BE_32(&data->object_id);
data->size=_X_BE_32(&data->size);
data->object_version=_X_BE_16(&data->object_version);
@@ -201,36 +230,48 @@ static void rmff_dump_dataheader(rmff_data_t *data, char *buffer) {
data->size=_X_BE_32(&data->size);
data->object_version=_X_BE_16(&data->object_version);
data->object_id=_X_BE_32(&data->object_id);
+
+ return RMFF_DATAHEADER_SIZE;
}
-int rmff_dump_header(rmff_header_t *h, char *buffer, int max) {
+int rmff_dump_header(rmff_header_t *h, void *buf_gen, int max) {
+ uint8_t *buffer = buf_gen;
- int written=0;
+ int written=0, size;
rmff_mdpr_t **stream=h->streams;
- rmff_dump_fileheader(h->fileheader, &buffer[written]);
- written+=h->fileheader->size;
- rmff_dump_prop(h->prop, &buffer[written]);
- written+=h->prop->size;
- rmff_dump_cont(h->cont, &buffer[written]);
- written+=h->cont->size;
+ if ((size=rmff_dump_fileheader(h->fileheader, &buffer[written], max)) < 0)
+ return -1;
+ written+=size;
+ max -= size;
+ if ((size=rmff_dump_prop(h->prop, &buffer[written], max)) < 0)
+ return -1;
+ written+=size;
+ max -= size;
+ if ((size=rmff_dump_cont(h->cont, &buffer[written], max)) < 0)
+ return -1;
+ written+=size;
+ max -= size;
if (stream)
{
while(*stream)
{
- rmff_dump_mdpr(*stream, &buffer[written]);
- written+=(*stream)->size;
+ if ((size=rmff_dump_mdpr(*stream, &buffer[written], max)) < 0)
+ return -1;
+ written+=size;
+ max -= size;
stream++;
}
}
- rmff_dump_dataheader(h->data, &buffer[written]);
- written+=18;
+ if ((size=rmff_dump_dataheader(h->data, &buffer[written], max)) < 0)
+ return -1;
+ written+=size;
return written;
}
-void rmff_dump_pheader(rmff_pheader_t *h, char *data) {
+void rmff_dump_pheader(rmff_pheader_t *h, uint8_t *data) {
data[0]=(h->object_version>>8) & 0xff;
data[1]=h->object_version & 0xff;
@@ -310,19 +351,13 @@ static rmff_mdpr_t *rmff_scan_mdpr(const char *data) {
mdpr->duration=_X_BE_32(&data[36]);
mdpr->stream_name_size=data[40];
- mdpr->stream_name = malloc(sizeof(char)*(mdpr->stream_name_size+1));
- memcpy(mdpr->stream_name, &data[41], mdpr->stream_name_size);
- mdpr->stream_name[mdpr->stream_name_size]=0;
+ mdpr->stream_name = xine_memdup0(&data[41], mdpr->stream_name_size);
mdpr->mime_type_size=data[41+mdpr->stream_name_size];
- mdpr->mime_type = malloc(sizeof(char)*(mdpr->mime_type_size+1));
- memcpy(mdpr->mime_type, &data[42+mdpr->stream_name_size], mdpr->mime_type_size);
- mdpr->mime_type[mdpr->mime_type_size]=0;
+ mdpr->mime_type = xine_memdup0(&data[42+mdpr->stream_name_size], mdpr->mime_type_size);
mdpr->type_specific_len=_X_BE_32(&data[42+mdpr->stream_name_size+mdpr->mime_type_size]);
- mdpr->type_specific_data = malloc(sizeof(char)*(mdpr->type_specific_len));
- memcpy(mdpr->type_specific_data,
- &data[46+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len);
+ mdpr->type_specific_data = xine_memdup(&data[46+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len);
return mdpr;
}
@@ -340,24 +375,17 @@ static rmff_cont_t *rmff_scan_cont(const char *data) {
lprintf("warning: unknown object version in CONT: 0x%04x\n", cont->object_version);
}
cont->title_len=_X_BE_16(&data[10]);
- cont->title = malloc(sizeof(char)*(cont->title_len+1));
- memcpy(cont->title, &data[12], cont->title_len);
- cont->title[cont->title_len]=0;
+ cont->title = xine_memdup0(&data[12], cont->title_len);
pos=cont->title_len+12;
cont->author_len=_X_BE_16(&data[pos]);
- cont->author = malloc(sizeof(char)*(cont->author_len+1));
- memcpy(cont->author, &data[pos+2], cont->author_len);
- cont->author[cont->author_len]=0;
+ cont->author = xine_memdup0(&data[pos+2], cont->author_len);
pos=pos+2+cont->author_len;
cont->copyright_len=_X_BE_16(&data[pos]);
- cont->copyright = malloc(sizeof(char)*(cont->copyright_len+1));
- memcpy(cont->copyright, &data[pos+2], cont->copyright_len);
+ cont->copyright = xine_memdup0(&data[pos+2], cont->copyright_len);
cont->copyright[cont->copyright_len]=0;
pos=pos+2+cont->copyright_len;
cont->comment_len=_X_BE_16(&data[pos]);
- cont->comment = malloc(sizeof(char)*(cont->comment_len+1));
- memcpy(cont->comment, &data[pos+2], cont->comment_len);
- cont->comment[cont->comment_len]=0;
+ cont->comment = xine_memdup0(&data[pos+2], cont->comment_len);
return cont;
}
@@ -403,10 +431,7 @@ rmff_header_t *rmff_scan_header(const char *data) {
header->fileheader=rmff_scan_fileheader(ptr);
ptr += header->fileheader->size;
- header->streams = malloc(sizeof(rmff_mdpr_t*)*(header->fileheader->num_headers));
- for (i=0; i<header->fileheader->num_headers; i++) {
- header->streams[i]=NULL;
- }
+ header->streams = calloc(header->fileheader->num_headers, sizeof(rmff_mdpr_t*));
for (i=1; i<header->fileheader->num_headers; i++) {
chunk_type = _X_BE_32(ptr);
@@ -450,6 +475,7 @@ rmff_header_t *rmff_scan_header(const char *data) {
return header;
}
+#if 0
rmff_header_t *rmff_scan_header_stream(int fd) {
rmff_header_t *header;
@@ -500,6 +526,7 @@ void rmff_scan_pheader(rmff_pheader_t *h, char *data) {
h->reserved=(uint8_t)data[10];
h->flags=(uint8_t)data[11];
}
+#endif
rmff_fileheader_t *rmff_new_fileheader(uint32_t num_headers) {
@@ -586,8 +613,7 @@ rmff_mdpr_t *rmff_new_mdpr(
mdpr->mime_type_size=strlen(mime_type);
}
mdpr->type_specific_len=type_specific_len;
- mdpr->type_specific_data = malloc(sizeof(char)*type_specific_len);
- memcpy(mdpr->type_specific_data,type_specific_data,type_specific_len);
+ mdpr->type_specific_data = xine_memdup(type_specific_data,type_specific_len);
mdpr->mlti_data=NULL;
mdpr->size=mdpr->stream_name_size+mdpr->mime_type_size+mdpr->type_specific_len+46;
@@ -646,6 +672,7 @@ rmff_data_t *rmff_new_dataheader(uint32_t num_packets, uint32_t next_data_header
return data;
}
+#if 0
void rmff_print_header(rmff_header_t *h) {
rmff_mdpr_t **stream;
@@ -712,6 +739,7 @@ void rmff_print_header(rmff_header_t *h) {
printf("next DATA : 0x%08x\n", h->data->next_data_header);
}
}
+#endif
void rmff_fix_header(rmff_header_t *h) {
@@ -820,6 +848,7 @@ void rmff_fix_header(rmff_header_t *h) {
}
}
+#if 0
int rmff_get_header_size(rmff_header_t *h) {
if (!h) return 0;
@@ -859,3 +888,4 @@ void rmff_free_header(rmff_header_t *h) {
}
free(h);
}
+#endif
diff --git a/src/input/libreal/rmff.h b/src/input/libreal/rmff.h
index d39942088..3fe3af284 100644
--- a/src/input/libreal/rmff.h
+++ b/src/input/libreal/rmff.h
@@ -39,6 +39,12 @@
#define RMFF_HEADER_SIZE 0x12
+#define RMFF_FILEHEADER_SIZE 18
+#define RMFF_PROPHEADER_SIZE 50
+#define RMFF_MDPRHEADER_SIZE 46
+#define RMFF_CONTHEADER_SIZE 18
+#define RMFF_DATAHEADER_SIZE 18
+
#define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \
(((long)(unsigned char)(ch3) ) | \
( (long)(unsigned char)(ch2) << 8 ) | \
@@ -216,6 +222,7 @@ rmff_data_t *rmff_new_dataheader(
*/
rmff_header_t *rmff_scan_header(const char *data);
+#if 0
/*
* scans a data packet header. Notice, that this function does not allocate
* the header struct itself.
@@ -231,30 +238,35 @@ rmff_header_t *rmff_scan_header_stream(int fd);
* prints header information in human readible form to stdout
*/
void rmff_print_header(rmff_header_t *h);
+#endif
/*
* does some checks and fixes header if possible
*/
void rmff_fix_header(rmff_header_t *h);
+#if 0
/*
* returns the size of the header (incl. first data-header)
*/
int rmff_get_header_size(rmff_header_t *h);
+#endif
/*
* dumps the header <h> to <buffer>. <max> is the size of <buffer>
*/
-int rmff_dump_header(rmff_header_t *h, char *buffer, int max);
+int rmff_dump_header(rmff_header_t *h, void *buffer, int max);
/*
* dumps a packet header
*/
-void rmff_dump_pheader(rmff_pheader_t *h, char *data);
+void rmff_dump_pheader(rmff_pheader_t *h, uint8_t *data);
+#if 0
/*
* frees a header struct
*/
void rmff_free_header(rmff_header_t *h);
+#endif
#endif
diff --git a/src/input/libreal/sdpplin.c b/src/input/libreal/sdpplin.c
index c62b6bbc1..d58a3d1fe 100644
--- a/src/input/libreal/sdpplin.c
+++ b/src/input/libreal/sdpplin.c
@@ -29,7 +29,7 @@
#include "rmff.h"
#include "rtsp.h"
#include "sdpplin.h"
-#include "xineutils.h"
+#include <xine/xineutils.h>
/*
* Decodes base64 strings (based upon b64 package)
@@ -199,8 +199,7 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data) {
if(filter(*data,"a=OpaqueData:buffer;",&buf)) {
decoded = b64_decode(buf, decoded, &(desc->mlti_data_size));
if ( decoded != NULL ) {
- desc->mlti_data = malloc(sizeof(char)*desc->mlti_data_size);
- memcpy(desc->mlti_data, decoded, desc->mlti_data_size);
+ desc->mlti_data = xine_memdup(decoded, desc->mlti_data_size);
handled=1;
*data=nl(*data);
lprintf("mlti_data_size: %i\n", desc->mlti_data_size);
@@ -294,7 +293,7 @@ sdpplin_t *sdpplin_parse(char *data) {
if(filter(data,"a=StreamCount:integer;",&buf)) {
desc->stream_count=atoi(buf);
- desc->stream = malloc(sizeof(sdpplin_stream_t*)*desc->stream_count);
+ desc->stream = calloc(desc->stream_count, sizeof(sdpplin_stream_t*));
handled=1;
data=nl(data);
}
diff --git a/src/input/librtsp/rtsp.c b/src/input/librtsp/rtsp.c
index 530ffc6cf..c660751fe 100644
--- a/src/input/librtsp/rtsp.c
+++ b/src/input/librtsp/rtsp.c
@@ -21,6 +21,8 @@
* *not* RFC 2326 compilant yet.
*/
+#include <config.h>
+
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
@@ -43,8 +45,8 @@
*/
#include "rtsp.h"
-#include "io_helper.h"
-#include "xineutils.h"
+#include <xine/io_helper.h>
+#include <xine/xineutils.h>
#define BUF_SIZE 4096
#define HEADER_SIZE 1024
@@ -77,7 +79,7 @@ struct rtsp_s {
* constants
*/
-const char rtsp_protocol_version[]="RTSP/1.0";
+static const char rtsp_protocol_version[]="RTSP/1.0";
/* server states */
#define RTSP_CONNECTED 1
@@ -103,8 +105,7 @@ const char rtsp_protocol_version[]="RTSP/1.0";
*/
static char *rtsp_get(rtsp_t *s) {
-
- char *buffer = malloc(BUF_SIZE);
+ char buffer[BUF_SIZE];
char *string = NULL;
if ( _x_io_tcp_read_line(s->stream, s->s, buffer, BUF_SIZE) >= 0 ) {
@@ -112,7 +113,6 @@ static char *rtsp_get(rtsp_t *s) {
string = strdup( buffer );
}
- free(buffer);
return string;
}
@@ -124,7 +124,7 @@ static char *rtsp_get(rtsp_t *s) {
static void rtsp_put(rtsp_t *s, const char *string) {
int len=strlen(string);
- char *buf = malloc(sizeof(char)*len+2);
+ char buf[len+2];
lprintf(">> '%s'", string);
@@ -135,8 +135,6 @@ static void rtsp_put(rtsp_t *s, const char *string) {
_x_io_tcp_write(s->stream, s->s, buf, len+2);
lprintf("done.\n");
-
- free(buf);
}
/*
@@ -171,13 +169,11 @@ static int rtsp_get_code(rtsp_t *s, const char *string) {
static void rtsp_send_request(rtsp_t *s, const char *type, const char *what) {
char **payload=s->scheduled;
- char *buf;
-
- buf = malloc(strlen(type)+strlen(what)+strlen(rtsp_protocol_version)+3);
+ char buf[strlen(type)+strlen(what)+strlen(rtsp_protocol_version)+3];
sprintf(buf,"%s %s %s",type, what, rtsp_protocol_version);
rtsp_put(s,buf);
- free(buf);
+
if (payload)
while (*payload) {
rtsp_put(s,*payload);
@@ -199,11 +195,9 @@ static void rtsp_schedule_standard(rtsp_t *s) {
rtsp_schedule_field(s, tmp);
if (s->session) {
- char *buf;
- buf = malloc(strlen(s->session)+15);
+ char buf[strlen(s->session)+15];
sprintf(buf, "Session: %s", s->session);
rtsp_schedule_field(s, buf);
- free(buf);
}
}
/*
@@ -241,14 +235,13 @@ static int rtsp_get_answers(rtsp_t *s) {
}
}
if (!strncasecmp(answer,"Server:",7)) {
- char *buf = xine_xmalloc(strlen(answer));
+ char buf[strlen(answer)];
sscanf(answer,"%*s %s",buf);
if (s->server) free(s->server);
s->server=strdup(buf);
- free(buf);
}
if (!strncasecmp(answer,"Session:",8)) {
- char *buf = xine_xmalloc(strlen(answer));
+ char buf[strlen(answer)];
sscanf(answer,"%*s %s",buf);
if (s->session) {
if (strcmp(buf, s->session)) {
@@ -263,7 +256,6 @@ static int rtsp_get_answers(rtsp_t *s) {
s->session=strdup(buf);
}
- free(buf);
}
*answer_ptr=answer;
answer_ptr++;
@@ -304,8 +296,7 @@ int rtsp_request_options(rtsp_t *s, const char *what) {
buf=strdup(what);
} else
{
- buf = malloc(sizeof(char)*(strlen(s->host)+16));
- sprintf(buf,"rtsp://%s:%i", s->host, s->port);
+ asprintf(&buf,"rtsp://%s:%i", s->host, s->port);
}
rtsp_send_request(s,"OPTIONS",buf);
free(buf);
@@ -321,8 +312,7 @@ int rtsp_request_describe(rtsp_t *s, const char *what) {
buf=strdup(what);
} else
{
- buf = malloc(sizeof(char)*(strlen(s->host)+strlen(s->path)+16));
- sprintf(buf,"rtsp://%s:%i/%s", s->host, s->port, s->path);
+ asprintf(&buf,"rtsp://%s:%i/%s", s->host, s->port, s->path);
}
rtsp_send_request(s,"DESCRIBE",buf);
free(buf);
@@ -345,8 +335,7 @@ int rtsp_request_setparameter(rtsp_t *s, const char *what) {
buf=strdup(what);
} else
{
- buf = malloc(sizeof(char)*(strlen(s->host)+strlen(s->path)+16));
- sprintf(buf,"rtsp://%s:%i/%s", s->host, s->port, s->path);
+ asprintf(&buf,"rtsp://%s:%i/%s", s->host, s->port, s->path);
}
rtsp_send_request(s,"SET_PARAMETER",buf);
free(buf);
@@ -362,8 +351,7 @@ int rtsp_request_play(rtsp_t *s, const char *what) {
buf=strdup(what);
} else
{
- buf = malloc(sizeof(char)*(strlen(s->host)+strlen(s->path)+16));
- sprintf(buf,"rtsp://%s:%i/%s", s->host, s->port, s->path);
+ asprintf(&buf,"rtsp://%s:%i/%s", s->host, s->port, s->path);
}
rtsp_send_request(s,"PLAY",buf);
free(buf);
@@ -371,19 +359,21 @@ int rtsp_request_play(rtsp_t *s, const char *what) {
return rtsp_get_answers(s);
}
+#if 0
int rtsp_request_tearoff(rtsp_t *s, const char *what) {
rtsp_send_request(s,"TEAROFF",what);
return rtsp_get_answers(s);
}
+#endif
/*
* read opaque data from stream
*/
-int rtsp_read_data(rtsp_t *s, char *buffer, unsigned int size) {
-
+int rtsp_read_data(rtsp_t *s, void *buffer_gen, unsigned int size) {
+ uint8_t *buffer = buffer_gen;
int i,seq;
if (size>=4) {
@@ -412,8 +402,7 @@ int rtsp_read_data(rtsp_t *s, char *buffer, unsigned int size) {
}
/* lets make the server happy */
rtsp_put(s, "RTSP/1.0 451 Parameter Not Understood");
- rest = malloc(sizeof(char)*17);
- sprintf(rest,"CSeq: %u", seq);
+ asprintf(&rest,"CSeq: %u", seq);
rtsp_put(s, rest);
free(rest);
rtsp_put(s, "");
@@ -486,9 +475,7 @@ rtsp_t *rtsp_connect(xine_stream_t *stream, const char *mrl, const char *user_ag
pathbegin=slash-mrl_ptr;
hostend=colon-mrl_ptr;
- s->host = malloc(sizeof(char)*hostend+1);
- strncpy(s->host, mrl_ptr, hostend);
- s->host[hostend]=0;
+ s->host = strndup(mrl_ptr, hostend);
if (pathbegin < strlen(mrl_ptr)) s->path=strdup(mrl_ptr+pathbegin+1);
if (colon != slash) {
@@ -572,6 +559,7 @@ char *rtsp_search_answers(rtsp_t *s, const char *tag) {
return NULL;
}
+#if 0
/*
* session id management
*/
@@ -589,6 +577,7 @@ char *rtsp_get_session(rtsp_t *s) {
return s->session;
}
+#endif
char *rtsp_get_mrl(rtsp_t *s) {
@@ -612,6 +601,7 @@ void rtsp_schedule_field(rtsp_t *s, const char *string) {
s->scheduled[i]=strdup(string);
}
+#if 0
/*
* removes the first scheduled field which prefix matches string.
*/
@@ -632,6 +622,7 @@ void rtsp_unschedule_field(rtsp_t *s, const char *string) {
*(ptr-1)=*ptr;
} while(*ptr);
}
+#endif
/*
* unschedule all fields
diff --git a/src/input/librtsp/rtsp.h b/src/input/librtsp/rtsp.h
index dc2624459..1cec57e1e 100644
--- a/src/input/librtsp/rtsp.h
+++ b/src/input/librtsp/rtsp.h
@@ -25,7 +25,7 @@
#define HAVE_RTSP_H
/*#include <inttypes.h> */
-#include "xine_internal.h"
+#include <xine/xine_internal.h>
#ifdef __CYGWIN__
#define uint32_t unsigned int
@@ -47,11 +47,13 @@ int rtsp_request_describe(rtsp_t *s, const char *what);
int rtsp_request_setup(rtsp_t *s, const char *what);
int rtsp_request_setparameter(rtsp_t *s, const char *what);
int rtsp_request_play(rtsp_t *s, const char *what);
+#if 0
int rtsp_request_tearoff(rtsp_t *s, const char *what);
+#endif
int rtsp_send_ok(rtsp_t *s);
-int rtsp_read_data(rtsp_t *s, char *buffer, unsigned int size);
+int rtsp_read_data(rtsp_t *s, void *buffer, unsigned int size);
char* rtsp_search_answers(rtsp_t *s, const char *tag);
void rtsp_add_to_payload(char **payload, const char *string);
@@ -61,15 +63,19 @@ void rtsp_free_answers(rtsp_t *this);
int rtsp_read (rtsp_t *this, char *data, int len);
void rtsp_close (rtsp_t *this);
+#if 0
void rtsp_set_session(rtsp_t *s, const char *id);
char *rtsp_get_session(rtsp_t *s);
+#endif
char *rtsp_get_mrl(rtsp_t *s);
/*int rtsp_peek_header (rtsp_t *this, char *data); */
void rtsp_schedule_field(rtsp_t *s, const char *string);
+#if 0
void rtsp_unschedule_field(rtsp_t *s, const char *string);
+#endif
void rtsp_unschedule_all(rtsp_t *s);
#endif
diff --git a/src/input/librtsp/rtsp_session.c b/src/input/librtsp/rtsp_session.c
index f3ddb59bc..d8f7ae583 100644
--- a/src/input/librtsp/rtsp_session.c
+++ b/src/input/librtsp/rtsp_session.c
@@ -41,7 +41,7 @@
#include "real.h"
#include "rmff.h"
#include "asmrp.h"
-#include "xineutils.h"
+#include <xine/xineutils.h>
#define BUF_SIZE 4096
#define HEADER_SIZE 4096
@@ -65,15 +65,15 @@ struct rtsp_session_s {
};
/* network bandwidth */
-const uint32_t rtsp_bandwidths[]={14400,19200,28800,33600,34430,57600,
- 115200,262200,393216,524300,1544000,10485800};
+static const uint32_t rtsp_bandwidths[]={14400,19200,28800,33600,34430,57600,
+ 115200,262200,393216,524300,1544000,10485800};
-const char *rtsp_bandwidth_strs[]={"14.4 Kbps (Modem)", "19.2 Kbps (Modem)",
- "28.8 Kbps (Modem)", "33.6 Kbps (Modem)",
- "34.4 Kbps (Modem)", "57.6 Kbps (Modem)",
- "115.2 Kbps (ISDN)", "262.2 Kbps (Cable/DSL)",
- "393.2 Kbps (Cable/DSL)","524.3 Kbps (Cable/DSL)",
- "1.5 Mbps (T1)", "10.5 Mbps (LAN)", NULL};
+static const char *const rtsp_bandwidth_strs[]={"14.4 Kbps (Modem)", "19.2 Kbps (Modem)",
+ "28.8 Kbps (Modem)", "33.6 Kbps (Modem)",
+ "34.4 Kbps (Modem)", "57.6 Kbps (Modem)",
+ "115.2 Kbps (ISDN)", "262.2 Kbps (Cable/DSL)",
+ "393.2 Kbps (Cable/DSL)","524.3 Kbps (Cable/DSL)",
+ "1.5 Mbps (T1)", "10.5 Mbps (LAN)", NULL};
rtsp_session_t *rtsp_session_start(xine_stream_t *stream, char *mrl) {
@@ -87,7 +87,7 @@ rtsp_session_t *rtsp_session_start(xine_stream_t *stream, char *mrl) {
uint32_t bandwidth;
bandwidth_id = xine->config->register_enum(xine->config, "media.network.bandwidth", 10,
- (char **)rtsp_bandwidth_strs,
+ rtsp_bandwidth_strs,
_("network bandwidth"),
_("Specify the bandwidth of your internet connection here. "
"This will be used when streaming servers offer different versions "
@@ -148,6 +148,11 @@ connect:
rtsp_session->header_left =
rtsp_session->header_len = rmff_dump_header(h,rtsp_session->header,HEADER_SIZE);
+ if (rtsp_session->header_len < 0) {
+ xprintf (stream->xine, XINE_VERBOSITY_LOG,
+ _("rtsp_session: rtsp server returned overly-large headers, session can not be established.\n"));
+ goto session_abort;
+ }
xine_buffer_copyin(rtsp_session->recv, 0, rtsp_session->header, rtsp_session->header_len);
rtsp_session->recv_size = rtsp_session->header_len;
@@ -157,6 +162,7 @@ connect:
{
xprintf(stream->xine, XINE_VERBOSITY_LOG,
_("rtsp_session: rtsp server type '%s' not supported yet. sorry.\n"), server);
+ session_abort:
rtsp_close(rtsp_session->s);
free(server);
xine_buffer_free(rtsp_session->recv);
@@ -189,7 +195,7 @@ int rtsp_session_read (rtsp_session_t *this, char *data, int len) {
int to_copy;
char *dest=data;
- char *source=this->recv + this->recv_read;
+ uint8_t *source=this->recv + this->recv_read;
int fill=this->recv_size - this->recv_read;
if (len < 0)
diff --git a/src/input/media_helper.h b/src/input/media_helper.h
index 7e6303dfd..a8e376fdc 100644
--- a/src/input/media_helper.h
+++ b/src/input/media_helper.h
@@ -22,7 +22,7 @@
#ifndef HAVE_MEDIA_HELPER_H
#define HAVE_MEDIA_HELPER_H
-#include "xine_internal.h"
+#include <xine/xine_internal.h>
int media_eject_media (xine_t *xine, const char *device);
diff --git a/src/input/mms.c b/src/input/mms.c
index f11a89cf3..ba584b4f8 100644
--- a/src/input/mms.c
+++ b/src/input/mms.c
@@ -56,8 +56,8 @@
/*
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
#include "bswap.h"
#include "http_helper.h"
@@ -532,7 +532,7 @@ static int interp_asf_header (mms_t *this) {
return 1;
}
-static const char *const mmst_proto_s[] = { "mms", "mmst", NULL };
+static const char mmst_proto_s[][8] = { "mms", "mmst", "" };
static int mmst_valid_proto (char *proto) {
int i = 0;
@@ -542,7 +542,7 @@ static int mmst_valid_proto (char *proto) {
if (!proto)
return 0;
- while(mmst_proto_s[i]) {
+ while(*(mmst_proto_s[i])) {
if (!strcasecmp(proto, mmst_proto_s[i])) {
return 1;
}
@@ -601,7 +601,7 @@ static int mms_tcp_connect(mms_t *this) {
}
static void mms_gen_guid(char guid[]) {
- static char digit[16] = "0123456789ABCDEF";
+ static const char digit[16] = "0123456789ABCDEF";
int i = 0;
srand(time(NULL));
@@ -742,7 +742,7 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) {
/* TODO: insert network timing request here */
/* command 0x2 */
lprintf("send command 0x02\n");
- string_utf16 (url_conv, &this->scmd_body[8], "\002\000\\\\192.168.0.129\\TCP\\1037\0000", 28);
+ string_utf16 (url_conv, &this->scmd_body[8], (ICONV_CONST char*)"\002\000\\\\192.168.0.129\\TCP\\1037\0000", 28);
memset (this->scmd_body, 0, 8);
if (!send_command (this, 2, 0, 0, 28 * 2 + 8)) {
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
diff --git a/src/input/mms.h b/src/input/mms.h
index a483fa0c6..67ea5ba0b 100644
--- a/src/input/mms.h
+++ b/src/input/mms.h
@@ -24,7 +24,7 @@
#define HAVE_MMS_H
#include <inttypes.h>
-#include "xine_internal.h"
+#include <xine/xine_internal.h>
typedef struct mms_s mms_t;
diff --git a/src/input/mmsh.c b/src/input/mmsh.c
index ae1c62bc1..3a33e8d7f 100644
--- a/src/input/mmsh.c
+++ b/src/input/mmsh.c
@@ -51,8 +51,8 @@
/*
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
#include "bswap.h"
#include "http_helper.h"
@@ -447,7 +447,7 @@ static int interp_header (mmsh_t *this) {
return 1;
}
-static const char *const mmsh_proto_s[] = { "mms", "mmsh", NULL };
+static const char mmsh_proto_s[][8] = { "mms", "mmsh", "" };
static int mmsh_valid_proto (char *proto) {
int i = 0;
@@ -457,7 +457,7 @@ static int mmsh_valid_proto (char *proto) {
if (!proto)
return 0;
- while(mmsh_proto_s[i]) {
+ while(*(mmsh_proto_s[i])) {
if (!strcasecmp(proto, mmsh_proto_s[i])) {
return 1;
}
diff --git a/src/input/mmsh.h b/src/input/mmsh.h
index 633d3b5f6..eeceb030b 100644
--- a/src/input/mmsh.h
+++ b/src/input/mmsh.h
@@ -24,7 +24,7 @@
#define HAVE_MMSH_H
#include <inttypes.h>
-#include "xine_internal.h"
+#include <xine/xine_internal.h>
typedef struct mmsh_s mmsh_t;
diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c
index 624af4081..03a24d38f 100644
--- a/src/input/net_buf_ctrl.c
+++ b/src/input/net_buf_ctrl.c
@@ -113,13 +113,9 @@ static void nbc_set_speed_normal (nbc_t *this) {
stream->xine->clock->set_option (stream->xine->clock, CLOCK_SCR_ADJUSTABLE, 1);
}
-void nbc_check_buffers (nbc_t *this) {
- /* Deprecated */
-}
-
static void display_stats (nbc_t *this) {
- const char *buffering[2] = {" ", "buf"};
- const char *enabled[2] = {"off", "on "};
+ static const char buffering[2][4] = {" ", "buf"};
+ static const char enabled[2][4] = {"off", "on "};
printf("bufing: %d, enb: %d\n", this->buffering, this->enabled);
printf("net_buf_ctrl: vid %3d%% %4.1fs %4" PRId64 "kbps %1d, "\
@@ -564,22 +560,3 @@ void nbc_close (nbc_t *this) {
free (this);
xprintf(xine, XINE_VERBOSITY_DEBUG, "\nnet_buf_ctrl: nbc_close: done\n");
}
-
-
-void nbc_set_high_water_mark(nbc_t *this, int value) {
-/*
- Deprecated
- this->high_water_mark = value;
-*/
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "\nnet_buf_ctrl: this method is deprecated, please fix the input plugin\n");
-}
-
-void nbc_set_low_water_mark(nbc_t *this, int value) {
-/*
- Deprecated
- this->low_water_mark = value;
-*/
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "\nnet_buf_ctrl: this method is deprecated, please fix the input plugin\n");
-}
diff --git a/src/input/net_buf_ctrl.h b/src/input/net_buf_ctrl.h
index 79f698008..87d6d84a1 100644
--- a/src/input/net_buf_ctrl.h
+++ b/src/input/net_buf_ctrl.h
@@ -23,18 +23,12 @@
#ifndef HAVE_NET_BUF_CTRL_H
#define HAVE_NET_BUF_CTRL_H
-#include "xine_internal.h"
+#include <xine/xine_internal.h>
typedef struct nbc_s nbc_t;
nbc_t *nbc_init (xine_stream_t *xine);
-void nbc_check_buffers (nbc_t *this);
-
void nbc_close (nbc_t *this);
-void nbc_set_high_water_mark(nbc_t *this, int value);
-
-void nbc_set_low_water_mark(nbc_t *this, int value);
-
#endif
diff --git a/src/input/pnm.c b/src/input/pnm.c
index 38d65b850..564151279 100644
--- a/src/input/pnm.c
+++ b/src/input/pnm.c
@@ -21,6 +21,8 @@
* based upon code from joschka
*/
+#include <config.h>
+
#include <unistd.h>
#include <stdio.h>
#include <sys/socket.h>
@@ -43,9 +45,9 @@
#include "pnm.h"
#include "libreal/rmff.h"
#include "bswap.h"
-#include "io_helper.h"
-#include "xineutils.h"
-#include "xine_internal.h"
+#include <xine/io_helper.h>
+#include <xine/xineutils.h>
+#include <xine/xine_internal.h>
#define BUF_SIZE 4096
#define HEADER_SIZE 4096
@@ -90,7 +92,7 @@ struct pnm_s {
/* header of rm files */
#define RM_HEADER_SIZE 0x12
-const unsigned char rm_header[]={
+static const unsigned char rm_header[]={
0x2e, 0x52, 0x4d, 0x46, /* object_id ".RMF" */
0x00, 0x00, 0x00, 0x12, /* header_size 0x12 */
0x00, 0x00, /* object_version 0x00 */
@@ -100,7 +102,7 @@ const unsigned char rm_header[]={
/* data chunk header */
#define PNM_DATA_HEADER_SIZE 18
-const unsigned char pnm_data_header[]={
+static const unsigned char pnm_data_header[]={
'D','A','T','A',
0,0,0,0, /* data chunk size */
0,0, /* object version */
@@ -732,9 +734,7 @@ pnm_t *pnm_connect(xine_stream_t *stream, const char *mrl) {
pathbegin=slash-mrl_ptr;
hostend=colon-mrl_ptr;
- p->host = malloc(sizeof(char)*hostend+1);
- strncpy(p->host, mrl_ptr, hostend);
- p->host[hostend]=0;
+ p->host = strndup(mrl_ptr, hostend);
if (pathbegin < strlen(mrl_ptr)) p->path=strdup(mrl_ptr+pathbegin+1);
if (colon != slash) {
diff --git a/src/input/pnm.h b/src/input/pnm.h
index 838fbadcc..bf3514bae 100644
--- a/src/input/pnm.h
+++ b/src/input/pnm.h
@@ -26,7 +26,7 @@
#ifndef __CYGWIN__
#include <inttypes.h>
#endif
-#include "xine_internal.h"
+#include <xine/xine_internal.h>
typedef struct pnm_s pnm_t;
diff --git a/src/input/sha1.c b/src/input/sha1.c
index b70e50d5f..98873e6f6 100644
--- a/src/input/sha1.c
+++ b/src/input/sha1.c
@@ -315,12 +315,12 @@ void sha_print(unsigned char digest[20])
}
}
-char *sha_version(void)
+const char *sha_version(void)
{
#if (SHA_VERSION == 1)
- static char *version = "SHA-1";
+ static const char *version = "SHA-1";
#else
- static char *version = "SHA";
+ static const char *version = "SHA";
#endif
return(version);
}
diff --git a/src/input/sha1.h b/src/input/sha1.h
index 9f2659d60..810eecd96 100644
--- a/src/input/sha1.h
+++ b/src/input/sha1.h
@@ -30,7 +30,7 @@ void sha_final(unsigned char [20], SHA_INFO *);
void sha_stream(unsigned char [20], SHA_INFO *, FILE *);
void sha_print(unsigned char [20]);
-char *sha_version(void);
+const char *sha_version(void);
#define SHA_VERSION 1
diff --git a/src/input/vcd/xine-extra.h b/src/input/vcd/xine-extra.h
index 0650f863d..59f562cbd 100644
--- a/src/input/vcd/xine-extra.h
+++ b/src/input/vcd/xine-extra.h
@@ -36,9 +36,9 @@
#endif
/* Xine includes */
-#include "xine_internal.h"
-#include "input_plugin.h"
-#include "xineutils.h"
+#include <xine/xine_internal.h>
+#include <xine/input_plugin.h>
+#include <xine/xineutils.h>
/*!
This routine is like xine_log, except it takes a va_list instead of
diff --git a/src/input/vcd/xineplug_inp_vcd.c b/src/input/vcd/xineplug_inp_vcd.c
index 45d9789ba..27b1cfbbf 100644
--- a/src/input/vcd/xineplug_inp_vcd.c
+++ b/src/input/vcd/xineplug_inp_vcd.c
@@ -52,8 +52,8 @@
#define xine_config_entry_t xine_cfg_entry_t
/* Xine includes */
-#include "xineutils.h"
-#include "input_plugin.h"
+#include <xine/xineutils.h>
+#include <xine/input_plugin.h>
#include "xine-extra.h"
@@ -272,11 +272,9 @@ vcd_add_mrl_slot(vcd_input_class_t *this, const char *mrl, off_t size,
this->mrls[*i]->type = mrl_vcd;
this->mrls[*i]->size = size * M2F2_SECTOR_SIZE;
- this->mrls[*i]->mrl = (char *) malloc(strlen(mrl) + 1);
+ this->mrls[*i]->mrl = strdup(mrl);
if (NULL==this->mrls[*i]->mrl) {
- LOG_ERR("Can't malloc %zu bytes for MRL name %s", sizeof(xine_mrl_t), mrl);
- } else {
- sprintf(this->mrls[*i]->mrl, "%s", mrl);
+ LOG_ERR("Can't strndup %zu bytes for MRL name %s", strlen(mrl), mrl);
}
(*i)++;
}