Add support for H264 over RTP
[libav.git] / libavformat / rtp_internal.h
CommitLineData
4934884a
RM
1/*
2 * RTP definitions
3 * Copyright (c) 2006 Ryan Martell <rdm4@martellventures.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20// this is a bit of a misnomer, because rtp & rtsp internal structures and prototypes are in here.
21#ifndef RTP_INTERNAL_H
22#define RTP_INTERNAL_H
23
24typedef int (*DynamicPayloadPacketHandlerProc) (struct RTPDemuxContext * s,
25 AVPacket * pkt,
26 uint32_t timestamp,
27 const uint8_t * buf,
28 int len);
29
30typedef struct RTPDynamicProtocolHandler_s {
31 // fields from AVRtpDynamicPayloadType_s
32 const char enc_name[50]; /* XXX: still why 50 ? ;-) */
33 enum CodecType codec_type;
34 enum CodecID codec_id;
35
36 // may be null
37 int (*parse_sdp_a_line) (AVStream * stream,
38 void *protocol_data,
39 const char *line); ///< Parse the a= line from the sdp field
40 void *(*open) (); ///< allocate any data needed by the rtp parsing for this dynamic data.
41 void (*close)(void *protocol_data); ///< free any data needed by the rtp parsing for this dynamic data.
42 DynamicPayloadPacketHandlerProc parse_packet; ///< parse handler for this dynamic packet.
43
44 struct RTPDynamicProtocolHandler_s *next;
45} RTPDynamicProtocolHandler;
46
47// moved out of rtp.c, because the h264 decoder needs to know about this structure..
48struct RTPDemuxContext {
49 AVFormatContext *ic;
50 AVStream *st;
51 int payload_type;
52 uint32_t ssrc;
53 uint16_t seq;
54 uint32_t timestamp;
55 uint32_t base_timestamp;
56 uint32_t cur_timestamp;
57 int max_payload_size;
58 struct MpegTSContext *ts; /* only used for MP2T payloads */
59 int read_buf_index;
60 int read_buf_size;
61
62 /* rtcp sender statistics receive */
63 int64_t last_rtcp_ntp_time; // TODO: move into statistics
64 int64_t first_rtcp_ntp_time; // TODO: move into statistics
65 uint32_t last_rtcp_timestamp; // TODO: move into statistics
66
67 /* rtcp sender statistics */
68 unsigned int packet_count; // TODO: move into statistics (outgoing)
69 unsigned int octet_count; // TODO: move into statistics (outgoing)
70 unsigned int last_octet_count; // TODO: move into statistics (outgoing)
71 int first_packet;
72 /* buffer for output */
73 uint8_t buf[RTP_MAX_PACKET_LENGTH];
74 uint8_t *buf_ptr;
75
76 /* special infos for au headers parsing */
77 rtp_payload_data_t *rtp_payload_data; // TODO: Move into dynamic payload handlers
78
79 /* dynamic payload stuff */
80 DynamicPayloadPacketHandlerProc parse_packet; ///< This is also copied from the dynamic protocol handler structure
81 void *dynamic_protocol_context; ///< This is a copy from the values setup from the sdp parsing, in rtsp.c don't free me.
82};
83
84extern RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler;
85#endif /* RTP_INTERNAL_H */
86