Changeset 4c20f3dc05464b7568cfff194cb4d400f3f11a3a

Show
Ignore:
Timestamp:
10/06/08 19:05:07 (4 months ago)
Author:
Rémi Denis-Courmont <rdenis@simphalempin.com>
git-committer:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1213117507 +0300
git-parent:

[a48b31078719ddd3ee9890ccf66613043376408f]

git-author:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1213116873 +0300
Message:

RTP Vorbis payload format (incomplete)

(as per RFC queue'd draft-ietf-avt-rtp-vorbis-09).
Not tested against other implementations, and some pretty bad PTS
issues. RTP only provides us with a valid PTS for the first frame in a
packet, and we don't know the length of each frame, so, hmm... I wonder
how to compute the PTS for non-first frames...

Also, we would need either an SDP parser to use Vorbis (properly) as a
dynamic payload type, or to use a proprietary static payload type and a
proprietary static RTP clock frequency.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/rtp.c

    rc52079a r4c20f3d  
    601601 * Hmm, none implemented yet. 
    602602 */ 
    603 #if 0 
    604 /* PT=dynamic 
    605  * vorbis: Xiph Vorbis audio (draft-ietf-avt-rtp-vorbis-09, RFC FIXME) 
    606  */ 
    607 typedef struct rtp_vorbis_t 
    608 { 
    609     es_out_id_t *id; 
    610     block_t     *block; 
    611 } rtp_vorbis_t; 
    612  
    613 static void *vorbis_init (demux_t *demux) 
    614 { 
    615     es_format_t fmt; 
    616     rtp_vorbis_t *self = malloc (sizeof (*self)); 
    617  
    618     if (self == NULL) 
    619         return NULL; 
    620  
    621     es_format_Init (&fmt, AUDIO_ES, VLC_FOURCC ('v', 'o', 'r', 'b')); 
    622     self->id = codec_init (demux, &fmt); 
    623     self->block = NULL; 
    624     return self; 
    625 } 
    626  
    627 static void vorbis_destroy (demux_t *demux, void *data) 
    628 { 
    629     rtp_vorbis_t *self = data; 
    630  
    631     if (!data) 
    632         return; 
    633     if (self->block) 
    634     { 
    635         self->block->i_flags |= BLOCK_FLAG_CORRUPTED; 
    636         codec_decode (demux, NULL, self->block); 
    637     } 
    638     codec_destroy (demux, self->id); 
    639     free (self); 
    640 } 
    641  
    642 static void vorbis_decode (demux_t *demux, void *data, block_t *block) 
    643 { 
    644     rtp_vorbis_t *self = data; 
    645  
    646     if (!data || block->i_buffer < 4) 
    647         goto drop; 
    648  
    649     /* 32-bits Vorbis RTP header */ 
    650     uint32_t ident = GetDWBE (block->p_buffer); 
    651     block->i_buffer -= 4; 
    652     block->p_buffer += 4; 
    653  
    654     unsigned fragtype = (ident >> 6) & 3; 
    655     unsigned datatype = (ident >> 4) & 3; 
    656     unsigned pkts = (ident) & 15; 
    657     ident >>= 8; 
    658  
    659     /* Vorbis RTP defragmentation */ 
    660     if ((fragtype != 0) && (pkts > 0)) 
    661         goto drop; 
    662  
    663     if (self->block && (block->i_flags & BLOCK_FLAG_DISCONTINUITY)) 
    664     {   /* Screwed! discontinuity within a fragmented packet */ 
    665         msg_Warn (demux, "discontinuity in fragmented Vorbis packet"); 
    666         self->block->i_flags |= BLOCK_FLAG_CORRUPTED; 
    667         codec_decode (demux, NULL, self->block); 
    668         self->block = NULL; 
    669     } 
    670  
    671     if (fragtype <= 1) 
    672     { 
    673         if (self->block) /* Buggy sender! */ 
    674         { 
    675             block_Release (self->block); 
    676             self->block = NULL; 
    677         } 
    678         if (fragtype == 1) 
    679         { 
    680             self->block = block; 
    681             return; 
    682         } 
    683     } 
    684     else 
    685     { 
    686         if (!self->block) /* Buggy sender! */ 
    687             goto drop; 
    688  
    689         size_t len = self->block->i_buffer; 
    690         self->block = block_Realloc (self->block, 0, len + block->i_buffer); 
    691         if (self->block) 
    692             memcpy (self->block->p_buffer + len, block->p_buffer, 
    693                     block->i_buffer); 
    694         block_Release (block); 
    695         if (fragtype == 2 || !self->block) 
    696             return; 
    697  
    698         /* End of fragment reached */ 
    699         block = self->block; 
    700         self->block = NULL; 
    701     } 
    702  
    703     switch (datatype) 
    704     { 
    705       case 0: 
    706         msg_Dbg (demux, "Payload: raw"); 
    707         break; 
    708       case 1: 
    709         msg_Dbg (demux, "Payload: configuration"); 
    710         break; 
    711       case 2: 
    712         msg_Dbg (demux, "Payload: comment"); 
    713         break; 
    714       default: 
    715         block_Release (block); 
    716         return; 
    717     } 
    718     msg_Dbg (demux, "Packets number %u", pkts); 
    719     msg_Dbg (demux, "Configuration %"PRIu32, ident); 
    720  
    721     codec_decode (demux, NULL, block); 
    722     return; 
    723  
    724 drop: 
    725     block_Release (block); 
    726 } 
    727 #endif 
    728603 
    729604/**