Simplify libass version check.
[mplayer/glamo.git] / stream / stream_live555.c
blob813977847ea9d8838b12eff3520067c31bca9385
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "config.h"
21 #include <unistd.h>
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <string.h>
26 #include "stream.h"
27 #include "network.h"
28 #include "libmpdemux/demuxer.h"
29 #include "help_mp.h"
31 extern int network_bandwidth;
33 static int _rtsp_streaming_seek(int fd, off_t pos, streaming_ctrl_t* streaming_ctrl) {
34 return -1; // For now, we don't handle RTSP stream seeking
37 static int rtsp_streaming_start(stream_t* stream) {
38 stream->streaming_ctrl->streaming_seek = _rtsp_streaming_seek;
39 return 0;
43 static int open_live_rtsp_sip(stream_t *stream,int mode, void* opts, int* file_format) {
44 URL_t *url;
46 stream->streaming_ctrl = streaming_ctrl_new();
47 if( stream->streaming_ctrl==NULL ) {
48 return STREAM_ERROR;
50 stream->streaming_ctrl->bandwidth = network_bandwidth;
51 url = url_new(stream->url);
52 stream->streaming_ctrl->url = check4proxies(url);
53 //url_free(url);
55 mp_msg(MSGT_OPEN, MSGL_INFO, "STREAM_LIVE555, URL: %s\n", stream->url);
57 if(rtsp_streaming_start(stream) < 0) {
58 mp_msg(MSGT_NETWORK,MSGL_ERR,"rtsp_streaming_start failed\n");
59 goto fail;
62 *file_format = DEMUXER_TYPE_RTP;
63 stream->type = STREAMTYPE_STREAM;
64 stream->flags = STREAM_NON_CACHEABLE;
65 return STREAM_OK;
67 fail:
68 streaming_ctrl_free( stream->streaming_ctrl );
69 stream->streaming_ctrl = NULL;
70 return STREAM_ERROR;
73 static int open_live_sdp(stream_t *stream,int mode, void* opts, int* file_format) {
74 int f;
75 char *filename = stream->url;
76 off_t len;
77 char* sdpDescription;
78 ssize_t numBytesRead;
80 if(strncmp("sdp://",filename,6) == 0) {
81 filename += 6;
82 f = open(filename,O_RDONLY|O_BINARY);
83 if(f < 0) {
84 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);
85 return STREAM_ERROR;
88 len=lseek(f,0,SEEK_END);
89 lseek(f,0,SEEK_SET);
90 if(len == -1)
91 return STREAM_ERROR;
92 if(len > SIZE_MAX - 1)
93 return STREAM_ERROR;
95 sdpDescription = malloc(len+1);
96 if(sdpDescription == NULL) return STREAM_ERROR;
97 numBytesRead = read(f, sdpDescription, len);
98 if(numBytesRead != len) {
99 free(sdpDescription);
100 return STREAM_ERROR;
102 sdpDescription[len] = '\0'; // to be safe
103 stream->priv = sdpDescription;
105 stream->type = STREAMTYPE_SDP;
106 *file_format = DEMUXER_TYPE_RTP;
107 return STREAM_OK;
109 return STREAM_UNSUPPORTED;
113 const stream_info_t stream_info_rtsp_sip = {
114 "standard RTSP and SIP",
115 "RTSP and SIP",
116 "Ross Finlayson",
117 "Uses LIVE555 Streaming Media library.",
118 open_live_rtsp_sip,
119 {"rtsp", "sip", NULL },
120 NULL,
121 0 // Urls are an option string
124 const stream_info_t stream_info_sdp = {
125 "SDP stream descriptor",
126 "SDP",
127 "Ross Finlayson",
128 "Uses LIVE555 Streaming Media library.",
129 open_live_sdp,
130 {"sdp", NULL },
131 NULL,
132 0 // Urls are an option string