[MPlayer-dev-eng] [PATCH] vstream client support
Joey Parrish
joey at nicewarrior.org
Wed Feb 23 02:34:43 CET 2005
On Wed, Feb 23, 2005 at 01:00:36AM +0100, Reimar Döffinger wrote:
> doxygen-Style comments are missing...
For new functions, yes. I don't have any new functions. These are
standard interfaces that are the same across all stream modules. It's
ludicrous to document them with doxygen. The function pointers in
stream.h should be doxygened, if anything.
> > + if(!p->host) {
> > + mp_msg(MSGT_OPEN, MSGL_ERR, "We need a host name (ex: tivo://hostname/fsid)\n");
> > + m_struct_free(&stream_opts, opts);
> > + return STREAM_ERROR;
>
> Does this have to be freed here? And if initialization succeed, when
> should it be freed then? At the end of this function? Or on close?
stream_netstream does it, which is what I based my module on.
If I can trust other stream modules, then it should be freed when I
return with an error. However, I don't free it on success, because I
cast it to my private struct and use it later in that fashion.
It should be freed on close, which in the new version it is.
> > + if (!strcmp(p->fsid, "list")) {
> > + vstream_list_streams(0);
> > + return STREAM_ERROR;
> > + } else if (!strcmp(p->fsid, "llist")) {
> > + vstream_list_streams(1);
> > + return STREAM_ERROR;
> > + }
>
> Hmmm. Don't you need a m_struct_free here, too? I actually prefer gotos
> to have all the freeing in one place (and only one exit point of the
> function) this helps a lot avoiding such things.
For consistency, yes, I should. But this is the code I didn't copy from
netstream. :) I'll add free statements there, too. Thanks.
> > + stream->start_pos = 0;
> > + stream->end_pos = vstream_streamsize();
> > + mp_msg(MSGT_OPEN, MSGL_DBG2, "Tivo stream size is %d\n", stream->end_pos);
>
> Maybe better MSGL_V, I think _DBG2 is for messages that might be
> printed several times or output a lot in general...
Okay, I'll change it to _V.
Updated patch attached. I've also incorporated Diego's comments about
European text style. (I can't help that American schools raised me to
be incompatible with the rest of the world.) It's a hard habit to
break, as you may notice from this paragraph. :)
--Joey
--
"Of the seven dwarves, the only one who shaved was Dopey.
That should tell us something about the wisdom of shaving."
-------------- next part --------------
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.968
diff -u -r1.968 configure
--- configure 22 Feb 2005 14:40:43 -0000 1.968
+++ configure 22 Feb 2005 22:25:08 -0000
@@ -189,6 +189,7 @@
--disable-gethostbyname2 gethostbyname() function is not provided by the C
library [autodetect]
--disable-ftp Disable ftp support [enabled]
+ --disable-vstream Disable tivo vstream client support [autodetect]
Codecs:
--enable-gif enable gif support [autodetect]
@@ -1405,6 +1406,7 @@
_inet6=auto
_gethostbyname2=auto
_ftp=yes
+_vstream=auto
for ac_option do
case "$ac_option" in
# Skip 1st pass
@@ -1648,6 +1650,8 @@
--disable-unrarlib) _unrarlib=no ;;
--enable-ftp) _ftp=yes ;;
--disable-ftp) _ftp=no ;;
+ --enable-vstream) _vstream=yes ;;
+ --disable-vstream) _vstream=no ;;
--enable-fribidi) _fribidi=yes ;;
--disable-fribidi) _fribidi=no ;;
@@ -6186,6 +6190,26 @@
fi
echores "$_ftp"
+echocheck "vstream client"
+if test "$_vstream" = auto ; then
+ _vstream=no
+ cat > $TMPC <<EOF
+#include <vstream-client.h>
+void vstream_error(const char *format, ... ) {}
+int main(void) { vstream_start(); return 0; }
+EOF
+ cc_check -lvstream-client && _vstream=yes
+fi
+if test "$_vstream" = yes ; then
+ _def_vstream='#define HAVE_VSTREAM 1'
+ _inputmodules="vstream $_inputmodules"
+ _ld_vstream='-lvstream-client'
+else
+ _noinputmodules="vstream $_noinputmodules"
+ _def_vstream='#undef HAVE_VSTREAM'
+fi
+echores "$_vstream"
+
# endian testing
echocheck "byte order"
if test "$_big_endian" = auto ; then
@@ -6658,7 +6682,7 @@
MPLAYER_NETWORK = $_network
STREAMING_LIVE_DOT_COM = $_live
-MPLAYER_NETWORK_LIB = $_ld_live $_ld_network
+MPLAYER_NETWORK_LIB = $_ld_live $_ld_vstream $_ld_network
DVBIN = $_dvbin
VIDIX = $_vidix
SHARED_PP = $_shared_pp
@@ -7336,6 +7360,9 @@
/* enable ftp support */
$_def_ftp
+/* enable vstream support */
+$_def_vstream
+
/* enable winsock2 instead of Unix functions*/
$_def_winsock2
Index: DOCS/man/de/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/de/mplayer.1,v
retrieving revision 1.123
diff -u -r1.123 mplayer.1
--- DOCS/man/de/mplayer.1 4 Feb 2005 20:47:44 -0000 1.123
+++ DOCS/man/de/mplayer.1 22 Feb 2005 22:25:12 -0000
@@ -142,6 +142,24 @@
.
.br
.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://Rechnername/list
+[Optionen]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://Rechnername/llist
+[Optionen]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://Rechnername/fsid
+[Optionen]
+.br
+.in
.B gmplayer
[Optionen]
[\-skin\ skin]
Index: DOCS/man/en/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/en/mplayer.1,v
retrieving revision 1.883
diff -u -r1.883 mplayer.1
--- DOCS/man/en/mplayer.1 22 Feb 2005 12:53:31 -0000 1.883
+++ DOCS/man/en/mplayer.1 22 Feb 2005 22:25:15 -0000
@@ -137,6 +137,24 @@
.
.br
.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://host/list
+[options]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://host/llist
+[options]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://host/fsid
+[options]
+.br
+.in
.B gmplayer
[options]
[\-skin\ skin]
Index: DOCS/man/es/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/es/mplayer.1,v
retrieving revision 1.54
diff -u -r1.54 mplayer.1
--- DOCS/man/es/mplayer.1 16 Dec 2004 23:54:56 -0000 1.54
+++ DOCS/man/es/mplayer.1 22 Feb 2005 22:25:18 -0000
@@ -153,6 +153,24 @@
.
.br
.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://host/list
+[opciones]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://host/llist
+[opciones]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://host/fsid
+[opciones]
+.br
+.in
.B gmplayer
[opciones]
[\-skin\ skin]
Index: DOCS/man/fr/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/fr/mplayer.1,v
retrieving revision 1.209
diff -u -r1.209 mplayer.1
--- DOCS/man/fr/mplayer.1 15 Feb 2005 20:51:28 -0000 1.209
+++ DOCS/man/fr/mplayer.1 22 Feb 2005 22:25:21 -0000
@@ -139,6 +139,24 @@
[options]
.
.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://hôte/list
+[options]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://hôte/llist
+[options]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://hôte/fsid
+[options]
+.br
.B gmplayer
[options]
[\-skin\ skin]
Index: DOCS/man/hu/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/hu/mplayer.1,v
retrieving revision 1.98
diff -u -r1.98 mplayer.1
--- DOCS/man/hu/mplayer.1 16 Dec 2004 23:54:57 -0000 1.98
+++ DOCS/man/hu/mplayer.1 22 Feb 2005 22:25:23 -0000
@@ -136,6 +136,24 @@
.RI [ \ file\ | \ URL\ | \ -\ ]
[\-o\ file]
.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://gépnév/list
+[opciók]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://gépnév/llist
+[opciók]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://gépnév/fsid
+[opciók]
+.br
.B gmplayer
[opciók]
[\-skin\ skin]
Index: DOCS/man/it/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/it/mplayer.1,v
retrieving revision 1.32
diff -u -r1.32 mplayer.1
--- DOCS/man/it/mplayer.1 11 Jan 2005 11:54:04 -0000 1.32
+++ DOCS/man/it/mplayer.1 22 Feb 2005 22:25:27 -0000
@@ -141,6 +141,24 @@
.
.br
.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://host/list
+[opzioni]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://host/llist
+[opzioni]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://host/fsid
+[opzioni]
+.br
+.in
.B gmplayer
[opzioni]
[\-skin\ skin]
Index: DOCS/man/pl/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/pl/mplayer.1,v
retrieving revision 1.110
diff -u -r1.110 mplayer.1
--- DOCS/man/pl/mplayer.1 19 Feb 2005 23:15:34 -0000 1.110
+++ DOCS/man/pl/mplayer.1 22 Feb 2005 22:25:30 -0000
@@ -141,6 +141,24 @@
.
.br
.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://host/list
+[opcje]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://host/llist
+[opcje]
+.br
+.in
+.B mplayer
+'in +\n[.k]u
+.I tivo://host/fsid
+[opcje]
+.br
+.in
.B gmplayer
[opcje]
[\-skin\ skórka]
Index: DOCS/xml/en/formats.xml
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/xml/en/formats.xml,v
retrieving revision 1.20
diff -u -r1.20 formats.xml
--- DOCS/xml/en/formats.xml 7 Dec 2004 02:54:38 -0000 1.20
+++ DOCS/xml/en/formats.xml 22 Feb 2005 22:25:31 -0000
@@ -60,6 +60,14 @@
MP2 and uncompressed LPCM are allowed, too. <emphasis role="bold">Read the
<link linkend="dvd">DVD</link> section</emphasis>!
</simpara></listitem>
+<listitem><simpara>
+ TY: This is a TiVo MPEG stream. It contains MPEG PES data for audio and
+ video streams, as well as extra information like closed captions. The
+ container is not an MPEG program stream, but a closed format created by
+ TiVo. For more information on TiVo stream format, please refer to
+ <ulink url="http://dvd-create.sourceforge.net/tystudio/tystream.shtml">
+ the TyStudio page</ulink>.
+ </simpara></listitem>
</itemizedlist>
<para>
Index: libmpdemux/Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/Makefile,v
retrieving revision 1.87
diff -u -r1.87 Makefile
--- libmpdemux/Makefile 21 Feb 2005 23:18:31 -0000 1.87
+++ libmpdemux/Makefile 22 Feb 2005 22:25:31 -0000
@@ -3,7 +3,7 @@
include ../config.mak
-SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_ty.c demux_ty_osd.c demux_pva.c demux_viv.c demuxer.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c stream_null.c stream_ftp.c tv.c tvi_dummy.c tvi_v4l.c tvi_v4l2.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_alsa1x.c ai_oss.c audio_in.c demux_smjpeg.c demux_lmlm4.c cue_read.c extension.c demux_gif.c demux_ts.c demux_realaud.c url.c muxer_rawvideo.c demux_lavf.c demux_nsv.c demux_vqf.c
+SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_ty.c demux_ty_osd.c demux_pva.c demux_viv.c demuxer.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c stream_null.c stream_ftp.c stream_vstream.c tv.c tvi_dummy.c tvi_v4l.c tvi_v4l2.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_alsa1x.c ai_oss.c audio_in.c demux_smjpeg.c demux_lmlm4.c cue_read.c extension.c demux_gif.c demux_ts.c demux_realaud.c url.c muxer_rawvideo.c demux_lavf.c demux_nsv.c demux_vqf.c
ifeq ($(XMMS_PLUGINS),yes)
SRCS += demux_xmms.c
endif
Index: libmpdemux/open.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/open.c,v
retrieving revision 1.101
diff -u -r1.101 open.c
--- libmpdemux/open.c 3 Dec 2004 14:14:29 -0000 1.101
+++ libmpdemux/open.c 22 Feb 2005 22:25:33 -0000
@@ -496,7 +496,7 @@
if (strncmp("tv://", filename, 5) && strncmp("mf://", filename, 5) &&
strncmp("vcd://", filename, 6) && strncmp("dvb://", filename, 6) &&
strncmp("cdda://", filename, 7) && strncmp("cddb://", filename, 7) &&
- strncmp("mpst://", filename, 7) &&
+ strncmp("mpst://", filename, 7) && strncmp("tivo://", filename, 7) &&
strstr(filename, "://")) {
url = url_new(filename);
}
Index: libmpdemux/stream.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/stream.c,v
retrieving revision 1.72
diff -u -r1.72 stream.c
--- libmpdemux/stream.c 13 Mar 2004 16:10:02 -0000 1.72
+++ libmpdemux/stream.c 22 Feb 2005 22:25:33 -0000
@@ -64,6 +64,9 @@
#ifdef HAVE_FTP
extern stream_info_t stream_info_ftp;
#endif
+#ifdef HAVE_VSTREAM
+extern stream_info_t stream_info_vstream;
+#endif
extern stream_info_t stream_info_null;
extern stream_info_t stream_info_file;
@@ -84,6 +87,9 @@
#ifdef HAVE_FTP
&stream_info_ftp,
#endif
+#ifdef HAVE_VSTREAM
+ &stream_info_vstream,
+#endif
&stream_info_null,
&stream_info_file,
NULL
Index: libmpdemux/stream.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/stream.h,v
retrieving revision 1.69
diff -u -r1.69 stream.h
--- libmpdemux/stream.h 22 Aug 2004 18:47:48 -0000 1.69
+++ libmpdemux/stream.h 22 Feb 2005 22:25:33 -0000
@@ -19,6 +19,7 @@
#define STREAMTYPE_SMB 11 // smb:// url, using libsmbclient (samba)
#define STREAMTYPE_VCDBINCUE 12 // vcd directly from bin/cue files
#define STREAMTYPE_DVB 13
+#define STREAMTYPE_VSTREAM 14
#define STREAM_BUFFER_SIZE 2048
--- /dev/null Mon Mar 3 06:52:35 2003
+++ libmpdemux/stream_vstream.c Tue Feb 22 19:28:38 2005
@@ -0,0 +1,188 @@
+/*
+ * stream_vstream.c
+ *
+ * Copyright (C) Joey Parrish
+ *
+ * This file is part of MPlayer, a free movie player.
+ *
+ * MPlayer 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, or (at your option)
+ * any later version.
+ *
+ * MPlayer 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 GNU Make; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ */
+
+/*
+ * If you have a tivo with the vstream server installed, (and most tivo
+ * hackers do,) then you can connect to it and stream ty files using
+ * this module. The url syntax is tivo://host/fsid or tivo://host/list
+ * to list the available recordings and their fsid's.
+ * This module depends on libvstream-client, which is available from
+ * http://armory.nicewarrior.org/projects/vstream-client .
+ *
+ */
+
+
+#include "config.h"
+
+#ifdef HAVE_VSTREAM
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <inttypes.h>
+#include <errno.h>
+
+#include "mp_msg.h"
+#include "stream.h"
+#include "help_mp.h"
+#include "../m_option.h"
+#include "../m_struct.h"
+
+#include <vstream-client.h>
+
+void vstream_error(const char *format, ...) {
+ char buf[1024];
+ va_list va;
+ va_start(va, format);
+ vsnprintf(buf, 1024, format, va);
+ va_end(va);
+ mp_msg(MSGT_STREAM, MSGL_ERR, buf);
+}
+
+static struct stream_priv_s {
+ char* host;
+ char* fsid;
+} stream_priv_dflts = {
+ NULL,
+ NULL
+};
+
+#define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f)
+/// URL definition
+static m_option_t stream_opts_fields[] = {
+ {"hostname", ST_OFF(host), CONF_TYPE_STRING, 0, 0 ,0, NULL},
+ {"filename", ST_OFF(fsid), CONF_TYPE_STRING, 0, 0 ,0, NULL},
+ { NULL, NULL, 0, 0, 0, 0, NULL }
+};
+
+static struct m_struct_st stream_opts = {
+ "vstream",
+ sizeof(struct stream_priv_s),
+ &stream_priv_dflts,
+ stream_opts_fields
+};
+
+static int fill_buffer(stream_t *s, char* buffer, int max_len){
+ struct stream_priv_s* p = (struct stream_priv_s*)s->priv;
+ int len = vstream_load_chunk(p->fsid, buffer, max_len, s->pos);
+ if (len <= 0) return 0;
+ return len;
+}
+
+static int seek(stream_t *s,off_t newpos) {
+ s->pos = newpos;
+ return 1;
+}
+
+static int control(struct stream_st *s,int cmd,void* arg) {
+ return STREAM_UNSUPORTED;
+}
+
+static void close_s(struct stream_st *s) {
+ struct stream_priv_s* p = (struct stream_priv_s*)s->priv;
+ m_struct_free(&stream_opts, p);
+}
+
+static int open_s(stream_t *stream, int mode, void* opts, int* file_format) {
+ int f;
+ struct stream_priv_s* p = (struct stream_priv_s*)opts;
+
+ if(mode != STREAM_READ)
+ return STREAM_UNSUPORTED;
+
+ if(!p->host) {
+ mp_msg(MSGT_OPEN, MSGL_ERR, "We need a host name (ex: tivo://hostname/fsid)\n");
+ m_struct_free(&stream_opts, opts);
+ return STREAM_ERROR;
+ }
+
+ if(!p->fsid || strlen(p->fsid) == 0) {
+ mp_msg(MSGT_OPEN, MSGL_ERR, "We need an fsid (ex: tivo://hostname/fsid)\n");
+ m_struct_free(&stream_opts, opts);
+ return STREAM_ERROR;
+ }
+
+ f = connect2Server(p->host, VSERVER_PORT, 1);
+
+ if(f < 0) {
+ mp_msg(MSGT_OPEN, MSGL_ERR, "Connection to %s failed\n", p->host);
+ m_struct_free(&stream_opts, opts);
+ return STREAM_ERROR;
+ }
+ stream->fd = f;
+
+ vstream_set_socket_fd(f);
+
+ if (!strcmp(p->fsid, "list")) {
+ vstream_list_streams(0);
+ m_struct_free(&stream_opts, opts);
+ return STREAM_ERROR;
+ } else if (!strcmp(p->fsid, "llist")) {
+ vstream_list_streams(1);
+ m_struct_free(&stream_opts, opts);
+ return STREAM_ERROR;
+ }
+
+ if (vstream_start()) {
+ mp_msg(MSGT_OPEN, MSGL_ERR, "Cryptic internal error #1\n");
+ m_struct_free(&stream_opts, opts);
+ return STREAM_ERROR;
+ }
+ if (vstream_startstream(p->fsid)) {
+ mp_msg(MSGT_OPEN, MSGL_ERR, "Cryptic internal error #2\n");
+ m_struct_free(&stream_opts, opts);
+ return STREAM_ERROR;
+ }
+
+ stream->start_pos = 0;
+ stream->end_pos = vstream_streamsize();
+ mp_msg(MSGT_OPEN, MSGL_V, "Tivo stream size is %d\n", stream->end_pos);
+
+ stream->priv = p;
+ stream->fill_buffer = fill_buffer;
+ stream->control = control;
+ stream->seek = seek;
+ stream->close = close_s;
+ stream->type = STREAMTYPE_VSTREAM;
+
+ return STREAM_OK;
+}
+
+stream_info_t stream_info_vstream = {
+ "vstream client",
+ "vstream",
+ "Joey Parrish <joey at nicewarrior.org>",
+ "",
+ open_s,
+ { "tivo", NULL },
+ &stream_opts,
+ 1 // Url is an option string
+};
+
+#endif
More information about the MPlayer-dev-eng
mailing list