~ubuntu-branches/ubuntu/saucy/gst-libav1.0/saucy-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavformat/rtpenc_vp8.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-07-30 09:00:15 UTC
  • mfrom: (1.1.16) (7.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20130730090015-sc1ou2yssu7q5w4e
Tags: 1.1.3-1
* New upstream development snapshot:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.1.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "rtpenc.h"
23
23
 
24
24
/* Based on a draft spec for VP8 RTP.
25
 
 * ( http://www.webmproject.org/code/specs/rtp/ ) */
 
25
 * ( http://tools.ietf.org/html/draft-ietf-payload-vp8-05 ) */
26
26
void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buf, int size)
27
27
{
28
28
    RTPMuxContext *s = s1->priv_data;
29
 
    int len, max_packet_size;
 
29
    int len, max_packet_size, header_size;
30
30
 
31
31
    s->buf_ptr      = s->buf;
32
32
    s->timestamp    = s->cur_timestamp;
33
 
    max_packet_size = s->max_payload_size - 1; // minus one for header byte
34
 
 
35
 
    *s->buf_ptr++ = 1; // 0b1 indicates start of frame
 
33
 
 
34
    // extended control bit set, reference frame, start of partition,
 
35
    // partition id 0
 
36
    *s->buf_ptr++ = 0x90;
 
37
    *s->buf_ptr++ = 0x80; // Picture id present
 
38
    *s->buf_ptr++ = s->frame_count++ & 0x7f;
 
39
    // Calculate the number of remaining bytes
 
40
    header_size     = s->buf_ptr - s->buf;
 
41
    max_packet_size = s->max_payload_size - header_size;
 
42
 
36
43
    while (size > 0) {
37
44
        len = FFMIN(size, max_packet_size);
38
45
 
39
46
        memcpy(s->buf_ptr, buf, len);
40
 
        ff_rtp_send_data(s1, s->buf, len+1, size == len); // marker bit is last packet in frame
 
47
        // marker bit is last packet in frame
 
48
        ff_rtp_send_data(s1, s->buf, len + header_size, size == len);
41
49
 
42
50
        size         -= len;
43
51
        buf          += len;
44
 
        s->buf_ptr    = s->buf;
45
 
        *s->buf_ptr++ = 0; // payload descriptor
 
52
        // Clear the partition start bit, keep the rest of the header untouched
 
53
        s->buf[0]    &= ~0x10;
46
54
    }
47
55
}