Mercurial > libavformat.hg
comparison rtp_mpv.c @ 2406:18e94e5989d8 libavformat
Move the RTP packetization code for MPEG12 video in its own file (rtp_mpv.c)
author | lucabe |
---|---|
date | Fri, 24 Aug 2007 07:13:34 +0000 |
parents | rtp.c@b21c2af60bc9 |
children | 9134c5f663bd |
comparison
equal
deleted
inserted
replaced
2405:1c57f2391cf9 | 2406:18e94e5989d8 |
---|---|
1 /* | |
2 * RTP packetization for MPEG video | |
3 * Copyright (c) 2002 Fabrice Bellard. | |
4 * | |
5 * This file is part of FFmpeg. | |
6 * | |
7 * FFmpeg is free software; you can redistribute it and/or | |
8 * modify it under the terms of the GNU Lesser General Public | |
9 * License as published by the Free Software Foundation; either | |
10 * version 2.1 of the License, or (at your option) any later version. | |
11 * | |
12 * FFmpeg is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
18 * License along with FFmpeg; if not, write to the Free Software | |
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
20 */ | |
21 #include "avformat.h" | |
22 #include "rtp_internal.h" | |
23 | |
24 /* NOTE: a single frame must be passed with sequence header if | |
25 needed. XXX: use slices. */ | |
26 void ff_rtp_send_mpegvideo(AVFormatContext *s1, const uint8_t *buf1, int size) | |
27 { | |
28 RTPDemuxContext *s = s1->priv_data; | |
29 AVStream *st = s1->streams[0]; | |
30 int len, h, max_packet_size; | |
31 uint8_t *q; | |
32 | |
33 max_packet_size = s->max_payload_size; | |
34 | |
35 while (size > 0) { | |
36 /* XXX: more correct headers */ | |
37 h = 0; | |
38 if (st->codec->sub_id == 2) | |
39 h |= 1 << 26; /* mpeg 2 indicator */ | |
40 q = s->buf; | |
41 *q++ = h >> 24; | |
42 *q++ = h >> 16; | |
43 *q++ = h >> 8; | |
44 *q++ = h; | |
45 | |
46 if (st->codec->sub_id == 2) { | |
47 h = 0; | |
48 *q++ = h >> 24; | |
49 *q++ = h >> 16; | |
50 *q++ = h >> 8; | |
51 *q++ = h; | |
52 } | |
53 | |
54 len = max_packet_size - (q - s->buf); | |
55 if (len > size) | |
56 len = size; | |
57 | |
58 memcpy(q, buf1, len); | |
59 q += len; | |
60 | |
61 /* 90 KHz time stamp */ | |
62 s->timestamp = s->base_timestamp + | |
63 av_rescale((int64_t)s->cur_timestamp * st->codec->time_base.num, 90000, st->codec->time_base.den); //FIXME pass timestamps | |
64 ff_rtp_send_data(s1, s->buf, q - s->buf, (len == size)); | |
65 | |
66 buf1 += len; | |
67 size -= len; | |
68 } | |
69 s->cur_timestamp++; | |
70 } | |
71 | |
72 |