Changeset bd056290df9e85c7534862a31e2e62fa5b6c3c73
- Timestamp:
- 02/27/07 22:15:49
(2 years ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1172610949 +0000
- git-parent:
[c28624748ceb2bcc6d33d2a569a4f1b826ff2e8d]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1172610949 +0000
- Message:
- Support for customizing the checksum coverage
- Make UDP-Lite an option rather than a distinct shortcut
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r4551908 |
rbd05629 |
|
| 106 | 106 | #define AUTO_MCAST_LONGTEXT N_("Allocates an outbound multicast address " \ |
|---|
| 107 | 107 | "automatically.") |
|---|
| | 108 | #define UDPLITE_TEXT N_("UDP-Lite") |
|---|
| | 109 | #define UDPLITE_LONGTEXT N_("Use UDP-Lite/IP instead of normal UDP/IP") |
|---|
| | 110 | #define CSCOV_TEXT N_("Checksum coverage") |
|---|
| | 111 | #define CSCOV_LONGTEXT N_("Payload bytes covered by layer-4 checksum") |
|---|
| 108 | 112 | |
|---|
| 109 | 113 | vlc_module_begin(); |
|---|
| … | … | |
| 120 | 124 | add_bool( SOUT_CFG_PREFIX "auto-mcast", 0, NULL, AUTO_MCAST_TEXT, |
|---|
| 121 | 125 | AUTO_MCAST_LONGTEXT, VLC_TRUE ); |
|---|
| | 126 | add_bool( SOUT_CFG_PREFIX "udplite", 0, NULL, UDPLITE_TEXT, UDPLITE_LONGTEXT, VLC_TRUE ); |
|---|
| | 127 | add_integer( SOUT_CFG_PREFIX "cscov", 12, NULL, CSCOV_TEXT, CSCOV_LONGTEXT, VLC_TRUE ); |
|---|
| 122 | 128 | |
|---|
| 123 | 129 | set_capability( "sout access", 100 ); |
|---|
| 124 | 130 | add_shortcut( "udp" ); |
|---|
| 125 | 131 | add_shortcut( "rtp" ); // Will work only with ts muxer |
|---|
| 126 | | add_shortcut( "udplite" ); |
|---|
| 127 | 132 | set_callbacks( Open, Close ); |
|---|
| 128 | 133 | vlc_module_end(); |
|---|
| … | … | |
| 137 | 142 | "group", |
|---|
| 138 | 143 | "raw", |
|---|
| | 144 | "lite", |
|---|
| | 145 | "cscov", |
|---|
| 139 | 146 | NULL |
|---|
| 140 | 147 | }; |
|---|
| … | … | |
| 205 | 212 | * Open: open the file |
|---|
| 206 | 213 | *****************************************************************************/ |
|---|
| 207 | | /* FIXME: lots of leaks in error handling here! */ |
|---|
| 208 | 214 | static int Open( vlc_object_t *p_this ) |
|---|
| 209 | 215 | { |
|---|
| … | … | |
| 212 | 218 | |
|---|
| 213 | 219 | char *psz_dst_addr = NULL; |
|---|
| 214 | | int i_dst_port, proto = IPPROTO_UDP, cscov = 8; |
|---|
| | 220 | int i_dst_port, proto = IPPROTO_UDP; |
|---|
| 215 | 221 | const char *protoname = "UDP"; |
|---|
| 216 | 222 | |
|---|
| … | … | |
| 224 | 230 | ppsz_core_options, p_access->p_cfg ); |
|---|
| 225 | 231 | |
|---|
| 226 | | if( !( p_sys = calloc ( 1, sizeof( sout_access_out_sys_t ) ) ) ) |
|---|
| 227 | | { |
|---|
| 228 | | msg_Err( p_access, "not enough memory" ); |
|---|
| 229 | | return VLC_EGENERIC; |
|---|
| 230 | | } |
|---|
| 231 | | p_access->p_sys = p_sys; |
|---|
| 232 | | |
|---|
| 233 | | if( p_access->psz_access != NULL ) |
|---|
| 234 | | { |
|---|
| 235 | | if (strcmp (p_access->psz_access, "rtp") == 0) |
|---|
| 236 | | p_sys->b_rtpts = VLC_TRUE; |
|---|
| 237 | | if (strcmp (p_access->psz_access, "udplite") == 0) |
|---|
| 238 | | { |
|---|
| 239 | | protoname = "UDP-Lite"; |
|---|
| 240 | | proto = IPPROTO_UDPLITE; |
|---|
| 241 | | p_sys->b_rtpts = VLC_TRUE; |
|---|
| 242 | | } |
|---|
| 243 | | } |
|---|
| 244 | | if (p_sys->b_rtpts) |
|---|
| 245 | | cscov += RTP_HEADER_LENGTH; |
|---|
| 246 | | |
|---|
| 247 | | i_dst_port = DEFAULT_PORT; |
|---|
| 248 | | if (var_CreateGetBool (p_access, SOUT_CFG_PREFIX"auto-mcast")) |
|---|
| 249 | | { |
|---|
| 250 | | char buf[INET6_ADDRSTRLEN]; |
|---|
| 251 | | if (MakeRandMulticast (AF_INET, buf, sizeof (buf)) != NULL) |
|---|
| 252 | | psz_dst_addr = strdup (buf); |
|---|
| 253 | | } |
|---|
| 254 | | else |
|---|
| 255 | | { |
|---|
| 256 | | char *psz_parser = psz_dst_addr = strdup( p_access->psz_path ); |
|---|
| 257 | | |
|---|
| 258 | | if (psz_parser[0] == '[') |
|---|
| 259 | | psz_parser = strchr (psz_parser, ']'); |
|---|
| 260 | | |
|---|
| 261 | | psz_parser = strchr (psz_parser, ':'); |
|---|
| 262 | | if (psz_parser != NULL) |
|---|
| 263 | | { |
|---|
| 264 | | *psz_parser++ = '\0'; |
|---|
| 265 | | i_dst_port = atoi (psz_parser); |
|---|
| 266 | | } |
|---|
| 267 | | } |
|---|
| 268 | | |
|---|
| 269 | 232 | if (var_Create (p_access, "dst-port", VLC_VAR_INTEGER) |
|---|
| 270 | 233 | || var_Create (p_access, "src-port", VLC_VAR_INTEGER) |
|---|
| … | … | |
| 272 | 235 | || var_Create (p_access, "src-addr", VLC_VAR_STRING)) |
|---|
| 273 | 236 | { |
|---|
| 274 | | free (p_sys); |
|---|
| 275 | | free (psz_dst_addr); |
|---|
| 276 | 237 | return VLC_ENOMEM; |
|---|
| | 238 | } |
|---|
| | 239 | |
|---|
| | 240 | if( !( p_sys = calloc ( 1, sizeof( sout_access_out_sys_t ) ) ) ) |
|---|
| | 241 | { |
|---|
| | 242 | msg_Err( p_access, "not enough memory" ); |
|---|
| | 243 | return VLC_ENOMEM; |
|---|
| | 244 | } |
|---|
| | 245 | p_access->p_sys = p_sys; |
|---|
| | 246 | |
|---|
| | 247 | if( p_access->psz_access != NULL ) |
|---|
| | 248 | { |
|---|
| | 249 | if (strcmp (p_access->psz_access, "rtp") == 0) |
|---|
| | 250 | p_sys->b_rtpts = VLC_TRUE; |
|---|
| | 251 | } |
|---|
| | 252 | |
|---|
| | 253 | if (var_GetBool (p_access, SOUT_CFG_PREFIX"lite")) |
|---|
| | 254 | { |
|---|
| | 255 | protoname = "UDP-Lite"; |
|---|
| | 256 | proto = IPPROTO_UDPLITE; |
|---|
| | 257 | } |
|---|
| | 258 | |
|---|
| | 259 | i_dst_port = DEFAULT_PORT; |
|---|
| | 260 | if (var_GetBool (p_access, SOUT_CFG_PREFIX"auto-mcast")) |
|---|
| | 261 | { |
|---|
| | 262 | char buf[INET6_ADDRSTRLEN]; |
|---|
| | 263 | if (MakeRandMulticast (AF_INET, buf, sizeof (buf)) != NULL) |
|---|
| | 264 | psz_dst_addr = strdup (buf); |
|---|
| | 265 | } |
|---|
| | 266 | else |
|---|
| | 267 | { |
|---|
| | 268 | char *psz_parser = psz_dst_addr = strdup( p_access->psz_path ); |
|---|
| | 269 | |
|---|
| | 270 | if (psz_parser[0] == '[') |
|---|
| | 271 | psz_parser = strchr (psz_parser, ']'); |
|---|
| | 272 | |
|---|
| | 273 | psz_parser = strchr (psz_parser, ':'); |
|---|
| | 274 | if (psz_parser != NULL) |
|---|
| | 275 | { |
|---|
| | 276 | *psz_parser++ = '\0'; |
|---|
| | 277 | i_dst_port = atoi (psz_parser); |
|---|
| | 278 | } |
|---|
| 277 | 279 | } |
|---|
| 278 | 280 | |
|---|
| … | … | |
| 326 | 328 | shutdown( i_handle, SHUT_RD ); |
|---|
| 327 | 329 | |
|---|
| | 330 | int cscov = var_GetInteger (p_access, SOUT_CFG_PREFIX"cscov"); |
|---|
| | 331 | if (cscov) |
|---|
| | 332 | { |
|---|
| | 333 | switch (proto) |
|---|
| | 334 | { |
|---|
| 328 | 335 | #ifdef UDPLITE_SEND_CSCOV |
|---|
| 329 | | if (proto == IPPROTO_UDPLITE) |
|---|
| 330 | | setsockopt (i_handle, SOL_UDPLITE, UDPLITE_SEND_CSCOV, |
|---|
| 331 | | &cscov, sizeof (cscov)); |
|---|
| 332 | | #endif |
|---|
| | 336 | case IPPROTO_UDPLITE: |
|---|
| | 337 | cscov += 8; |
|---|
| | 338 | setsockopt (i_handle, SOL_UDPLITE, UDPLITE_SEND_CSCOV, |
|---|
| | 339 | &(int){ cscov }, sizeof (cscov)); |
|---|
| | 340 | break; |
|---|
| | 341 | #endif |
|---|
| | 342 | #ifdef DCCP_SOCKOPT_RECV_CSCOV |
|---|
| | 343 | /* FIXME: ^^is this the right name ? */ |
|---|
| | 344 | /* FIXME: is this inherited by accept() ? */ |
|---|
| | 345 | case IPPROTO_DCCP: |
|---|
| | 346 | cscov = ((cscov + 3) >> 2) + 1; |
|---|
| | 347 | if (cscov > 15) |
|---|
| | 348 | break; /* out of DCCP cscov range */ |
|---|
| | 349 | setsockopt (i_handle, SOL_DCCP, DCCP_SOCKOPT_RECV_CSCOV, |
|---|
| | 350 | &(int){ cscov }, sizeof (cscov)); |
|---|
| | 351 | break; |
|---|
| | 352 | #endif |
|---|
| | 353 | } |
|---|
| | 354 | } |
|---|
| 333 | 355 | |
|---|
| 334 | 356 | var_Get( p_access, SOUT_CFG_PREFIX "caching", &val ); |
|---|