Originally committed as revision 17016 to svn://svn.ffmpeg.org/ffmpeg/trunk
Luca Abeni authored on 2009/02/06 19:35:52... | ... |
@@ -32,7 +32,7 @@ |
32 | 32 |
#include "libavformat/avformat.h" |
33 | 33 |
#include "libavformat/network.h" |
34 | 34 |
#include "libavformat/os_support.h" |
35 |
-#include "libavformat/rtp.h" |
|
35 |
+#include "libavformat/rtpdec.h" |
|
36 | 36 |
#include "libavformat/rtsp.h" |
37 | 37 |
#include "libavutil/avstring.h" |
38 | 38 |
#include "libavutil/random.h" |
... | ... |
@@ -1,7 +1,6 @@ |
1 | 1 |
/* |
2 | 2 |
* RTP definitions |
3 | 3 |
* Copyright (c) 2002 Fabrice Bellard |
4 |
- * Copyright (c) 2006 Ryan Martell <rdm4@martellventures.com> |
|
5 | 4 |
* |
6 | 5 |
* This file is part of FFmpeg. |
7 | 6 |
* |
... | ... |
@@ -23,65 +22,12 @@ |
23 | 23 |
#define AVFORMAT_RTP_H |
24 | 24 |
|
25 | 25 |
#include "libavcodec/avcodec.h" |
26 |
-#include "avformat.h" |
|
27 | 26 |
|
28 |
-/** Structure listing useful vars to parse RTP packet payload*/ |
|
29 |
-typedef struct rtp_payload_data |
|
30 |
-{ |
|
31 |
- int sizelength; |
|
32 |
- int indexlength; |
|
33 |
- int indexdeltalength; |
|
34 |
- int profile_level_id; |
|
35 |
- int streamtype; |
|
36 |
- int objecttype; |
|
37 |
- char *mode; |
|
38 |
- |
|
39 |
- /** mpeg 4 AU headers */ |
|
40 |
- struct AUHeaders { |
|
41 |
- int size; |
|
42 |
- int index; |
|
43 |
- int cts_flag; |
|
44 |
- int cts; |
|
45 |
- int dts_flag; |
|
46 |
- int dts; |
|
47 |
- int rap_flag; |
|
48 |
- int streamstate; |
|
49 |
- } *au_headers; |
|
50 |
- int nb_au_headers; |
|
51 |
- int au_headers_length_bytes; |
|
52 |
- int cur_au_index; |
|
53 |
-} RTPPayloadData; |
|
54 |
- |
|
55 |
-typedef struct PayloadContext PayloadContext; |
|
56 |
-typedef struct RTPDynamicProtocolHandler_s RTPDynamicProtocolHandler; |
|
57 |
- |
|
58 |
-#define RTP_MIN_PACKET_LENGTH 12 |
|
59 | 27 |
#define RTP_MAX_PACKET_LENGTH 1500 /* XXX: suppress this define */ |
60 | 28 |
|
61 |
-int rtp_get_codec_info(AVCodecContext *codec, int payload_type); |
|
62 |
- |
|
63 | 29 |
/** return < 0 if unknown payload type */ |
64 | 30 |
int rtp_get_payload_type(AVCodecContext *codec); |
65 | 31 |
|
66 |
-typedef struct RTPDemuxContext RTPDemuxContext; |
|
67 |
-RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, RTPPayloadData *rtp_payload_data); |
|
68 |
-void rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, |
|
69 |
- RTPDynamicProtocolHandler *handler); |
|
70 |
-int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, |
|
71 |
- const uint8_t *buf, int len); |
|
72 |
-void rtp_parse_close(RTPDemuxContext *s); |
|
73 |
- |
|
74 |
-int rtp_get_local_port(URLContext *h); |
|
75 |
-int rtp_set_remote_url(URLContext *h, const char *uri); |
|
76 |
-void rtp_get_file_handles(URLContext *h, int *prtp_fd, int *prtcp_fd); |
|
77 |
- |
|
78 |
-/** |
|
79 |
- * some rtp servers assume client is dead if they don't hear from them... |
|
80 |
- * so we send a Receiver Report to the provided ByteIO context |
|
81 |
- * (we don't have access to the rtcp handle from here) |
|
82 |
- */ |
|
83 |
-int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count); |
|
84 |
- |
|
85 | 32 |
#define RTP_PT_PRIVATE 96 |
86 | 33 |
#define RTP_VERSION 2 |
87 | 34 |
#define RTP_MAX_SDES 256 /**< maximum text length for SDES */ |
... | ... |
@@ -90,111 +36,4 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count); |
90 | 90 |
#define RTCP_TX_RATIO_NUM 5 |
91 | 91 |
#define RTCP_TX_RATIO_DEN 1000 |
92 | 92 |
|
93 |
-// these statistics are used for rtcp receiver reports... |
|
94 |
-typedef struct { |
|
95 |
- uint16_t max_seq; ///< highest sequence number seen |
|
96 |
- uint32_t cycles; ///< shifted count of sequence number cycles |
|
97 |
- uint32_t base_seq; ///< base sequence number |
|
98 |
- uint32_t bad_seq; ///< last bad sequence number + 1 |
|
99 |
- int probation; ///< sequence packets till source is valid |
|
100 |
- int received; ///< packets received |
|
101 |
- int expected_prior; ///< packets expected in last interval |
|
102 |
- int received_prior; ///< packets received in last interval |
|
103 |
- uint32_t transit; ///< relative transit time for previous packet |
|
104 |
- uint32_t jitter; ///< estimated jitter. |
|
105 |
-} RTPStatistics; |
|
106 |
- |
|
107 |
-/** |
|
108 |
- * Packet parsing for "private" payloads in the RTP specs. |
|
109 |
- * |
|
110 |
- * @param ctx RTSP demuxer context |
|
111 |
- * @param s stream context |
|
112 |
- * @param st stream that this packet belongs to |
|
113 |
- * @param pkt packet in which to write the parsed data |
|
114 |
- * @param timestamp pointer in which to write the timestamp of this RTP packet |
|
115 |
- * @param buf pointer to raw RTP packet data |
|
116 |
- * @param len length of buf |
|
117 |
- * @param flags flags from the RTP packet header (PKT_FLAG_*) |
|
118 |
- */ |
|
119 |
-typedef int (*DynamicPayloadPacketHandlerProc) (AVFormatContext *ctx, |
|
120 |
- PayloadContext *s, |
|
121 |
- AVStream *st, |
|
122 |
- AVPacket * pkt, |
|
123 |
- uint32_t *timestamp, |
|
124 |
- const uint8_t * buf, |
|
125 |
- int len, int flags); |
|
126 |
- |
|
127 |
-struct RTPDynamicProtocolHandler_s { |
|
128 |
- // fields from AVRtpDynamicPayloadType_s |
|
129 |
- const char enc_name[50]; /* XXX: still why 50 ? ;-) */ |
|
130 |
- enum CodecType codec_type; |
|
131 |
- enum CodecID codec_id; |
|
132 |
- |
|
133 |
- // may be null |
|
134 |
- int (*parse_sdp_a_line) (AVFormatContext *s, |
|
135 |
- int st_index, |
|
136 |
- PayloadContext *priv_data, |
|
137 |
- const char *line); ///< Parse the a= line from the sdp field |
|
138 |
- PayloadContext *(*open) (); ///< allocate any data needed by the rtp parsing for this dynamic data. |
|
139 |
- void (*close)(PayloadContext *protocol_data); ///< free any data needed by the rtp parsing for this dynamic data. |
|
140 |
- DynamicPayloadPacketHandlerProc parse_packet; ///< parse handler for this dynamic packet. |
|
141 |
- |
|
142 |
- struct RTPDynamicProtocolHandler_s *next; |
|
143 |
-}; |
|
144 |
- |
|
145 |
-// moved out of rtp.c, because the h264 decoder needs to know about this structure.. |
|
146 |
-struct RTPDemuxContext { |
|
147 |
- AVFormatContext *ic; |
|
148 |
- AVStream *st; |
|
149 |
- int payload_type; |
|
150 |
- uint32_t ssrc; |
|
151 |
- uint16_t seq; |
|
152 |
- uint32_t timestamp; |
|
153 |
- uint32_t base_timestamp; |
|
154 |
- uint32_t cur_timestamp; |
|
155 |
- int max_payload_size; |
|
156 |
- struct MpegTSContext *ts; /* only used for MP2T payloads */ |
|
157 |
- int read_buf_index; |
|
158 |
- int read_buf_size; |
|
159 |
- int num_frames; |
|
160 |
- /* used to send back RTCP RR */ |
|
161 |
- URLContext *rtp_ctx; |
|
162 |
- char hostname[256]; |
|
163 |
- |
|
164 |
- RTPStatistics statistics; ///< Statistics for this stream (used by RTCP receiver reports) |
|
165 |
- |
|
166 |
- /* rtcp sender statistics receive */ |
|
167 |
- int64_t last_rtcp_ntp_time; // TODO: move into statistics |
|
168 |
- int64_t first_rtcp_ntp_time; // TODO: move into statistics |
|
169 |
- uint32_t last_rtcp_timestamp; // TODO: move into statistics |
|
170 |
- |
|
171 |
- /* rtcp sender statistics */ |
|
172 |
- unsigned int packet_count; // TODO: move into statistics (outgoing) |
|
173 |
- unsigned int octet_count; // TODO: move into statistics (outgoing) |
|
174 |
- unsigned int last_octet_count; // TODO: move into statistics (outgoing) |
|
175 |
- int first_packet; |
|
176 |
- /* buffer for output */ |
|
177 |
- uint8_t buf[RTP_MAX_PACKET_LENGTH]; |
|
178 |
- uint8_t *buf_ptr; |
|
179 |
- |
|
180 |
- /* special infos for au headers parsing */ |
|
181 |
- RTPPayloadData *rtp_payload_data; // TODO: Move into dynamic payload handlers |
|
182 |
- |
|
183 |
- /* dynamic payload stuff */ |
|
184 |
- DynamicPayloadPacketHandlerProc parse_packet; ///< This is also copied from the dynamic protocol handler structure |
|
185 |
- PayloadContext *dynamic_protocol_context; ///< This is a copy from the values setup from the sdp parsing, in rtsp.c don't free me. |
|
186 |
- int max_frames_per_packet; |
|
187 |
-}; |
|
188 |
- |
|
189 |
-extern RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler; |
|
190 |
-void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler); |
|
191 |
- |
|
192 |
-int rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size); ///< from rtsp.c, but used by rtp dynamic protocol handlers. |
|
193 |
- |
|
194 |
-void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m); |
|
195 |
-const char *ff_rtp_enc_name(int payload_type); |
|
196 |
-enum CodecID ff_rtp_codec_id(const char *buf, enum CodecType codec_type); |
|
197 |
- |
|
198 |
-void av_register_rtp_dynamic_payload_handlers(void); |
|
199 |
- |
|
200 | 93 |
#endif /* AVFORMAT_RTP_H */ |
... | ... |
@@ -20,14 +20,14 @@ |
20 | 20 |
|
21 | 21 |
#include "avformat.h" |
22 | 22 |
#include "rtp_aac.h" |
23 |
-#include "rtp.h" |
|
23 |
+#include "rtpenc.h" |
|
24 | 24 |
|
25 | 25 |
#define MAX_FRAMES_PER_PACKET (s->max_frames_per_packet ? s->max_frames_per_packet : 5) |
26 | 26 |
#define MAX_AU_HEADERS_SIZE (2 + 2 * MAX_FRAMES_PER_PACKET) |
27 | 27 |
|
28 | 28 |
void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size) |
29 | 29 |
{ |
30 |
- RTPDemuxContext *s = s1->priv_data; |
|
30 |
+ RTPMuxContext *s = s1->priv_data; |
|
31 | 31 |
int len, max_packet_size; |
32 | 32 |
uint8_t *p; |
33 | 33 |
|
... | ... |
@@ -22,13 +22,13 @@ |
22 | 22 |
|
23 | 23 |
#include "libavcodec/mpegvideo.h" |
24 | 24 |
#include "avformat.h" |
25 |
-#include "rtp.h" |
|
25 |
+#include "rtpenc.h" |
|
26 | 26 |
|
27 | 27 |
/* NOTE: a single frame must be passed with sequence header if |
28 | 28 |
needed. XXX: use slices. */ |
29 | 29 |
void ff_rtp_send_mpegvideo(AVFormatContext *s1, const uint8_t *buf1, int size) |
30 | 30 |
{ |
31 |
- RTPDemuxContext *s = s1->priv_data; |
|
31 |
+ RTPMuxContext *s = s1->priv_data; |
|
32 | 32 |
int len, h, max_packet_size; |
33 | 33 |
uint8_t *q; |
34 | 34 |
int begin_of_slice, end_of_slice, frame_type, temporal_reference; |
36 | 36 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,187 @@ |
0 |
+/* |
|
1 |
+ * RTP demuxer definitions |
|
2 |
+ * Copyright (c) 2002 Fabrice Bellard |
|
3 |
+ * Copyright (c) 2006 Ryan Martell <rdm4@martellventures.com> |
|
4 |
+ * |
|
5 |
+ * This file is part of FFmpeg. |
|
6 |
+ * |
|
7 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
8 |
+ * modify it under the terms of the GNU Lesser General Public |
|
9 |
+ * License as published by the Free Software Foundation; either |
|
10 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
11 |
+ * |
|
12 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
13 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 |
+ * Lesser General Public License for more details. |
|
16 |
+ * |
|
17 |
+ * You should have received a copy of the GNU Lesser General Public |
|
18 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
19 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
20 |
+ */ |
|
21 |
+#ifndef AVFORMAT_RTPDEC_H |
|
22 |
+#define AVFORMAT_RTPDEC_H |
|
23 |
+ |
|
24 |
+#include "libavcodec/avcodec.h" |
|
25 |
+#include "avformat.h" |
|
26 |
+#include "rtp.h" |
|
27 |
+ |
|
28 |
+/** Structure listing useful vars to parse RTP packet payload*/ |
|
29 |
+typedef struct rtp_payload_data |
|
30 |
+{ |
|
31 |
+ int sizelength; |
|
32 |
+ int indexlength; |
|
33 |
+ int indexdeltalength; |
|
34 |
+ int profile_level_id; |
|
35 |
+ int streamtype; |
|
36 |
+ int objecttype; |
|
37 |
+ char *mode; |
|
38 |
+ |
|
39 |
+ /** mpeg 4 AU headers */ |
|
40 |
+ struct AUHeaders { |
|
41 |
+ int size; |
|
42 |
+ int index; |
|
43 |
+ int cts_flag; |
|
44 |
+ int cts; |
|
45 |
+ int dts_flag; |
|
46 |
+ int dts; |
|
47 |
+ int rap_flag; |
|
48 |
+ int streamstate; |
|
49 |
+ } *au_headers; |
|
50 |
+ int nb_au_headers; |
|
51 |
+ int au_headers_length_bytes; |
|
52 |
+ int cur_au_index; |
|
53 |
+} RTPPayloadData; |
|
54 |
+ |
|
55 |
+typedef struct PayloadContext PayloadContext; |
|
56 |
+typedef struct RTPDynamicProtocolHandler_s RTPDynamicProtocolHandler; |
|
57 |
+ |
|
58 |
+#define RTP_MIN_PACKET_LENGTH 12 |
|
59 |
+ |
|
60 |
+int rtp_get_codec_info(AVCodecContext *codec, int payload_type); |
|
61 |
+ |
|
62 |
+typedef struct RTPDemuxContext RTPDemuxContext; |
|
63 |
+RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, RTPPayloadData *rtp_payload_data); |
|
64 |
+void rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, |
|
65 |
+ RTPDynamicProtocolHandler *handler); |
|
66 |
+int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, |
|
67 |
+ const uint8_t *buf, int len); |
|
68 |
+void rtp_parse_close(RTPDemuxContext *s); |
|
69 |
+ |
|
70 |
+int rtp_get_local_port(URLContext *h); |
|
71 |
+int rtp_set_remote_url(URLContext *h, const char *uri); |
|
72 |
+void rtp_get_file_handles(URLContext *h, int *prtp_fd, int *prtcp_fd); |
|
73 |
+ |
|
74 |
+/** |
|
75 |
+ * some rtp servers assume client is dead if they don't hear from them... |
|
76 |
+ * so we send a Receiver Report to the provided ByteIO context |
|
77 |
+ * (we don't have access to the rtcp handle from here) |
|
78 |
+ */ |
|
79 |
+int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count); |
|
80 |
+ |
|
81 |
+// these statistics are used for rtcp receiver reports... |
|
82 |
+typedef struct { |
|
83 |
+ uint16_t max_seq; ///< highest sequence number seen |
|
84 |
+ uint32_t cycles; ///< shifted count of sequence number cycles |
|
85 |
+ uint32_t base_seq; ///< base sequence number |
|
86 |
+ uint32_t bad_seq; ///< last bad sequence number + 1 |
|
87 |
+ int probation; ///< sequence packets till source is valid |
|
88 |
+ int received; ///< packets received |
|
89 |
+ int expected_prior; ///< packets expected in last interval |
|
90 |
+ int received_prior; ///< packets received in last interval |
|
91 |
+ uint32_t transit; ///< relative transit time for previous packet |
|
92 |
+ uint32_t jitter; ///< estimated jitter. |
|
93 |
+} RTPStatistics; |
|
94 |
+ |
|
95 |
+/** |
|
96 |
+ * Packet parsing for "private" payloads in the RTP specs. |
|
97 |
+ * |
|
98 |
+ * @param ctx RTSP demuxer context |
|
99 |
+ * @param s stream context |
|
100 |
+ * @param st stream that this packet belongs to |
|
101 |
+ * @param pkt packet in which to write the parsed data |
|
102 |
+ * @param timestamp pointer in which to write the timestamp of this RTP packet |
|
103 |
+ * @param buf pointer to raw RTP packet data |
|
104 |
+ * @param len length of buf |
|
105 |
+ * @param flags flags from the RTP packet header (PKT_FLAG_*) |
|
106 |
+ */ |
|
107 |
+typedef int (*DynamicPayloadPacketHandlerProc) (AVFormatContext *ctx, |
|
108 |
+ PayloadContext *s, |
|
109 |
+ AVStream *st, |
|
110 |
+ AVPacket * pkt, |
|
111 |
+ uint32_t *timestamp, |
|
112 |
+ const uint8_t * buf, |
|
113 |
+ int len, int flags); |
|
114 |
+ |
|
115 |
+struct RTPDynamicProtocolHandler_s { |
|
116 |
+ // fields from AVRtpDynamicPayloadType_s |
|
117 |
+ const char enc_name[50]; /* XXX: still why 50 ? ;-) */ |
|
118 |
+ enum CodecType codec_type; |
|
119 |
+ enum CodecID codec_id; |
|
120 |
+ |
|
121 |
+ // may be null |
|
122 |
+ int (*parse_sdp_a_line) (AVFormatContext *s, |
|
123 |
+ int st_index, |
|
124 |
+ PayloadContext *priv_data, |
|
125 |
+ const char *line); ///< Parse the a= line from the sdp field |
|
126 |
+ PayloadContext *(*open) (); ///< allocate any data needed by the rtp parsing for this dynamic data. |
|
127 |
+ void (*close)(PayloadContext *protocol_data); ///< free any data needed by the rtp parsing for this dynamic data. |
|
128 |
+ DynamicPayloadPacketHandlerProc parse_packet; ///< parse handler for this dynamic packet. |
|
129 |
+ |
|
130 |
+ struct RTPDynamicProtocolHandler_s *next; |
|
131 |
+}; |
|
132 |
+ |
|
133 |
+// moved out of rtp.c, because the h264 decoder needs to know about this structure.. |
|
134 |
+struct RTPDemuxContext { |
|
135 |
+ AVFormatContext *ic; |
|
136 |
+ AVStream *st; |
|
137 |
+ int payload_type; |
|
138 |
+ uint32_t ssrc; |
|
139 |
+ uint16_t seq; |
|
140 |
+ uint32_t timestamp; |
|
141 |
+ uint32_t base_timestamp; |
|
142 |
+ uint32_t cur_timestamp; |
|
143 |
+ int max_payload_size; |
|
144 |
+ struct MpegTSContext *ts; /* only used for MP2T payloads */ |
|
145 |
+ int read_buf_index; |
|
146 |
+ int read_buf_size; |
|
147 |
+ /* used to send back RTCP RR */ |
|
148 |
+ URLContext *rtp_ctx; |
|
149 |
+ char hostname[256]; |
|
150 |
+ |
|
151 |
+ RTPStatistics statistics; ///< Statistics for this stream (used by RTCP receiver reports) |
|
152 |
+ |
|
153 |
+ /* rtcp sender statistics receive */ |
|
154 |
+ int64_t last_rtcp_ntp_time; // TODO: move into statistics |
|
155 |
+ int64_t first_rtcp_ntp_time; // TODO: move into statistics |
|
156 |
+ uint32_t last_rtcp_timestamp; // TODO: move into statistics |
|
157 |
+ |
|
158 |
+ /* rtcp sender statistics */ |
|
159 |
+ unsigned int packet_count; // TODO: move into statistics (outgoing) |
|
160 |
+ unsigned int octet_count; // TODO: move into statistics (outgoing) |
|
161 |
+ unsigned int last_octet_count; // TODO: move into statistics (outgoing) |
|
162 |
+ int first_packet; |
|
163 |
+ /* buffer for output */ |
|
164 |
+ uint8_t buf[RTP_MAX_PACKET_LENGTH]; |
|
165 |
+ uint8_t *buf_ptr; |
|
166 |
+ |
|
167 |
+ /* special infos for au headers parsing */ |
|
168 |
+ RTPPayloadData *rtp_payload_data; // TODO: Move into dynamic payload handlers |
|
169 |
+ |
|
170 |
+ /* dynamic payload stuff */ |
|
171 |
+ DynamicPayloadPacketHandlerProc parse_packet; ///< This is also copied from the dynamic protocol handler structure |
|
172 |
+ PayloadContext *dynamic_protocol_context; ///< This is a copy from the values setup from the sdp parsing, in rtsp.c don't free me. |
|
173 |
+ int max_frames_per_packet; |
|
174 |
+}; |
|
175 |
+ |
|
176 |
+extern RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler; |
|
177 |
+void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler); |
|
178 |
+ |
|
179 |
+int rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size); ///< from rtsp.c, but used by rtp dynamic protocol handlers. |
|
180 |
+ |
|
181 |
+const char *ff_rtp_enc_name(int payload_type); |
|
182 |
+enum CodecID ff_rtp_codec_id(const char *buf, enum CodecType codec_type); |
|
183 |
+ |
|
184 |
+void av_register_rtp_dynamic_payload_handlers(void); |
|
185 |
+ |
|
186 |
+#endif /* AVFORMAT_RTPDEC_H */ |
... | ... |
@@ -26,7 +26,7 @@ |
26 | 26 |
#include <unistd.h> |
27 | 27 |
#include "network.h" |
28 | 28 |
|
29 |
-#include "rtp.h" |
|
29 |
+#include "rtpenc.h" |
|
30 | 30 |
#include "rtp_mpv.h" |
31 | 31 |
#include "rtp_aac.h" |
32 | 32 |
#include "rtp_h264.h" |
... | ... |
@@ -44,7 +44,7 @@ static uint64_t ntp_time(void) |
44 | 44 |
|
45 | 45 |
static int rtp_write_header(AVFormatContext *s1) |
46 | 46 |
{ |
47 |
- RTPDemuxContext *s = s1->priv_data; |
|
47 |
+ RTPMuxContext *s = s1->priv_data; |
|
48 | 48 |
int payload_type, max_packet_size, n; |
49 | 49 |
AVStream *st; |
50 | 50 |
|
... | ... |
@@ -117,7 +117,7 @@ static int rtp_write_header(AVFormatContext *s1) |
117 | 117 |
/* send an rtcp sender report packet */ |
118 | 118 |
static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time) |
119 | 119 |
{ |
120 |
- RTPDemuxContext *s = s1->priv_data; |
|
120 |
+ RTPMuxContext *s = s1->priv_data; |
|
121 | 121 |
uint32_t rtp_ts; |
122 | 122 |
|
123 | 123 |
dprintf(s1, "RTCP: %02x %"PRIx64" %x\n", s->payload_type, ntp_time, s->timestamp); |
... | ... |
@@ -142,7 +142,7 @@ static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time) |
142 | 142 |
must update the timestamp itself */ |
143 | 143 |
void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m) |
144 | 144 |
{ |
145 |
- RTPDemuxContext *s = s1->priv_data; |
|
145 |
+ RTPMuxContext *s = s1->priv_data; |
|
146 | 146 |
|
147 | 147 |
dprintf(s1, "rtp_send_data size=%d\n", len); |
148 | 148 |
|
... | ... |
@@ -166,7 +166,7 @@ void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m) |
166 | 166 |
static void rtp_send_samples(AVFormatContext *s1, |
167 | 167 |
const uint8_t *buf1, int size, int sample_size) |
168 | 168 |
{ |
169 |
- RTPDemuxContext *s = s1->priv_data; |
|
169 |
+ RTPMuxContext *s = s1->priv_data; |
|
170 | 170 |
int len, max_packet_size, n; |
171 | 171 |
|
172 | 172 |
max_packet_size = (s->max_payload_size / sample_size) * sample_size; |
... | ... |
@@ -194,7 +194,7 @@ static void rtp_send_samples(AVFormatContext *s1, |
194 | 194 |
static void rtp_send_mpegaudio(AVFormatContext *s1, |
195 | 195 |
const uint8_t *buf1, int size) |
196 | 196 |
{ |
197 |
- RTPDemuxContext *s = s1->priv_data; |
|
197 |
+ RTPMuxContext *s = s1->priv_data; |
|
198 | 198 |
int len, count, max_packet_size; |
199 | 199 |
|
200 | 200 |
max_packet_size = s->max_payload_size; |
... | ... |
@@ -246,7 +246,7 @@ static void rtp_send_mpegaudio(AVFormatContext *s1, |
246 | 246 |
static void rtp_send_raw(AVFormatContext *s1, |
247 | 247 |
const uint8_t *buf1, int size) |
248 | 248 |
{ |
249 |
- RTPDemuxContext *s = s1->priv_data; |
|
249 |
+ RTPMuxContext *s = s1->priv_data; |
|
250 | 250 |
int len, max_packet_size; |
251 | 251 |
|
252 | 252 |
max_packet_size = s->max_payload_size; |
... | ... |
@@ -268,7 +268,7 @@ static void rtp_send_raw(AVFormatContext *s1, |
268 | 268 |
static void rtp_send_mpegts_raw(AVFormatContext *s1, |
269 | 269 |
const uint8_t *buf1, int size) |
270 | 270 |
{ |
271 |
- RTPDemuxContext *s = s1->priv_data; |
|
271 |
+ RTPMuxContext *s = s1->priv_data; |
|
272 | 272 |
int len, out_len; |
273 | 273 |
|
274 | 274 |
while (size >= TS_PACKET_SIZE) { |
... | ... |
@@ -291,7 +291,7 @@ static void rtp_send_mpegts_raw(AVFormatContext *s1, |
291 | 291 |
/* write an RTP packet. 'buf1' must contain a single specific frame. */ |
292 | 292 |
static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) |
293 | 293 |
{ |
294 |
- RTPDemuxContext *s = s1->priv_data; |
|
294 |
+ RTPMuxContext *s = s1->priv_data; |
|
295 | 295 |
AVStream *st = s1->streams[0]; |
296 | 296 |
int rtcp_bytes; |
297 | 297 |
int size= pkt->size; |
... | ... |
@@ -352,7 +352,7 @@ AVOutputFormat rtp_muxer = { |
352 | 352 |
NULL_IF_CONFIG_SMALL("RTP output format"), |
353 | 353 |
NULL, |
354 | 354 |
NULL, |
355 |
- sizeof(RTPDemuxContext), |
|
355 |
+ sizeof(RTPMuxContext), |
|
356 | 356 |
CODEC_ID_PCM_MULAW, |
357 | 357 |
CODEC_ID_NONE, |
358 | 358 |
rtp_write_header, |
359 | 359 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,61 @@ |
0 |
+/* |
|
1 |
+ * RTP muxer definitions |
|
2 |
+ * Copyright (c) 2002 Fabrice Bellard |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+#ifndef AVFORMAT_RTPENC_H |
|
21 |
+#define AVFORMAT_RTPENC_H |
|
22 |
+ |
|
23 |
+#include "avformat.h" |
|
24 |
+#include "rtp.h" |
|
25 |
+ |
|
26 |
+struct RTPMuxContext { |
|
27 |
+ AVFormatContext *ic; |
|
28 |
+ AVStream *st; |
|
29 |
+ int payload_type; |
|
30 |
+ uint32_t ssrc; |
|
31 |
+ uint16_t seq; |
|
32 |
+ uint32_t timestamp; |
|
33 |
+ uint32_t base_timestamp; |
|
34 |
+ uint32_t cur_timestamp; |
|
35 |
+ int max_payload_size; |
|
36 |
+ int num_frames; |
|
37 |
+ |
|
38 |
+ /* rtcp sender statistics receive */ |
|
39 |
+ int64_t last_rtcp_ntp_time; // TODO: move into statistics |
|
40 |
+ int64_t first_rtcp_ntp_time; // TODO: move into statistics |
|
41 |
+ |
|
42 |
+ /* rtcp sender statistics */ |
|
43 |
+ unsigned int packet_count; // TODO: move into statistics (outgoing) |
|
44 |
+ unsigned int octet_count; // TODO: move into statistics (outgoing) |
|
45 |
+ unsigned int last_octet_count; // TODO: move into statistics (outgoing) |
|
46 |
+ int first_packet; |
|
47 |
+ /* buffer for output */ |
|
48 |
+ uint8_t buf[RTP_MAX_PACKET_LENGTH]; |
|
49 |
+ uint8_t *buf_ptr; |
|
50 |
+ |
|
51 |
+ int max_frames_per_packet; |
|
52 |
+}; |
|
53 |
+ |
|
54 |
+typedef struct RTPMuxContext RTPMuxContext; |
|
55 |
+ |
|
56 |
+void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m); |
|
57 |
+ |
|
58 |
+void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size); |
|
59 |
+ |
|
60 |
+#endif /* AVFORMAT_RTPENC_H */ |
... | ... |
@@ -27,11 +27,11 @@ |
27 | 27 |
|
28 | 28 |
#include "avformat.h" |
29 | 29 |
#include "avc.h" |
30 |
-#include "rtp_h264.h" |
|
30 |
+#include "rtpenc.h" |
|
31 | 31 |
|
32 | 32 |
static void nal_send(AVFormatContext *s1, const uint8_t *buf, int size, int last) |
33 | 33 |
{ |
34 |
- RTPDemuxContext *s = s1->priv_data; |
|
34 |
+ RTPMuxContext *s = s1->priv_data; |
|
35 | 35 |
|
36 | 36 |
av_log(s1, AV_LOG_DEBUG, "Sending NAL %x of len %d M=%d\n", buf[0] & 0x1F, size, last); |
37 | 37 |
if (size <= s->max_payload_size) { |
... | ... |
@@ -63,7 +63,7 @@ static void nal_send(AVFormatContext *s1, const uint8_t *buf, int size, int last |
63 | 63 |
void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size) |
64 | 64 |
{ |
65 | 65 |
const uint8_t *r; |
66 |
- RTPDemuxContext *s = s1->priv_data; |
|
66 |
+ RTPMuxContext *s = s1->priv_data; |
|
67 | 67 |
|
68 | 68 |
s->timestamp = s->cur_timestamp; |
69 | 69 |
r = ff_avc_find_startcode(buf1, buf1 + size); |