dvdnav: Support for image highlights for dvdnav menus.
[mplayer/glamo.git] / stream / stream_live555.c
blob0226eab22d293bdf9e3957e49045e850eed4a17d
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"
30 extern int network_bandwidth;
32 static int _rtsp_streaming_seek(int fd, off_t pos, streaming_ctrl_t* streaming_ctrl) {
33 return -1; // For now, we don't handle RTSP stream seeking
36 static int rtsp_streaming_start(stream_t* stream) {
37 stream->streaming_ctrl->streaming_seek = _rtsp_streaming_seek;
38 return 0;
42 static int open_live_rtsp_sip(stream_t *stream,int mode, void* opts, int* file_format) {
43 URL_t *url;
45 stream->streaming_ctrl = streaming_ctrl_new();
46 if( stream->streaming_ctrl==NULL ) {
47 return STREAM_ERROR;
49 stream->streaming_ctrl->bandwidth = network_bandwidth;
50 url = url_new(stream->url);
51 stream->streaming_ctrl->url = check4proxies(url);
52 //url_free(url);
54 mp_msg(MSGT_OPEN, MSGL_INFO, "STREAM_LIVE555, URL: %s\n", stream->url);
56 if(rtsp_streaming_start(stream) < 0) {
57 mp_msg(MSGT_NETWORK,MSGL_ERR,"rtsp_streaming_start failed\n");
58 goto fail;
61 *file_format = DEMUXER_TYPE_RTP;
62 stream->type = STREAMTYPE_STREAM;
63 stream->flags = STREAM_NON_CACHEABLE;
64 return STREAM_OK;
66 fail:
67 streaming_ctrl_free( stream->streaming_ctrl );
68 stream->streaming_ctrl = NULL;
69 return STREAM_ERROR;
72 static int open_live_sdp(stream_t *stream,int mode, void* opts, int* file_format) {
73 int f;
74 char *filename = stream->url;
75 off_t len;
76 char* sdpDescription;
77 ssize_t numBytesRead;
79 if(strncmp("sdp://",filename,6) == 0) {
80 filename += 6;
81 f = open(filename,O_RDONLY|O_BINARY);
82 if(f < 0) {
83 mp_tmsg(MSGT_OPEN,MSGL_ERR,"File not found: '%s'\n",filename);
84 return STREAM_ERROR;
87 len=lseek(f,0,SEEK_END);
88 lseek(f,0,SEEK_SET);
89 if(len == -1)
90 return STREAM_ERROR;
91 if(len > SIZE_MAX - 1)
92 return STREAM_ERROR;
94 sdpDescription = malloc(len+1);
95 if(sdpDescription == NULL) return STREAM_ERROR;
96 numBytesRead = read(f, sdpDescription, len);
97 if(numBytesRead != len) {
98 free(sdpDescription);
99 return STREAM_ERROR;
101 sdpDescription[len] = '\0'; // to be safe
102 stream->priv = sdpDescription;
104 stream->type = STREAMTYPE_SDP;
105 *file_format = DEMUXER_TYPE_RTP;
106 return STREAM_OK;
108 return STREAM_UNSUPPORTED;
112 const stream_info_t stream_info_rtsp_sip = {
113 "standard RTSP and SIP",
114 "RTSP and SIP",
115 "Ross Finlayson",
116 "Uses LIVE555 Streaming Media library.",
117 open_live_rtsp_sip,
118 {"rtsp", "sip", NULL },
119 NULL,
120 0 // Urls are an option string
123 const stream_info_t stream_info_sdp = {
124 "SDP stream descriptor",
125 "SDP",
126 "Ross Finlayson",
127 "Uses LIVE555 Streaming Media library.",
128 open_live_sdp,
129 {"sdp", NULL },
130 NULL,
131 0 // Urls are an option string