annotate stream/stream_livedotcom.c @ 26210:c5a06bc58309

Do not disable all Mac OS X support when pthreads are unavailable.
author diego
date Sat, 15 Mar 2008 09:20:41 +0000
parents c1d17bd6683c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15585
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
1
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
2 #include "config.h"
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
3
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
4 #include <unistd.h>
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
5 #include <stdlib.h>
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
6 #include <stdio.h>
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
7 #include <string.h>
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
8
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
9 #include "stream.h"
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
10 #include "network.h"
19312
ab8d6b6deb63 proper inclusion of demuxer.h (including libmpdemux in Makefile only was to make previous split easier)
ben
parents: 19271
diff changeset
11 #include "libmpdemux/demuxer.h"
15585
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
12 #include "help_mp.h"
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
13
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
14 extern int network_bandwidth;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
15
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
16 static int _rtsp_streaming_seek(int fd, off_t pos, streaming_ctrl_t* streaming_ctrl) {
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
17 return -1; // For now, we don't handle RTSP stream seeking
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
18 }
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
19
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
20 static int rtsp_streaming_start(stream_t* stream) {
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
21 stream->streaming_ctrl->streaming_seek = _rtsp_streaming_seek;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
22 return 0;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
23 }
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
24
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
25
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
26 static int open_live_rtsp_sip(stream_t *stream,int mode, void* opts, int* file_format) {
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
27 URL_t *url;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
28
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
29 stream->streaming_ctrl = streaming_ctrl_new();
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
30 if( stream->streaming_ctrl==NULL ) {
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
31 return STREAM_ERROR;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
32 }
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
33 stream->streaming_ctrl->bandwidth = network_bandwidth;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
34 url = url_new(stream->url);
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
35 stream->streaming_ctrl->url = check4proxies(url);
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
36 //url_free(url);
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
37
16572
56a5f69e9b35 "LIVE.COM Streaming Media" is now called "LIVE555 Streaming Media".
rsf
parents: 15777
diff changeset
38 mp_msg(MSGT_OPEN, MSGL_INFO, "STREAM_LIVE555, URL: %s\n", stream->url);
15585
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
39
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
40 if(rtsp_streaming_start(stream) < 0) {
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
41 mp_msg(MSGT_NETWORK,MSGL_ERR,"rtsp_streaming_start failed\n");
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
42 goto fail;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
43 }
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
44
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
45 *file_format = DEMUXER_TYPE_RTP;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
46 stream->type = STREAMTYPE_STREAM;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
47 return STREAM_OK;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
48
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
49 fail:
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
50 streaming_ctrl_free( stream->streaming_ctrl );
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
51 stream->streaming_ctrl = NULL;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
52 return STREAM_ERROR;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
53 }
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
54
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
55 static int open_live_sdp(stream_t *stream,int mode, void* opts, int* file_format) {
17089
rathann
parents: 16572
diff changeset
56 int f;
15585
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
57 char *filename = stream->url;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
58 off_t len;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
59 char* sdpDescription;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
60 ssize_t numBytesRead;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
61
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
62 if(strncmp("sdp://",filename,6) == 0) {
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
63 filename += 6;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
64 #if defined(__CYGWIN__) || defined(__MINGW32__)
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
65 f = open(filename,O_RDONLY|O_BINARY);
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
66 #else
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
67 f = open(filename,O_RDONLY);
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
68 #endif
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
69 if(f < 0) {
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
70 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
71 return STREAM_ERROR;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
72 }
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
73
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
74 len=lseek(f,0,SEEK_END);
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
75 lseek(f,0,SEEK_SET);
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
76 if(len == -1)
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
77 return STREAM_ERROR;
18558
4928dd61f136 Fix potential integer overflows in memory allocation.
rtogni
parents: 17089
diff changeset
78 if(len > SIZE_MAX - 1)
4928dd61f136 Fix potential integer overflows in memory allocation.
rtogni
parents: 17089
diff changeset
79 return STREAM_ERROR;
15585
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
80
19062
83c3afeab35d drops casts from void * on malloc/calloc from libmpdemux code
reynaldo
parents: 18922
diff changeset
81 sdpDescription = malloc(len+1);
15585
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
82 if(sdpDescription == NULL) return STREAM_ERROR;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
83 numBytesRead = read(f, sdpDescription, len);
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
84 if(numBytesRead != len) {
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
85 free(sdpDescription);
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
86 return STREAM_ERROR;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
87 }
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
88 sdpDescription[len] = '\0'; // to be safe
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
89 stream->priv = sdpDescription;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
90
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
91 stream->type = STREAMTYPE_SDP;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
92 *file_format = DEMUXER_TYPE_RTP;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
93 return STREAM_OK;
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
94 }
24257
d261f5109660 cosmetics: typo fix UNSUPORTED --> UNSUPPORTED
diego
parents: 19312
diff changeset
95 return STREAM_UNSUPPORTED;
15585
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
96 }
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
97
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
98
25211
c1d17bd6683c Mark all stream_info_t as const
reimar
parents: 24257
diff changeset
99 const stream_info_t stream_info_rtsp_sip = {
15777
diego
parents: 15585
diff changeset
100 "standard RTSP and SIP",
diego
parents: 15585
diff changeset
101 "RTSP and SIP",
15585
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
102 "Ross Finlayson",
16572
56a5f69e9b35 "LIVE.COM Streaming Media" is now called "LIVE555 Streaming Media".
rsf
parents: 15777
diff changeset
103 "Uses LIVE555 Streaming Media library.",
15585
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
104 open_live_rtsp_sip,
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
105 {"rtsp", "sip", NULL },
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
106 NULL,
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
107 0 // Urls are an option string
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
108 };
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
109
25211
c1d17bd6683c Mark all stream_info_t as const
reimar
parents: 24257
diff changeset
110 const stream_info_t stream_info_sdp = {
15777
diego
parents: 15585
diff changeset
111 "SDP stream descriptor",
diego
parents: 15585
diff changeset
112 "SDP",
15585
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
113 "Ross Finlayson",
16572
56a5f69e9b35 "LIVE.COM Streaming Media" is now called "LIVE555 Streaming Media".
rsf
parents: 15777
diff changeset
114 "Uses LIVE555 Streaming Media library.",
15585
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
115 open_live_sdp,
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
116 {"sdp", NULL },
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
117 NULL,
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
118 0 // Urls are an option string
281d155fb37f ported all network streams to the new API
nicodvb
parents:
diff changeset
119 };