• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavformat/rtpdec.h

Go to the documentation of this file.
00001 /*
00002  * RTP demuxer definitions
00003  * Copyright (c) 2002 Fabrice Bellard
00004  * Copyright (c) 2006 Ryan Martell <rdm4@martellventures.com>
00005  *
00006  * This file is part of Libav.
00007  *
00008  * Libav is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * Libav is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with Libav; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021  */
00022 #ifndef AVFORMAT_RTPDEC_H
00023 #define AVFORMAT_RTPDEC_H
00024 
00025 #include "libavcodec/avcodec.h"
00026 #include "avformat.h"
00027 #include "rtp.h"
00028 #include "url.h"
00029 
00030 typedef struct PayloadContext PayloadContext;
00031 typedef struct RTPDynamicProtocolHandler_s RTPDynamicProtocolHandler;
00032 
00033 #define RTP_MIN_PACKET_LENGTH 12
00034 #define RTP_MAX_PACKET_LENGTH 1500 /* XXX: suppress this define */
00035 
00036 #define RTP_REORDER_QUEUE_DEFAULT_SIZE 10
00037 
00038 #define RTP_NOTS_VALUE ((uint32_t)-1)
00039 
00040 typedef struct RTPDemuxContext RTPDemuxContext;
00041 RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size);
00042 void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx,
00043                                        RTPDynamicProtocolHandler *handler);
00044 int ff_rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
00045                         uint8_t **buf, int len);
00046 void ff_rtp_parse_close(RTPDemuxContext *s);
00047 int64_t ff_rtp_queued_packet_time(RTPDemuxContext *s);
00048 void ff_rtp_reset_packet_queue(RTPDemuxContext *s);
00049 int ff_rtp_get_local_rtp_port(URLContext *h);
00050 int ff_rtp_get_local_rtcp_port(URLContext *h);
00051 
00052 int ff_rtp_set_remote_url(URLContext *h, const char *uri);
00053 
00065 void ff_rtp_send_punch_packets(URLContext* rtp_handle);
00066 
00072 int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count);
00073 
00077 int ff_rtp_get_rtcp_file_handle(URLContext *h);
00078 
00079 // these statistics are used for rtcp receiver reports...
00080 typedef struct {
00081     uint16_t max_seq;           
00082     uint32_t cycles;            
00083     uint32_t base_seq;          
00084     uint32_t bad_seq;           
00085     int probation;              
00086     int received;               
00087     int expected_prior;         
00088     int received_prior;         
00089     uint32_t transit;           
00090     uint32_t jitter;            
00091 } RTPStatistics;
00092 
00093 #define RTP_FLAG_KEY    0x1 ///< RTP packet contains a keyframe
00094 #define RTP_FLAG_MARKER 0x2 ///< RTP marker bit was set for this packet
00095 
00107 typedef int (*DynamicPayloadPacketHandlerProc) (AVFormatContext *ctx,
00108                                                 PayloadContext *s,
00109                                                 AVStream *st,
00110                                                 AVPacket * pkt,
00111                                                 uint32_t *timestamp,
00112                                                 const uint8_t * buf,
00113                                                 int len, int flags);
00114 
00115 struct RTPDynamicProtocolHandler_s {
00116     // fields from AVRtpDynamicPayloadType_s
00117     const char enc_name[50];    /* XXX: still why 50 ? ;-) */
00118     enum AVMediaType codec_type;
00119     enum CodecID codec_id;
00120     int static_payload_id; /* 0 means no payload id is set. 0 is a valid
00121                             * payload ID (PCMU), too, but that format doesn't
00122                             * require any custom depacketization code. */
00123 
00124     // may be null
00125     int (*init)(AVFormatContext *s, int st_index, PayloadContext *priv_data); 
00126     int (*parse_sdp_a_line) (AVFormatContext *s,
00127                              int st_index,
00128                              PayloadContext *priv_data,
00129                              const char *line); 
00130     PayloadContext *(*alloc) (void); 
00131     void (*free)(PayloadContext *protocol_data); 
00132     DynamicPayloadPacketHandlerProc parse_packet; 
00133 
00134     struct RTPDynamicProtocolHandler_s *next;
00135 };
00136 
00137 typedef struct RTPPacket {
00138     uint16_t seq;
00139     uint8_t *buf;
00140     int len;
00141     int64_t recvtime;
00142     struct RTPPacket *next;
00143 } RTPPacket;
00144 
00145 // moved out of rtp.c, because the h264 decoder needs to know about this structure..
00146 struct RTPDemuxContext {
00147     AVFormatContext *ic;
00148     AVStream *st;
00149     int payload_type;
00150     uint32_t ssrc;
00151     uint16_t seq;
00152     uint32_t timestamp;
00153     uint32_t base_timestamp;
00154     uint32_t cur_timestamp;
00155     int64_t  unwrapped_timestamp;
00156     int64_t  range_start_offset;
00157     int max_payload_size;
00158     struct MpegTSContext *ts;   /* only used for MP2T payloads */
00159     int read_buf_index;
00160     int read_buf_size;
00161     /* used to send back RTCP RR */
00162     URLContext *rtp_ctx;
00163     char hostname[256];
00164 
00165     RTPStatistics statistics; 
00166 
00168     int prev_ret;     
00169     RTPPacket* queue; 
00170     int queue_len;    
00171     int queue_size;   
00172 
00174     /* rtcp sender statistics receive */
00175     int64_t last_rtcp_ntp_time;    // TODO: move into statistics
00176     int64_t first_rtcp_ntp_time;   // TODO: move into statistics
00177     uint32_t last_rtcp_timestamp;  // TODO: move into statistics
00178     int64_t rtcp_ts_offset;
00179 
00180     /* rtcp sender statistics */
00181     unsigned int packet_count;     // TODO: move into statistics (outgoing)
00182     unsigned int octet_count;      // TODO: move into statistics (outgoing)
00183     unsigned int last_octet_count; // TODO: move into statistics (outgoing)
00184     int first_packet;
00185     /* buffer for output */
00186     uint8_t buf[RTP_MAX_PACKET_LENGTH];
00187     uint8_t *buf_ptr;
00188 
00189     /* dynamic payload stuff */
00190     DynamicPayloadPacketHandlerProc parse_packet;     
00191     PayloadContext *dynamic_protocol_context;        
00192     int max_frames_per_packet;
00193 };
00194 
00195 void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler);
00196 RTPDynamicProtocolHandler *ff_rtp_handler_find_by_name(const char *name,
00197                                                   enum AVMediaType codec_type);
00198 RTPDynamicProtocolHandler *ff_rtp_handler_find_by_id(int id,
00199                                                 enum AVMediaType codec_type);
00200 
00201 int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size); 
00202 
00203 int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p,
00204                   int (*parse_fmtp)(AVStream *stream,
00205                                     PayloadContext *data,
00206                                     char *attr, char *value));
00207 
00208 void av_register_rtp_dynamic_payload_handlers(void);
00209 
00210 #endif /* AVFORMAT_RTPDEC_H */
Generated on Thu Jul 11 2013 15:38:24 for Libav by doxygen 1.7.1