URI:
       trtp.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       trtp.c (1038B)
       ---
            1 #include <u.h>
            2 #include <libc.h>
            3 #include <ip.h>
            4 #include "dat.h"
            5 #include "protos.h"
            6 
            7 typedef struct Hdr Hdr;
            8 struct Hdr {
            9         uchar        hdr;                /* RTP header */
           10         uchar        marker;        /* Payload and marker */
           11         uchar        seq[2];        /* Sequence number */
           12         uchar        ts[4];                /* Time stamp */
           13         uchar        ssrc[4];        /* Synchronization source identifier */
           14 };
           15 
           16 enum{
           17         RTPLEN = 12,                /* Minimum size of an RTP header */
           18 };
           19 
           20 static int
           21 p_seprint(Msg *m)
           22 {
           23         Hdr*h;
           24         ushort seq;
           25         ulong ssrc, ts;
           26         int cc, i;
           27 
           28         if(m->pe - m->ps < RTPLEN)
           29                 return -1;
           30 
           31         h = (Hdr*)m->ps;
           32         cc = h->hdr & 0xf;
           33         if(m->pe - m->ps < RTPLEN + cc * 4)
           34                 return -1;
           35 
           36         m->ps += RTPLEN;
           37 
           38         seq = NetS(h->seq);
           39         ts = NetL(h->ts);
           40         ssrc = NetL(h->ssrc);
           41 
           42         m->p = seprint(m->p, m->e, "version=%d x=%d cc=%d seq=%d ts=%ld ssrc=%ulx",
           43                                 (h->hdr >> 6) & 3, (h->hdr >> 4) & 1, cc, seq, ts, ssrc);
           44         for(i = 0; i < cc; i++){
           45                 m->p = seprint(m->p, m->e, " csrc[%d]=%d",
           46                                 i, NetL(m->ps));
           47                 m->ps += 4;
           48         }
           49         m->pr = nil;
           50         return 0;
           51 }
           52 
           53 Proto rtp = {
           54         "rtp",
           55         nil,
           56         nil,
           57         p_seprint,
           58         nil,
           59         nil,
           60         nil,
           61         defaultframer
           62 };