Mercurial > mplayer.hg
annotate libmpdemux/stream_livedotcom.c @ 18907:fe73d14fb7a9
#define USE_LIBAVUTIL and USE_LIBAVUTIL_SO
author | nicodvb |
---|---|
date | Wed, 05 Jul 2006 20:26:39 +0000 |
parents | 4928dd61f136 |
children | d2d9d011203f |
rev | line source |
---|---|
15585 | 1 |
2 #include "config.h" | |
3 | |
4 #ifdef MPLAYER_NETWORK | |
5 #include <unistd.h> | |
6 #include <stdlib.h> | |
7 #include <stdio.h> | |
8 #include <string.h> | |
9 | |
10 #include "stream.h" | |
11 #include "network.h" | |
12 #include "demuxer.h" | |
13 #include "help_mp.h" | |
14 | |
16572
56a5f69e9b35
"LIVE.COM Streaming Media" is now called "LIVE555 Streaming Media".
rsf
parents:
15777
diff
changeset
|
15 #ifdef STREAMING_LIVE555 |
15585 | 16 |
17 extern int network_bandwidth; | |
18 | |
19 static int _rtsp_streaming_seek(int fd, off_t pos, streaming_ctrl_t* streaming_ctrl) { | |
20 return -1; // For now, we don't handle RTSP stream seeking | |
21 } | |
22 | |
23 static int rtsp_streaming_start(stream_t* stream) { | |
24 stream->streaming_ctrl->streaming_seek = _rtsp_streaming_seek; | |
25 return 0; | |
26 } | |
27 | |
28 | |
29 static int open_live_rtsp_sip(stream_t *stream,int mode, void* opts, int* file_format) { | |
30 URL_t *url; | |
31 | |
32 stream->streaming_ctrl = streaming_ctrl_new(); | |
33 if( stream->streaming_ctrl==NULL ) { | |
34 return STREAM_ERROR; | |
35 } | |
36 stream->streaming_ctrl->bandwidth = network_bandwidth; | |
37 url = url_new(stream->url); | |
38 stream->streaming_ctrl->url = check4proxies(url); | |
39 //url_free(url); | |
40 | |
16572
56a5f69e9b35
"LIVE.COM Streaming Media" is now called "LIVE555 Streaming Media".
rsf
parents:
15777
diff
changeset
|
41 mp_msg(MSGT_OPEN, MSGL_INFO, "STREAM_LIVE555, URL: %s\n", stream->url); |
15585 | 42 |
43 if(rtsp_streaming_start(stream) < 0) { | |
44 mp_msg(MSGT_NETWORK,MSGL_ERR,"rtsp_streaming_start failed\n"); | |
45 goto fail; | |
46 } | |
47 | |
48 *file_format = DEMUXER_TYPE_RTP; | |
49 stream->type = STREAMTYPE_STREAM; | |
50 return STREAM_OK; | |
51 | |
52 fail: | |
53 streaming_ctrl_free( stream->streaming_ctrl ); | |
54 stream->streaming_ctrl = NULL; | |
55 return STREAM_ERROR; | |
56 } | |
57 | |
58 static int open_live_sdp(stream_t *stream,int mode, void* opts, int* file_format) { | |
17089 | 59 int f; |
15585 | 60 char *filename = stream->url; |
61 off_t len; | |
62 char* sdpDescription; | |
63 ssize_t numBytesRead; | |
64 | |
65 if(strncmp("sdp://",filename,6) == 0) { | |
66 filename += 6; | |
67 #if defined(__CYGWIN__) || defined(__MINGW32__) | |
68 f = open(filename,O_RDONLY|O_BINARY); | |
69 #else | |
70 f = open(filename,O_RDONLY); | |
71 #endif | |
72 if(f < 0) { | |
73 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename); | |
74 return STREAM_ERROR; | |
75 } | |
76 | |
77 len=lseek(f,0,SEEK_END); | |
78 lseek(f,0,SEEK_SET); | |
79 if(len == -1) | |
80 return STREAM_ERROR; | |
18558
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
17089
diff
changeset
|
81 if(len > SIZE_MAX - 1) |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
17089
diff
changeset
|
82 return STREAM_ERROR; |
15585 | 83 |
84 sdpDescription = (char*)malloc(len+1); | |
85 if(sdpDescription == NULL) return STREAM_ERROR; | |
86 numBytesRead = read(f, sdpDescription, len); | |
87 if(numBytesRead != len) { | |
88 free(sdpDescription); | |
89 return STREAM_ERROR; | |
90 } | |
91 sdpDescription[len] = '\0'; // to be safe | |
92 stream->priv = sdpDescription; | |
93 | |
94 stream->type = STREAMTYPE_SDP; | |
95 *file_format = DEMUXER_TYPE_RTP; | |
96 return STREAM_OK; | |
97 } | |
17089 | 98 return STREAM_UNSUPORTED; |
15585 | 99 } |
100 | |
101 | |
102 stream_info_t stream_info_rtsp_sip = { | |
15777 | 103 "standard RTSP and SIP", |
104 "RTSP and SIP", | |
15585 | 105 "Ross Finlayson", |
16572
56a5f69e9b35
"LIVE.COM Streaming Media" is now called "LIVE555 Streaming Media".
rsf
parents:
15777
diff
changeset
|
106 "Uses LIVE555 Streaming Media library.", |
15585 | 107 open_live_rtsp_sip, |
108 {"rtsp", "sip", NULL }, | |
109 NULL, | |
110 0 // Urls are an option string | |
111 }; | |
112 | |
113 stream_info_t stream_info_sdp = { | |
15777 | 114 "SDP stream descriptor", |
115 "SDP", | |
15585 | 116 "Ross Finlayson", |
16572
56a5f69e9b35
"LIVE.COM Streaming Media" is now called "LIVE555 Streaming Media".
rsf
parents:
15777
diff
changeset
|
117 "Uses LIVE555 Streaming Media library.", |
15585 | 118 open_live_sdp, |
119 {"sdp", NULL }, | |
120 NULL, | |
121 0 // Urls are an option string | |
122 }; | |
123 | |
124 #endif | |
125 #endif |