annotate rtp_internal.h @ 4153:74f56dba37d3 libavformat

add metadata in AVStream, AVProgram and AVChapter
author aurel
date Sun, 04 Jan 2009 22:31:55 +0000
parents af2c0aef892b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
1 /*
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
2 * RTP definitions
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
3 * Copyright (c) 2006 Ryan Martell <rdm4@martellventures.com>
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
4 *
1421
2a02386efc5a move licence header fixes
gpoirier
parents: 1420
diff changeset
5 * This file is part of FFmpeg.
2a02386efc5a move licence header fixes
gpoirier
parents: 1420
diff changeset
6 *
2a02386efc5a move licence header fixes
gpoirier
parents: 1420
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
1420
af616468863c Fix licence header (aka <pedantic mode='on' /> )
gpoirier
parents: 1419
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
11 *
1420
af616468863c Fix licence header (aka <pedantic mode='on' /> )
gpoirier
parents: 1419
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
15 * Lesser General Public License for more details.
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
16 *
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1422
0c8c68a6b35f Last fix of licence header
gpoirier
parents: 1421
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
20 */
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
21
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
22 // this is a bit of a misnomer, because rtp & rtsp internal structures and prototypes are in here.
3852
1b6245500d8c Globally rename the header inclusion guard names.
stefano
parents: 3286
diff changeset
23 #ifndef AVFORMAT_RTP_INTERNAL_H
1b6245500d8c Globally rename the header inclusion guard names.
stefano
parents: 3286
diff changeset
24 #define AVFORMAT_RTP_INTERNAL_H
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
25
2171
a6d6b2b19341 include all prerequisites in header files
mru
parents: 1445
diff changeset
26 #include <stdint.h>
3286
6f61c3b36632 Use full path for #includes from another directory.
diego
parents: 2941
diff changeset
27 #include "libavcodec/avcodec.h"
2171
a6d6b2b19341 include all prerequisites in header files
mru
parents: 1445
diff changeset
28 #include "rtp.h"
a6d6b2b19341 include all prerequisites in header files
mru
parents: 1445
diff changeset
29
1445
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
30 // these statistics are used for rtcp receiver reports...
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
31 typedef struct {
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
32 uint16_t max_seq; ///< highest sequence number seen
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
33 uint32_t cycles; ///< shifted count of sequence number cycles
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
34 uint32_t base_seq; ///< base sequence number
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
35 uint32_t bad_seq; ///< last bad sequence number + 1
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
36 int probation; ///< sequence packets till source is valid
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
37 int received; ///< packets received
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
38 int expected_prior; ///< packets expected in last interval
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
39 int received_prior; ///< packets received in last interval
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
40 uint32_t transit; ///< relative transit time for previous packet
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
41 uint32_t jitter; ///< estimated jitter.
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
42 } RTPStatistics;
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
43
2941
6da0564c9d02 Add a flags field to the RTPDynamicPayloadPacketHandlerProc (PKT_FLAG_*).
rbultje
parents: 2759
diff changeset
44 /**
6da0564c9d02 Add a flags field to the RTPDynamicPayloadPacketHandlerProc (PKT_FLAG_*).
rbultje
parents: 2759
diff changeset
45 * Packet parsing for "private" payloads in the RTP specs.
6da0564c9d02 Add a flags field to the RTPDynamicPayloadPacketHandlerProc (PKT_FLAG_*).
rbultje
parents: 2759
diff changeset
46 *
6da0564c9d02 Add a flags field to the RTPDynamicPayloadPacketHandlerProc (PKT_FLAG_*).
rbultje
parents: 2759
diff changeset
47 * @param s stream context
3976
64056a0c38ce Change function prototype of RTPDynamicPayloadHandler.parse_packet() to
rbultje
parents: 3975
diff changeset
48 * @param st stream that this packet belongs to
2941
6da0564c9d02 Add a flags field to the RTPDynamicPayloadPacketHandlerProc (PKT_FLAG_*).
rbultje
parents: 2759
diff changeset
49 * @param pkt packet in which to write the parsed data
6da0564c9d02 Add a flags field to the RTPDynamicPayloadPacketHandlerProc (PKT_FLAG_*).
rbultje
parents: 2759
diff changeset
50 * @param timestamp pointer in which to write the timestamp of this RTP packet
6da0564c9d02 Add a flags field to the RTPDynamicPayloadPacketHandlerProc (PKT_FLAG_*).
rbultje
parents: 2759
diff changeset
51 * @param buf pointer to raw RTP packet data
6da0564c9d02 Add a flags field to the RTPDynamicPayloadPacketHandlerProc (PKT_FLAG_*).
rbultje
parents: 2759
diff changeset
52 * @param len length of buf
6da0564c9d02 Add a flags field to the RTPDynamicPayloadPacketHandlerProc (PKT_FLAG_*).
rbultje
parents: 2759
diff changeset
53 * @param flags flags from the RTP packet header (PKT_FLAG_*)
6da0564c9d02 Add a flags field to the RTPDynamicPayloadPacketHandlerProc (PKT_FLAG_*).
rbultje
parents: 2759
diff changeset
54 */
3976
64056a0c38ce Change function prototype of RTPDynamicPayloadHandler.parse_packet() to
rbultje
parents: 3975
diff changeset
55 typedef int (*DynamicPayloadPacketHandlerProc) (PayloadContext *s,
64056a0c38ce Change function prototype of RTPDynamicPayloadHandler.parse_packet() to
rbultje
parents: 3975
diff changeset
56 AVStream *st,
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
57 AVPacket * pkt,
1431
2d8a17631520 fix more dynamic protocol stuff, needed by the forthcoming h264
gpoirier
parents: 1425
diff changeset
58 uint32_t *timestamp,
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
59 const uint8_t * buf,
2941
6da0564c9d02 Add a flags field to the RTPDynamicPayloadPacketHandlerProc (PKT_FLAG_*).
rbultje
parents: 2759
diff changeset
60 int len, int flags);
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
61
3977
1f1c4535f421 Remove access into RTPDemuxContext in rtsp.c, which allows making it opaque
rbultje
parents: 3976
diff changeset
62 struct RTPDynamicProtocolHandler_s {
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
63 // fields from AVRtpDynamicPayloadType_s
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
64 const char enc_name[50]; /* XXX: still why 50 ? ;-) */
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
65 enum CodecType codec_type;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
66 enum CodecID codec_id;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
67
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
68 // may be null
4067
8adccfc01be3 Change function prototype of the sdp_parse_a_line in DynamicProtocolHandler.
rbultje
parents: 3977
diff changeset
69 int (*parse_sdp_a_line) (AVFormatContext *s,
8adccfc01be3 Change function prototype of the sdp_parse_a_line in DynamicProtocolHandler.
rbultje
parents: 3977
diff changeset
70 int st_index,
3975
44561554cb7e Rename RTP payload contexts to PayloadContext, suggested by Luca in
rbultje
parents: 3901
diff changeset
71 PayloadContext *priv_data,
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
72 const char *line); ///< Parse the a= line from the sdp field
3975
44561554cb7e Rename RTP payload contexts to PayloadContext, suggested by Luca in
rbultje
parents: 3901
diff changeset
73 PayloadContext *(*open) (); ///< allocate any data needed by the rtp parsing for this dynamic data.
44561554cb7e Rename RTP payload contexts to PayloadContext, suggested by Luca in
rbultje
parents: 3901
diff changeset
74 void (*close)(PayloadContext *protocol_data); ///< free any data needed by the rtp parsing for this dynamic data.
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
75 DynamicPayloadPacketHandlerProc parse_packet; ///< parse handler for this dynamic packet.
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
76
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
77 struct RTPDynamicProtocolHandler_s *next;
3977
1f1c4535f421 Remove access into RTPDemuxContext in rtsp.c, which allows making it opaque
rbultje
parents: 3976
diff changeset
78 };
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
79
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
80 // moved out of rtp.c, because the h264 decoder needs to know about this structure..
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
81 struct RTPDemuxContext {
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
82 AVFormatContext *ic;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
83 AVStream *st;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
84 int payload_type;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
85 uint32_t ssrc;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
86 uint16_t seq;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
87 uint32_t timestamp;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
88 uint32_t base_timestamp;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
89 uint32_t cur_timestamp;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
90 int max_payload_size;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
91 struct MpegTSContext *ts; /* only used for MP2T payloads */
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
92 int read_buf_index;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
93 int read_buf_size;
1425
00d9393a126f make ffmpeg able to send back a RTCP receiver report.
gpoirier
parents: 1422
diff changeset
94 /* used to send back RTCP RR */
00d9393a126f make ffmpeg able to send back a RTCP receiver report.
gpoirier
parents: 1422
diff changeset
95 URLContext *rtp_ctx;
00d9393a126f make ffmpeg able to send back a RTCP receiver report.
gpoirier
parents: 1422
diff changeset
96 char hostname[256];
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
97
1445
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
98 RTPStatistics statistics; ///< Statistics for this stream (used by RTCP receiver reports)
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
99
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
100 /* rtcp sender statistics receive */
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
101 int64_t last_rtcp_ntp_time; // TODO: move into statistics
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
102 int64_t first_rtcp_ntp_time; // TODO: move into statistics
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
103 uint32_t last_rtcp_timestamp; // TODO: move into statistics
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
104
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
105 /* rtcp sender statistics */
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
106 unsigned int packet_count; // TODO: move into statistics (outgoing)
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
107 unsigned int octet_count; // TODO: move into statistics (outgoing)
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
108 unsigned int last_octet_count; // TODO: move into statistics (outgoing)
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
109 int first_packet;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
110 /* buffer for output */
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
111 uint8_t buf[RTP_MAX_PACKET_LENGTH];
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
112 uint8_t *buf_ptr;
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
113
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
114 /* special infos for au headers parsing */
4101
af2c0aef892b Rename rtp_payload_data_t to avoid clashes with the POSIX namespace
lucabe
parents: 4067
diff changeset
115 RTPPayloadData *rtp_payload_data; // TODO: Move into dynamic payload handlers
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
116
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
117 /* dynamic payload stuff */
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
118 DynamicPayloadPacketHandlerProc parse_packet; ///< This is also copied from the dynamic protocol handler structure
3975
44561554cb7e Rename RTP payload contexts to PayloadContext, suggested by Luca in
rbultje
parents: 3901
diff changeset
119 PayloadContext *dynamic_protocol_context; ///< This is a copy from the values setup from the sdp parsing, in rtsp.c don't free me.
2587
d751acab2622 Allow to set the maximum number of frames per RTP packet (and add support for
lucabe
parents: 2545
diff changeset
120 int max_frames_per_packet;
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
121 };
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
122
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
123 extern RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler;
3901
f936c4b8b96d Give register_dynamic_payload_handler() in rtpdec.c a ff_ prefix and export
rbultje
parents: 3852
diff changeset
124 void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler);
1445
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
125
db97355877b1 add valid statistics for the RTCP receiver report.
gpoirier
parents: 1431
diff changeset
126 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.
2406
18e94e5989d8 Move the RTP packetization code for MPEG12 video in its own file (rtp_mpv.c)
lucabe
parents: 2171
diff changeset
127
18e94e5989d8 Move the RTP packetization code for MPEG12 video in its own file (rtp_mpv.c)
lucabe
parents: 2171
diff changeset
128 void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m);
2759
b252e318023a Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents: 2620
diff changeset
129 const char *ff_rtp_enc_name(int payload_type);
b252e318023a Remove the "AVRtpPayloadTypes[i].pt == i" assumption from RTP and RTSP
lucabe
parents: 2620
diff changeset
130 enum CodecID ff_rtp_codec_id(const char *buf, enum CodecType codec_type);
2545
213268d7594e move unrelated functions declarations out of allformats.h
aurel
parents: 2406
diff changeset
131
213268d7594e move unrelated functions declarations out of allformats.h
aurel
parents: 2406
diff changeset
132 void av_register_rtp_dynamic_payload_handlers(void);
213268d7594e move unrelated functions declarations out of allformats.h
aurel
parents: 2406
diff changeset
133
3852
1b6245500d8c Globally rename the header inclusion guard names.
stefano
parents: 3286
diff changeset
134 #endif /* AVFORMAT_RTP_INTERNAL_H */
1419
8fb4910bdcc0 Add support for H264 over RTP
gpoirier
parents:
diff changeset
135