annotate rtp.c @ 298:0b2eed7b1210 libavformat

movenc patch by (Gildas Bazin <gbazin at altern dot org>)
author michael
date Mon, 03 Nov 2003 21:51:07 +0000
parents 6091b76cfc2a
children ef53bff8bf23
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
2 * RTP input/output format
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
3 * Copyright (c) 2002 Fabrice Bellard.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
4 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
18 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
19 #include "avformat.h"
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
20 #include "mpegts.h"
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
21
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
22 #include <unistd.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
23 #include <sys/types.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24 #include <sys/socket.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
25 #include <netinet/in.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
26 #ifndef __BEOS__
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
27 # include <arpa/inet.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
28 #else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
29 # include "barpainet.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
30 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
31 #include <netdb.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
32
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
33 //#define DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
34
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
35
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
36 /* TODO: - add RTCP statistics reporting (should be optional).
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
37
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
38 - add support for h263/mpeg4 packetized output : IDEA: send a
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
39 buffer to 'rtp_write_packet' contains all the packets for ONE
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
40 frame. Each packet should have a four byte header containing
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
41 the length in big endian format (same trick as
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
42 'url_open_dyn_packet_buf')
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
43 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
44
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
45 #define RTP_VERSION 2
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
46
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
47 #define RTP_MAX_SDES 256 /* maximum text length for SDES */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
48
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
49 /* RTCP paquets use 0.5 % of the bandwidth */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
50 #define RTCP_TX_RATIO_NUM 5
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
51 #define RTCP_TX_RATIO_DEN 1000
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
52
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
53 typedef enum {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
54 RTCP_SR = 200,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
55 RTCP_RR = 201,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
56 RTCP_SDES = 202,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
57 RTCP_BYE = 203,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
58 RTCP_APP = 204
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
59 } rtcp_type_t;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
60
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
61 typedef enum {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
62 RTCP_SDES_END = 0,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
63 RTCP_SDES_CNAME = 1,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
64 RTCP_SDES_NAME = 2,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
65 RTCP_SDES_EMAIL = 3,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
66 RTCP_SDES_PHONE = 4,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
67 RTCP_SDES_LOC = 5,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
68 RTCP_SDES_TOOL = 6,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
69 RTCP_SDES_NOTE = 7,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
70 RTCP_SDES_PRIV = 8,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
71 RTCP_SDES_IMG = 9,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
72 RTCP_SDES_DOOR = 10,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
73 RTCP_SDES_SOURCE = 11
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
74 } rtcp_sdes_type_t;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
75
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
76 struct RTPDemuxContext {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
77 AVFormatContext *ic;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
78 AVStream *st;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
79 int payload_type;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
80 uint32_t ssrc;
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
81 uint16_t seq;
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
82 uint32_t timestamp;
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
83 uint32_t base_timestamp;
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
84 uint32_t cur_timestamp;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
85 int max_payload_size;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
86 MpegTSContext *ts; /* only used for RTP_PT_MPEG2TS payloads */
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
87 int read_buf_index;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
88 int read_buf_size;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
89
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
90 /* rtcp sender statistics receive */
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
91 int64_t last_rtcp_ntp_time;
173
38f64fabb24b fixed NTP generation for mpeg
bellard
parents: 85
diff changeset
92 int64_t first_rtcp_ntp_time;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
93 uint32_t last_rtcp_timestamp;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
94 /* rtcp sender statistics */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
95 unsigned int packet_count;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
96 unsigned int octet_count;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
97 unsigned int last_octet_count;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
98 int first_packet;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
99 /* buffer for output */
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
100 uint8_t buf[RTP_MAX_PACKET_LENGTH];
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
101 uint8_t *buf_ptr;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
102 };
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
103
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
104 int rtp_get_codec_info(AVCodecContext *codec, int payload_type)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
105 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
106 switch(payload_type) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
107 case RTP_PT_ULAW:
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
108 codec->codec_type = CODEC_TYPE_AUDIO;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
109 codec->codec_id = CODEC_ID_PCM_MULAW;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
110 codec->channels = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
111 codec->sample_rate = 8000;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
112 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
113 case RTP_PT_ALAW:
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
114 codec->codec_type = CODEC_TYPE_AUDIO;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
115 codec->codec_id = CODEC_ID_PCM_ALAW;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
116 codec->channels = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
117 codec->sample_rate = 8000;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
118 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
119 case RTP_PT_S16BE_STEREO:
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
120 codec->codec_type = CODEC_TYPE_AUDIO;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
121 codec->codec_id = CODEC_ID_PCM_S16BE;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
122 codec->channels = 2;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
123 codec->sample_rate = 44100;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
124 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
125 case RTP_PT_S16BE_MONO:
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
126 codec->codec_type = CODEC_TYPE_AUDIO;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
127 codec->codec_id = CODEC_ID_PCM_S16BE;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
128 codec->channels = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
129 codec->sample_rate = 44100;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
130 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
131 case RTP_PT_MPEGAUDIO:
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
132 codec->codec_type = CODEC_TYPE_AUDIO;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
133 codec->codec_id = CODEC_ID_MP2;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
134 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
135 case RTP_PT_JPEG:
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
136 codec->codec_type = CODEC_TYPE_VIDEO;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
137 codec->codec_id = CODEC_ID_MJPEG;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
138 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
139 case RTP_PT_MPEGVIDEO:
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
140 codec->codec_type = CODEC_TYPE_VIDEO;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
141 codec->codec_id = CODEC_ID_MPEG1VIDEO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
142 break;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
143 case RTP_PT_MPEG2TS:
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
144 codec->codec_type = CODEC_TYPE_DATA;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
145 codec->codec_id = CODEC_ID_MPEG2TS;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
146 break;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
147 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
148 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
149 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
150 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
151 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
152
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
153 /* return < 0 if unknown payload type */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
154 int rtp_get_payload_type(AVCodecContext *codec)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
155 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
156 int payload_type;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
157
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
158 /* compute the payload type */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
159 payload_type = -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
160 switch(codec->codec_id) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
161 case CODEC_ID_PCM_MULAW:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
162 payload_type = RTP_PT_ULAW;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
163 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
164 case CODEC_ID_PCM_ALAW:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
165 payload_type = RTP_PT_ALAW;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
166 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
167 case CODEC_ID_PCM_S16BE:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
168 if (codec->channels == 1) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
169 payload_type = RTP_PT_S16BE_MONO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
170 } else if (codec->channels == 2) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
171 payload_type = RTP_PT_S16BE_STEREO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
172 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
173 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
174 case CODEC_ID_MP2:
232
eb90c0a5a1ba CODEC_ID_MP3LAME is obsolete
bellard
parents: 173
diff changeset
175 case CODEC_ID_MP3:
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
176 payload_type = RTP_PT_MPEGAUDIO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
177 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
178 case CODEC_ID_MJPEG:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
179 payload_type = RTP_PT_JPEG;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
180 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
181 case CODEC_ID_MPEG1VIDEO:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
182 payload_type = RTP_PT_MPEGVIDEO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
183 break;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
184 case CODEC_ID_MPEG2TS:
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
185 payload_type = RTP_PT_MPEG2TS;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
186 break;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
187 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
188 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
189 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
190 return payload_type;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
191 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
192
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
193 static inline uint32_t decode_be32(const uint8_t *p)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
194 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
195 return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
196 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
197
173
38f64fabb24b fixed NTP generation for mpeg
bellard
parents: 85
diff changeset
198 static inline uint64_t decode_be64(const uint8_t *p)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
199 {
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
200 return ((uint64_t)decode_be32(p) << 32) | decode_be32(p + 4);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
201 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
202
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
203 static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int len)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
204 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
205 if (buf[1] != 200)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
206 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
207 s->last_rtcp_ntp_time = decode_be64(buf + 8);
173
38f64fabb24b fixed NTP generation for mpeg
bellard
parents: 85
diff changeset
208 if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE)
38f64fabb24b fixed NTP generation for mpeg
bellard
parents: 85
diff changeset
209 s->first_rtcp_ntp_time = s->last_rtcp_ntp_time;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
210 s->last_rtcp_timestamp = decode_be32(buf + 16);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
211 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
212 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
213
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
214 /**
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
215 * open a new RTP parse context for stream 'st'. 'st' can be NULL for
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
216 * MPEG2TS streams to indicate that they should be demuxed inside the
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
217 * rtp demux (otherwise CODEC_ID_MPEG2TS packets are returned)
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
218 */
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
219 RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, int payload_type)
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
220 {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
221 RTPDemuxContext *s;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
222
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
223 s = av_mallocz(sizeof(RTPDemuxContext));
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
224 if (!s)
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
225 return NULL;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
226 s->payload_type = payload_type;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
227 s->last_rtcp_ntp_time = AV_NOPTS_VALUE;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
228 s->first_rtcp_ntp_time = AV_NOPTS_VALUE;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
229 s->ic = s1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
230 s->st = st;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
231 if (payload_type == RTP_PT_MPEG2TS) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
232 s->ts = mpegts_parse_open(s->ic);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
233 if (s->ts == NULL) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
234 av_free(s);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
235 return NULL;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
236 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
237 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
238 return s;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
239 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
240
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
241 /**
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
242 * Parse an RTP or RTCP packet directly sent as a buffer.
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
243 * @param s RTP parse context.
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
244 * @param pkt returned packet
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
245 * @param buf input buffer or NULL to read the next packets
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
246 * @param len buffer len
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
247 * @return 0 if a packet is returned, 1 if a packet is returned and more can follow
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
248 * (use buf as NULL to read the next). -1 if no packet (error or no more packet).
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
249 */
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
250 int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
251 const uint8_t *buf, int len)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
252 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
253 unsigned int ssrc, h;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
254 int payload_type, seq, delta_timestamp, ret;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
255 AVStream *st;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
256 uint32_t timestamp;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
257
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
258 if (!buf) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
259 /* return the next packets, if any */
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
260 if (s->read_buf_index >= s->read_buf_size)
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
261 return -1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
262 ret = mpegts_parse_packet(s->ts, pkt, s->buf + s->read_buf_index,
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
263 s->read_buf_size - s->read_buf_index);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
264 if (ret < 0)
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
265 return -1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
266 s->read_buf_index += ret;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
267 if (s->read_buf_index < s->read_buf_size)
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
268 return 1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
269 else
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
270 return 0;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
271 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
272
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
273 if (len < 12)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
274 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
275
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
276 if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
277 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
278 if (buf[1] >= 200 && buf[1] <= 204) {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
279 rtcp_parse_packet(s, buf, len);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
280 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
281 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
282 payload_type = buf[1] & 0x7f;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
283 seq = (buf[2] << 8) | buf[3];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
284 timestamp = decode_be32(buf + 4);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
285 ssrc = decode_be32(buf + 8);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
286
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
287 /* NOTE: we can handle only one payload type */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
288 if (s->payload_type != payload_type)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
289 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
290 #if defined(DEBUG) || 1
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
291 if (seq != ((s->seq + 1) & 0xffff)) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
292 printf("RTP: PT=%02x: bad cseq %04x expected=%04x\n",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
293 payload_type, seq, ((s->seq + 1) & 0xffff));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
294 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
295 s->seq = seq;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
296 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
297 len -= 12;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
298 buf += 12;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
299
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
300 st = s->st;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
301 if (!st) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
302 /* specific MPEG2TS demux support */
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
303 ret = mpegts_parse_packet(s->ts, pkt, buf, len);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
304 if (ret < 0)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
305 return -1;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
306 if (ret < len) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
307 s->read_buf_size = len - ret;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
308 memcpy(s->buf, buf + ret, s->read_buf_size);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
309 s->read_buf_index = 0;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
310 return 1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
311 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
312 } else {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
313 switch(st->codec.codec_id) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
314 case CODEC_ID_MP2:
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
315 /* better than nothing: skip mpeg audio RTP header */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
316 if (len <= 4)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
317 return -1;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
318 h = decode_be32(buf);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
319 len -= 4;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
320 buf += 4;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
321 av_new_packet(pkt, len);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
322 memcpy(pkt->data, buf, len);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
323 break;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
324 case CODEC_ID_MPEG1VIDEO:
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
325 /* better than nothing: skip mpeg audio RTP header */
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
326 if (len <= 4)
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
327 return -1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
328 h = decode_be32(buf);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
329 buf += 4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
330 len -= 4;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
331 if (h & (1 << 26)) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
332 /* mpeg2 */
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
333 if (len <= 4)
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
334 return -1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
335 buf += 4;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
336 len -= 4;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
337 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
338 av_new_packet(pkt, len);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
339 memcpy(pkt->data, buf, len);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
340 break;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
341 default:
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
342 av_new_packet(pkt, len);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
343 memcpy(pkt->data, buf, len);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
344 break;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
345 }
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
346
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
347 switch(st->codec.codec_id) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
348 case CODEC_ID_MP2:
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
349 case CODEC_ID_MPEG1VIDEO:
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
350 if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
351 int64_t addend;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
352 /* XXX: is it really necessary to unify the timestamp base ? */
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
353 /* compute pts from timestamp with received ntp_time */
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
354 delta_timestamp = timestamp - s->last_rtcp_timestamp;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
355 /* convert to 90 kHz without overflow */
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
356 addend = (s->last_rtcp_ntp_time - s->first_rtcp_ntp_time) >> 14;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
357 addend = (addend * 5625) >> 14;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
358 pkt->pts = addend + delta_timestamp;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
359 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
360 break;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
361 default:
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
362 /* no timestamp info yet */
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
363 break;
173
38f64fabb24b fixed NTP generation for mpeg
bellard
parents: 85
diff changeset
364 }
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
365 pkt->stream_index = s->st->index;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
366 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
367 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
368 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
369
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
370 void rtp_parse_close(RTPDemuxContext *s)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
371 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
372 if (s->payload_type == RTP_PT_MPEG2TS) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
373 mpegts_parse_close(s->ts);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
374 }
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
375 av_free(s);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
376 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
377
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
378 /* rtp output */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
379
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
380 static int rtp_write_header(AVFormatContext *s1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
381 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
382 RTPDemuxContext *s = s1->priv_data;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
383 int payload_type, max_packet_size, n;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
384 AVStream *st;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
385
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
386 if (s1->nb_streams != 1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
387 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
388 st = s1->streams[0];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
389
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
390 payload_type = rtp_get_payload_type(&st->codec);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
391 if (payload_type < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
392 payload_type = RTP_PT_PRIVATE; /* private payload type */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
393 s->payload_type = payload_type;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
394
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
395 s->base_timestamp = random();
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
396 s->timestamp = s->base_timestamp;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
397 s->ssrc = random();
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
398 s->first_packet = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
399
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
400 max_packet_size = url_fget_max_packet_size(&s1->pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
401 if (max_packet_size <= 12)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
402 return AVERROR_IO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
403 s->max_payload_size = max_packet_size - 12;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
404
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
405 switch(st->codec.codec_id) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
406 case CODEC_ID_MP2:
232
eb90c0a5a1ba CODEC_ID_MP3LAME is obsolete
bellard
parents: 173
diff changeset
407 case CODEC_ID_MP3:
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
408 s->buf_ptr = s->buf + 4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
409 s->cur_timestamp = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
410 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
411 case CODEC_ID_MPEG1VIDEO:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
412 s->cur_timestamp = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
413 break;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
414 case CODEC_ID_MPEG2TS:
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
415 n = s->max_payload_size / TS_PACKET_SIZE;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
416 if (n < 1)
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
417 n = 1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
418 s->max_payload_size = n * TS_PACKET_SIZE;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
419 s->buf_ptr = s->buf;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
420 break;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
421 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
422 s->buf_ptr = s->buf;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
423 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
424 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
425
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
426 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
427 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
428
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
429 /* send an rtcp sender report packet */
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
430 static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
431 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
432 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
433 #if defined(DEBUG)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
434 printf("RTCP: %02x %Lx %x\n", s->payload_type, ntp_time, s->timestamp);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
435 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
436 put_byte(&s1->pb, (RTP_VERSION << 6));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
437 put_byte(&s1->pb, 200);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
438 put_be16(&s1->pb, 6); /* length in words - 1 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
439 put_be32(&s1->pb, s->ssrc);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
440 put_be64(&s1->pb, ntp_time);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
441 put_be32(&s1->pb, s->timestamp);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
442 put_be32(&s1->pb, s->packet_count);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
443 put_be32(&s1->pb, s->octet_count);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
444 put_flush_packet(&s1->pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
445 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
446
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
447 /* send an rtp packet. sequence number is incremented, but the caller
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
448 must update the timestamp itself */
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
449 static void rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
450 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
451 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
452
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
453 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
454 printf("rtp_send_data size=%d\n", len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
455 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
456
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
457 /* build the RTP header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
458 put_byte(&s1->pb, (RTP_VERSION << 6));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
459 put_byte(&s1->pb, s->payload_type & 0x7f);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
460 put_be16(&s1->pb, s->seq);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
461 put_be32(&s1->pb, s->timestamp);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
462 put_be32(&s1->pb, s->ssrc);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
463
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
464 put_buffer(&s1->pb, buf1, len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
465 put_flush_packet(&s1->pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
466
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
467 s->seq++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
468 s->octet_count += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
469 s->packet_count++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
470 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
471
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
472 /* send an integer number of samples and compute time stamp and fill
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
473 the rtp send buffer before sending. */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
474 static void rtp_send_samples(AVFormatContext *s1,
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
475 const uint8_t *buf1, int size, int sample_size)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
476 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
477 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
478 int len, max_packet_size, n;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
479
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
480 max_packet_size = (s->max_payload_size / sample_size) * sample_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
481 /* not needed, but who nows */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
482 if ((size % sample_size) != 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
483 av_abort();
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
484 while (size > 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
485 len = (max_packet_size - (s->buf_ptr - s->buf));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
486 if (len > size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
487 len = size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
488
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
489 /* copy data */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
490 memcpy(s->buf_ptr, buf1, len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
491 s->buf_ptr += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
492 buf1 += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
493 size -= len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
494 n = (s->buf_ptr - s->buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
495 /* if buffer full, then send it */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
496 if (n >= max_packet_size) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
497 rtp_send_data(s1, s->buf, n);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
498 s->buf_ptr = s->buf;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
499 /* update timestamp */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
500 s->timestamp += n / sample_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
501 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
502 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
503 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
504
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
505 /* NOTE: we suppose that exactly one frame is given as argument here */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
506 /* XXX: test it */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
507 static void rtp_send_mpegaudio(AVFormatContext *s1,
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
508 const uint8_t *buf1, int size)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
509 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
510 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
511 AVStream *st = s1->streams[0];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
512 int len, count, max_packet_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
513
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
514 max_packet_size = s->max_payload_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
515
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
516 /* test if we must flush because not enough space */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
517 len = (s->buf_ptr - s->buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
518 if ((len + size) > max_packet_size) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
519 if (len > 4) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
520 rtp_send_data(s1, s->buf, s->buf_ptr - s->buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
521 s->buf_ptr = s->buf + 4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
522 /* 90 KHz time stamp */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
523 s->timestamp = s->base_timestamp +
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
524 (s->cur_timestamp * 90000LL) / st->codec.sample_rate;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
525 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
526 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
527
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
528 /* add the packet */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
529 if (size > max_packet_size) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
530 /* big packet: fragment */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
531 count = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
532 while (size > 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
533 len = max_packet_size - 4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
534 if (len > size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
535 len = size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
536 /* build fragmented packet */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
537 s->buf[0] = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
538 s->buf[1] = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
539 s->buf[2] = count >> 8;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
540 s->buf[3] = count;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
541 memcpy(s->buf + 4, buf1, len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
542 rtp_send_data(s1, s->buf, len + 4);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
543 size -= len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
544 buf1 += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
545 count += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
546 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
547 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
548 if (s->buf_ptr == s->buf + 4) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
549 /* no fragmentation possible */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
550 s->buf[0] = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
551 s->buf[1] = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
552 s->buf[2] = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
553 s->buf[3] = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
554 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
555 memcpy(s->buf_ptr, buf1, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
556 s->buf_ptr += size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
557 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
558 s->cur_timestamp += st->codec.frame_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
559 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
560
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
561 /* NOTE: a single frame must be passed with sequence header if
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
562 needed. XXX: use slices. */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
563 static void rtp_send_mpegvideo(AVFormatContext *s1,
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
564 const uint8_t *buf1, int size)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
565 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
566 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
567 AVStream *st = s1->streams[0];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
568 int len, h, max_packet_size;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
569 uint8_t *q;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
570
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
571 max_packet_size = s->max_payload_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
572
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
573 while (size > 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
574 /* XXX: more correct headers */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
575 h = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
576 if (st->codec.sub_id == 2)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
577 h |= 1 << 26; /* mpeg 2 indicator */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
578 q = s->buf;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
579 *q++ = h >> 24;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
580 *q++ = h >> 16;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
581 *q++ = h >> 8;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
582 *q++ = h;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
583
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
584 if (st->codec.sub_id == 2) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
585 h = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
586 *q++ = h >> 24;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
587 *q++ = h >> 16;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
588 *q++ = h >> 8;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
589 *q++ = h;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
590 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
591
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
592 len = max_packet_size - (q - s->buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
593 if (len > size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
594 len = size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
595
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
596 memcpy(q, buf1, len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
597 q += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
598
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
599 /* 90 KHz time stamp */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
600 s->timestamp = s->base_timestamp +
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
601 av_rescale((int64_t)s->cur_timestamp * st->codec.frame_rate_base, 90000, st->codec.frame_rate);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
602 rtp_send_data(s1, s->buf, q - s->buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
603
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
604 buf1 += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
605 size -= len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
606 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
607 s->cur_timestamp++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
608 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
609
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
610 static void rtp_send_raw(AVFormatContext *s1,
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
611 const uint8_t *buf1, int size)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
612 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
613 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
614 AVStream *st = s1->streams[0];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
615 int len, max_packet_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
616
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
617 max_packet_size = s->max_payload_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
618
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
619 while (size > 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
620 len = max_packet_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
621 if (len > size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
622 len = size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
623
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
624 /* 90 KHz time stamp */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
625 s->timestamp = s->base_timestamp +
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
626 av_rescale((int64_t)s->cur_timestamp * st->codec.frame_rate_base, 90000, st->codec.frame_rate);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
627 rtp_send_data(s1, buf1, len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
628
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
629 buf1 += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
630 size -= len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
631 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
632 s->cur_timestamp++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
633 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
634
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
635 /* NOTE: size is assumed to be an integer multiple of TS_PACKET_SIZE */
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
636 static void rtp_send_mpegts_raw(AVFormatContext *s1,
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
637 const uint8_t *buf1, int size)
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
638 {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
639 RTPDemuxContext *s = s1->priv_data;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
640 int len, out_len;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
641
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
642 while (size >= TS_PACKET_SIZE) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
643 len = s->max_payload_size - (s->buf_ptr - s->buf);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
644 if (len > size)
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
645 len = size;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
646 memcpy(s->buf_ptr, buf1, len);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
647 buf1 += len;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
648 size -= len;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
649 s->buf_ptr += len;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
650
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
651 out_len = s->buf_ptr - s->buf;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
652 if (out_len >= s->max_payload_size) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
653 rtp_send_data(s1, s->buf, out_len);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
654 s->buf_ptr = s->buf;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
655 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
656 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
657 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
658
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
659 /* write an RTP packet. 'buf1' must contain a single specific frame. */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
660 static int rtp_write_packet(AVFormatContext *s1, int stream_index,
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
661 const uint8_t *buf1, int size, int64_t pts)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
662 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
663 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
664 AVStream *st = s1->streams[0];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
665 int rtcp_bytes;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
666 int64_t ntp_time;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
667
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
668 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
669 printf("%d: write len=%d\n", stream_index, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
670 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
671
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
672 /* XXX: mpeg pts hardcoded. RTCP send every 0.5 seconds */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
673 rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) /
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
674 RTCP_TX_RATIO_DEN;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
675 if (s->first_packet || rtcp_bytes >= 28) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
676 /* compute NTP time */
173
38f64fabb24b fixed NTP generation for mpeg
bellard
parents: 85
diff changeset
677 /* XXX: 90 kHz timestamp hardcoded */
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
678 ntp_time = (pts << 28) / 5625;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
679 rtcp_send_sr(s1, ntp_time);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
680 s->last_octet_count = s->octet_count;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
681 s->first_packet = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
682 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
683
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
684 switch(st->codec.codec_id) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
685 case CODEC_ID_PCM_MULAW:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
686 case CODEC_ID_PCM_ALAW:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
687 case CODEC_ID_PCM_U8:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
688 case CODEC_ID_PCM_S8:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
689 rtp_send_samples(s1, buf1, size, 1 * st->codec.channels);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
690 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
691 case CODEC_ID_PCM_U16BE:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
692 case CODEC_ID_PCM_U16LE:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
693 case CODEC_ID_PCM_S16BE:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
694 case CODEC_ID_PCM_S16LE:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
695 rtp_send_samples(s1, buf1, size, 2 * st->codec.channels);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
696 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
697 case CODEC_ID_MP2:
232
eb90c0a5a1ba CODEC_ID_MP3LAME is obsolete
bellard
parents: 173
diff changeset
698 case CODEC_ID_MP3:
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
699 rtp_send_mpegaudio(s1, buf1, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
700 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
701 case CODEC_ID_MPEG1VIDEO:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
702 rtp_send_mpegvideo(s1, buf1, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
703 break;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
704 case CODEC_ID_MPEG2TS:
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
705 rtp_send_mpegts_raw(s1, buf1, size);
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
706 break;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
707 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
708 /* better than nothing : send the codec raw data */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
709 rtp_send_raw(s1, buf1, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
710 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
711 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
712 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
713 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
714
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
715 static int rtp_write_trailer(AVFormatContext *s1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
716 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
717 // RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
718 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
719 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
720
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
721 AVOutputFormat rtp_mux = {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
722 "rtp",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
723 "RTP output format",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
724 NULL,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
725 NULL,
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
726 sizeof(RTPDemuxContext),
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
727 CODEC_ID_PCM_MULAW,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
728 CODEC_ID_NONE,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
729 rtp_write_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
730 rtp_write_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
731 rtp_write_trailer,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
732 };
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
733
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
734 int rtp_init(void)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
735 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
736 av_register_output_format(&rtp_mux);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
737 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
738 }