Mercurial > mplayer.hg
annotate stream/stream_rtp.c @ 34238:30adc04c4041
configure: add CONFIG_GNUTLS/CONFIG_OPENSSL to config.h for libavformat
author | diego |
---|---|
date | Mon, 07 Nov 2011 19:54:47 +0000 |
parents | a93891202051 |
children | ebcf337f1786 |
rev | line source |
---|---|
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
1 /* |
26737
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
2 * stream layer for MPEG over RTP, based on previous work from Dave Chapman |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
3 * |
26737
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
4 * Copyright (C) 2006 Benjamin Zores |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
5 * |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
6 * This file is part of MPlayer. |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
7 * |
26737
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
8 * MPlayer is free software; you can redistribute it and/or modify |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
11 * (at your option) any later version. |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
12 * |
26737
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
13 * MPlayer is distributed in the hope that it will be useful, |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
16 * GNU General Public License for more details. |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
17 * |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
18 * You should have received a copy of the GNU General Public License along |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
19 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25211
diff
changeset
|
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
21 */ |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
22 |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
23 #include "config.h" |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
24 |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
25 #include <stdlib.h> |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
26 #include <string.h> |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
27 |
34174
a93891202051
Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents:
31427
diff
changeset
|
28 #include "mp_msg.h" |
31427
9494acd724a9
Remove duplicate network_bandwidth extern declarations.
diego
parents:
29263
diff
changeset
|
29 #include "network.h" |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
30 #include "stream.h" |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
31 #include "url.h" |
19318
a3ddd3320b47
removed udp socket creation code from rtp stack to a new dedicated udp helper file
ben
parents:
19313
diff
changeset
|
32 #include "udp.h" |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
33 #include "rtp.h" |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
34 |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
35 static int |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
36 rtp_streaming_read (int fd, char *buffer, |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
37 int size, streaming_ctrl_t *streaming_ctrl) |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
38 { |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
39 return read_rtp_from_server (fd, buffer, size); |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
40 } |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
41 |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
42 static int |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
43 rtp_streaming_start (stream_t *stream) |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
44 { |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
45 streaming_ctrl_t *streaming_ctrl; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
46 int fd; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
47 |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
48 if (!stream) |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
49 return -1; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
50 |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
51 streaming_ctrl = stream->streaming_ctrl; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
52 fd = stream->fd; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26737
diff
changeset
|
53 |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
54 if (fd < 0) |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
55 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26737
diff
changeset
|
56 fd = udp_open_socket (streaming_ctrl->url); |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
57 if (fd < 0) |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
58 return -1; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
59 stream->fd = fd; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
60 } |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
61 |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
62 streaming_ctrl->streaming_read = rtp_streaming_read; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
63 streaming_ctrl->streaming_seek = nop_streaming_seek; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
64 streaming_ctrl->prebuffer_size = 64 * 1024; /* 64 KBytes */ |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
65 streaming_ctrl->buffering = 0; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
66 streaming_ctrl->status = streaming_playing_e; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26737
diff
changeset
|
67 |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
68 return 0; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
69 } |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
70 |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
71 static int |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
72 rtp_stream_open (stream_t *stream, int mode, void *opts, int *file_format) |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
73 { |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
74 URL_t *url; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26737
diff
changeset
|
75 |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
76 mp_msg (MSGT_OPEN, MSGL_INFO, "STREAM_RTP, URL: %s\n", stream->url); |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
77 stream->streaming_ctrl = streaming_ctrl_new (); |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
78 if (!stream->streaming_ctrl) |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
79 return STREAM_ERROR; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
80 |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
81 stream->streaming_ctrl->bandwidth = network_bandwidth; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
82 url = url_new (stream->url); |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
83 stream->streaming_ctrl->url = check4proxies (url); |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
84 |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
85 if (url->port == 0) |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
86 { |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
87 mp_msg (MSGT_NETWORK, MSGL_ERR, |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
88 "You must enter a port number for RTP streams!\n"); |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
89 streaming_ctrl_free (stream->streaming_ctrl); |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
90 stream->streaming_ctrl = NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26737
diff
changeset
|
91 |
24257 | 92 return STREAM_UNSUPPORTED; |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
93 } |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
94 |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
95 if (rtp_streaming_start (stream) < 0) |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
96 { |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
97 mp_msg (MSGT_NETWORK, MSGL_ERR, "rtp_streaming_start failed\n"); |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
98 streaming_ctrl_free (stream->streaming_ctrl); |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
99 stream->streaming_ctrl = NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26737
diff
changeset
|
100 |
24257 | 101 return STREAM_UNSUPPORTED; |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
102 } |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
103 |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
104 stream->type = STREAMTYPE_STREAM; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
105 fixup_network_stream_cache (stream); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26737
diff
changeset
|
106 |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
107 return STREAM_OK; |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
108 } |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
109 |
25211 | 110 const stream_info_t stream_info_rtp = { |
19313
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
111 "MPEG over RTP streaming", |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
112 "rtp", |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
113 "Dave Chapman, Benjamin Zores", |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
114 "native rtp support", |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
115 rtp_stream_open, |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
116 { "rtp", NULL}, |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
117 NULL, |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
118 0 // Urls are an option string |
0792ad01e9bf
split rtp stack, udp input layer and rtp input layer from rtp.c
ben
parents:
diff
changeset
|
119 }; |