Statistics
| Branch: | Revision:

ffmpeg / libavformat / rtp_internal.h @ 98561024

History | View | Annotate | Download (4.82 KB)

1 4934884a Ryan Martell
/*
2
 * RTP definitions
3
 * Copyright (c) 2006 Ryan Martell <rdm4@martellventures.com>
4
 *
5 9eeec55d Guillaume Poirier
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
8 4934884a Ryan Martell
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10 cbced386 Guillaume Poirier
 * version 2.1 of the License, or (at your option) any later version.
11 4934884a Ryan Martell
 *
12 cbced386 Guillaume Poirier
 * FFmpeg is distributed in the hope that it will be useful,
13 4934884a Ryan Martell
 * 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 550b2843 Guillaume Poirier
 * License along with FFmpeg; if not, write to the Free Software
19 4934884a Ryan Martell
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21
22
// this is a bit of a misnomer, because rtp & rtsp internal structures and prototypes are in here.
23
#ifndef RTP_INTERNAL_H
24
#define RTP_INTERNAL_H
25
26 99545457 Måns Rullgård
#include <stdint.h>
27
#include "avcodec.h"
28
#include "rtp.h"
29
30 4a6cc061 Ryan Martell
// 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;
43
44
45 4934884a Ryan Martell
typedef int (*DynamicPayloadPacketHandlerProc) (struct RTPDemuxContext * s,
46
                                                AVPacket * pkt,
47 d0deedcb Ryan Martell
                                                uint32_t *timestamp,
48 4934884a Ryan Martell
                                                const uint8_t * buf,
49
                                                int len);
50
51
typedef struct RTPDynamicProtocolHandler_s {
52
    // fields from AVRtpDynamicPayloadType_s
53
    const char enc_name[50];    /* XXX: still why 50 ? ;-) */
54
    enum CodecType codec_type;
55
    enum CodecID codec_id;
56
57
    // may be null
58
    int (*parse_sdp_a_line) (AVStream * stream,
59
                             void *protocol_data,
60
                             const char *line); ///< Parse the a= line from the sdp field
61
    void *(*open) (); ///< allocate any data needed by the rtp parsing for this dynamic data.
62
    void (*close)(void *protocol_data); ///< free any data needed by the rtp parsing for this dynamic data.
63
    DynamicPayloadPacketHandlerProc parse_packet; ///< parse handler for this dynamic packet.
64
65
    struct RTPDynamicProtocolHandler_s *next;
66
} RTPDynamicProtocolHandler;
67
68
// moved out of rtp.c, because the h264 decoder needs to know about this structure..
69
struct RTPDemuxContext {
70
    AVFormatContext *ic;
71
    AVStream *st;
72
    int payload_type;
73
    uint32_t ssrc;
74
    uint16_t seq;
75
    uint32_t timestamp;
76
    uint32_t base_timestamp;
77
    uint32_t cur_timestamp;
78
    int max_payload_size;
79
    struct MpegTSContext *ts;   /* only used for MP2T payloads */
80
    int read_buf_index;
81
    int read_buf_size;
82 dbf30963 Thijs
    /* used to send back RTCP RR */
83
    URLContext *rtp_ctx;
84
    char hostname[256];
85 4934884a Ryan Martell
86 4a6cc061 Ryan Martell
    RTPStatistics statistics; ///< Statistics for this stream (used by RTCP receiver reports)
87
88 4934884a Ryan Martell
    /* rtcp sender statistics receive */
89
    int64_t last_rtcp_ntp_time;    // TODO: move into statistics
90
    int64_t first_rtcp_ntp_time;   // TODO: move into statistics
91
    uint32_t last_rtcp_timestamp;  // TODO: move into statistics
92
93
    /* rtcp sender statistics */
94
    unsigned int packet_count;     // TODO: move into statistics (outgoing)
95
    unsigned int octet_count;      // TODO: move into statistics (outgoing)
96
    unsigned int last_octet_count; // TODO: move into statistics (outgoing)
97
    int first_packet;
98
    /* buffer for output */
99
    uint8_t buf[RTP_MAX_PACKET_LENGTH];
100
    uint8_t *buf_ptr;
101
102
    /* special infos for au headers parsing */
103
    rtp_payload_data_t *rtp_payload_data; // TODO: Move into dynamic payload handlers
104
105
    /* dynamic payload stuff */
106
    DynamicPayloadPacketHandlerProc parse_packet;     ///< This is also copied from the dynamic protocol handler structure
107
    void *dynamic_protocol_context;        ///< This is a copy from the values setup from the sdp parsing, in rtsp.c don't free me.
108
};
109
110
extern RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler;
111 4a6cc061 Ryan Martell
112
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.
113 98561024 Luca Abeni
114
void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m);
115 4934884a Ryan Martell
#endif /* RTP_INTERNAL_H */