dport = 5004; /* avt-profile-1 port */
/* Try to connect */
- int fd = -1;
+ int fd = -1, rtcp_fd = -1;
switch (tp)
{
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
- fd = net_OpenDgram (obj, dhost, dport, shost, sport, AF_UNSPEC,
- tp);
+ fd = net_OpenDgram (obj, dhost, (dport + 1) & ~1,
+ shost, (sport + 1) & ~1, AF_UNSPEC, tp);
+ if (fd == -1)
+ break;
+ rtcp_fd = net_OpenDgram (obj, dhost, dport | 1, shost,
+ sport ? (sport | 1) : 0, AF_UNSPEC, tp);
break;
case IPPROTO_DCCP:
#endif
#ifdef SOCK_DCCP
var_Create (obj, "dccp-service", VLC_VAR_STRING);
- var_SetString (obj, "dccp-service", "RTPV");
- fd = net_Connect (obj, shost, sport, SOCK_DCCP, tp);
+ var_SetString (obj, "dccp-service", "RTPV"); /* FIXME: RTPA? */
+ fd = net_Connect (obj, shost, (sport + 1) & ~1, SOCK_DCCP, tp);
#else
msg_Err (obj, "DCCP support not included");
#endif
break;
case IPPROTO_TCP:
- fd = net_Connect (obj, shost, sport, SOCK_STREAM, tp);
+ fd = net_Connect (obj, shost, (sport + 1) & ~1, SOCK_STREAM, tp);
break;
}
if (p_sys == NULL)
{
net_Close (fd);
+ if (rtcp_fd != -1)
+ net_Close (rtcp_fd);
return VLC_EGENERIC;
}
p_sys->srtp = NULL;
p_sys->fd = fd;
+ p_sys->rtcp_fd = rtcp_fd;
p_sys->caching = var_CreateGetInteger (obj, "rtp-caching");
p_sys->max_src = var_CreateGetInteger (obj, "rtp-max-src");
p_sys->timeout = var_CreateGetInteger (obj, "rtp-timeout");
if (p_sys->session == NULL)
goto error;
- char *key = var_GetNonEmptyString (demux, "srtp-key");
+ char *key = var_CreateGetNonEmptyString (demux, "srtp-key");
if (key)
{
p_sys->srtp = srtp_create (SRTP_ENCR_AES_CM, SRTP_AUTH_HMAC_SHA1, 10,
- SRTP_PRF_AES_CM, 0);
+ SRTP_PRF_AES_CM, SRTP_RCC_MODE1);
if (p_sys->srtp == NULL)
{
free (key);
goto error;
}
- char *salt = var_GetNonEmptyString (demux, "srtp-salt");
+ char *salt = var_CreateGetNonEmptyString (demux, "srtp-salt");
errno = srtp_setkeystring (p_sys->srtp, key, salt ? salt : "");
free (salt);
free (key);
srtp_destroy (p_sys->srtp);
if (p_sys->session)
rtp_session_destroy (demux, p_sys->session);
+ if (p_sys->rtcp_fd != -1)
+ net_Close (p_sys->rtcp_fd);
net_Close (p_sys->fd);
free (p_sys);
}
len = net_Read (VLC_OBJECT (demux), fd, NULL,
block->p_buffer, block->i_buffer, false);
if (((len <= 0) && fd_dead (fd))
- || demux->b_die)
+ || !vlc_object_alive (demux))
{
block_Release (block);
return NULL;
* Hmm, none implemented yet.
*/
-/* PT=dynamic
- * vorbis: Xiph Vorbis audio (draft-ietf-avt-rtp-vorbis-09, RFC FIXME)
- */
-typedef struct rtp_vorbis_t
-{
- es_out_id_t *id;
- block_t *block;
-} rtp_vorbis_t;
-
-static void *vorbis_init (demux_t *demux)
-{
- es_format_t fmt;
- rtp_vorbis_t *self = malloc (sizeof (*self));
-
- if (self == NULL)
- return NULL;
-
- es_format_Init (&fmt, AUDIO_ES, VLC_FOURCC ('v', 'o', 'r', 'b'));
- self->id = codec_init (demux, &fmt);
- self->block = NULL;
- return self;
-}
-
-static void vorbis_destroy (demux_t *demux, void *data)
-{
- rtp_vorbis_t *self = data;
-
- if (!data)
- return;
- if (self->block)
- {
- self->block->i_flags |= BLOCK_FLAG_CORRUPTED;
- codec_decode (demux, NULL, self->block);
- }
- codec_destroy (demux, self->id);
- free (self);
-}
-
-static void vorbis_decode (demux_t *demux, void *data, block_t *block)
-{
- rtp_vorbis_t *self = data;
-
- if (!data || block->i_buffer < 4)
- goto drop;
-
- /* 32-bits Vorbis RTP header */
- uint32_t ident = GetDWBE (block->p_buffer);
- block->i_buffer -= 4;
- block->p_buffer += 4;
-
- unsigned fragtype = (ident >> 6) & 3;
- unsigned datatype = (ident >> 4) & 3;
- unsigned pkts = (ident) & 15;
- ident >>= 8;
-
- /* Vorbis RTP defragmentation */
- if ((fragtype != 0) && (pkts > 0))
- goto drop;
-
- if (self->block && (block->i_flags & BLOCK_FLAG_DISCONTINUITY))
- { /* Screwed! discontinuity within a fragmented packet */
- msg_Warn (demux, "discontinuity in fragmented Vorbis packet");
- self->block->i_flags |= BLOCK_FLAG_CORRUPTED;
- codec_decode (demux, NULL, self->block);
- self->block = NULL;
- }
-
- if (fragtype <= 1)
- {
- if (self->block) /* Buggy sender! */
- {
- block_Release (self->block);
- self->block = NULL;
- }
- if (fragtype == 1)
- {
- self->block = block;
- return;
- }
- }
- else
- {
- if (!self->block) /* Buggy sender! */
- goto drop;
-
- size_t len = self->block->i_buffer;
- self->block = block_Realloc (self->block, 0, len + block->i_buffer);
- if (self->block)
- memcpy (self->block->p_buffer + len, block->p_buffer,
- block->i_buffer);
- block_Release (block);
- if (fragtype == 2 || !self->block)
- return;
-
- /* End of fragment reached */
- block = self->block;
- self->block = NULL;
- }
-
- switch (datatype)
- {
- case 0:
- msg_Dbg (demux, "Payload: raw");
- break;
- case 1:
- msg_Dbg (demux, "Payload: configuration");
- break;
- case 2:
- msg_Dbg (demux, "Payload: comment");
- break;
- default:
- block_Release (block);
- return;
- }
- msg_Dbg (demux, "Packets number %u", pkts);
- msg_Dbg (demux, "Configuration %"PRIu32, ident);
-
- codec_decode (demux, NULL, block);
- return;
-
-drop:
- block_Release (block);
-}
-
/**
* Processing callback
*/
msg_Dbg (demux, "detected MPEG Audio");
pt.init = mpa_init;
pt.decode = mpa_decode;
- pt.frequency = 44100;
+ pt.frequency = 90000;
break;
case 32:
pt.frequency = 90000;
break;
- case 96:
- msg_Dbg (demux, "detected Vorbis");
- pt.init = vorbis_init;
- pt.destroy = vorbis_destroy;
- pt.decode = vorbis_decode;
- pt.frequency = 4281000;
- break;
-
default:
goto drop;
}