Reindent after r15927, see discussion in "[PATCH] rtsp cleanup part 1:
[ffmpeg-lucabe.git] / libavformat / rtp_internal.h
blobfdfb8ff02f57be5a4225dbd9b2a63fee98d222f4
1 /*
2 * RTP definitions
3 * Copyright (c) 2006 Ryan Martell <rdm4@martellventures.com>
5 * This file is part of FFmpeg.
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.
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.
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
22 // this is a bit of a misnomer, because rtp & rtsp internal structures and prototypes are in here.
23 #ifndef AVFORMAT_RTP_INTERNAL_H
24 #define AVFORMAT_RTP_INTERNAL_H
26 #include <stdint.h>
27 #include "libavcodec/avcodec.h"
28 #include "rtp.h"
30 // these statistics are used for rtcp receiver reports...
31 typedef struct {
32 uint16_t max_seq; ///< highest sequence number seen
33 uint32_t cycles; ///< shifted count of sequence number cycles
34 uint32_t base_seq; ///< base sequence number
35 uint32_t bad_seq; ///< last bad sequence number + 1
36 int probation; ///< sequence packets till source is valid
37 int received; ///< packets received
38 int expected_prior; ///< packets expected in last interval
39 int received_prior; ///< packets received in last interval
40 uint32_t transit; ///< relative transit time for previous packet
41 uint32_t jitter; ///< estimated jitter.
42 } RTPStatistics;
44 /**
45 * Packet parsing for "private" payloads in the RTP specs.
47 * @param s stream context
48 * @param pkt packet in which to write the parsed data
49 * @param timestamp pointer in which to write the timestamp of this RTP packet
50 * @param buf pointer to raw RTP packet data
51 * @param len length of buf
52 * @param flags flags from the RTP packet header (PKT_FLAG_*)
54 typedef int (*DynamicPayloadPacketHandlerProc) (struct RTPDemuxContext * s,
55 AVPacket * pkt,
56 uint32_t *timestamp,
57 const uint8_t * buf,
58 int len, int flags);
60 typedef struct RTPDynamicProtocolHandler_s {
61 // fields from AVRtpDynamicPayloadType_s
62 const char enc_name[50]; /* XXX: still why 50 ? ;-) */
63 enum CodecType codec_type;
64 enum CodecID codec_id;
66 // may be null
67 int (*parse_sdp_a_line) (AVStream * stream,
68 void *protocol_data,
69 const char *line); ///< Parse the a= line from the sdp field
70 void *(*open) (); ///< allocate any data needed by the rtp parsing for this dynamic data.
71 void (*close)(void *protocol_data); ///< free any data needed by the rtp parsing for this dynamic data.
72 DynamicPayloadPacketHandlerProc parse_packet; ///< parse handler for this dynamic packet.
74 struct RTPDynamicProtocolHandler_s *next;
75 } RTPDynamicProtocolHandler;
77 // moved out of rtp.c, because the h264 decoder needs to know about this structure..
78 struct RTPDemuxContext {
79 AVFormatContext *ic;
80 AVStream *st;
81 int payload_type;
82 uint32_t ssrc;
83 uint16_t seq;
84 uint32_t timestamp;
85 uint32_t base_timestamp;
86 uint32_t cur_timestamp;
87 int max_payload_size;
88 struct MpegTSContext *ts; /* only used for MP2T payloads */
89 int read_buf_index;
90 int read_buf_size;
91 /* used to send back RTCP RR */
92 URLContext *rtp_ctx;
93 char hostname[256];
95 RTPStatistics statistics; ///< Statistics for this stream (used by RTCP receiver reports)
97 /* rtcp sender statistics receive */
98 int64_t last_rtcp_ntp_time; // TODO: move into statistics
99 int64_t first_rtcp_ntp_time; // TODO: move into statistics
100 uint32_t last_rtcp_timestamp; // TODO: move into statistics
102 /* rtcp sender statistics */
103 unsigned int packet_count; // TODO: move into statistics (outgoing)
104 unsigned int octet_count; // TODO: move into statistics (outgoing)
105 unsigned int last_octet_count; // TODO: move into statistics (outgoing)
106 int first_packet;
107 /* buffer for output */
108 uint8_t buf[RTP_MAX_PACKET_LENGTH];
109 uint8_t *buf_ptr;
111 /* special infos for au headers parsing */
112 rtp_payload_data_t *rtp_payload_data; // TODO: Move into dynamic payload handlers
114 /* dynamic payload stuff */
115 DynamicPayloadPacketHandlerProc parse_packet; ///< This is also copied from the dynamic protocol handler structure
116 void *dynamic_protocol_context; ///< This is a copy from the values setup from the sdp parsing, in rtsp.c don't free me.
117 int max_frames_per_packet;
120 extern RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler;
121 void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler);
123 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.
125 void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m);
126 const char *ff_rtp_enc_name(int payload_type);
127 enum CodecID ff_rtp_codec_id(const char *buf, enum CodecType codec_type);
129 void av_register_rtp_dynamic_payload_handlers(void);
131 #endif /* AVFORMAT_RTP_INTERNAL_H */