annotate libmpdemux/open.c @ 15561:6e2c6d2553bd

disable preinit until it's fixed (it breaks -speed...codec is initialized with wrong samplerate)
author rfelker
date Tue, 24 May 2005 08:29:45 +0000
parents 2c5186ed83b9
children 281d155fb37f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
1
4343
b0c8eed7473c Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents: 4291
diff changeset
2 #include <ctype.h>
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
3 #include <stdio.h>
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
4 #include <stdlib.h>
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
5 #include <string.h>
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
6 #include <unistd.h>
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
7 #include <fcntl.h>
9746
27fff718ede6 Stream cleanup, don't use blah_on options anymore.
albeu
parents: 9712
diff changeset
8 #include <string.h>
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
9
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
10 #include "config.h"
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1482
diff changeset
11 #include "mp_msg.h"
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
12 #include "help_mp.h"
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
13
1468
fbed9c34069c freebsd fix
arpi
parents: 1467
diff changeset
14 #ifdef __FreeBSD__
fbed9c34069c freebsd fix
arpi
parents: 1467
diff changeset
15 #include <sys/cdrio.h>
fbed9c34069c freebsd fix
arpi
parents: 1467
diff changeset
16 #endif
fbed9c34069c freebsd fix
arpi
parents: 1467
diff changeset
17
10594
57bdcdb061d7 Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents: 10560
diff changeset
18 #include "../m_option.h"
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
19 #include "stream.h"
1482
4800d1c58dab --enable-streaming fix
arpi
parents: 1468
diff changeset
20 #include "demuxer.h"
4551
716b00618bfc add mfi support
pontscho
parents: 4390
diff changeset
21 #include "mf.h"
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
22
10121
d42177a0da2a Changed the STREAMING defines to MPLAYER_NETWORK to avoid name definition clash.
bertrand
parents: 10067
diff changeset
23 #ifdef MPLAYER_NETWORK
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
24 #include "url.h"
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
25 #include "network.h"
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7854
diff changeset
26 extern int streaming_start( stream_t *stream, int *demuxer_type, URL_t *url);
6910
1a747aee653b applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents: 6853
diff changeset
27 #ifdef STREAMING_LIVE_DOT_COM
1a747aee653b applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents: 6853
diff changeset
28 #include "demux_rtp.h"
1a747aee653b applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents: 6853
diff changeset
29 #endif
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
30 static URL_t* url;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
31 #endif
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
32
9746
27fff718ede6 Stream cleanup, don't use blah_on options anymore.
albeu
parents: 9712
diff changeset
33 /// We keep these 2 for the gui atm, but they will be removed.
15484
15b5b56d809f restore vcd_track
nicodvb
parents: 15478
diff changeset
34 int vcd_track=0;
4222
de7eddb3fd70 Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents: 4146
diff changeset
35 char* cdrom_device=NULL;
5380
8a01cde9cf39 DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents: 4729
diff changeset
36
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
37 // Open a new stream (stdin/file/vcd/url)
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
38
9795
20f8944a6e0c Remove -sdp
albeu
parents: 9773
diff changeset
39 stream_t* open_stream(char* filename,char** options, int* file_format){
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
40 stream_t* stream=NULL;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
41 int f=-1;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
42 off_t len;
12223
e7c8200ffdc5 Respect -playlist for asx streams
rtognimp
parents: 10807
diff changeset
43
e7c8200ffdc5 Respect -playlist for asx streams
rtognimp
parents: 10807
diff changeset
44 // Check if playlist or unknown
e7c8200ffdc5 Respect -playlist for asx streams
rtognimp
parents: 10807
diff changeset
45 if (*file_format != DEMUXER_TYPE_PLAYLIST){
e7c8200ffdc5 Respect -playlist for asx streams
rtognimp
parents: 10807
diff changeset
46 *file_format=DEMUXER_TYPE_UNKNOWN;
e7c8200ffdc5 Respect -playlist for asx streams
rtognimp
parents: 10807
diff changeset
47 }
e7c8200ffdc5 Respect -playlist for asx streams
rtognimp
parents: 10807
diff changeset
48
9746
27fff718ede6 Stream cleanup, don't use blah_on options anymore.
albeu
parents: 9712
diff changeset
49 if(!filename) {
27fff718ede6 Stream cleanup, don't use blah_on options anymore.
albeu
parents: 9712
diff changeset
50 mp_msg(MSGT_OPEN,MSGL_ERR,"NULL filename, report this bug\n");
27fff718ede6 Stream cleanup, don't use blah_on options anymore.
albeu
parents: 9712
diff changeset
51 return NULL;
27fff718ede6 Stream cleanup, don't use blah_on options anymore.
albeu
parents: 9712
diff changeset
52 }
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
53
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents: 8712
diff changeset
54
10121
d42177a0da2a Changed the STREAMING defines to MPLAYER_NETWORK to avoid name definition clash.
bertrand
parents: 10067
diff changeset
55 #ifdef MPLAYER_NETWORK
9878
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
56 #ifdef STREAMING_LIVE_DOT_COM
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
57 // Check for a SDP file:
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
58 if (strncmp("sdp://",filename,6) == 0) {
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
59 filename += 6;
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
60 #if defined(__CYGWIN__) || defined(__MINGW32__)
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
61 f=open(filename,O_RDONLY|O_BINARY);
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
62 #else
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
63 f=open(filename,O_RDONLY);
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
64 #endif
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
65 if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);return NULL; }
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
66
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
67 len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET);
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
68 if (len == -1)
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
69 return NULL;
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
70
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
71 #ifdef _LARGEFILE_SOURCE
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
72 mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len);
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
73 #else
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
74 mp_msg(MSGT_OPEN,MSGL_V,"File size is %u bytes\n", (unsigned int)len);
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
75 #endif
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
76 return stream_open_sdp(f, len, file_format);
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
77 }
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
78 #endif
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
79
10697
f0cddd635519 added a workaround to get rid of 'Unable to open URL: mf://*.jpg' and such nonsense (tv,mf,vcd)
alex
parents: 10601
diff changeset
80 // FIXME: to avoid nonsense error messages...
f0cddd635519 added a workaround to get rid of 'Unable to open URL: mf://*.jpg' and such nonsense (tv,mf,vcd)
alex
parents: 10601
diff changeset
81 if (strncmp("tv://", filename, 5) && strncmp("mf://", filename, 5) &&
10735
8a10d5d0ce86 serious bugs - 1l absinth (changed to absinth against cola inflation)
alex
parents: 10697
diff changeset
82 strncmp("vcd://", filename, 6) && strncmp("dvb://", filename, 6) &&
10807
fb66c426cd91 cdda && cddb aren't uris too (hopefully all the pseudo urls are catched before url_new())
alex
parents: 10735
diff changeset
83 strncmp("cdda://", filename, 7) && strncmp("cddb://", filename, 7) &&
14836
8b9738526dd7 added a stream module for the vstream client library
joey
parents: 14092
diff changeset
84 strncmp("mpst://", filename, 7) && strncmp("tivo://", filename, 7) &&
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 15452
diff changeset
85 strncmp("file://", filename, 7) && strncmp("cue://", filename, 6) &&
15520
2c5186ed83b9 ported smb:// to the new stream api
nicodvb
parents: 15518
diff changeset
86 strncmp("ftp://", filename, 6) && strncmp("smb://", filename, 6) &&
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents: 15484
diff changeset
87 strncmp("dvd://", filename, 6) && strncmp("dvdnav://", filename, 9) &&
12270
24c13ef4f42b Escape urls (needed for urls in playlists)
rtognimp
parents: 12269
diff changeset
88 strstr(filename, "://")) {
12391
2677bfac3838 Fix url escaping and avoid double escape
rtognimp
parents: 12270
diff changeset
89 url = url_new(filename);
12270
24c13ef4f42b Escape urls (needed for urls in playlists)
rtognimp
parents: 12269
diff changeset
90 }
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
91 if(url) {
4251
05affdf4bdcd Moved network related code from open.c to network.c
bertrand
parents: 4222
diff changeset
92 stream=new_stream(f,STREAMTYPE_STREAM);
4729
f51bd827ed1c fixed MP3 ICY detection, return detected file format for open_stream
alex
parents: 4551
diff changeset
93 if( streaming_start( stream, file_format, url )<0){
4251
05affdf4bdcd Moved network related code from open.c to network.c
bertrand
parents: 4222
diff changeset
94 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename);
12269
c0c2eb1bfbf1 Stop parsing an url after connection failure
rtognimp
parents: 12223
diff changeset
95 url_free(url);
12571
eba4d274e0a0 Fix playback of file after playing an url
rtognimp
parents: 12412
diff changeset
96 url = NULL;
12269
c0c2eb1bfbf1 Stop parsing an url after connection failure
rtognimp
parents: 12223
diff changeset
97 return NULL;
9795
20f8944a6e0c Remove -sdp
albeu
parents: 9773
diff changeset
98 } else {
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
99 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ConnToServer, url->hostname );
3045
6c14fd789ba5 Changed the order of processing the network opening.
bertrand
parents: 2935
diff changeset
100 url_free(url);
12571
eba4d274e0a0 Fix playback of file after playing an url
rtognimp
parents: 12412
diff changeset
101 url = NULL;
2315
c3c73ba53f0e streaming fixed
arpi
parents: 2314
diff changeset
102 return stream;
12412
57157e702e48 100l for me
rtognimp
parents: 12398
diff changeset
103 }
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
104 }
9878
95727467a091 Moved the "sdp://" test above the URL streaming test, so that SDP files can
rsf
parents: 9801
diff changeset
105 #endif
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
106
6320
12136df07dbd common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents: 5932
diff changeset
107 //============ Open STDIN or plain FILE ============
6910
1a747aee653b applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents: 6853
diff changeset
108
9795
20f8944a6e0c Remove -sdp
albeu
parents: 9773
diff changeset
109 return open_stream_full(filename,STREAM_READ,options,file_format);
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
110 }
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
111