annotate rtp.c @ 456:c13fd248e222 libavformat

match latest spec seeking to startcode-less frames
author michael
date Sun, 02 May 2004 01:03:55 +0000
parents 845f9de2c883
children 60f897e8dd2d
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 }
305
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
237 } else {
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
238 switch(st->codec.codec_id) {
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
239 case CODEC_ID_MPEG1VIDEO:
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
240 case CODEC_ID_MPEG2VIDEO:
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
241 case CODEC_ID_MP2:
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
242 case CODEC_ID_MP3:
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
243 case CODEC_ID_MPEG4:
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
244 st->need_parsing = 1;
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
245 break;
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
246 default:
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
247 break;
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
248 }
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
249 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
250 return s;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
251 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
252
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
253 /**
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
254 * 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
255 * @param s RTP parse context.
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
256 * @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
257 * @param buf input buffer or NULL to read the next packets
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
258 * @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
259 * @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
260 * (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
261 */
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
262 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
263 const uint8_t *buf, int len)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
264 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
265 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
266 int payload_type, seq, delta_timestamp, ret;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
267 AVStream *st;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
268 uint32_t timestamp;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
269
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
270 if (!buf) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
271 /* 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
272 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
273 return -1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
274 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
275 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
276 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
277 return -1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
278 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
279 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
280 return 1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
281 else
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
282 return 0;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
283 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
284
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
285 if (len < 12)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
286 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
287
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
288 if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
289 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
290 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
291 rtcp_parse_packet(s, buf, len);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
292 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
293 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
294 payload_type = buf[1] & 0x7f;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
295 seq = (buf[2] << 8) | buf[3];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
296 timestamp = decode_be32(buf + 4);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
297 ssrc = decode_be32(buf + 8);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
298
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
299 /* NOTE: we can handle only one payload type */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
300 if (s->payload_type != payload_type)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
301 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
302 #if defined(DEBUG) || 1
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
303 if (seq != ((s->seq + 1) & 0xffff)) {
370
845f9de2c883 av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 305
diff changeset
304 av_log(&s->st->codec, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n",
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
305 payload_type, seq, ((s->seq + 1) & 0xffff));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
306 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
307 s->seq = seq;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
308 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
309 len -= 12;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
310 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
311
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
312 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
313 if (!st) {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
314 /* 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
315 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
316 if (ret < 0)
0
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 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
319 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
320 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
321 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
322 return 1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
323 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
324 } else {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
325 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
326 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
327 /* better than nothing: skip mpeg audio RTP header */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
328 if (len <= 4)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
329 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
330 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
331 len -= 4;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
332 buf += 4;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
333 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
334 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
335 break;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
336 case CODEC_ID_MPEG1VIDEO:
305
ef53bff8bf23 use parsers
bellard
parents: 294
diff changeset
337 /* better than nothing: skip mpeg video RTP header */
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
338 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
339 return -1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
340 h = decode_be32(buf);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
341 buf += 4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
342 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
343 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
344 /* mpeg2 */
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
345 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
346 return -1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
347 buf += 4;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
348 len -= 4;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
349 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
350 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
351 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
352 break;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
353 default:
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
354 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
355 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
356 break;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
357 }
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
358
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
359 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
360 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
361 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
362 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
363 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
364 /* 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
365 /* 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
366 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
367 /* 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
368 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
369 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
370 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
371 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
372 break;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
373 default:
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
374 /* 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
375 break;
173
38f64fabb24b fixed NTP generation for mpeg
bellard
parents: 85
diff changeset
376 }
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
377 pkt->stream_index = s->st->index;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
378 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
379 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
380 }
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 void rtp_parse_close(RTPDemuxContext *s)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
383 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
384 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
385 mpegts_parse_close(s->ts);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
386 }
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
387 av_free(s);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
388 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
389
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
390 /* rtp output */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
391
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
392 static int rtp_write_header(AVFormatContext *s1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
393 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
394 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
395 int payload_type, max_packet_size, n;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
396 AVStream *st;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
397
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
398 if (s1->nb_streams != 1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
399 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
400 st = s1->streams[0];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
401
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
402 payload_type = rtp_get_payload_type(&st->codec);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
403 if (payload_type < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
404 payload_type = RTP_PT_PRIVATE; /* private payload type */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
405 s->payload_type = payload_type;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
406
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
407 s->base_timestamp = random();
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
408 s->timestamp = s->base_timestamp;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
409 s->ssrc = random();
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
410 s->first_packet = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
411
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
412 max_packet_size = url_fget_max_packet_size(&s1->pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
413 if (max_packet_size <= 12)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
414 return AVERROR_IO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
415 s->max_payload_size = max_packet_size - 12;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
416
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
417 switch(st->codec.codec_id) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
418 case CODEC_ID_MP2:
232
eb90c0a5a1ba CODEC_ID_MP3LAME is obsolete
bellard
parents: 173
diff changeset
419 case CODEC_ID_MP3:
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
420 s->buf_ptr = s->buf + 4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
421 s->cur_timestamp = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
422 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
423 case CODEC_ID_MPEG1VIDEO:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
424 s->cur_timestamp = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
425 break;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
426 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
427 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
428 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
429 n = 1;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
430 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
431 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
432 break;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
433 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
434 s->buf_ptr = s->buf;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
435 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
436 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
437
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
438 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
439 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
440
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
441 /* send an rtcp sender report packet */
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
442 static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
443 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
444 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
445 #if defined(DEBUG)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
446 printf("RTCP: %02x %Lx %x\n", s->payload_type, ntp_time, s->timestamp);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
447 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
448 put_byte(&s1->pb, (RTP_VERSION << 6));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
449 put_byte(&s1->pb, 200);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
450 put_be16(&s1->pb, 6); /* length in words - 1 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
451 put_be32(&s1->pb, s->ssrc);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
452 put_be64(&s1->pb, ntp_time);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
453 put_be32(&s1->pb, s->timestamp);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
454 put_be32(&s1->pb, s->packet_count);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
455 put_be32(&s1->pb, s->octet_count);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
456 put_flush_packet(&s1->pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
457 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
458
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
459 /* send an rtp packet. sequence number is incremented, but the caller
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
460 must update the timestamp itself */
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
461 static void rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
462 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
463 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
464
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
465 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
466 printf("rtp_send_data size=%d\n", len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
467 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
468
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
469 /* build the RTP header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
470 put_byte(&s1->pb, (RTP_VERSION << 6));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
471 put_byte(&s1->pb, s->payload_type & 0x7f);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
472 put_be16(&s1->pb, s->seq);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
473 put_be32(&s1->pb, s->timestamp);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
474 put_be32(&s1->pb, s->ssrc);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
475
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
476 put_buffer(&s1->pb, buf1, len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
477 put_flush_packet(&s1->pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
478
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
479 s->seq++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
480 s->octet_count += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
481 s->packet_count++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
482 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
483
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
484 /* send an integer number of samples and compute time stamp and fill
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
485 the rtp send buffer before sending. */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
486 static void rtp_send_samples(AVFormatContext *s1,
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
487 const uint8_t *buf1, int size, int sample_size)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
488 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
489 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
490 int len, max_packet_size, n;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
491
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
492 max_packet_size = (s->max_payload_size / sample_size) * sample_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
493 /* not needed, but who nows */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
494 if ((size % sample_size) != 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
495 av_abort();
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
496 while (size > 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
497 len = (max_packet_size - (s->buf_ptr - s->buf));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
498 if (len > size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
499 len = size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
500
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
501 /* copy data */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
502 memcpy(s->buf_ptr, buf1, len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
503 s->buf_ptr += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
504 buf1 += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
505 size -= len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
506 n = (s->buf_ptr - s->buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
507 /* if buffer full, then send it */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
508 if (n >= max_packet_size) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
509 rtp_send_data(s1, s->buf, n);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
510 s->buf_ptr = s->buf;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
511 /* update timestamp */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
512 s->timestamp += n / sample_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
513 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
514 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
515 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
516
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
517 /* NOTE: we suppose that exactly one frame is given as argument here */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
518 /* XXX: test it */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
519 static void rtp_send_mpegaudio(AVFormatContext *s1,
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
520 const uint8_t *buf1, int size)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
521 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
522 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
523 AVStream *st = s1->streams[0];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
524 int len, count, max_packet_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
525
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
526 max_packet_size = s->max_payload_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
527
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
528 /* test if we must flush because not enough space */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
529 len = (s->buf_ptr - s->buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
530 if ((len + size) > max_packet_size) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
531 if (len > 4) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
532 rtp_send_data(s1, s->buf, s->buf_ptr - s->buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
533 s->buf_ptr = s->buf + 4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
534 /* 90 KHz time stamp */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
535 s->timestamp = s->base_timestamp +
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
536 (s->cur_timestamp * 90000LL) / st->codec.sample_rate;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
537 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
538 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
539
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
540 /* add the packet */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
541 if (size > max_packet_size) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
542 /* big packet: fragment */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
543 count = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
544 while (size > 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
545 len = max_packet_size - 4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
546 if (len > size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
547 len = size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
548 /* build fragmented packet */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
549 s->buf[0] = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
550 s->buf[1] = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
551 s->buf[2] = count >> 8;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
552 s->buf[3] = count;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
553 memcpy(s->buf + 4, buf1, len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
554 rtp_send_data(s1, s->buf, len + 4);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
555 size -= len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
556 buf1 += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
557 count += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
558 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
559 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
560 if (s->buf_ptr == s->buf + 4) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
561 /* no fragmentation possible */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
562 s->buf[0] = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
563 s->buf[1] = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
564 s->buf[2] = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
565 s->buf[3] = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
566 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
567 memcpy(s->buf_ptr, buf1, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
568 s->buf_ptr += size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
569 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
570 s->cur_timestamp += st->codec.frame_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
571 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
572
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
573 /* NOTE: a single frame must be passed with sequence header if
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
574 needed. XXX: use slices. */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
575 static void rtp_send_mpegvideo(AVFormatContext *s1,
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
576 const uint8_t *buf1, int size)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
577 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
578 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
579 AVStream *st = s1->streams[0];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
580 int len, h, max_packet_size;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
581 uint8_t *q;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
582
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
583 max_packet_size = s->max_payload_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
584
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
585 while (size > 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
586 /* XXX: more correct headers */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
587 h = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
588 if (st->codec.sub_id == 2)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
589 h |= 1 << 26; /* mpeg 2 indicator */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
590 q = s->buf;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
591 *q++ = h >> 24;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
592 *q++ = h >> 16;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
593 *q++ = h >> 8;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
594 *q++ = h;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
595
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
596 if (st->codec.sub_id == 2) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
597 h = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
598 *q++ = h >> 24;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
599 *q++ = h >> 16;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
600 *q++ = h >> 8;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
601 *q++ = h;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
602 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
603
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
604 len = max_packet_size - (q - s->buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
605 if (len > size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
606 len = size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
607
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
608 memcpy(q, buf1, len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
609 q += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
610
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
611 /* 90 KHz time stamp */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
612 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
613 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
614 rtp_send_data(s1, s->buf, q - s->buf);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
615
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
616 buf1 += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
617 size -= len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
618 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
619 s->cur_timestamp++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
620 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
621
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
622 static void rtp_send_raw(AVFormatContext *s1,
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
623 const uint8_t *buf1, int size)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
624 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
625 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
626 AVStream *st = s1->streams[0];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
627 int len, max_packet_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
628
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
629 max_packet_size = s->max_payload_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
630
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
631 while (size > 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
632 len = max_packet_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
633 if (len > size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
634 len = size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
635
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
636 /* 90 KHz time stamp */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
637 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
638 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
639 rtp_send_data(s1, buf1, len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
640
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
641 buf1 += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
642 size -= len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
643 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
644 s->cur_timestamp++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
645 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
646
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
647 /* 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
648 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
649 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
650 {
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
651 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
652 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
653
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
654 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
655 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
656 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
657 len = size;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
658 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
659 buf1 += len;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
660 size -= len;
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
661 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
662
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
663 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
664 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
665 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
666 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
667 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
668 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
669 }
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
670
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
671 /* write an RTP packet. 'buf1' must contain a single specific frame. */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
672 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
673 const uint8_t *buf1, int size, int64_t pts)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
674 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
675 RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
676 AVStream *st = s1->streams[0];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
677 int rtcp_bytes;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
678 int64_t ntp_time;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
679
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
680 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
681 printf("%d: write len=%d\n", stream_index, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
682 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
683
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
684 /* XXX: mpeg pts hardcoded. RTCP send every 0.5 seconds */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
685 rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) /
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
686 RTCP_TX_RATIO_DEN;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
687 if (s->first_packet || rtcp_bytes >= 28) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
688 /* compute NTP time */
173
38f64fabb24b fixed NTP generation for mpeg
bellard
parents: 85
diff changeset
689 /* XXX: 90 kHz timestamp hardcoded */
241
3d92f793fd67 64 bit pts for writing - more const usage
bellard
parents: 232
diff changeset
690 ntp_time = (pts << 28) / 5625;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
691 rtcp_send_sr(s1, ntp_time);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
692 s->last_octet_count = s->octet_count;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
693 s->first_packet = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
694 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
695
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
696 switch(st->codec.codec_id) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
697 case CODEC_ID_PCM_MULAW:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
698 case CODEC_ID_PCM_ALAW:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
699 case CODEC_ID_PCM_U8:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
700 case CODEC_ID_PCM_S8:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
701 rtp_send_samples(s1, buf1, size, 1 * st->codec.channels);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
702 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
703 case CODEC_ID_PCM_U16BE:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
704 case CODEC_ID_PCM_U16LE:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
705 case CODEC_ID_PCM_S16BE:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
706 case CODEC_ID_PCM_S16LE:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
707 rtp_send_samples(s1, buf1, size, 2 * st->codec.channels);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
708 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
709 case CODEC_ID_MP2:
232
eb90c0a5a1ba CODEC_ID_MP3LAME is obsolete
bellard
parents: 173
diff changeset
710 case CODEC_ID_MP3:
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
711 rtp_send_mpegaudio(s1, buf1, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
712 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
713 case CODEC_ID_MPEG1VIDEO:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
714 rtp_send_mpegvideo(s1, buf1, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
715 break;
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
716 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
717 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
718 break;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
719 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
720 /* better than nothing : send the codec raw data */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
721 rtp_send_raw(s1, buf1, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
722 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
723 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
724 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
725 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
726
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
727 static int rtp_write_trailer(AVFormatContext *s1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
728 {
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
729 // RTPDemuxContext *s = s1->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
730 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
731 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
732
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
733 AVOutputFormat rtp_mux = {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
734 "rtp",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
735 "RTP output format",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
736 NULL,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
737 NULL,
294
6091b76cfc2a added MPEG2TS support in RTP, SDP and RTSP - replaced fake RTP demux by a specific API
bellard
parents: 241
diff changeset
738 sizeof(RTPDemuxContext),
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
739 CODEC_ID_PCM_MULAW,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
740 CODEC_ID_NONE,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
741 rtp_write_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
742 rtp_write_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
743 rtp_write_trailer,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
744 };
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
745
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
746 int rtp_init(void)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
747 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
748 av_register_output_format(&rtp_mux);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
749 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
750 }