OSDN Git Service

add tstools.
[rec10/rec10-git.git] / tstools / DtsEdit / src / gpac / ietf.h
diff --git a/tstools/DtsEdit/src/gpac/ietf.h b/tstools/DtsEdit/src/gpac/ietf.h
new file mode 100644 (file)
index 0000000..e6552e5
--- /dev/null
@@ -0,0 +1,1319 @@
+/*\r
+ *                     GPAC - Multimedia Framework C SDK\r
+ *\r
+ *                     Copyright (c) Jean Le Feuvre 2000-2005\r
+ *                                     All rights reserved\r
+ *\r
+ *  This file is part of GPAC / IETF RTP/RTSP/SDP sub-project\r
+ *\r
+ *  GPAC is free software; you can redistribute it and/or modify\r
+ *  it under the terms of the GNU Lesser General Public License as published by\r
+ *  the Free Software Foundation; either version 2, or (at your option)\r
+ *  any later version.\r
+ *   \r
+ *  GPAC is distributed in the hope that it will be useful,\r
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *  GNU Lesser General Public License for more details.\r
+ *   \r
+ *  You should have received a copy of the GNU Lesser General Public\r
+ *  License along with this library; see the file COPYING.  If not, write to\r
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
+ *\r
+ */\r
+\r
+\r
+#ifndef        _GF_IETF_H_\r
+#define _GF_IETF_H_\r
+\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#include <gpac/list.h>\r
+#include <gpac/bitstream.h>\r
+#include <gpac/sync_layer.h>\r
+#include <gpac/network.h>\r
+\r
+\r
+/****************************************************************************\r
+\r
+                               RTSP VERSION 1.0 LIBRARY EXPORTS\r
+\r
+****************************************************************************/\r
+\r
+#define GF_RTSP_VERSION                "RTSP/1.0"\r
+\r
+\r
+/*\r
+ *             RTSP NOTIF CODES\r
+ */\r
+enum\r
+{\r
+       NC_RTSP_Continue                =               100,\r
+       NC_RTSP_OK                              =               200,\r
+       NC_RTSP_Created                 =               201,\r
+       NC_RTSP_Low_on_Storage_Space    =       250,\r
+\r
+       NC_RTSP_Multiple_Choice =       300,\r
+       NC_RTSP_Moved_Permanently       =       301,\r
+       NC_RTSP_Moved_Temporarily       =       302,\r
+       NC_RTSP_See_Other       =       303,\r
+       NC_RTSP_Use_Proxy       =       305,\r
+\r
+       NC_RTSP_Bad_Request     =       400,\r
+       NC_RTSP_Unauthorized    =       401,\r
+       NC_RTSP_Payment_Required        =       402,\r
+       NC_RTSP_Forbidden       =       403,\r
+       NC_RTSP_Not_Found       =       404,\r
+       NC_RTSP_Method_Not_Allowed      =       405,\r
+       NC_RTSP_Not_Acceptable  =       406,\r
+       NC_RTSP_Proxy_Authentication_Required   =       407,\r
+       NC_RTSP_Request_Timeout =       408,\r
+       NC_RTSP_Gone    =       410,\r
+       NC_RTSP_Length_Required =       411,\r
+       NC_RTSP_Precondition_Failed     =       412,\r
+       NC_RTSP_Request_Entity_Too_Large        =       413,\r
+       NC_RTSP_Request_URI_Too_Long    =       414,\r
+       NC_RTSP_Unsupported_Media_Type  =       415,\r
+\r
+       NC_RTSP_Invalid_parameter       =       451,\r
+       NC_RTSP_Illegal_Conference_Identifier   =       452,\r
+       NC_RTSP_Not_Enough_Bandwidth    =       453,\r
+       NC_RTSP_Session_Not_Found       =       454,\r
+       NC_RTSP_Method_Not_Valid_In_This_State  =       455,\r
+       NC_RTSP_Header_Field_Not_Valid  =       456,\r
+       NC_RTSP_Invalid_Range   =       457,\r
+       NC_RTSP_Parameter_Is_ReadOnly   =       458,\r
+       NC_RTSP_Aggregate_Operation_Not_Allowed =       459,\r
+       NC_RTSP_Only_Aggregate_Operation_Allowed        =       460,\r
+       NC_RTSP_Unsupported_Transport   =       461,\r
+       NC_RTSP_Destination_Unreachable =       462,\r
+       \r
+       NC_RTSP_Internal_Server_Error   =       500,\r
+       NC_RTSP_Not_Implemented =       501,\r
+       NC_RTSP_Bad_Gateway     =       502,\r
+       NC_RTSP_Service_Unavailable     =       503,\r
+       NC_RTSP_Gateway_Timeout =       504,\r
+       NC_RTSP_RTSP_Version_Not_Supported      =       505,\r
+\r
+       NC_RTSP_Option_not_support      =       551,\r
+};\r
+\r
+const char *gf_rtsp_nc_to_string(u32 ErrCode);\r
+\r
+/*\r
+               Common structures between commands and responses\r
+*/\r
+\r
+/*\r
+       RTSP Range information - RTSP Session level only (though this is almost the same\r
+       format as an SDP range, this is not used in the SDP lib as "a=range" is not part of SDP\r
+       but part of RTSP\r
+*/\r
+typedef struct {\r
+       /* start and end range. If end is -1, the range is open (from start to unknown) */\r
+       Double start, end;\r
+       /* use SMPTE range (Start and End specify the number of frames) (currently not supported) */\r
+       u32 UseSMPTE;\r
+       /* framerate for SMPTE range */\r
+       Double FPS;\r
+} GF_RTSPRange;\r
+\r
+/*\r
+parses a Range line and returns range header structure. can be used for RTSP extension of SDP\r
+NB: Only support for npt for now\r
+*/\r
+GF_RTSPRange *gf_rtsp_range_parse(char *range_buf);\r
+\r
+GF_RTSPRange *gf_rtsp_range_new();\r
+void gf_rtsp_range_del(GF_RTSPRange *range);\r
+\r
+/*\r
+                       Transport structure \r
+               contains all network info for RTSP sessions (ports, uni/multi-cast, ...)\r
+*/\r
+\r
+/*\r
+       Transport Profiles as defined in RFC 2326\r
+*/\r
+#define GF_RTSP_PROFILE_RTP_AVP                        "RTP/AVP"\r
+#define GF_RTSP_PROFILE_RTP_AVP_TCP            "RTP/AVP/TCP"\r
+#define GF_RTSP_PROFILE_UDP                            "udp"\r
+\r
+\r
+typedef struct\r
+{\r
+       /* set to 1 if unicast */\r
+       Bool IsUnicast;\r
+       /* for multicast */\r
+       char *destination;\r
+       /* for redirections internal to servers */\r
+       char *source;\r
+       /*IsRecord is usually 0 (PLAY) . If set, Append specify that the stream should\r
+       be concatenated to existing resources */\r
+       Bool IsRecord, Append;\r
+       /* in case transport is on TCP/RTSP, If only 1 ID is specified, it is stored in rtpID (this\r
+       is not RTP interleaving) */\r
+       Bool IsInterleaved, rtpID, rtcpID;\r
+       /* Multicast specific */\r
+       u32 MulticastLayers;\r
+       u8 TTL;\r
+       /*RTP specific*/\r
+\r
+       /*port for multicast*/\r
+       /*server port in unicast - RTP implies low is even , and last is low+1*/\r
+       u16 port_first, port_last;\r
+       /*client port in unicast - RTP implies low is even , and last is low+1*/\r
+       u16 client_port_first, client_port_last;\r
+       u32 SSRC;\r
+\r
+       /*Transport protocol. In this version we only support RTP/AVP, the following flag tells \r
+       us if this is RTP/AVP/TCP or RTP/AVP (default)*/\r
+       char *Profile;\r
+} GF_RTSPTransport;\r
+\r
+\r
+GF_RTSPTransport *gf_rtsp_transport_clone(GF_RTSPTransport *original);\r
+void gf_rtsp_transport_del(GF_RTSPTransport *transp);\r
+\r
+\r
+/*\r
+                               RTSP Command\r
+               the RTSP Response is sent by a client / received by a server\r
+       text Allocation is done by the lib when parsing a command, and\r
+       is automatically freed when calling reset / delete. Therefore you must\r
+       set/allocate the fields yourself when writing a command (client)\r
+\r
+*/\r
+\r
+/*ALL RTSP METHODS - all other methods will be ignored*/\r
+#define GF_RTSP_DESCRIBE               "DESCRIBE"\r
+#define GF_RTSP_SETUP                  "SETUP"\r
+#define GF_RTSP_PLAY                   "PLAY"\r
+#define GF_RTSP_PAUSE                  "PAUSE"\r
+#define GF_RTSP_RECORD                 "RECORD"\r
+#define GF_RTSP_TEARDOWN               "TEARDOWN"\r
+#define GF_RTSP_GET_PARAMETER  "GET_PARAMETER"\r
+#define GF_RTSP_SET_PARAMETER  "SET_PARAMETER"\r
+#define GF_RTSP_OPTIONS                "OPTIONS"\r
+#define GF_RTSP_ANNOUNCE               "ANNOUNCE"\r
+#define GF_RTSP_REDIRECTE              "REDIRECT"\r
+\r
+\r
+typedef struct\r
+{\r
+       char *Accept;\r
+       char *Accept_Encoding;\r
+       char *Accept_Language;\r
+       char *Authorization;\r
+       u32 Bandwidth;\r
+       u32 Blocksize;\r
+       char *Cache_Control;\r
+       char *Conference;\r
+       char *Connection;\r
+       u32 Content_Length;\r
+       u32 CSeq;\r
+       char *From;\r
+       char *Proxy_Authorization;\r
+       char *Proxy_Require;\r
+       GF_RTSPRange *Range;\r
+       char *Referer;\r
+       Double Scale;\r
+       char *Session;\r
+       Double Speed;\r
+       /*nota : RTSP allows several configurations for a single channel (multicast and \r
+       unicast , ...). Usually only 1*/\r
+       GF_List *Transports;\r
+       char *User_Agent;\r
+\r
+       /*type of the command, one of the described above*/\r
+       char *method;\r
+       \r
+       /*Header extensions*/\r
+       GF_List *Xtensions;\r
+\r
+       /*body of the command, size is Content-Length (auto computed when sent). It is not \r
+       terminated by a NULL char*/\r
+       char *body;\r
+\r
+       /*\r
+                       Specify ControlString if your request targets\r
+               a specific media stream in the service. If null, the service name only will be used\r
+               for control (for ex, both A and V streams in a single file)\r
+               If the request is GF_RTSP_OPTIONS, you must provide a control string containing the options \r
+               you want to query\r
+       */\r
+       char *ControlString;\r
+\r
+       /*user data: this is never touched by the lib, its intend is to help stacking\r
+       RTSP commands in your app*/\r
+       void *user_data;\r
+\r
+\r
+       /*\r
+               Server side Extensions\r
+       */\r
+\r
+       /*full URL of the command. Not used at client side, as the URL is ALWAYS relative\r
+       to the server / service of the RTSP session \r
+       On the server side however redirections are up to the server, so we cannot decide for it        */\r
+       char *service_name;\r
+       /*RTSP status code of the command as parsed. One of the above RTSP StatusCode*/\r
+       u32 StatusCode;\r
+} GF_RTSPCommand;\r
+\r
+\r
+GF_RTSPCommand *gf_rtsp_command_new();\r
+void gf_rtsp_command_del(GF_RTSPCommand *com);\r
+void gf_rtsp_command_reset(GF_RTSPCommand *com);\r
+\r
+\r
+\r
+/*\r
+                               RTSP Response\r
+               the RTSP Response is received by a client / sent by a server\r
+       text Allocation is done by the lib when parsing a response, and\r
+       is automatically freed when calling reset / delete. Therefore you must\r
+       allocate the fields yourself when writing a response (server)\r
+\r
+*/\r
+\r
+/*\r
+       RTP-Info for RTP channels. There may be several RTP-Infos in one response\r
+       based on the server implementation (DSS/QTSS begaves this way)\r
+*/\r
+typedef struct\r
+{\r
+       /*control string of the channel*/\r
+       char *url;\r
+       /*seq num for asociated rtp_time*/\r
+       u32 seq;\r
+       /*rtp TimeStamp corresponding to the Range start specified in the PLAY request*/\r
+       u32 rtp_time;\r
+       /*ssrc of sender if known, 0 otherwise*/\r
+       u32 ssrc;\r
+} GF_RTPInfo;\r
+\r
+\r
+\r
+/*\r
+       RTSP Response\r
+*/\r
+typedef struct\r
+{\r
+       /* response code*/\r
+       u32 ResponseCode;\r
+       /* comment from the server */\r
+       char *ResponseInfo;\r
+       \r
+       /*      Header Fields   */\r
+       char *Accept;\r
+       char *Accept_Encoding;\r
+       char *Accept_Language;\r
+       char *Allow;\r
+       char *Authorization;\r
+       u32 Bandwidth;\r
+       u32 Blocksize;\r
+       char *Cache_Control;\r
+       char *Conference;\r
+       char *Connection;\r
+       char *Content_Base;\r
+       char *Content_Encoding;\r
+       char *Content_Language;\r
+       u32 Content_Length;\r
+       char *Content_Location;\r
+       char *Content_Type;\r
+       u32 CSeq;\r
+       char *Date;\r
+       char *Expires;\r
+       char *From;\r
+       char *Host;\r
+       char *If_Match;\r
+       char *If_Modified_Since;\r
+       char *Last_Modified;\r
+       char *Location;\r
+       char *Proxy_Authenticate;\r
+       char *Proxy_Require;\r
+       char *Public;\r
+       GF_RTSPRange *Range;\r
+       char *Referer;\r
+       char *Require;\r
+       char *Retry_After;\r
+       GF_List *RTP_Infos;\r
+       Double Scale;\r
+       char *Server;\r
+       char *Session;\r
+       u32 SessionTimeOut;\r
+       Double Speed;\r
+       char *Timestamp;\r
+       /*nota : RTSP allows several configurations for a single channel (multicast and \r
+       unicast , ...). Usually only 1*/\r
+       GF_List *Transports;\r
+       char *Unsupported;\r
+       char *User_Agent;\r
+       char *Vary;\r
+       char *Via;\r
+       char *WWW_Authenticate;\r
+\r
+       /*Header extensions*/\r
+       GF_List *Xtensions;\r
+\r
+       /*body of the response, size is Content-Length (auto computed when sent). It is not \r
+       terminated by a NULL char when response is parsed but must be null-terminated when \r
+       response is being sent*/\r
+       char *body;\r
+} GF_RTSPResponse;\r
+\r
+\r
+GF_RTSPResponse *gf_rtsp_response_new();\r
+void gf_rtsp_response_del(GF_RTSPResponse *rsp);\r
+void gf_rtsp_response_reset(GF_RTSPResponse *rsp);\r
+\r
+\r
+\r
+typedef struct _tag_rtsp_session GF_RTSPSession;\r
+\r
+GF_RTSPSession *gf_rtsp_session_new(char *sURL, u16 DefaultPort);\r
+void gf_rtsp_session_del(GF_RTSPSession *sess);\r
+\r
+GF_Err gf_rtsp_set_buffer_size(GF_RTSPSession *sess, u32 BufferSize);\r
+\r
+/*force the IP address the client is using*/\r
+void gf_rtsp_set_mobile_ip(GF_RTSPSession *sess, char *MobileIP);\r
+\r
+\r
+/*Reset state machine, invalidate SessionID\r
+NOTE: RFC2326 requires that the session is reseted when all RTP streams\r
+are closed. As this lib doesn't maintain the number of valid streams\r
+you MUST call reset when all your streams are shutdown (either requested through\r
+TEARDOWN or signaled through RTCP BYE packets for RTP, or any other signaling means\r
+for other protocols)\r
+reset connection will destroy the socket - this is isefull in case of timeouts, because\r
+some servers do not restart with the right CSeq...*/\r
+void gf_rtsp_session_reset(GF_RTSPSession *sess, Bool ResetConnection);\r
+\r
+u32 gf_rtsp_is_my_session(GF_RTSPSession *sess, char *url);\r
+const char *gf_rtsp_get_last_session_id(GF_RTSPSession *sess);\r
+char *gf_rtsp_get_server_name(GF_RTSPSession *sess);\r
+char *gf_rtsp_get_service_name(GF_RTSPSession *sess);\r
+u16 gf_rtsp_get_session_port(GF_RTSPSession *sess);\r
+\r
+/*Fetch an RTSP response from the server the GF_RTSPResponse will be reseted before fetch*/\r
+GF_Err gf_rtsp_get_response(GF_RTSPSession *sess, GF_RTSPResponse *rsp);\r
+\r
+\r
+/*RTSP State Machine. The only non blocking mode is GF_RTSP_STATE_WAIT_FOR_CONTROL*/\r
+enum\r
+{\r
+       /*Initialized (connection might be off, but all structures are in place)\r
+       This is the default state between # requests (aka, DESCRIBE and SETUP\r
+       or SETUP and PLAY ...)*/\r
+       GF_RTSP_STATE_INIT      =       0,\r
+       /*Waiting*/\r
+       GF_RTSP_STATE_WAITING,\r
+       /*PLAY, PAUSE, RECORD. Aggregation is allowed for the same type, you can send several command\r
+       in a row. However the session will return GF_SERVICE_ERROR if you do not have \r
+       a valid SessionID in the command\r
+       You cannot issue a SETUP / DESCRIBE while in this state*/\r
+       GF_RTSP_STATE_WAIT_FOR_CONTROL,\r
+\r
+       /*FATAL ERROR: session is invalidated by server. Call reset and restart from SETUP if needed*/\r
+       GF_RTSP_STATE_INVALIDATED\r
+};\r
+\r
+u32 gf_rtsp_get_session_state(GF_RTSPSession *sess);\r
+/*aggregate command state-machine: the PLAY/PAUSE can be aggregated \r
+(sent before the reply is received). This function gets the last command sent*/\r
+char *gf_rtsp_get_last_request(GF_RTSPSession *sess);\r
+/*foce a reset in case of pbs*/\r
+void gf_rtsp_reset_aggregation(GF_RTSPSession *sess);\r
+\r
+/*\r
+       Send an RTSP request to the server.\r
+*/\r
+GF_Err gf_rtsp_send_command(GF_RTSPSession *sess, GF_RTSPCommand *com);\r
+\r
+\r
+GF_Err gf_rtsp_set_interleave_callback(GF_RTSPSession *sess,\r
+                                               GF_Err (*SignalData)(GF_RTSPSession *sess, void *cbk_ptr, char *buffer, u32 bufferSize, Bool IsRTCP)\r
+                               );\r
+\r
+\r
+GF_Err gf_rtsp_session_read(GF_RTSPSession *sess);\r
+\r
+GF_Err gf_rtsp_register_interleave(GF_RTSPSession *sess, void *the_ch, u8 LowInterID, u8 HighInterID);\r
+u32 gf_rtsp_unregister_interleave(GF_RTSPSession *sess, u8 LowInterID);\r
+\r
+\r
+\r
+/*\r
+                       Server side session constructor\r
+       create a new RTSP session from an existing socket in listen state. If no pending connection\r
+       is detected, return NULL\r
+*/\r
+GF_RTSPSession *gf_rtsp_session_new_server(GF_Socket *rtsp_listener);\r
+\r
+/*fetch an RTSP request. The GF_RTSPCommand will be reseted before fetch*/\r
+GF_Err gf_rtsp_get_command(GF_RTSPSession *sess, GF_RTSPCommand *com);\r
+\r
+/*unpack the URL, check the service name / server. Typically used when a client sends a \r
+ DESCRIBE || SETUP url RTSP/1.0. Server / service name check must be performed by your app as redirection\r
+or services available are unknown here.*/\r
+GF_Err gf_rtsp_load_service_name(GF_RTSPSession *sess, char *URL);\r
+\r
+/*geenrates a session ID fpor the given session*/\r
+char *gf_rtsp_generate_session_id(GF_RTSPSession *sess);\r
+\r
+/*send the RTSP response*/\r
+GF_Err gf_rtsp_send_response(GF_RTSPSession *sess, GF_RTSPResponse *rsp);\r
+\r
+/*gets the IP address of the local host running the session\r
+buffer shall be GF_MAX_IP_NAME_LEN long*/\r
+GF_Err gf_rtsp_get_session_ip(GF_RTSPSession *sess, char *buffer);\r
+\r
+/*returns the next available ID for interleaving. It is recommended that you use 2 \r
+consecutive IDs for RTP/RTCP interleaving*/\r
+u8 gf_rtsp_get_next_interleave_id(GF_RTSPSession *sess);\r
+\r
+/*gets the IP address of the connected peer - buffer shall be GF_MAX_IP_NAME_LEN long*/\r
+GF_Err gf_rtsp_get_remote_address(GF_RTSPSession *sess, char *buffer);\r
+\r
+\r
+/*\r
+               RTP LIB EXPORTS\r
+*/\r
+\r
+\r
+typedef struct tagRTP_HEADER {\r
+       /*version, must be 2*/\r
+       u8 Version;\r
+       /*padding bits in the payload*/\r
+       u8 Padding;\r
+       /*header extension is defined*/\r
+       u8 Extension;\r
+       /*number of CSRC (<=15)*/\r
+       u8 CSRCCount;\r
+       /*Marker Bit*/\r
+       u8 Marker;\r
+       /*payload type on 7 bits*/\r
+       u8 PayloadType;\r
+       /*packet seq number*/\r
+       u16 SequenceNumber;\r
+       /*packet time stamp*/\r
+       u32 TimeStamp;\r
+       /*sync source identifier*/\r
+       u32 SSRC;\r
+       /*in our basic client, CSRC should always be NULL*/\r
+       u32 CSRC[16];\r
+} GF_RTPHeader;\r
+\r
+\r
+\r
+\r
+/*\r
+       structure containing the rtpmap information\r
+*/\r
+typedef struct\r
+{\r
+       /*dynamic payload type of this map*/\r
+       u32 PayloadType;\r
+       /*registered payload name of this map*/\r
+       char *payload_name;\r
+       /*RTP clock rate (TS resolution) of this map*/\r
+       u32 ClockRate;\r
+       /*optional parameters for audio, specifying number of channels. Unused for other media types.*/\r
+       u32 AudioChannels;\r
+} GF_RTPMap;\r
+\r
+\r
+\r
+typedef struct __tag_rtp_channel GF_RTPChannel;\r
+\r
+GF_RTPChannel *gf_rtp_new();\r
+void gf_rtp_del(GF_RTPChannel *ch);\r
+\r
+/*you configure a server channel through the transport structure, with the same info as a \r
+client channel, the client_port_* info designing the REMOTE client and port_* designing\r
+your server channel*/\r
+GF_Err gf_rtp_setup_transport(GF_RTPChannel *ch, GF_RTSPTransport *trans_info, char *remote_address);\r
+\r
+/*auto-setup of rtp/rtcp transport ports - only effective in unicast, non interleaved cases. \r
+for multicast port setup MUST be done through the above gf_rtp_setup_transport function\r
+this will take care of port reuse*/\r
+GF_Err gf_rtp_set_ports(GF_RTPChannel *ch, u16 first_port);\r
+\r
+/*init of payload information. only ONE payload per sync source is supported in this\r
+version of the library (a sender cannot switch payload types on a single media)*/\r
+GF_Err gf_rtp_setup_payload(GF_RTPChannel *ch, GF_RTPMap *map);\r
+\r
+/*enables sending of NAT keep-alive packets for NAT traversal\r
+       @nat_timeout: specifies the inactivity period in ms after which NAT keepalive packets are sent. \r
+       If 0, disables NAT keep-alive packets \r
+*/\r
+void gf_rtp_enable_nat_keepalive(GF_RTPChannel *ch, u32 nat_timeout);\r
+\r
+\r
+/*initialize the RTP channel.\r
+\r
+UDPBufferSize: UDP stack buffer size if configurable by OS/ISP - ignored otherwise\r
+NOTE: on WinCE devices, this is not configurable on an app bases but for the whole OS\r
+you must update the device registry with:\r
+       [HKEY_LOCAL_MACHINE\Comm\Afd]\r
+       DgramBuffer=dword:N\r
+\r
+       where N is the number of UDP datagrams a socket should be able to buffer. For multimedia\r
+app you should set N as large as possible. The device MUST be reseted for the param to take effect\r
+\r
+ReorederingSize: max number of packets to queue for reordering. 0 means no reordering\r
+MaxReorderDelay: max time to wait in ms before releasing first packet in reoderer when only one packet is present.\r
+If 0 and reordering size is specified, defaults to 200 ms (usually enough).\r
+IsSource: if true, the channel is a sender (media data, sender report, Receiver report processing)\r
+if source, you must specify the Path MTU size. The RTP lib won't send any packet bigger than this size\r
+your application shall perform payload size splitting if needed\r
+local_interface_ip: local interface address to use for multicast. If NULL, default address is used\r
+*/\r
+GF_Err gf_rtp_initialize(GF_RTPChannel *ch, u32 UDPBufferSize, Bool IsSource, u32 PathMTU, u32 ReorederingSize, u32 MaxReorderDelay, char *local_interface_ip);\r
+\r
+/*init the RTP info after a PLAY or PAUSE, rtp_time is the rtp TimeStamp of the RTP packet\r
+with seq_num sequence number. This info is needed to compute the CurrentTime of the RTP channel \r
+ssrc may not be known if sender hasn't indicated it (use 0 then)*/\r
+GF_Err gf_rtp_set_info_rtp(GF_RTPChannel *ch, u32 seq_num, u32 rtp_time, u32 ssrc);\r
+\r
+/*retrieve current RTP time in sec. If rtp_time was unknown (not on demand media) the time is absolute.\r
+Otherwise this is the time in ms elapsed since the last PLAY range start value\r
+Not supported yet if played without RTSP (aka RTCP time not supported)*/\r
+Double gf_rtp_get_current_time(GF_RTPChannel *ch);\r
+\r
+\r
+void gf_rtp_reset_buffers(GF_RTPChannel *ch);\r
+\r
+/*read any data on UDP only (not valid for TCP). Performs re-ordering if configured for it\r
+returns amount of data read (raw UDP packet size)*/\r
+u32 gf_rtp_read_rtp(GF_RTPChannel *ch, char *buffer, u32 buffer_size);\r
+u32 gf_rtp_read_rtcp(GF_RTPChannel *ch, char *buffer, u32 buffer_size);\r
+\r
+/*decodes an RTP packet and gets the begining of the RTP payload*/\r
+GF_Err gf_rtp_decode_rtp(GF_RTPChannel *ch, char *pck, u32 pck_size, GF_RTPHeader *rtp_hdr, u32 *PayloadStart);\r
+\r
+/*decodes an RTCP packet and update timing info, send RR too*/\r
+GF_Err gf_rtp_decode_rtcp(GF_RTPChannel *ch, char *pck, u32 pck_size);\r
+\r
+/*computes and send Receiver report. If the channel is a TCP channel, you must specify\r
+the callback function. NOTE: many RTP implementation do NOT process RTCP info received on TCP...\r
+the lib will decide whether the report shall be sent or not, therefore you should call\r
+this function at regular times*/\r
+GF_Err gf_rtp_send_rtcp_report(GF_RTPChannel *ch, \r
+                                               GF_Err (*RTP_TCPCallback)(void *cbk, char *pck, u32 pck_size),\r
+                                               void *rtsp_cbk);\r
+\r
+/*send a BYE info (leaving the session)*/\r
+GF_Err gf_rtp_send_bye(GF_RTPChannel *ch,\r
+                                               GF_Err (*RTP_TCPCallback)(void *cbk, char *pck, u32 pck_size),\r
+                                               void *rtsp_cbk);\r
+\r
+\r
+/*send RTP packet*/\r
+GF_Err gf_rtp_send_packet(GF_RTPChannel *ch, GF_RTPHeader *rtp_hdr, char *extra_header, u32 extra_header_size, char *pck, u32 pck_size);\r
+\r
+enum\r
+{\r
+       GF_RTCP_INFO_NAME = 0,\r
+       GF_RTCP_INFO_EMAIL,\r
+       GF_RTCP_INFO_PHONE,\r
+       GF_RTCP_INFO_LOCATION,\r
+       GF_RTCP_INFO_TOOL,\r
+       GF_RTCP_INFO_NOTE,\r
+       GF_RTCP_INFO_PRIV\r
+};\r
+\r
+/*sets RTCP info sent in RTCP reports. info_string shall NOT exceed 255 chars*/\r
+GF_Err gf_rtp_set_info_rtcp(GF_RTPChannel *ch, u32 InfoCode, char *info_string);\r
+\r
+u32 gf_rtp_is_unicast(GF_RTPChannel *ch);\r
+u32 gf_rtp_is_interleaved(GF_RTPChannel *ch);\r
+u32 gf_rtp_get_clockrate(GF_RTPChannel *ch);\r
+u32 gf_rtp_is_active(GF_RTPChannel *ch);\r
+u8 gf_rtp_get_low_interleave_id(GF_RTPChannel *ch);\r
+u8 gf_rtp_get_hight_interleave_id(GF_RTPChannel *ch);\r
+GF_RTSPTransport *gf_rtp_get_transport(GF_RTPChannel *ch);\r
+u32 gf_rtp_get_local_ssrc(GF_RTPChannel *ch);\r
+\r
+Float gf_rtp_get_loss(GF_RTPChannel *ch);\r
+u32 gf_rtp_get_tcp_bytes_sent(GF_RTPChannel *ch);\r
+void gf_rtp_get_ports(GF_RTPChannel *ch, u16 *rtp_port, u16 *rtcp_port);\r
+\r
+\r
+\r
+\r
+       \r
+/****************************************************************************\r
+\r
+                                       SDP LIBRARY EXPORTS\r
+               \r
+                 Note: SDP is mainly a text protocol with \r
+       well defined containers. The following structures are used to write / read\r
+       SDP informations, and the library also provides consistency checking\r
+\r
+  When reading SDP, all text items/structures are allocated by the lib, and you\r
+  must call gf_sdp_info_reset(GF_SDPInfo *sdp) or gf_sdp_info_del(GF_SDPInfo *sdp) to release the memory\r
+\r
+  When writing the SDP from a GF_SDPInfo, the output buffer is allocated by the library, \r
+  and you must release it yourself\r
+\r
+  Some quick constructors are available for GF_SDPConnection and GF_SDPMedia in order to set up\r
+  some specific parameters to their default value\r
+\r
+  An extra function gf_sdp_info_check(GF_SDPInfo *sdp) is provided for compliency check \r
+  with RFC2327: all requested fields are checked as well as conflicting information forbidden\r
+  in RFC 2327\r
+****************************************************************************/\r
+\r
+/*\r
+       All attributes x-ZZZZ are considered as extensions attributes. If no "x-" is found \r
+       the attributes in the RTSP response is SKIPPED. The "x-" radical is removed in the structure\r
+       when parsing commands / responses\r
+*/\r
+typedef struct\r
+{\r
+       char *Name;\r
+       char *Value;\r
+} GF_X_Attribute;\r
+\r
+\r
+/*\r
+       Structure for bandwidth info\r
+*/\r
+typedef struct\r
+{\r
+       /*"CT", "AS" are defined. Private extensions must be "X-*" ( * "are recommended to be short")*/\r
+       char *name;\r
+       /*in kBitsPerSec*/\r
+       u32 value;\r
+} GF_SDPBandwidth;\r
+\r
+/*\r
+       Structure for Time info\r
+*/\r
+/*we do not support more than ... time offsets / zone adjustment\r
+if more are needed, RFC recommends to use several entries rather than a big*/\r
+#define GF_SDP_MAX_TIMEOFFSET  10\r
+\r
+typedef struct\r
+{\r
+       /*NPT time in sec*/\r
+       u32 StartTime;\r
+       /*if 0, session is unbound. NPT time in sec*/\r
+       u32 StopTime;\r
+       /*if 0 session is not repeated. Expressed in sec.\r
+       Session is signaled repeated every repeatInterval*/\r
+       u32 RepeatInterval;\r
+       /*active duration of the session in sec*/\r
+       u32 ActiveDuration;\r
+\r
+       /*time offsets to use with repeat. Specify a non-regular repeat time from the Start time*/\r
+       u32 OffsetFromStart[GF_SDP_MAX_TIMEOFFSET];\r
+       /*Number of offsets*/\r
+       u32 NbRepeatOffsets;\r
+\r
+       /*EX of repeat:\r
+       a session happens 3 times a week, on mon 1PM, thu 3PM and fri 10AM\r
+       1- StartTime should be NPT for the session on the very first monday, StopTime\r
+       the end of this session\r
+       2- the repeatInterval should be 1 week, ActiveDuration the length of the session\r
+       3- 3 offsets: 0 (for monday) (3*24+2)*3600 for thu and (4*24-3) for fri\r
+       */\r
+\r
+\r
+       /*timezone adjustments, to cope with #timezones, daylight saving countries and co ...\r
+       Ex: adjTime = [2882844526 2898848070] adjOffset=[-1h 0]\r
+       [0]: at 2882844526 the time base by which the session's repeat times are calculated \r
+       is shifted back by 1 hour\r
+       [1]: at time 2898848070 the session's original time base is restored\r
+       */\r
+\r
+       /*Adjustment time at which the corresponding time offset is to be applied to the \r
+       session time line (time used to compute the "repeat session"). \r
+       All Expressed in NPT*/\r
+       u32 AdjustmentTime[GF_SDP_MAX_TIMEOFFSET];\r
+       /* Offset with the session time line, ALWAYS ABSOLUTE OFFSET TO the specified StartTime*/\r
+       s32 AdjustmentOffset[GF_SDP_MAX_TIMEOFFSET];\r
+       /*Number of offsets.*/\r
+       u32 NbZoneOffsets;\r
+} GF_SDPTiming;\r
+\r
+\r
+typedef struct\r
+{\r
+       /*only "IN" currently defined*/\r
+       char *net_type;\r
+       /*"IP4","IP6"*/\r
+       char *add_type;\r
+       /*hex IPv6 address or doted IPv4 address*/\r
+       char *host;\r
+       /*TTL - MUST BE PRESENT if IP is multicast - -1 otherwise*/\r
+       s32 TTL;\r
+       /*multiple address counts - ONLY in media descriptions if needed. This\r
+       is used for content scaling, when # quality of the same media are multicasted on\r
+       # IP addresses*/\r
+       u32 add_count;\r
+} GF_SDPConnection;\r
+\r
+/*\r
+       FMTP: description of dynamic payload types. This is opaque at the SDP level.\r
+       Each attributes is assumed to be formatted as <param_name=param_val; ...>\r
+       If not the case the attribute will have an empty value string and only the\r
+       parameter name.\r
+*/\r
+typedef struct\r
+{\r
+       /*payload type of the format described*/\r
+       u32 PayloadType;\r
+       /*list of GF_X_Attribute elements. The Value field may be NULL*/\r
+       GF_List *Attributes;\r
+} GF_SDP_FMTP;\r
+\r
+typedef struct\r
+{\r
+       /*m=\r
+       0: application - 1:video - 2: audio - 3: text - 4:data - 5: control*/\r
+       u32 Type;\r
+       /*Port Number - For transports based on UDP, the value should be in the range 1024 \r
+       to 65535 inclusive. For RTP compliance it should be an even number*/\r
+       u32 PortNumber;\r
+       /*number of ports described. If >= 2, the next media(s) in the SDP will be configured\r
+       to use the next tuple (for RTP). If 0 or 1, ignored\r
+       Note: this is used for scalable media: PortNumber indicates the port of the base \r
+       media and NumPorts the ports||total number of the upper layers*/\r
+       u32 NumPorts;\r
+       /*currently ony "RTP/AVP" and "udp" defined*/\r
+       char *Profile;\r
+\r
+       /*list of GF_SDPConnection's. A media can have several connection in case of scalable content*/\r
+       GF_List *Connections;\r
+\r
+       /*RTPMaps contains a list SDPRTPMaps*/\r
+       GF_List *RTPMaps;\r
+\r
+       /*FMTP contains a list of FMTP structures*/\r
+       GF_List *FMTP;\r
+       \r
+       /*for RTP this is PayloadType, but can be opaque (string) depending on the app.\r
+       Formated as XX WW QQ FF\r
+       When reading the SDP, the payloads defined in RTPMap are removed from this list\r
+       When writing the SDP for RTP, you should only specify static payload types here,\r
+       as dynamic ones are stored in RTPMaps and automatically written*/\r
+       char *fmt_list;\r
+\r
+       /*all attributes not defined in RFC 2327 for the media*/\r
+       GF_List *Attributes;\r
+\r
+       /*Other SDP attributes for media desc*/\r
+\r
+       /*k=\r
+       method is 'clear' (key follows), 'base64' (key in base64), 'uri' (key is the URI) \r
+       or 'prompt' (key not included)*/\r
+       char *k_method, *k_key;\r
+\r
+       GF_List *Bandwidths;\r
+\r
+       /*0 if not present*/\r
+       u32 PacketTime;\r
+       /*0: none - 1: recv, 2: send, 3 both*/\r
+       u32 SendReceive;\r
+       char *orientation, *sdplang, *lang;\r
+       /*for video only, 0.0 if not present*/\r
+       Double FrameRate;\r
+       /*between 0 and 10, -1 if not present*/\r
+       s32 Quality;\r
+} GF_SDPMedia;\r
+\r
+typedef struct\r
+{\r
+       /*v=*/\r
+       u32 Version;\r
+       /*o=*/\r
+       char *o_username, *o_session_id, *o_version, *o_address;\r
+       /*"IN" for Net, "IP4" or "IP6" for address are currently valid*/\r
+       char *o_net_type, *o_add_type;\r
+\r
+       /*s=*/\r
+       char *s_session_name;\r
+       /*i=*/\r
+       char *i_description;\r
+       /*u=*/\r
+       char *u_uri;\r
+       /*e=*/\r
+       char *e_email;\r
+       /*p=*/\r
+       char *p_phone;\r
+       /*c= either 1 or 0 GF_SDPConnection */\r
+       GF_SDPConnection *c_connection; \r
+       /*b=*/\r
+       GF_List *b_bandwidth;\r
+       /*All time info (t, r, z)*/\r
+       GF_List *Timing;\r
+       /*k=\r
+       method is 'clear' (key follows), 'base64' (key in base64), 'uri' (key is the URI) \r
+       or 'prompt' (key not included)*/\r
+       char *k_method, *k_key;\r
+       /*all possible attributes (a=), session level*/\r
+       char *a_cat, *a_keywds, *a_tool;\r
+       /*0: none, 1: recv, 2: send, 3 both*/\r
+       u32 a_SendReceive;\r
+       /*should be `broadcast', `meeting', `moderated', `test' or `H332'*/\r
+       char *a_type;\r
+       char *a_charset;\r
+       char *a_sdplang, *a_lang;\r
+\r
+       /*all attributes not defined in RFC 2327 for the presentation*/\r
+       GF_List *Attributes;\r
+       \r
+       /*list of media in the SDP*/\r
+       GF_List *media_desc;\r
+} GF_SDPInfo;\r
+\r
+\r
+/*\r
+  Memory Consideration: the destructors free all non-NULL string. You should therefore \r
+  be carefull while (de-)assigning the strings. The function gf_sdp_info_parse() performs a complete \r
+  reset of the GF_SDPInfo\r
+*/\r
+/*constructor*/\r
+GF_SDPInfo *gf_sdp_info_new();\r
+/*destructor*/\r
+void gf_sdp_info_del(GF_SDPInfo *sdp);\r
+/*reset all structures (destroys substructure too)*/\r
+void gf_sdp_info_reset(GF_SDPInfo *sdp);\r
+/*Parses a memory SDP buffer*/\r
+GF_Err gf_sdp_info_parse(GF_SDPInfo *sdp, char *sdp_text, u32 text_size);\r
+/*check the consistency of the GF_SDPInfo*/\r
+GF_Err gf_sdp_info_check(GF_SDPInfo *sdp);\r
+/*write the SDP to a new buffer and returns it. Automatically checks the SDP before calling*/\r
+GF_Err gf_sdp_info_write(GF_SDPInfo *sdp, char **out_str_buf);\r
+\r
+\r
+/*\r
+       Const/dest for GF_SDPMedia\r
+*/\r
+GF_SDPMedia *gf_sdp_media_new();\r
+void gf_sdp_media_del(GF_SDPMedia *media);\r
+\r
+/*\r
+       Const/dest for GF_SDPConnection\r
+*/\r
+GF_SDPConnection *gf_sdp_conn_new();\r
+void gf_sdp_conn_del(GF_SDPConnection *conn);\r
+\r
+/*\r
+       Const/dest for SDP FMTP\r
+*/\r
+GF_SDP_FMTP *gf_sdp_fmtp_new();\r
+void gf_sdp_fmtp_del(GF_SDP_FMTP *fmtp);\r
+\r
+\r
+\r
+/*\r
+       RTP packetizer\r
+*/\r
+\r
+\r
+/*RTP<->SL mapping*/\r
+typedef struct \r
+{\r
+       /*1 - required options*/\r
+\r
+       /*mode, or "" if no mode ("generic" should be used instead)*/\r
+       char mode[30];\r
+       \r
+       /*config of the stream if carried in SDP*/\r
+       char *config;\r
+       u32 configSize;\r
+       /* Stream Type*/\r
+       u8 StreamType;\r
+       /* stream profile and level indication - for AVC/H264, 0xPPCCLL, with PP:profile, CC:compatibility, LL:level*/\r
+       u32 PL_ID;\r
+\r
+\r
+       /*2 - optional options*/\r
+       \r
+       /*size of AUs if constant*/\r
+       u32 ConstantSize;\r
+       /*duration of AUs if constant, in RTP timescale*/\r
+       u32 ConstantDuration;\r
+\r
+       /* Object Type Indication */\r
+       u8 ObjectTypeIndication;\r
+       /*audio max displacement when interleaving (eg, de-interleaving window buffer max length) in RTP timescale*/\r
+       u32 maxDisplacement;\r
+       /*de-interleaveBufferSize if not recomputable from maxDisplacement*/\r
+       u32 deinterleaveBufferSize;\r
+       \r
+       /*The number of bits on which the AU-size field is encoded in the AU-header*/\r
+       u32 SizeLength;\r
+       /*The number of bits on which the AU-Index is encoded in the first AU-header*/\r
+       u32 IndexLength;\r
+       /*The number of bits on which the AU-Index-delta field is encoded in any non-first AU-header*/\r
+       u32 IndexDeltaLength;\r
+\r
+       /*The number of bits on which the DTS-delta field is encoded in the AU-header*/\r
+       u32 DTSDeltaLength;\r
+       /*The number of bits on which the CTS-delta field is encoded in the AU-header*/\r
+       u32 CTSDeltaLength;\r
+       /*random access point flag present*/\r
+       Bool RandomAccessIndication;\r
+       \r
+       /*The number of bits on which the Stream-state field is encoded in the AU-header (systems only)*/\r
+       u32 StreamStateIndication;\r
+       /*The number of bits that is used to encode the auxiliary-data-size field \r
+       (no normative usage of this section)*/\r
+       u32 AuxiliaryDataSizeLength;\r
+\r
+       /*ISMACryp stuff*/\r
+       u8 IV_length, IV_delta_length;\r
+       u8 KI_length;\r
+\r
+       /*internal stuff*/\r
+       /*len of first AU header in an RTP payload*/\r
+       u32 auh_first_min_len;\r
+       u32 auh_min_len;\r
+} GP_RTPSLMap;\r
+       \r
+\r
+/*packetizer config flags - some flags are dynamically re-assigned when detecting multiSL / B-Frames / ...*/\r
+enum\r
+{\r
+       /*forces MPEG-4 generic transport if MPEG-4 systems mapping is available*/\r
+       GP_RTP_PCK_FORCE_MPEG4 =        (1),\r
+       /*Enables AUs concatenation in an RTP packet (if payload supports it) - this forces GP_RTP_PCK_SIGNAL_SIZE for MPEG-4*/\r
+       GP_RTP_PCK_USE_MULTI    =       (1<<1),\r
+       /*if set, audio interleaving is used if payload supports it (forces GP_RTP_PCK_USE_MULTI flag)\r
+               THIS IS CURRENTLY NOT IMPLEMENTED*/\r
+       GP_RTP_PCK_USE_INTERLEAVING =   (1<<2),\r
+       /*uses static RTP payloadID if any defined*/\r
+       GP_RTP_PCK_USE_STATIC_ID =      (1<<3),\r
+\r
+       /*MPEG-4 generic transport option*/\r
+       /*if flag set, RAP flag is signaled in RTP payload*/\r
+       GP_RTP_PCK_SIGNAL_RAP   =       (1<<4),\r
+       /*if flag set, AU indexes are signaled in RTP payload*/\r
+       GP_RTP_PCK_SIGNAL_AU_IDX        =       (1<<5),\r
+       /*if flag set, AU size is signaled in RTP payload*/\r
+       GP_RTP_PCK_SIGNAL_SIZE  =       (1<<6),\r
+       /*if flag set, CTS is signaled in RTP payload - DTS is automatically set if needed*/\r
+       GP_RTP_PCK_SIGNAL_TS    =       (1<<7),\r
+\r
+       /*setup payload for carouseling of systems streams*/\r
+       GP_RTP_PCK_AUTO_CAROUSEL = (1<<8),\r
+\r
+       /*use LATM payload for AAC-LC*/\r
+       GP_RTP_PCK_USE_LATM_AAC =       (1<<9),\r
+\r
+       /*ISMACryp options*/\r
+       /*signals that input data is selectively encrypted (eg not all input frames are encrypted) \r
+       - this is usually automatically set by hinter*/\r
+       GP_RTP_PCK_SELECTIVE_ENCRYPTION =       (1<<10),\r
+       /*signals that each sample will have its own key indicator - ignored in non-multi modes\r
+       if not set and key indicator changes, a new RTP packet will be forced*/\r
+       GP_RTP_PCK_KEY_IDX_PER_AU =     (1<<11),\r
+};\r
+\r
+\r
+\r
+/*\r
+               Generic packetization tools - used by track hinters and future live tools\r
+*/\r
+\r
+/*currently supported payload types*/\r
+enum \r
+{\r
+       /*not defined*/\r
+       GF_RTP_PAYT_UNKNOWN,\r
+       /*use generic MPEG-4 transport - RFC 3016 and RFC 3640*/\r
+       GF_RTP_PAYT_MPEG4,\r
+       /*use generic MPEG-1/2 video transport - RFC 2250*/\r
+       GF_RTP_PAYT_MPEG12_VIDEO,\r
+       /*use generic MPEG-1/2 audio transport - RFC 2250*/\r
+       GF_RTP_PAYT_MPEG12_AUDIO,\r
+       /*use H263 transport - RFC 2429*/\r
+       GF_RTP_PAYT_H263,\r
+       /*use AMR transport - RFC 3267*/\r
+       GF_RTP_PAYT_AMR,\r
+       /*use AMR-WB transport - RFC 3267*/\r
+       GF_RTP_PAYT_AMR_WB,\r
+       /*use QCELP transport - RFC 2658*/\r
+       GF_RTP_PAYT_QCELP,\r
+       /*use EVRC/SMV transport - RFC 3558*/\r
+       GF_RTP_PAYT_EVRC_SMV,\r
+       /*use 3GPP Text transport - no RFC yet, only draft*/\r
+       GF_RTP_PAYT_3GPP_TEXT,\r
+       /*use H264 transport - no RFC yet, only draft*/\r
+       GF_RTP_PAYT_H264_AVC,\r
+       /*use LATM for AAC-LC*/\r
+       GF_RTP_PAYT_LATM,\r
+       /*use 3GPP DIMS format*/\r
+       GF_RTP_PAYT_3GPP_DIMS,\r
+       /*use AC3 audio format*/\r
+       GF_RTP_PAYT_AC3,\r
+};\r
+\r
+\r
+\r
+/*\r
+       RTP packetizer\r
+*/\r
+\r
+\r
+\r
+/*\r
+               RTP -> SL packetization tool\r
+       You should ONLY modify the GF_SLHeader while packetizing, all the rest is private\r
+       to the tool.\r
+       Also note that AU start/end is automatically updated, therefore you should only\r
+       set CTS-DTS-OCR-sequenceNumber (which is automatically incremented when spliting a payload)\r
+       -padding-idle infos\r
+       SL flags are computed on the fly, but you may wish to modify them in case of \r
+       packet drop/... at the encoder side\r
+\r
+*/\r
+struct __tag_rtp_packetizer\r
+{\r
+       /*input packet sl header cfg. modify only if needed*/\r
+       GF_SLHeader sl_header;\r
+\r
+       /*\r
+       \r
+               PRIVATE _ DO NOT TOUCH\r
+       */\r
+       \r
+       /*RTP payload type (RFC type, NOT the RTP hdr payT)*/\r
+       u32 rtp_payt;\r
+       /*packetization flags*/\r
+       u32 flags;\r
+       /*Path MTU size without 12-bytes RTP header*/\r
+       u32 Path_MTU;\r
+       /*max packet duration in RTP TS*/\r
+       u32 max_ptime;\r
+\r
+       /*payload type of RTP packets - only one payload type can be used in GPAC*/\r
+       u8 PayloadType;\r
+\r
+       /*RTP header of current packet*/\r
+       GF_RTPHeader rtp_header;\r
+\r
+       /*RTP packet handling callbacks*/\r
+       void (*OnNewPacket)(void *cbk_obj, GF_RTPHeader *header);\r
+       void (*OnPacketDone)(void *cbk_obj, GF_RTPHeader *header);\r
+       void (*OnDataReference)(void *cbk_obj, u32 payload_size, u32 offset_from_orig);\r
+       void (*OnData)(void *cbk_obj, char *data, u32 data_size, Bool is_header);\r
+       void *cbk_obj;\r
+       \r
+               /*********************************\r
+                       MPEG-4 Generic hinting \r
+               *********************************/\r
+\r
+       /*SL to RTP map*/\r
+       GP_RTPSLMap slMap;\r
+       /*SL conf and state*/\r
+       GF_SLConfig sl_config;\r
+\r
+       /*set to 1 if firstSL in RTP packet*/\r
+       Bool first_sl_in_rtp;\r
+       Bool has_AU_header;\r
+       /*current info writers*/\r
+       GF_BitStream *pck_hdr, *payload;\r
+\r
+       /*AU SN of last au*/\r
+       u32 last_au_sn;\r
+\r
+       /*info for the current packet*/\r
+       u32 auh_size, bytesInPacket;\r
+\r
+               /*********************************\r
+                               ISMACryp info\r
+               *********************************/\r
+       Bool force_flush, is_encrypted;\r
+       u64 IV, first_AU_IV;\r
+       char *key_indicator;\r
+\r
+               /*********************************\r
+                               AVC-H264 info\r
+               *********************************/\r
+       /*AVC non-IDR flag: set if all NAL in current packet are non-IDR (disposable)*/\r
+       Bool avc_non_idr;\r
+\r
+               /*********************************\r
+                               AC3 info\r
+               *********************************/\r
+       /*ac3 ft flags*/\r
+       u8 ac3_ft;\r
+\r
+};\r
+\r
+/*generic rtp builder (packetizer)*/\r
+typedef struct __tag_rtp_packetizer GP_RTPPacketizer;\r
+\r
+/*creates a new builder\r
+       @hintType: hint media type, one of the above\r
+       @flags: hint flags (cf above)\r
+       @slc: user-given SL config to use. If none specified, default RFC config is used\r
+       @cbk_obj: callback object passed back in functions\r
+       @OnNewPacket: callback function starting new RTP packet\r
+               @header: rtp header for new packet - note that RTP header flags are not used until PacketDone is called\r
+       @OnPacketDone: callback function closing current RTP packet\r
+               @header: final rtp header for packet\r
+       @OnDataReference: optional, to call each time data from input buffer is added to current RTP packet. \r
+               If not set, data must be added through OnData\r
+               @payload_size: size of reference data\r
+               @offset_from_orig: start offset in input buffer\r
+       @OnData: to call each time data is added to current RTP packet (either extra data from payload or\r
+               data from input when not using referencing)\r
+               @is_head: signal the data added MUST be inserted at the begining of the payload. Otherwise data\r
+               is concatenated as received\r
+*/\r
+GP_RTPPacketizer *gf_rtp_builder_new(u32 hintType, \r
+                                               GF_SLConfig *slc, \r
+                                               u32 flags,\r
+                                               void *cbk_obj, \r
+                                               void (*OnNewPacket)(void *cbk, GF_RTPHeader *header),\r
+                                               void (*OnPacketDone)(void *cbk, GF_RTPHeader *header),\r
+                                               void (*OnDataReference)(void *cbk, u32 payload_size, u32 offset_from_orig),\r
+                                               void (*OnData)(void *cbk, char *data, u32 data_size, Bool is_head)\r
+                                       );\r
+\r
+/*destroy builder*/\r
+void gf_rtp_builder_del(GP_RTPPacketizer *builder);\r
+\r
+/*\r
+               init the builder\r
+       @MaxPayloadSize: maximum payload size of RTP packets (eg MTU minus IP/UDP/RTP headers)\r
+       @max_ptime: maximum packet duration IN RTP TIMESCALE\r
+       @StreamType: MPEG-4 system stream type - MUST always be provided for payloads format specifying \r
+               audio or video streams\r
+       @OTI : MPEG-4 system objectTypeIndication - may be 0 if stream is not mpeg4 systems\r
+\r
+                       *** all other params are for MultiSL draft ***\r
+       \r
+         @avgSize: average size of an AU. This is not always known (real-time encoding). \r
+In this case you should specify a rough compute indicating how many packets could be \r
+stored per RTP packet. for ex AAC stereo at 44100 k / 64kbps , one AU ~= 380 bytes\r
+so 3 AUs for 1500 MTU is ok - BE CAREFULL: MultiSL adds some SL info on top of the 12\r
+byte RTP header so you should specify a smaller size\r
+The packetizer will ALWAYS make sure there's no pb storing the packets so specifying \r
+more will result in a slight overhead in the SL mapping but the gain to singleSL \r
+will still be worth it.\r
+       -Nota: at init, the packetizer can decide to switch to SingleSL if the average size \r
+specified is too close to the PathMTU\r
+\r
+       @maxSize: max size of an AU. If unknown (real-time) set to 0\r
+       @avgTS: average CTS progression (1000/FPS for video)\r
+       @maxDTS: maximum DTS offset in case of bidirectional coding. \r
+       @IV_length: size (in bytes) of IV when ISMACrypted\r
+       @KI_length: size (in bytes) of key indicator when ISMACrypted\r
+       @pref_mode: MPEG-4 generic only, specifies the payload mode - can be NULL (mode generic)\r
+*/\r
+\r
+void gf_rtp_builder_init(GP_RTPPacketizer *builder, u8 PayloadType, u32 MaxPayloadSize, u32 max_ptime,\r
+                                          u32 StreamType, u32 OTI, u32 PL_ID,\r
+                                          u32 avgSize, u32 maxSize, \r
+                                          u32 avgTS, u32 maxDTS,\r
+                                          u32 IV_length, u32 KI_length,\r
+                                          char *pref_mode);\r
+\r
+/*set frame crypto info*/\r
+void gp_rtp_builder_set_cryp_info(GP_RTPPacketizer *builder, u64 IV, char *key_indicator, Bool is_encrypted);\r
+/*packetize input buffer\r
+@data, @data_size: input buffer\r
+@IsAUEnd: set to one if this buffer is the last of the AU\r
+@FullAUSize: complete access unit size if known, 0 otherwise\r
+@duration: sample duration in rtp timescale (only needed for 3GPP text streams)\r
+@descIndex: sample description index (only needed for 3GPP text streams)\r
+*/\r
+GF_Err gf_rtp_builder_process(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize, u32 duration, u8 descIndex);\r
+\r
+/*format the "fmtp: " attribute for the MPEG-4 generic packetizer. sdpline shall be at least 2000 char*/\r
+GF_Err gf_rtp_builder_format_sdp(GP_RTPPacketizer *builder, char *payload_name, char *sdpLine, char *dsi, u32 dsi_size);\r
+/*formats SDP payload name and media name - both MUST be at least 20 bytes*/\r
+Bool gf_rtp_builder_get_payload_name(GP_RTPPacketizer *builder, char *szPayloadName, char *szMediaName);\r
+\r
+\r
+\r
+\r
+\r
+/*rtp payload flags*/\r
+enum\r
+{\r
+       /*AU end was detected (eg next packet is AU start)*/\r
+       GF_RTP_NEW_AU = (1),\r
+       /*AMR config*/\r
+       GF_RTP_AMR_ALIGN = (1<<1),\r
+       /*for RFC3016, signals bitstream inspection for RAP discovery*/\r
+       GF_RTP_M4V_CHECK_RAP = (1<<2),\r
+       /*flag set when unreliable usage of the M bit is detected*/\r
+       GF_RTP_UNRELIABLE_M = (1<<3),\r
+\r
+       /*AWFULL hack at rtp level to cope with ffmpeg h264 crashes when jumping in stream without IDR*/\r
+       GF_RTP_AVC_WAIT_RAP = (1<<4),\r
+       /*ISMACryp stuff*/\r
+       GF_RTP_HAS_ISMACRYP = (1<<5),\r
+       GF_RTP_ISMA_SEL_ENC = (1<<6),\r
+       GF_RTP_ISMA_HAS_KEY_IDX = (1<<7)\r
+};\r
+\r
+/*\r
+               SL -> RTP packetization tool\r
+\r
+*/\r
+struct __tag_rtp_depacketizer\r
+{\r
+       /*depacketize routine*/\r
+       void (*depacketize)(struct __tag_rtp_depacketizer *rtp, GF_RTPHeader *hdr, char *payload, u32 size);\r
+\r
+       /*output packet sl header cfg*/\r
+       GF_SLHeader sl_hdr;\r
+\r
+       /*RTP payload type (RFC type, NOT the RTP hdr payT)*/\r
+       u32 payt;\r
+       /*depacketization flags*/\r
+       u32 flags;\r
+\r
+       /*callback routine*/\r
+       void (*on_sl_packet)(void *udta, char *payload, u32 size, GF_SLHeader *hdr, GF_Err e);\r
+       void *udta;\r
+\r
+       /*SL <-> RTP map*/\r
+       GP_RTPSLMap sl_map;\r
+       u32 clock_rate;\r
+\r
+       /*inter-packet reconstruction bitstream (for 3GP text and H264)*/\r
+       GF_BitStream *inter_bs;\r
+\r
+       /*H264/AVC config*/\r
+       u32 h264_pck_mode;\r
+       \r
+       /*3GP text reassembler state*/\r
+       u8 nb_txt_frag, cur_txt_frag, sidx, txt_len, nb_mod_frag;\r
+\r
+       /*ISMACryp*/\r
+       u32 isma_scheme;\r
+       char *key;\r
+};\r
+\r
+/*generic rtp builder (packetizer)*/\r
+typedef struct __tag_rtp_depacketizer GF_RTPDepacketizer;\r
+\r
+GF_RTPDepacketizer *gf_rtp_depacketizer_new(GF_SDPMedia *media, void (*sl_packet_cbk)(void *udta, char *payload, u32 size, GF_SLHeader *hdr, GF_Err e), void *udta);\r
+void gf_rtp_depacketizer_del(GF_RTPDepacketizer *rtp);\r
+void gf_rtp_depacketizer_reset(GF_RTPDepacketizer *rtp, Bool full_reset);\r
+void gf_rtp_depacketizer_process(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char *payload, u32 size);\r
+\r
+void gf_rtp_depacketizer_get_slconfig(GF_RTPDepacketizer *rtp, GF_SLConfig *sl);\r
+\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif         /*_GF_IETF_H_*/\r
+\r