2001-08-09 01:17:24 +00:00
|
|
|
|
2002-01-24 23:02:59 +00:00
|
|
|
#include <ctype.h>
|
2001-08-09 01:17:24 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
2003-03-30 17:07:31 +00:00
|
|
|
#include <string.h>
|
2001-08-09 01:17:24 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
2001-08-17 00:40:25 +00:00
|
|
|
#include "mp_msg.h"
|
2001-08-18 20:32:09 +00:00
|
|
|
#include "help_mp.h"
|
2001-08-09 01:17:24 +00:00
|
|
|
|
2001-08-09 15:47:40 +00:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <sys/cdrio.h>
|
|
|
|
#endif
|
|
|
|
|
2003-08-13 16:29:32 +00:00
|
|
|
#include "../m_option.h"
|
2001-08-09 01:17:24 +00:00
|
|
|
#include "stream.h"
|
2001-08-11 12:46:01 +00:00
|
|
|
#include "demuxer.h"
|
2002-02-06 20:16:35 +00:00
|
|
|
#include "mf.h"
|
2001-08-09 01:17:24 +00:00
|
|
|
|
2003-05-17 12:24:01 +00:00
|
|
|
#ifdef MPLAYER_NETWORK
|
2001-08-09 01:17:24 +00:00
|
|
|
#include "url.h"
|
|
|
|
#include "network.h"
|
2002-11-06 23:54:29 +00:00
|
|
|
extern int streaming_start( stream_t *stream, int *demuxer_type, URL_t *url);
|
2002-08-05 00:39:07 +00:00
|
|
|
#ifdef STREAMING_LIVE_DOT_COM
|
|
|
|
#include "demux_rtp.h"
|
|
|
|
#endif
|
2001-08-09 01:17:24 +00:00
|
|
|
static URL_t* url;
|
|
|
|
#endif
|
|
|
|
|
2003-03-30 17:07:31 +00:00
|
|
|
/// We keep these 2 for the gui atm, but they will be removed.
|
2005-05-15 20:52:06 +00:00
|
|
|
int vcd_track=0;
|
2002-01-17 20:40:07 +00:00
|
|
|
char* cdrom_device=NULL;
|
2002-03-28 20:40:21 +00:00
|
|
|
|
2001-08-09 01:17:24 +00:00
|
|
|
// Open a new stream (stdin/file/vcd/url)
|
|
|
|
|
2003-04-02 16:26:58 +00:00
|
|
|
stream_t* open_stream(char* filename,char** options, int* file_format){
|
2001-08-09 01:17:24 +00:00
|
|
|
stream_t* stream=NULL;
|
|
|
|
int f=-1;
|
|
|
|
off_t len;
|
2004-04-17 16:46:41 +00:00
|
|
|
|
|
|
|
// Check if playlist or unknown
|
|
|
|
if (*file_format != DEMUXER_TYPE_PLAYLIST){
|
|
|
|
*file_format=DEMUXER_TYPE_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2003-03-30 17:07:31 +00:00
|
|
|
if(!filename) {
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR,"NULL filename, report this bug\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-08-09 01:17:24 +00:00
|
|
|
|
2003-01-04 20:11:06 +00:00
|
|
|
|
2003-05-17 12:24:01 +00:00
|
|
|
#ifdef MPLAYER_NETWORK
|
2003-04-08 05:14:43 +00:00
|
|
|
#ifdef STREAMING_LIVE_DOT_COM
|
|
|
|
// Check for a SDP file:
|
|
|
|
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 NULL; }
|
|
|
|
|
|
|
|
len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET);
|
|
|
|
if (len == -1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
#ifdef _LARGEFILE_SOURCE
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len);
|
|
|
|
#else
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_V,"File size is %u bytes\n", (unsigned int)len);
|
|
|
|
#endif
|
|
|
|
return stream_open_sdp(f, len, file_format);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-08-25 21:40:38 +00:00
|
|
|
// FIXME: to avoid nonsense error messages...
|
|
|
|
if (strncmp("tv://", filename, 5) && strncmp("mf://", filename, 5) &&
|
2003-08-31 18:51:05 +00:00
|
|
|
strncmp("vcd://", filename, 6) && strncmp("dvb://", filename, 6) &&
|
2003-09-03 19:26:33 +00:00
|
|
|
strncmp("cdda://", filename, 7) && strncmp("cddb://", filename, 7) &&
|
2005-02-27 04:25:12 +00:00
|
|
|
strncmp("mpst://", filename, 7) && strncmp("tivo://", filename, 7) &&
|
2005-05-15 07:38:42 +00:00
|
|
|
strncmp("file://", filename, 7) && strncmp("cue://", filename, 6) &&
|
2005-05-19 20:58:11 +00:00
|
|
|
strncmp("ftp://", filename, 6) && strncmp("smb://", filename, 6) &&
|
2005-05-19 19:50:39 +00:00
|
|
|
strncmp("dvd://", filename, 6) && strncmp("dvdnav://", filename, 9) &&
|
2004-04-24 13:22:05 +00:00
|
|
|
strstr(filename, "://")) {
|
2004-05-01 23:35:25 +00:00
|
|
|
url = url_new(filename);
|
2004-04-24 13:22:05 +00:00
|
|
|
}
|
2001-08-09 01:17:24 +00:00
|
|
|
if(url) {
|
|
|
|
stream=new_stream(f,STREAMTYPE_STREAM);
|
2002-02-16 21:48:59 +00:00
|
|
|
if( streaming_start( stream, file_format, url )<0){
|
2001-11-20 22:48:43 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename);
|
2004-04-24 13:19:20 +00:00
|
|
|
url_free(url);
|
2004-06-11 20:57:03 +00:00
|
|
|
url = NULL;
|
2004-04-24 13:19:20 +00:00
|
|
|
return NULL;
|
2003-04-02 16:26:58 +00:00
|
|
|
} else {
|
2002-01-19 09:04:02 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ConnToServer, url->hostname );
|
2001-11-20 22:48:43 +00:00
|
|
|
url_free(url);
|
2004-06-11 20:57:03 +00:00
|
|
|
url = NULL;
|
2001-10-20 20:35:12 +00:00
|
|
|
return stream;
|
2004-05-03 18:19:16 +00:00
|
|
|
}
|
2001-08-09 01:17:24 +00:00
|
|
|
}
|
2003-01-02 10:53:22 +00:00
|
|
|
#endif
|
2002-06-07 00:42:08 +00:00
|
|
|
|
2003-04-08 05:14:43 +00:00
|
|
|
//============ Open STDIN or plain FILE ============
|
2002-08-05 00:39:07 +00:00
|
|
|
|
2003-04-02 16:26:58 +00:00
|
|
|
return open_stream_full(filename,STREAM_READ,options,file_format);
|
2001-08-09 01:17:24 +00:00
|
|
|
}
|
2001-08-20 21:20:03 +00:00
|
|
|
|