From 93b837f0a781e329ec1c06910226b1afd852931a Mon Sep 17 00:00:00 2001 From: nicodvb Date: Fri, 4 Jul 2008 15:54:45 +0000 Subject: added support for the device part in the url; patch by Mathieu SCHROETER mathieu.schroeter gamesover ch git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27195 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream_dvd.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'stream') diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index 85a0d6ba03..941cb824a2 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -42,6 +42,7 @@ #include "libavutil/intreadwrite.h" extern char* dvd_device; +static char* dvd_device_current; int dvd_angle=1; int dvd_speed=0; /* 0 => don't touch speed */ @@ -138,14 +139,17 @@ const char * const dvd_audio_stream_channels[6] = { "mono", "stereo", "unknown", static struct stream_priv_s { int title; + char* device; } stream_priv_dflts = { - 1 + 1, + NULL }; #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f) /// URL definition static const m_option_t stream_opts_fields[] = { { "hostname", ST_OFF(title), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL }, + { "filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0 ,0, NULL}, { NULL, NULL, 0, 0, 0, 0, NULL } }; static const struct m_struct_st stream_opts = { @@ -484,7 +488,7 @@ void dvd_close(dvd_priv_t *d) { DVDClose(d->dvd); dvd_chapter = 1; dvd_last_chapter = 0; - dvd_set_speed(dvd_device, -1); /* -1 => restore default */ + dvd_set_speed(dvd_device_current, -1); /* -1 => restore default */ } static int fill_buffer(stream_t *s, char *but, int len) @@ -781,13 +785,18 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { /** * Open the disc. */ - if(!dvd_device) dvd_device=strdup(DEFAULT_DVD_DEVICE); - dvd_set_speed(dvd_device, dvd_speed); + if(p->device) + dvd_device_current = p->device; + else if(dvd_device) + dvd_device_current = dvd_device; + else + dvd_device_current = strdup(DEFAULT_DVD_DEVICE); + dvd_set_speed(dvd_device_current, dvd_speed); #if defined(__APPLE__) || defined(__DARWIN__) /* Dynamic DVD drive selection on Darwin */ - if(!strcmp(dvd_device, "/dev/rdiskN")) { + if(!strcmp(dvd_device_current, "/dev/rdiskN")) { int i; - size_t len = strlen(dvd_device)+1; + size_t len = strlen(dvd_device_current)+1; char *temp_device = malloc(len); for (i = 1; i < 10; i++) { @@ -817,9 +826,9 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { } else #endif /* defined(__APPLE__) || defined(__DARWIN__) */ { - dvd = DVDOpen(dvd_device); + dvd = DVDOpen(dvd_device_current); if(!dvd) { - mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,dvd_device, strerror(errno)); + mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,dvd_device_current, strerror(errno)); m_struct_free(&stream_opts,opts); return STREAM_UNSUPPORTED; } -- cgit v1.2.3 From 7043b6d0d171f68440dedbc0c5504e733050b4e0 Mon Sep 17 00:00:00 2001 From: nicodvb Date: Fri, 4 Jul 2008 15:57:33 +0000 Subject: dvd_device must be handled exclusively by the option parser; it can't be changed at will in ifo_stream_open() git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27196 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream_dvd.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'stream') diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index 941cb824a2..98b648126b 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -1091,8 +1091,6 @@ ifo_stream_open (stream_t *stream, int mode, void *opts, int *file_format) return STREAM_UNSUPPORTED; mp_msg(MSGT_DVD, MSGL_INFO, ".IFO detected. Redirecting to dvd://\n"); - if (!dvd_device) - dvd_device = strdup(dirname (stream->url)); filename = strdup(basename(stream->url)); -- cgit v1.2.3 From 8742c266db1a01e3b3de88f7983b38d6d15390a4 Mon Sep 17 00:00:00 2001 From: nicodvb Date: Fri, 4 Jul 2008 16:00:07 +0000 Subject: in ifo_stream_open() propagate the device based on the dirname of stream->url; patch by Mathieu SCHROETER mathieu.schroeter gamesover ch git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27197 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream_dvd.c | 1 + 1 file changed, 1 insertion(+) (limited to 'stream') diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index 98b648126b..32c852e0bd 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -1095,6 +1095,7 @@ ifo_stream_open (stream_t *stream, int mode, void *opts, int *file_format) filename = strdup(basename(stream->url)); dvd_priv=calloc(1, sizeof(struct stream_priv_s)); + dvd_priv->device = strdup(dirname(stream->url)); if(!strncasecmp(filename,"vts_",4)) { if(sscanf(filename+3, "_%02d_", &dvd_priv->title)!=1) -- cgit v1.2.3 From a4b4b991dc8d891a20caa41a44702a6fe1e03a3a Mon Sep 17 00:00:00 2001 From: nicodvb Date: Fri, 4 Jul 2008 16:03:57 +0000 Subject: cosmetics: in ifo_stream_oped() aligned the prototype to the style of the rest of the file and renamed dvd_priv to spriv (it's a stream_priv_s*, while dvd_priv is used for other purposes in the rest of the file) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27198 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream_dvd.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'stream') diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index 32c852e0bd..c9af10d517 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -1079,12 +1079,11 @@ fail: return STREAM_UNSUPPORTED; } -static int -ifo_stream_open (stream_t *stream, int mode, void *opts, int *file_format) +static int ifo_stream_open (stream_t *stream, int mode, void *opts, int *file_format) { char *ext; char* filename; - struct stream_priv_s *dvd_priv; + struct stream_priv_s *spriv; ext = strrchr (stream->url, '.'); if (!ext || strcasecmp (ext + 1, "ifo")) @@ -1094,20 +1093,20 @@ ifo_stream_open (stream_t *stream, int mode, void *opts, int *file_format) filename = strdup(basename(stream->url)); - dvd_priv=calloc(1, sizeof(struct stream_priv_s)); - dvd_priv->device = strdup(dirname(stream->url)); + spriv=calloc(1, sizeof(struct stream_priv_s)); + spriv->device = strdup(dirname(stream->url)); if(!strncasecmp(filename,"vts_",4)) { - if(sscanf(filename+3, "_%02d_", &dvd_priv->title)!=1) - dvd_priv->title=1; + if(sscanf(filename+3, "_%02d_", &spriv->title)!=1) + spriv->title=1; }else - dvd_priv->title=1; + spriv->title=1; free(filename); free(stream->url); stream->url=strdup("dvd://"); - return open_s(stream, mode, dvd_priv, file_format); + return open_s(stream, mode, spriv, file_format); } const stream_info_t stream_info_dvd = { -- cgit v1.2.3 From f3bf43f443e8c5435cb2467514ad1c5af19fd0bb Mon Sep 17 00:00:00 2001 From: diego Date: Fri, 4 Jul 2008 20:14:00 +0000 Subject: Rename stream_livedotcom.c to stream_live555.c, the name is used everywhere. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27199 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream_live555.c | 119 +++++++++++++++++++++++++++++++++++++++++++++ stream/stream_livedotcom.c | 119 --------------------------------------------- 2 files changed, 119 insertions(+), 119 deletions(-) create mode 100644 stream/stream_live555.c delete mode 100644 stream/stream_livedotcom.c (limited to 'stream') diff --git a/stream/stream_live555.c b/stream/stream_live555.c new file mode 100644 index 0000000000..13b5022883 --- /dev/null +++ b/stream/stream_live555.c @@ -0,0 +1,119 @@ + +#include "config.h" + +#include +#include +#include +#include + +#include "stream.h" +#include "network.h" +#include "libmpdemux/demuxer.h" +#include "help_mp.h" + +extern int network_bandwidth; + +static int _rtsp_streaming_seek(int fd, off_t pos, streaming_ctrl_t* streaming_ctrl) { + return -1; // For now, we don't handle RTSP stream seeking +} + +static int rtsp_streaming_start(stream_t* stream) { + stream->streaming_ctrl->streaming_seek = _rtsp_streaming_seek; + return 0; +} + + +static int open_live_rtsp_sip(stream_t *stream,int mode, void* opts, int* file_format) { + URL_t *url; + + stream->streaming_ctrl = streaming_ctrl_new(); + if( stream->streaming_ctrl==NULL ) { + return STREAM_ERROR; + } + stream->streaming_ctrl->bandwidth = network_bandwidth; + url = url_new(stream->url); + stream->streaming_ctrl->url = check4proxies(url); + //url_free(url); + + mp_msg(MSGT_OPEN, MSGL_INFO, "STREAM_LIVE555, URL: %s\n", stream->url); + + if(rtsp_streaming_start(stream) < 0) { + mp_msg(MSGT_NETWORK,MSGL_ERR,"rtsp_streaming_start failed\n"); + goto fail; + } + + *file_format = DEMUXER_TYPE_RTP; + stream->type = STREAMTYPE_STREAM; + return STREAM_OK; + +fail: + streaming_ctrl_free( stream->streaming_ctrl ); + stream->streaming_ctrl = NULL; + return STREAM_ERROR; +} + +static int open_live_sdp(stream_t *stream,int mode, void* opts, int* file_format) { + int f; + char *filename = stream->url; + off_t len; + char* sdpDescription; + ssize_t numBytesRead; + + if(strncmp("sdp://",filename,6) == 0) { + filename += 6; +#if defined(__CYGWIN__) || defined(__MINGW32__) + f = open(filename,O_RDONLY|O_BINARY); +#else + f = open(filename,O_RDONLY); +#endif + if(f < 0) { + mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename); + return STREAM_ERROR; + } + + len=lseek(f,0,SEEK_END); + lseek(f,0,SEEK_SET); + if(len == -1) + return STREAM_ERROR; + if(len > SIZE_MAX - 1) + return STREAM_ERROR; + + sdpDescription = malloc(len+1); + if(sdpDescription == NULL) return STREAM_ERROR; + numBytesRead = read(f, sdpDescription, len); + if(numBytesRead != len) { + free(sdpDescription); + return STREAM_ERROR; + } + sdpDescription[len] = '\0'; // to be safe + stream->priv = sdpDescription; + + stream->type = STREAMTYPE_SDP; + *file_format = DEMUXER_TYPE_RTP; + return STREAM_OK; + } + return STREAM_UNSUPPORTED; +} + + +const stream_info_t stream_info_rtsp_sip = { + "standard RTSP and SIP", + "RTSP and SIP", + "Ross Finlayson", + "Uses LIVE555 Streaming Media library.", + open_live_rtsp_sip, + {"rtsp", "sip", NULL }, + NULL, + 0 // Urls are an option string +}; + +const stream_info_t stream_info_sdp = { + "SDP stream descriptor", + "SDP", + "Ross Finlayson", + "Uses LIVE555 Streaming Media library.", + open_live_sdp, + {"sdp", NULL }, + NULL, + 0 // Urls are an option string +}; diff --git a/stream/stream_livedotcom.c b/stream/stream_livedotcom.c deleted file mode 100644 index 13b5022883..0000000000 --- a/stream/stream_livedotcom.c +++ /dev/null @@ -1,119 +0,0 @@ - -#include "config.h" - -#include -#include -#include -#include - -#include "stream.h" -#include "network.h" -#include "libmpdemux/demuxer.h" -#include "help_mp.h" - -extern int network_bandwidth; - -static int _rtsp_streaming_seek(int fd, off_t pos, streaming_ctrl_t* streaming_ctrl) { - return -1; // For now, we don't handle RTSP stream seeking -} - -static int rtsp_streaming_start(stream_t* stream) { - stream->streaming_ctrl->streaming_seek = _rtsp_streaming_seek; - return 0; -} - - -static int open_live_rtsp_sip(stream_t *stream,int mode, void* opts, int* file_format) { - URL_t *url; - - stream->streaming_ctrl = streaming_ctrl_new(); - if( stream->streaming_ctrl==NULL ) { - return STREAM_ERROR; - } - stream->streaming_ctrl->bandwidth = network_bandwidth; - url = url_new(stream->url); - stream->streaming_ctrl->url = check4proxies(url); - //url_free(url); - - mp_msg(MSGT_OPEN, MSGL_INFO, "STREAM_LIVE555, URL: %s\n", stream->url); - - if(rtsp_streaming_start(stream) < 0) { - mp_msg(MSGT_NETWORK,MSGL_ERR,"rtsp_streaming_start failed\n"); - goto fail; - } - - *file_format = DEMUXER_TYPE_RTP; - stream->type = STREAMTYPE_STREAM; - return STREAM_OK; - -fail: - streaming_ctrl_free( stream->streaming_ctrl ); - stream->streaming_ctrl = NULL; - return STREAM_ERROR; -} - -static int open_live_sdp(stream_t *stream,int mode, void* opts, int* file_format) { - int f; - char *filename = stream->url; - off_t len; - char* sdpDescription; - ssize_t numBytesRead; - - if(strncmp("sdp://",filename,6) == 0) { - filename += 6; -#if defined(__CYGWIN__) || defined(__MINGW32__) - f = open(filename,O_RDONLY|O_BINARY); -#else - f = open(filename,O_RDONLY); -#endif - if(f < 0) { - mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename); - return STREAM_ERROR; - } - - len=lseek(f,0,SEEK_END); - lseek(f,0,SEEK_SET); - if(len == -1) - return STREAM_ERROR; - if(len > SIZE_MAX - 1) - return STREAM_ERROR; - - sdpDescription = malloc(len+1); - if(sdpDescription == NULL) return STREAM_ERROR; - numBytesRead = read(f, sdpDescription, len); - if(numBytesRead != len) { - free(sdpDescription); - return STREAM_ERROR; - } - sdpDescription[len] = '\0'; // to be safe - stream->priv = sdpDescription; - - stream->type = STREAMTYPE_SDP; - *file_format = DEMUXER_TYPE_RTP; - return STREAM_OK; - } - return STREAM_UNSUPPORTED; -} - - -const stream_info_t stream_info_rtsp_sip = { - "standard RTSP and SIP", - "RTSP and SIP", - "Ross Finlayson", - "Uses LIVE555 Streaming Media library.", - open_live_rtsp_sip, - {"rtsp", "sip", NULL }, - NULL, - 0 // Urls are an option string -}; - -const stream_info_t stream_info_sdp = { - "SDP stream descriptor", - "SDP", - "Ross Finlayson", - "Uses LIVE555 Streaming Media library.", - open_live_sdp, - {"sdp", NULL }, - NULL, - 0 // Urls are an option string -}; -- cgit v1.2.3