Changeset 24d0946f7a13ab7ee7f5c41fcf374f677bb6fd89
- Timestamp:
- 07/06/08 17:02:30
(6 months ago)
- Author:
- Rémi Denis-Courmont <rdenis@simphalempin.com>
- git-committer:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1212850950 +0300
- git-parent:
[be0a4188843b2cb1ab4b68a7bd08d78e178a5a21]
- git-author:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1212848629 +0300
- Message:
RTP: support for DCCP
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rbe0a418 |
r24d0946 |
|
| 32 | 32 | #include <vlc_aout.h> |
|---|
| 33 | 33 | #include <vlc_network.h> |
|---|
| | 34 | #ifdef HAVE_POLL |
|---|
| | 35 | # include <poll.h> |
|---|
| | 36 | #endif |
|---|
| 34 | 37 | #include <vlc_plugin.h> |
|---|
| 35 | 38 | |
|---|
| … | … | |
| 89 | 92 | change_integer_range (0, 32767); |
|---|
| 90 | 93 | |
|---|
| | 94 | add_shortcut ("dccp"); |
|---|
| 91 | 95 | add_shortcut ("rtp"); |
|---|
| 92 | 96 | add_shortcut ("udplite"); |
|---|
| … | … | |
| 125 | 129 | int tp; /* transport protocol */ |
|---|
| 126 | 130 | |
|---|
| | 131 | if (!strcmp (demux->psz_access, "dccp")) |
|---|
| | 132 | tp = IPPROTO_DCCP; |
|---|
| | 133 | else |
|---|
| 127 | 134 | if (!strcmp (demux->psz_access, "rtp")) |
|---|
| 128 | 135 | tp = IPPROTO_UDP; |
|---|
| … | … | |
| 151 | 158 | |
|---|
| 152 | 159 | /* Try to connect */ |
|---|
| 153 | | int fd = net_OpenDgram (obj, dhost, dport, shost, sport, AF_UNSPEC, tp); |
|---|
| | 160 | int fd = -1; |
|---|
| | 161 | |
|---|
| | 162 | switch (tp) |
|---|
| | 163 | { |
|---|
| | 164 | case IPPROTO_UDP: |
|---|
| | 165 | case IPPROTO_UDPLITE: |
|---|
| | 166 | fd = net_OpenDgram (obj, dhost, dport, shost, sport, AF_UNSPEC, |
|---|
| | 167 | tp); |
|---|
| | 168 | break; |
|---|
| | 169 | |
|---|
| | 170 | case IPPROTO_DCCP: |
|---|
| | 171 | #ifndef SOCK_DCCP /* provisional API (FIXME) */ |
|---|
| | 172 | # ifdef __linux__ |
|---|
| | 173 | # define SOCK_DCCP 6 |
|---|
| | 174 | # endif |
|---|
| | 175 | #endif |
|---|
| | 176 | #ifdef SOCK_DCCP |
|---|
| | 177 | var_Create (obj, "dccp-service", VLC_VAR_STRING); |
|---|
| | 178 | var_SetString (obj, "dccp-service", "RTPV"); |
|---|
| | 179 | fd = net_Connect (obj, shost, sport, SOCK_DCCP, tp); |
|---|
| | 180 | #else |
|---|
| | 181 | msg_Err (obj, "DCCP support not included"); |
|---|
| | 182 | #endif |
|---|
| | 183 | break; |
|---|
| | 184 | } |
|---|
| | 185 | |
|---|
| 154 | 186 | free (tmp); |
|---|
| 155 | 187 | if (fd == -1) |
|---|
| … | … | |
| 266 | 298 | |
|---|
| 267 | 299 | /** |
|---|
| 268 | | * Gets a datagram from the network |
|---|
| | 300 | * Checks if a file descriptor is hung up. |
|---|
| | 301 | */ |
|---|
| | 302 | static bool fd_dead (int fd) |
|---|
| | 303 | { |
|---|
| | 304 | struct pollfd ufd = { .fd = fd, }; |
|---|
| | 305 | |
|---|
| | 306 | return (poll (&ufd, 1, 0) == 1) && (ufd.revents & POLLHUP); |
|---|
| | 307 | } |
|---|
| | 308 | |
|---|
| | 309 | |
|---|
| | 310 | /** |
|---|
| | 311 | * Gets a datagram from the network, or NULL in case of fatal error. |
|---|
| 269 | 312 | */ |
|---|
| 270 | 313 | static block_t *rtp_dgram_recv (demux_t *demux, int fd) |
|---|
| 271 | 314 | { |
|---|
| 272 | 315 | block_t *block = block_Alloc (0xffff); |
|---|
| 273 | | |
|---|
| 274 | | ssize_t len = net_Read (VLC_OBJECT (demux), fd, NULL, |
|---|
| 275 | | block->p_buffer, block->i_buffer, false); |
|---|
| 276 | | if (len == -1) |
|---|
| 277 | | { |
|---|
| 278 | | block_Release (block); |
|---|
| 279 | | return NULL; |
|---|
| 280 | | } |
|---|
| | 316 | ssize_t len; |
|---|
| | 317 | |
|---|
| | 318 | do |
|---|
| | 319 | { |
|---|
| | 320 | len = net_Read (VLC_OBJECT (demux), fd, NULL, |
|---|
| | 321 | block->p_buffer, block->i_buffer, false); |
|---|
| | 322 | if (((len <= 0) && fd_dead (fd)) |
|---|
| | 323 | || demux->b_die) |
|---|
| | 324 | { |
|---|
| | 325 | block_Release (block); |
|---|
| | 326 | return NULL; |
|---|
| | 327 | } |
|---|
| | 328 | } |
|---|
| | 329 | while (len == -1); |
|---|
| | 330 | |
|---|
| 281 | 331 | return block_Realloc (block, 0, len); |
|---|
| 282 | 332 | } |
|---|
| … | … | |
| 471 | 521 | block = rtp_dgram_recv (demux, p_sys->fd); |
|---|
| 472 | 522 | if (!block) |
|---|
| 473 | | return 1; |
|---|
| | 523 | return 0; |
|---|
| 474 | 524 | |
|---|
| 475 | 525 | if (block->i_buffer < 2) |
|---|