OSDN Git Service

stop using trunk directory in rectool
[rec10/rec10-git.git] / tstools / DtsEdit / src / gpac / ietf.h
1 /*\r
2  *                      GPAC - Multimedia Framework C SDK\r
3  *\r
4  *                      Copyright (c) Jean Le Feuvre 2000-2005\r
5  *                                      All rights reserved\r
6  *\r
7  *  This file is part of GPAC / IETF RTP/RTSP/SDP sub-project\r
8  *\r
9  *  GPAC is free software; you can redistribute it and/or modify\r
10  *  it under the terms of the GNU Lesser General Public License as published by\r
11  *  the Free Software Foundation; either version 2, or (at your option)\r
12  *  any later version.\r
13  *   \r
14  *  GPAC is distributed in the hope that it will be useful,\r
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
17  *  GNU Lesser General Public License for more details.\r
18  *   \r
19  *  You should have received a copy of the GNU Lesser General Public\r
20  *  License along with this library; see the file COPYING.  If not, write to\r
21  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
22  *\r
23  */\r
24 \r
25 \r
26 #ifndef _GF_IETF_H_\r
27 #define _GF_IETF_H_\r
28 \r
29 \r
30 #ifdef __cplusplus\r
31 extern "C" {\r
32 #endif\r
33 \r
34 #include <gpac/list.h>\r
35 #include <gpac/bitstream.h>\r
36 #include <gpac/sync_layer.h>\r
37 #include <gpac/network.h>\r
38 \r
39 \r
40 /****************************************************************************\r
41 \r
42                                 RTSP VERSION 1.0 LIBRARY EXPORTS\r
43 \r
44 ****************************************************************************/\r
45 \r
46 #define GF_RTSP_VERSION         "RTSP/1.0"\r
47 \r
48 \r
49 /*\r
50  *              RTSP NOTIF CODES\r
51  */\r
52 enum\r
53 {\r
54         NC_RTSP_Continue                =               100,\r
55         NC_RTSP_OK                              =               200,\r
56         NC_RTSP_Created                 =               201,\r
57         NC_RTSP_Low_on_Storage_Space    =       250,\r
58 \r
59         NC_RTSP_Multiple_Choice =       300,\r
60         NC_RTSP_Moved_Permanently       =       301,\r
61         NC_RTSP_Moved_Temporarily       =       302,\r
62         NC_RTSP_See_Other       =       303,\r
63         NC_RTSP_Use_Proxy       =       305,\r
64 \r
65         NC_RTSP_Bad_Request     =       400,\r
66         NC_RTSP_Unauthorized    =       401,\r
67         NC_RTSP_Payment_Required        =       402,\r
68         NC_RTSP_Forbidden       =       403,\r
69         NC_RTSP_Not_Found       =       404,\r
70         NC_RTSP_Method_Not_Allowed      =       405,\r
71         NC_RTSP_Not_Acceptable  =       406,\r
72         NC_RTSP_Proxy_Authentication_Required   =       407,\r
73         NC_RTSP_Request_Timeout =       408,\r
74         NC_RTSP_Gone    =       410,\r
75         NC_RTSP_Length_Required =       411,\r
76         NC_RTSP_Precondition_Failed     =       412,\r
77         NC_RTSP_Request_Entity_Too_Large        =       413,\r
78         NC_RTSP_Request_URI_Too_Long    =       414,\r
79         NC_RTSP_Unsupported_Media_Type  =       415,\r
80 \r
81         NC_RTSP_Invalid_parameter       =       451,\r
82         NC_RTSP_Illegal_Conference_Identifier   =       452,\r
83         NC_RTSP_Not_Enough_Bandwidth    =       453,\r
84         NC_RTSP_Session_Not_Found       =       454,\r
85         NC_RTSP_Method_Not_Valid_In_This_State  =       455,\r
86         NC_RTSP_Header_Field_Not_Valid  =       456,\r
87         NC_RTSP_Invalid_Range   =       457,\r
88         NC_RTSP_Parameter_Is_ReadOnly   =       458,\r
89         NC_RTSP_Aggregate_Operation_Not_Allowed =       459,\r
90         NC_RTSP_Only_Aggregate_Operation_Allowed        =       460,\r
91         NC_RTSP_Unsupported_Transport   =       461,\r
92         NC_RTSP_Destination_Unreachable =       462,\r
93         \r
94         NC_RTSP_Internal_Server_Error   =       500,\r
95         NC_RTSP_Not_Implemented =       501,\r
96         NC_RTSP_Bad_Gateway     =       502,\r
97         NC_RTSP_Service_Unavailable     =       503,\r
98         NC_RTSP_Gateway_Timeout =       504,\r
99         NC_RTSP_RTSP_Version_Not_Supported      =       505,\r
100 \r
101         NC_RTSP_Option_not_support      =       551,\r
102 };\r
103 \r
104 const char *gf_rtsp_nc_to_string(u32 ErrCode);\r
105 \r
106 /*\r
107                 Common structures between commands and responses\r
108 */\r
109 \r
110 /*\r
111         RTSP Range information - RTSP Session level only (though this is almost the same\r
112         format as an SDP range, this is not used in the SDP lib as "a=range" is not part of SDP\r
113         but part of RTSP\r
114 */\r
115 typedef struct {\r
116         /* start and end range. If end is -1, the range is open (from start to unknown) */\r
117         Double start, end;\r
118         /* use SMPTE range (Start and End specify the number of frames) (currently not supported) */\r
119         u32 UseSMPTE;\r
120         /* framerate for SMPTE range */\r
121         Double FPS;\r
122 } GF_RTSPRange;\r
123 \r
124 /*\r
125 parses a Range line and returns range header structure. can be used for RTSP extension of SDP\r
126 NB: Only support for npt for now\r
127 */\r
128 GF_RTSPRange *gf_rtsp_range_parse(char *range_buf);\r
129 \r
130 GF_RTSPRange *gf_rtsp_range_new();\r
131 void gf_rtsp_range_del(GF_RTSPRange *range);\r
132 \r
133 /*\r
134                         Transport structure \r
135                 contains all network info for RTSP sessions (ports, uni/multi-cast, ...)\r
136 */\r
137 \r
138 /*\r
139         Transport Profiles as defined in RFC 2326\r
140 */\r
141 #define GF_RTSP_PROFILE_RTP_AVP                 "RTP/AVP"\r
142 #define GF_RTSP_PROFILE_RTP_AVP_TCP             "RTP/AVP/TCP"\r
143 #define GF_RTSP_PROFILE_UDP                             "udp"\r
144 \r
145 \r
146 typedef struct\r
147 {\r
148         /* set to 1 if unicast */\r
149         Bool IsUnicast;\r
150         /* for multicast */\r
151         char *destination;\r
152         /* for redirections internal to servers */\r
153         char *source;\r
154         /*IsRecord is usually 0 (PLAY) . If set, Append specify that the stream should\r
155         be concatenated to existing resources */\r
156         Bool IsRecord, Append;\r
157         /* in case transport is on TCP/RTSP, If only 1 ID is specified, it is stored in rtpID (this\r
158         is not RTP interleaving) */\r
159         Bool IsInterleaved, rtpID, rtcpID;\r
160         /* Multicast specific */\r
161         u32 MulticastLayers;\r
162         u8 TTL;\r
163         /*RTP specific*/\r
164 \r
165         /*port for multicast*/\r
166         /*server port in unicast - RTP implies low is even , and last is low+1*/\r
167         u16 port_first, port_last;\r
168         /*client port in unicast - RTP implies low is even , and last is low+1*/\r
169         u16 client_port_first, client_port_last;\r
170         u32 SSRC;\r
171 \r
172         /*Transport protocol. In this version we only support RTP/AVP, the following flag tells \r
173         us if this is RTP/AVP/TCP or RTP/AVP (default)*/\r
174         char *Profile;\r
175 } GF_RTSPTransport;\r
176 \r
177 \r
178 GF_RTSPTransport *gf_rtsp_transport_clone(GF_RTSPTransport *original);\r
179 void gf_rtsp_transport_del(GF_RTSPTransport *transp);\r
180 \r
181 \r
182 /*\r
183                                 RTSP Command\r
184                 the RTSP Response is sent by a client / received by a server\r
185         text Allocation is done by the lib when parsing a command, and\r
186         is automatically freed when calling reset / delete. Therefore you must\r
187         set/allocate the fields yourself when writing a command (client)\r
188 \r
189 */\r
190 \r
191 /*ALL RTSP METHODS - all other methods will be ignored*/\r
192 #define GF_RTSP_DESCRIBE                "DESCRIBE"\r
193 #define GF_RTSP_SETUP                   "SETUP"\r
194 #define GF_RTSP_PLAY                    "PLAY"\r
195 #define GF_RTSP_PAUSE                   "PAUSE"\r
196 #define GF_RTSP_RECORD                  "RECORD"\r
197 #define GF_RTSP_TEARDOWN                "TEARDOWN"\r
198 #define GF_RTSP_GET_PARAMETER   "GET_PARAMETER"\r
199 #define GF_RTSP_SET_PARAMETER   "SET_PARAMETER"\r
200 #define GF_RTSP_OPTIONS         "OPTIONS"\r
201 #define GF_RTSP_ANNOUNCE                "ANNOUNCE"\r
202 #define GF_RTSP_REDIRECTE               "REDIRECT"\r
203 \r
204 \r
205 typedef struct\r
206 {\r
207         char *Accept;\r
208         char *Accept_Encoding;\r
209         char *Accept_Language;\r
210         char *Authorization;\r
211         u32 Bandwidth;\r
212         u32 Blocksize;\r
213         char *Cache_Control;\r
214         char *Conference;\r
215         char *Connection;\r
216         u32 Content_Length;\r
217         u32 CSeq;\r
218         char *From;\r
219         char *Proxy_Authorization;\r
220         char *Proxy_Require;\r
221         GF_RTSPRange *Range;\r
222         char *Referer;\r
223         Double Scale;\r
224         char *Session;\r
225         Double Speed;\r
226         /*nota : RTSP allows several configurations for a single channel (multicast and \r
227         unicast , ...). Usually only 1*/\r
228         GF_List *Transports;\r
229         char *User_Agent;\r
230 \r
231         /*type of the command, one of the described above*/\r
232         char *method;\r
233         \r
234         /*Header extensions*/\r
235         GF_List *Xtensions;\r
236 \r
237         /*body of the command, size is Content-Length (auto computed when sent). It is not \r
238         terminated by a NULL char*/\r
239         char *body;\r
240 \r
241         /*\r
242                         Specify ControlString if your request targets\r
243                 a specific media stream in the service. If null, the service name only will be used\r
244                 for control (for ex, both A and V streams in a single file)\r
245                 If the request is GF_RTSP_OPTIONS, you must provide a control string containing the options \r
246                 you want to query\r
247         */\r
248         char *ControlString;\r
249 \r
250         /*user data: this is never touched by the lib, its intend is to help stacking\r
251         RTSP commands in your app*/\r
252         void *user_data;\r
253 \r
254 \r
255         /*\r
256                 Server side Extensions\r
257         */\r
258 \r
259         /*full URL of the command. Not used at client side, as the URL is ALWAYS relative\r
260         to the server / service of the RTSP session \r
261         On the server side however redirections are up to the server, so we cannot decide for it        */\r
262         char *service_name;\r
263         /*RTSP status code of the command as parsed. One of the above RTSP StatusCode*/\r
264         u32 StatusCode;\r
265 } GF_RTSPCommand;\r
266 \r
267 \r
268 GF_RTSPCommand *gf_rtsp_command_new();\r
269 void gf_rtsp_command_del(GF_RTSPCommand *com);\r
270 void gf_rtsp_command_reset(GF_RTSPCommand *com);\r
271 \r
272 \r
273 \r
274 /*\r
275                                 RTSP Response\r
276                 the RTSP Response is received by a client / sent by a server\r
277         text Allocation is done by the lib when parsing a response, and\r
278         is automatically freed when calling reset / delete. Therefore you must\r
279         allocate the fields yourself when writing a response (server)\r
280 \r
281 */\r
282 \r
283 /*\r
284         RTP-Info for RTP channels. There may be several RTP-Infos in one response\r
285         based on the server implementation (DSS/QTSS begaves this way)\r
286 */\r
287 typedef struct\r
288 {\r
289         /*control string of the channel*/\r
290         char *url;\r
291         /*seq num for asociated rtp_time*/\r
292         u32 seq;\r
293         /*rtp TimeStamp corresponding to the Range start specified in the PLAY request*/\r
294         u32 rtp_time;\r
295         /*ssrc of sender if known, 0 otherwise*/\r
296         u32 ssrc;\r
297 } GF_RTPInfo;\r
298 \r
299 \r
300 \r
301 /*\r
302         RTSP Response\r
303 */\r
304 typedef struct\r
305 {\r
306         /* response code*/\r
307         u32 ResponseCode;\r
308         /* comment from the server */\r
309         char *ResponseInfo;\r
310         \r
311         /*      Header Fields   */\r
312         char *Accept;\r
313         char *Accept_Encoding;\r
314         char *Accept_Language;\r
315         char *Allow;\r
316         char *Authorization;\r
317         u32 Bandwidth;\r
318         u32 Blocksize;\r
319         char *Cache_Control;\r
320         char *Conference;\r
321         char *Connection;\r
322         char *Content_Base;\r
323         char *Content_Encoding;\r
324         char *Content_Language;\r
325         u32 Content_Length;\r
326         char *Content_Location;\r
327         char *Content_Type;\r
328         u32 CSeq;\r
329         char *Date;\r
330         char *Expires;\r
331         char *From;\r
332         char *Host;\r
333         char *If_Match;\r
334         char *If_Modified_Since;\r
335         char *Last_Modified;\r
336         char *Location;\r
337         char *Proxy_Authenticate;\r
338         char *Proxy_Require;\r
339         char *Public;\r
340         GF_RTSPRange *Range;\r
341         char *Referer;\r
342         char *Require;\r
343         char *Retry_After;\r
344         GF_List *RTP_Infos;\r
345         Double Scale;\r
346         char *Server;\r
347         char *Session;\r
348         u32 SessionTimeOut;\r
349         Double Speed;\r
350         char *Timestamp;\r
351         /*nota : RTSP allows several configurations for a single channel (multicast and \r
352         unicast , ...). Usually only 1*/\r
353         GF_List *Transports;\r
354         char *Unsupported;\r
355         char *User_Agent;\r
356         char *Vary;\r
357         char *Via;\r
358         char *WWW_Authenticate;\r
359 \r
360         /*Header extensions*/\r
361         GF_List *Xtensions;\r
362 \r
363         /*body of the response, size is Content-Length (auto computed when sent). It is not \r
364         terminated by a NULL char when response is parsed but must be null-terminated when \r
365         response is being sent*/\r
366         char *body;\r
367 } GF_RTSPResponse;\r
368 \r
369 \r
370 GF_RTSPResponse *gf_rtsp_response_new();\r
371 void gf_rtsp_response_del(GF_RTSPResponse *rsp);\r
372 void gf_rtsp_response_reset(GF_RTSPResponse *rsp);\r
373 \r
374 \r
375 \r
376 typedef struct _tag_rtsp_session GF_RTSPSession;\r
377 \r
378 GF_RTSPSession *gf_rtsp_session_new(char *sURL, u16 DefaultPort);\r
379 void gf_rtsp_session_del(GF_RTSPSession *sess);\r
380 \r
381 GF_Err gf_rtsp_set_buffer_size(GF_RTSPSession *sess, u32 BufferSize);\r
382 \r
383 /*force the IP address the client is using*/\r
384 void gf_rtsp_set_mobile_ip(GF_RTSPSession *sess, char *MobileIP);\r
385 \r
386 \r
387 /*Reset state machine, invalidate SessionID\r
388 NOTE: RFC2326 requires that the session is reseted when all RTP streams\r
389 are closed. As this lib doesn't maintain the number of valid streams\r
390 you MUST call reset when all your streams are shutdown (either requested through\r
391 TEARDOWN or signaled through RTCP BYE packets for RTP, or any other signaling means\r
392 for other protocols)\r
393 reset connection will destroy the socket - this is isefull in case of timeouts, because\r
394 some servers do not restart with the right CSeq...*/\r
395 void gf_rtsp_session_reset(GF_RTSPSession *sess, Bool ResetConnection);\r
396 \r
397 u32 gf_rtsp_is_my_session(GF_RTSPSession *sess, char *url);\r
398 const char *gf_rtsp_get_last_session_id(GF_RTSPSession *sess);\r
399 char *gf_rtsp_get_server_name(GF_RTSPSession *sess);\r
400 char *gf_rtsp_get_service_name(GF_RTSPSession *sess);\r
401 u16 gf_rtsp_get_session_port(GF_RTSPSession *sess);\r
402 \r
403 /*Fetch an RTSP response from the server the GF_RTSPResponse will be reseted before fetch*/\r
404 GF_Err gf_rtsp_get_response(GF_RTSPSession *sess, GF_RTSPResponse *rsp);\r
405 \r
406 \r
407 /*RTSP State Machine. The only non blocking mode is GF_RTSP_STATE_WAIT_FOR_CONTROL*/\r
408 enum\r
409 {\r
410         /*Initialized (connection might be off, but all structures are in place)\r
411         This is the default state between # requests (aka, DESCRIBE and SETUP\r
412         or SETUP and PLAY ...)*/\r
413         GF_RTSP_STATE_INIT      =       0,\r
414         /*Waiting*/\r
415         GF_RTSP_STATE_WAITING,\r
416         /*PLAY, PAUSE, RECORD. Aggregation is allowed for the same type, you can send several command\r
417         in a row. However the session will return GF_SERVICE_ERROR if you do not have \r
418         a valid SessionID in the command\r
419         You cannot issue a SETUP / DESCRIBE while in this state*/\r
420         GF_RTSP_STATE_WAIT_FOR_CONTROL,\r
421 \r
422         /*FATAL ERROR: session is invalidated by server. Call reset and restart from SETUP if needed*/\r
423         GF_RTSP_STATE_INVALIDATED\r
424 };\r
425 \r
426 u32 gf_rtsp_get_session_state(GF_RTSPSession *sess);\r
427 /*aggregate command state-machine: the PLAY/PAUSE can be aggregated \r
428 (sent before the reply is received). This function gets the last command sent*/\r
429 char *gf_rtsp_get_last_request(GF_RTSPSession *sess);\r
430 /*foce a reset in case of pbs*/\r
431 void gf_rtsp_reset_aggregation(GF_RTSPSession *sess);\r
432 \r
433 /*\r
434         Send an RTSP request to the server.\r
435 */\r
436 GF_Err gf_rtsp_send_command(GF_RTSPSession *sess, GF_RTSPCommand *com);\r
437 \r
438 \r
439 GF_Err gf_rtsp_set_interleave_callback(GF_RTSPSession *sess,\r
440                                                 GF_Err (*SignalData)(GF_RTSPSession *sess, void *cbk_ptr, char *buffer, u32 bufferSize, Bool IsRTCP)\r
441                                 );\r
442 \r
443 \r
444 GF_Err gf_rtsp_session_read(GF_RTSPSession *sess);\r
445 \r
446 GF_Err gf_rtsp_register_interleave(GF_RTSPSession *sess, void *the_ch, u8 LowInterID, u8 HighInterID);\r
447 u32 gf_rtsp_unregister_interleave(GF_RTSPSession *sess, u8 LowInterID);\r
448 \r
449 \r
450 \r
451 /*\r
452                         Server side session constructor\r
453         create a new RTSP session from an existing socket in listen state. If no pending connection\r
454         is detected, return NULL\r
455 */\r
456 GF_RTSPSession *gf_rtsp_session_new_server(GF_Socket *rtsp_listener);\r
457 \r
458 /*fetch an RTSP request. The GF_RTSPCommand will be reseted before fetch*/\r
459 GF_Err gf_rtsp_get_command(GF_RTSPSession *sess, GF_RTSPCommand *com);\r
460 \r
461 /*unpack the URL, check the service name / server. Typically used when a client sends a \r
462  DESCRIBE || SETUP url RTSP/1.0. Server / service name check must be performed by your app as redirection\r
463 or services available are unknown here.*/\r
464 GF_Err gf_rtsp_load_service_name(GF_RTSPSession *sess, char *URL);\r
465 \r
466 /*geenrates a session ID fpor the given session*/\r
467 char *gf_rtsp_generate_session_id(GF_RTSPSession *sess);\r
468 \r
469 /*send the RTSP response*/\r
470 GF_Err gf_rtsp_send_response(GF_RTSPSession *sess, GF_RTSPResponse *rsp);\r
471 \r
472 /*gets the IP address of the local host running the session\r
473 buffer shall be GF_MAX_IP_NAME_LEN long*/\r
474 GF_Err gf_rtsp_get_session_ip(GF_RTSPSession *sess, char *buffer);\r
475 \r
476 /*returns the next available ID for interleaving. It is recommended that you use 2 \r
477 consecutive IDs for RTP/RTCP interleaving*/\r
478 u8 gf_rtsp_get_next_interleave_id(GF_RTSPSession *sess);\r
479 \r
480 /*gets the IP address of the connected peer - buffer shall be GF_MAX_IP_NAME_LEN long*/\r
481 GF_Err gf_rtsp_get_remote_address(GF_RTSPSession *sess, char *buffer);\r
482 \r
483 \r
484 /*\r
485                 RTP LIB EXPORTS\r
486 */\r
487 \r
488 \r
489 typedef struct tagRTP_HEADER {\r
490         /*version, must be 2*/\r
491         u8 Version;\r
492         /*padding bits in the payload*/\r
493         u8 Padding;\r
494         /*header extension is defined*/\r
495         u8 Extension;\r
496         /*number of CSRC (<=15)*/\r
497         u8 CSRCCount;\r
498         /*Marker Bit*/\r
499         u8 Marker;\r
500         /*payload type on 7 bits*/\r
501         u8 PayloadType;\r
502         /*packet seq number*/\r
503         u16 SequenceNumber;\r
504         /*packet time stamp*/\r
505         u32 TimeStamp;\r
506         /*sync source identifier*/\r
507         u32 SSRC;\r
508         /*in our basic client, CSRC should always be NULL*/\r
509         u32 CSRC[16];\r
510 } GF_RTPHeader;\r
511 \r
512 \r
513 \r
514 \r
515 /*\r
516         structure containing the rtpmap information\r
517 */\r
518 typedef struct\r
519 {\r
520         /*dynamic payload type of this map*/\r
521         u32 PayloadType;\r
522         /*registered payload name of this map*/\r
523         char *payload_name;\r
524         /*RTP clock rate (TS resolution) of this map*/\r
525         u32 ClockRate;\r
526         /*optional parameters for audio, specifying number of channels. Unused for other media types.*/\r
527         u32 AudioChannels;\r
528 } GF_RTPMap;\r
529 \r
530 \r
531 \r
532 typedef struct __tag_rtp_channel GF_RTPChannel;\r
533 \r
534 GF_RTPChannel *gf_rtp_new();\r
535 void gf_rtp_del(GF_RTPChannel *ch);\r
536 \r
537 /*you configure a server channel through the transport structure, with the same info as a \r
538 client channel, the client_port_* info designing the REMOTE client and port_* designing\r
539 your server channel*/\r
540 GF_Err gf_rtp_setup_transport(GF_RTPChannel *ch, GF_RTSPTransport *trans_info, char *remote_address);\r
541 \r
542 /*auto-setup of rtp/rtcp transport ports - only effective in unicast, non interleaved cases. \r
543 for multicast port setup MUST be done through the above gf_rtp_setup_transport function\r
544 this will take care of port reuse*/\r
545 GF_Err gf_rtp_set_ports(GF_RTPChannel *ch, u16 first_port);\r
546 \r
547 /*init of payload information. only ONE payload per sync source is supported in this\r
548 version of the library (a sender cannot switch payload types on a single media)*/\r
549 GF_Err gf_rtp_setup_payload(GF_RTPChannel *ch, GF_RTPMap *map);\r
550 \r
551 /*enables sending of NAT keep-alive packets for NAT traversal\r
552         @nat_timeout: specifies the inactivity period in ms after which NAT keepalive packets are sent. \r
553         If 0, disables NAT keep-alive packets \r
554 */\r
555 void gf_rtp_enable_nat_keepalive(GF_RTPChannel *ch, u32 nat_timeout);\r
556 \r
557 \r
558 /*initialize the RTP channel.\r
559 \r
560 UDPBufferSize: UDP stack buffer size if configurable by OS/ISP - ignored otherwise\r
561 NOTE: on WinCE devices, this is not configurable on an app bases but for the whole OS\r
562 you must update the device registry with:\r
563         [HKEY_LOCAL_MACHINE\Comm\Afd]\r
564         DgramBuffer=dword:N\r
565 \r
566         where N is the number of UDP datagrams a socket should be able to buffer. For multimedia\r
567 app you should set N as large as possible. The device MUST be reseted for the param to take effect\r
568 \r
569 ReorederingSize: max number of packets to queue for reordering. 0 means no reordering\r
570 MaxReorderDelay: max time to wait in ms before releasing first packet in reoderer when only one packet is present.\r
571 If 0 and reordering size is specified, defaults to 200 ms (usually enough).\r
572 IsSource: if true, the channel is a sender (media data, sender report, Receiver report processing)\r
573 if source, you must specify the Path MTU size. The RTP lib won't send any packet bigger than this size\r
574 your application shall perform payload size splitting if needed\r
575 local_interface_ip: local interface address to use for multicast. If NULL, default address is used\r
576 */\r
577 GF_Err gf_rtp_initialize(GF_RTPChannel *ch, u32 UDPBufferSize, Bool IsSource, u32 PathMTU, u32 ReorederingSize, u32 MaxReorderDelay, char *local_interface_ip);\r
578 \r
579 /*init the RTP info after a PLAY or PAUSE, rtp_time is the rtp TimeStamp of the RTP packet\r
580 with seq_num sequence number. This info is needed to compute the CurrentTime of the RTP channel \r
581 ssrc may not be known if sender hasn't indicated it (use 0 then)*/\r
582 GF_Err gf_rtp_set_info_rtp(GF_RTPChannel *ch, u32 seq_num, u32 rtp_time, u32 ssrc);\r
583 \r
584 /*retrieve current RTP time in sec. If rtp_time was unknown (not on demand media) the time is absolute.\r
585 Otherwise this is the time in ms elapsed since the last PLAY range start value\r
586 Not supported yet if played without RTSP (aka RTCP time not supported)*/\r
587 Double gf_rtp_get_current_time(GF_RTPChannel *ch);\r
588 \r
589 \r
590 void gf_rtp_reset_buffers(GF_RTPChannel *ch);\r
591 \r
592 /*read any data on UDP only (not valid for TCP). Performs re-ordering if configured for it\r
593 returns amount of data read (raw UDP packet size)*/\r
594 u32 gf_rtp_read_rtp(GF_RTPChannel *ch, char *buffer, u32 buffer_size);\r
595 u32 gf_rtp_read_rtcp(GF_RTPChannel *ch, char *buffer, u32 buffer_size);\r
596 \r
597 /*decodes an RTP packet and gets the begining of the RTP payload*/\r
598 GF_Err gf_rtp_decode_rtp(GF_RTPChannel *ch, char *pck, u32 pck_size, GF_RTPHeader *rtp_hdr, u32 *PayloadStart);\r
599 \r
600 /*decodes an RTCP packet and update timing info, send RR too*/\r
601 GF_Err gf_rtp_decode_rtcp(GF_RTPChannel *ch, char *pck, u32 pck_size);\r
602 \r
603 /*computes and send Receiver report. If the channel is a TCP channel, you must specify\r
604 the callback function. NOTE: many RTP implementation do NOT process RTCP info received on TCP...\r
605 the lib will decide whether the report shall be sent or not, therefore you should call\r
606 this function at regular times*/\r
607 GF_Err gf_rtp_send_rtcp_report(GF_RTPChannel *ch, \r
608                                                 GF_Err (*RTP_TCPCallback)(void *cbk, char *pck, u32 pck_size),\r
609                                                 void *rtsp_cbk);\r
610 \r
611 /*send a BYE info (leaving the session)*/\r
612 GF_Err gf_rtp_send_bye(GF_RTPChannel *ch,\r
613                                                 GF_Err (*RTP_TCPCallback)(void *cbk, char *pck, u32 pck_size),\r
614                                                 void *rtsp_cbk);\r
615 \r
616 \r
617 /*send RTP packet*/\r
618 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
619 \r
620 enum\r
621 {\r
622         GF_RTCP_INFO_NAME = 0,\r
623         GF_RTCP_INFO_EMAIL,\r
624         GF_RTCP_INFO_PHONE,\r
625         GF_RTCP_INFO_LOCATION,\r
626         GF_RTCP_INFO_TOOL,\r
627         GF_RTCP_INFO_NOTE,\r
628         GF_RTCP_INFO_PRIV\r
629 };\r
630 \r
631 /*sets RTCP info sent in RTCP reports. info_string shall NOT exceed 255 chars*/\r
632 GF_Err gf_rtp_set_info_rtcp(GF_RTPChannel *ch, u32 InfoCode, char *info_string);\r
633 \r
634 u32 gf_rtp_is_unicast(GF_RTPChannel *ch);\r
635 u32 gf_rtp_is_interleaved(GF_RTPChannel *ch);\r
636 u32 gf_rtp_get_clockrate(GF_RTPChannel *ch);\r
637 u32 gf_rtp_is_active(GF_RTPChannel *ch);\r
638 u8 gf_rtp_get_low_interleave_id(GF_RTPChannel *ch);\r
639 u8 gf_rtp_get_hight_interleave_id(GF_RTPChannel *ch);\r
640 GF_RTSPTransport *gf_rtp_get_transport(GF_RTPChannel *ch);\r
641 u32 gf_rtp_get_local_ssrc(GF_RTPChannel *ch);\r
642 \r
643 Float gf_rtp_get_loss(GF_RTPChannel *ch);\r
644 u32 gf_rtp_get_tcp_bytes_sent(GF_RTPChannel *ch);\r
645 void gf_rtp_get_ports(GF_RTPChannel *ch, u16 *rtp_port, u16 *rtcp_port);\r
646 \r
647 \r
648 \r
649 \r
650         \r
651 /****************************************************************************\r
652 \r
653                                         SDP LIBRARY EXPORTS\r
654                 \r
655                   Note: SDP is mainly a text protocol with \r
656         well defined containers. The following structures are used to write / read\r
657         SDP informations, and the library also provides consistency checking\r
658 \r
659   When reading SDP, all text items/structures are allocated by the lib, and you\r
660   must call gf_sdp_info_reset(GF_SDPInfo *sdp) or gf_sdp_info_del(GF_SDPInfo *sdp) to release the memory\r
661 \r
662   When writing the SDP from a GF_SDPInfo, the output buffer is allocated by the library, \r
663   and you must release it yourself\r
664 \r
665   Some quick constructors are available for GF_SDPConnection and GF_SDPMedia in order to set up\r
666   some specific parameters to their default value\r
667 \r
668   An extra function gf_sdp_info_check(GF_SDPInfo *sdp) is provided for compliency check \r
669   with RFC2327: all requested fields are checked as well as conflicting information forbidden\r
670   in RFC 2327\r
671 ****************************************************************************/\r
672 \r
673 /*\r
674         All attributes x-ZZZZ are considered as extensions attributes. If no "x-" is found \r
675         the attributes in the RTSP response is SKIPPED. The "x-" radical is removed in the structure\r
676         when parsing commands / responses\r
677 */\r
678 typedef struct\r
679 {\r
680         char *Name;\r
681         char *Value;\r
682 } GF_X_Attribute;\r
683 \r
684 \r
685 /*\r
686         Structure for bandwidth info\r
687 */\r
688 typedef struct\r
689 {\r
690         /*"CT", "AS" are defined. Private extensions must be "X-*" ( * "are recommended to be short")*/\r
691         char *name;\r
692         /*in kBitsPerSec*/\r
693         u32 value;\r
694 } GF_SDPBandwidth;\r
695 \r
696 /*\r
697         Structure for Time info\r
698 */\r
699 /*we do not support more than ... time offsets / zone adjustment\r
700 if more are needed, RFC recommends to use several entries rather than a big*/\r
701 #define GF_SDP_MAX_TIMEOFFSET   10\r
702 \r
703 typedef struct\r
704 {\r
705         /*NPT time in sec*/\r
706         u32 StartTime;\r
707         /*if 0, session is unbound. NPT time in sec*/\r
708         u32 StopTime;\r
709         /*if 0 session is not repeated. Expressed in sec.\r
710         Session is signaled repeated every repeatInterval*/\r
711         u32 RepeatInterval;\r
712         /*active duration of the session in sec*/\r
713         u32 ActiveDuration;\r
714 \r
715         /*time offsets to use with repeat. Specify a non-regular repeat time from the Start time*/\r
716         u32 OffsetFromStart[GF_SDP_MAX_TIMEOFFSET];\r
717         /*Number of offsets*/\r
718         u32 NbRepeatOffsets;\r
719 \r
720         /*EX of repeat:\r
721         a session happens 3 times a week, on mon 1PM, thu 3PM and fri 10AM\r
722         1- StartTime should be NPT for the session on the very first monday, StopTime\r
723         the end of this session\r
724         2- the repeatInterval should be 1 week, ActiveDuration the length of the session\r
725         3- 3 offsets: 0 (for monday) (3*24+2)*3600 for thu and (4*24-3) for fri\r
726         */\r
727 \r
728 \r
729         /*timezone adjustments, to cope with #timezones, daylight saving countries and co ...\r
730         Ex: adjTime = [2882844526 2898848070] adjOffset=[-1h 0]\r
731         [0]: at 2882844526 the time base by which the session's repeat times are calculated \r
732         is shifted back by 1 hour\r
733         [1]: at time 2898848070 the session's original time base is restored\r
734         */\r
735 \r
736         /*Adjustment time at which the corresponding time offset is to be applied to the \r
737         session time line (time used to compute the "repeat session"). \r
738         All Expressed in NPT*/\r
739         u32 AdjustmentTime[GF_SDP_MAX_TIMEOFFSET];\r
740         /* Offset with the session time line, ALWAYS ABSOLUTE OFFSET TO the specified StartTime*/\r
741         s32 AdjustmentOffset[GF_SDP_MAX_TIMEOFFSET];\r
742         /*Number of offsets.*/\r
743         u32 NbZoneOffsets;\r
744 } GF_SDPTiming;\r
745 \r
746 \r
747 typedef struct\r
748 {\r
749         /*only "IN" currently defined*/\r
750         char *net_type;\r
751         /*"IP4","IP6"*/\r
752         char *add_type;\r
753         /*hex IPv6 address or doted IPv4 address*/\r
754         char *host;\r
755         /*TTL - MUST BE PRESENT if IP is multicast - -1 otherwise*/\r
756         s32 TTL;\r
757         /*multiple address counts - ONLY in media descriptions if needed. This\r
758         is used for content scaling, when # quality of the same media are multicasted on\r
759         # IP addresses*/\r
760         u32 add_count;\r
761 } GF_SDPConnection;\r
762 \r
763 /*\r
764         FMTP: description of dynamic payload types. This is opaque at the SDP level.\r
765         Each attributes is assumed to be formatted as <param_name=param_val; ...>\r
766         If not the case the attribute will have an empty value string and only the\r
767         parameter name.\r
768 */\r
769 typedef struct\r
770 {\r
771         /*payload type of the format described*/\r
772         u32 PayloadType;\r
773         /*list of GF_X_Attribute elements. The Value field may be NULL*/\r
774         GF_List *Attributes;\r
775 } GF_SDP_FMTP;\r
776 \r
777 typedef struct\r
778 {\r
779         /*m=\r
780         0: application - 1:video - 2: audio - 3: text - 4:data - 5: control*/\r
781         u32 Type;\r
782         /*Port Number - For transports based on UDP, the value should be in the range 1024 \r
783         to 65535 inclusive. For RTP compliance it should be an even number*/\r
784         u32 PortNumber;\r
785         /*number of ports described. If >= 2, the next media(s) in the SDP will be configured\r
786         to use the next tuple (for RTP). If 0 or 1, ignored\r
787         Note: this is used for scalable media: PortNumber indicates the port of the base \r
788         media and NumPorts the ports||total number of the upper layers*/\r
789         u32 NumPorts;\r
790         /*currently ony "RTP/AVP" and "udp" defined*/\r
791         char *Profile;\r
792 \r
793         /*list of GF_SDPConnection's. A media can have several connection in case of scalable content*/\r
794         GF_List *Connections;\r
795 \r
796         /*RTPMaps contains a list SDPRTPMaps*/\r
797         GF_List *RTPMaps;\r
798 \r
799         /*FMTP contains a list of FMTP structures*/\r
800         GF_List *FMTP;\r
801         \r
802         /*for RTP this is PayloadType, but can be opaque (string) depending on the app.\r
803         Formated as XX WW QQ FF\r
804         When reading the SDP, the payloads defined in RTPMap are removed from this list\r
805         When writing the SDP for RTP, you should only specify static payload types here,\r
806         as dynamic ones are stored in RTPMaps and automatically written*/\r
807         char *fmt_list;\r
808 \r
809         /*all attributes not defined in RFC 2327 for the media*/\r
810         GF_List *Attributes;\r
811 \r
812         /*Other SDP attributes for media desc*/\r
813 \r
814         /*k=\r
815         method is 'clear' (key follows), 'base64' (key in base64), 'uri' (key is the URI) \r
816         or 'prompt' (key not included)*/\r
817         char *k_method, *k_key;\r
818 \r
819         GF_List *Bandwidths;\r
820 \r
821         /*0 if not present*/\r
822         u32 PacketTime;\r
823         /*0: none - 1: recv, 2: send, 3 both*/\r
824         u32 SendReceive;\r
825         char *orientation, *sdplang, *lang;\r
826         /*for video only, 0.0 if not present*/\r
827         Double FrameRate;\r
828         /*between 0 and 10, -1 if not present*/\r
829         s32 Quality;\r
830 } GF_SDPMedia;\r
831 \r
832 typedef struct\r
833 {\r
834         /*v=*/\r
835         u32 Version;\r
836         /*o=*/\r
837         char *o_username, *o_session_id, *o_version, *o_address;\r
838         /*"IN" for Net, "IP4" or "IP6" for address are currently valid*/\r
839         char *o_net_type, *o_add_type;\r
840 \r
841         /*s=*/\r
842         char *s_session_name;\r
843         /*i=*/\r
844         char *i_description;\r
845         /*u=*/\r
846         char *u_uri;\r
847         /*e=*/\r
848         char *e_email;\r
849         /*p=*/\r
850         char *p_phone;\r
851         /*c= either 1 or 0 GF_SDPConnection */\r
852         GF_SDPConnection *c_connection; \r
853         /*b=*/\r
854         GF_List *b_bandwidth;\r
855         /*All time info (t, r, z)*/\r
856         GF_List *Timing;\r
857         /*k=\r
858         method is 'clear' (key follows), 'base64' (key in base64), 'uri' (key is the URI) \r
859         or 'prompt' (key not included)*/\r
860         char *k_method, *k_key;\r
861         /*all possible attributes (a=), session level*/\r
862         char *a_cat, *a_keywds, *a_tool;\r
863         /*0: none, 1: recv, 2: send, 3 both*/\r
864         u32 a_SendReceive;\r
865         /*should be `broadcast', `meeting', `moderated', `test' or `H332'*/\r
866         char *a_type;\r
867         char *a_charset;\r
868         char *a_sdplang, *a_lang;\r
869 \r
870         /*all attributes not defined in RFC 2327 for the presentation*/\r
871         GF_List *Attributes;\r
872         \r
873         /*list of media in the SDP*/\r
874         GF_List *media_desc;\r
875 } GF_SDPInfo;\r
876 \r
877 \r
878 /*\r
879   Memory Consideration: the destructors free all non-NULL string. You should therefore \r
880   be carefull while (de-)assigning the strings. The function gf_sdp_info_parse() performs a complete \r
881   reset of the GF_SDPInfo\r
882 */\r
883 /*constructor*/\r
884 GF_SDPInfo *gf_sdp_info_new();\r
885 /*destructor*/\r
886 void gf_sdp_info_del(GF_SDPInfo *sdp);\r
887 /*reset all structures (destroys substructure too)*/\r
888 void gf_sdp_info_reset(GF_SDPInfo *sdp);\r
889 /*Parses a memory SDP buffer*/\r
890 GF_Err gf_sdp_info_parse(GF_SDPInfo *sdp, char *sdp_text, u32 text_size);\r
891 /*check the consistency of the GF_SDPInfo*/\r
892 GF_Err gf_sdp_info_check(GF_SDPInfo *sdp);\r
893 /*write the SDP to a new buffer and returns it. Automatically checks the SDP before calling*/\r
894 GF_Err gf_sdp_info_write(GF_SDPInfo *sdp, char **out_str_buf);\r
895 \r
896 \r
897 /*\r
898         Const/dest for GF_SDPMedia\r
899 */\r
900 GF_SDPMedia *gf_sdp_media_new();\r
901 void gf_sdp_media_del(GF_SDPMedia *media);\r
902 \r
903 /*\r
904         Const/dest for GF_SDPConnection\r
905 */\r
906 GF_SDPConnection *gf_sdp_conn_new();\r
907 void gf_sdp_conn_del(GF_SDPConnection *conn);\r
908 \r
909 /*\r
910         Const/dest for SDP FMTP\r
911 */\r
912 GF_SDP_FMTP *gf_sdp_fmtp_new();\r
913 void gf_sdp_fmtp_del(GF_SDP_FMTP *fmtp);\r
914 \r
915 \r
916 \r
917 /*\r
918         RTP packetizer\r
919 */\r
920 \r
921 \r
922 /*RTP<->SL mapping*/\r
923 typedef struct \r
924 {\r
925         /*1 - required options*/\r
926 \r
927         /*mode, or "" if no mode ("generic" should be used instead)*/\r
928         char mode[30];\r
929         \r
930         /*config of the stream if carried in SDP*/\r
931         char *config;\r
932         u32 configSize;\r
933         /* Stream Type*/\r
934         u8 StreamType;\r
935         /* stream profile and level indication - for AVC/H264, 0xPPCCLL, with PP:profile, CC:compatibility, LL:level*/\r
936         u32 PL_ID;\r
937 \r
938 \r
939         /*2 - optional options*/\r
940         \r
941         /*size of AUs if constant*/\r
942         u32 ConstantSize;\r
943         /*duration of AUs if constant, in RTP timescale*/\r
944         u32 ConstantDuration;\r
945 \r
946         /* Object Type Indication */\r
947         u8 ObjectTypeIndication;\r
948         /*audio max displacement when interleaving (eg, de-interleaving window buffer max length) in RTP timescale*/\r
949         u32 maxDisplacement;\r
950         /*de-interleaveBufferSize if not recomputable from maxDisplacement*/\r
951         u32 deinterleaveBufferSize;\r
952         \r
953         /*The number of bits on which the AU-size field is encoded in the AU-header*/\r
954         u32 SizeLength;\r
955         /*The number of bits on which the AU-Index is encoded in the first AU-header*/\r
956         u32 IndexLength;\r
957         /*The number of bits on which the AU-Index-delta field is encoded in any non-first AU-header*/\r
958         u32 IndexDeltaLength;\r
959 \r
960         /*The number of bits on which the DTS-delta field is encoded in the AU-header*/\r
961         u32 DTSDeltaLength;\r
962         /*The number of bits on which the CTS-delta field is encoded in the AU-header*/\r
963         u32 CTSDeltaLength;\r
964         /*random access point flag present*/\r
965         Bool RandomAccessIndication;\r
966         \r
967         /*The number of bits on which the Stream-state field is encoded in the AU-header (systems only)*/\r
968         u32 StreamStateIndication;\r
969         /*The number of bits that is used to encode the auxiliary-data-size field \r
970         (no normative usage of this section)*/\r
971         u32 AuxiliaryDataSizeLength;\r
972 \r
973         /*ISMACryp stuff*/\r
974         u8 IV_length, IV_delta_length;\r
975         u8 KI_length;\r
976 \r
977         /*internal stuff*/\r
978         /*len of first AU header in an RTP payload*/\r
979         u32 auh_first_min_len;\r
980         u32 auh_min_len;\r
981 } GP_RTPSLMap;\r
982         \r
983 \r
984 /*packetizer config flags - some flags are dynamically re-assigned when detecting multiSL / B-Frames / ...*/\r
985 enum\r
986 {\r
987         /*forces MPEG-4 generic transport if MPEG-4 systems mapping is available*/\r
988         GP_RTP_PCK_FORCE_MPEG4 =        (1),\r
989         /*Enables AUs concatenation in an RTP packet (if payload supports it) - this forces GP_RTP_PCK_SIGNAL_SIZE for MPEG-4*/\r
990         GP_RTP_PCK_USE_MULTI    =       (1<<1),\r
991         /*if set, audio interleaving is used if payload supports it (forces GP_RTP_PCK_USE_MULTI flag)\r
992                 THIS IS CURRENTLY NOT IMPLEMENTED*/\r
993         GP_RTP_PCK_USE_INTERLEAVING =   (1<<2),\r
994         /*uses static RTP payloadID if any defined*/\r
995         GP_RTP_PCK_USE_STATIC_ID =      (1<<3),\r
996 \r
997         /*MPEG-4 generic transport option*/\r
998         /*if flag set, RAP flag is signaled in RTP payload*/\r
999         GP_RTP_PCK_SIGNAL_RAP   =       (1<<4),\r
1000         /*if flag set, AU indexes are signaled in RTP payload*/\r
1001         GP_RTP_PCK_SIGNAL_AU_IDX        =       (1<<5),\r
1002         /*if flag set, AU size is signaled in RTP payload*/\r
1003         GP_RTP_PCK_SIGNAL_SIZE  =       (1<<6),\r
1004         /*if flag set, CTS is signaled in RTP payload - DTS is automatically set if needed*/\r
1005         GP_RTP_PCK_SIGNAL_TS    =       (1<<7),\r
1006 \r
1007         /*setup payload for carouseling of systems streams*/\r
1008         GP_RTP_PCK_AUTO_CAROUSEL = (1<<8),\r
1009 \r
1010         /*use LATM payload for AAC-LC*/\r
1011         GP_RTP_PCK_USE_LATM_AAC =       (1<<9),\r
1012 \r
1013         /*ISMACryp options*/\r
1014         /*signals that input data is selectively encrypted (eg not all input frames are encrypted) \r
1015         - this is usually automatically set by hinter*/\r
1016         GP_RTP_PCK_SELECTIVE_ENCRYPTION =       (1<<10),\r
1017         /*signals that each sample will have its own key indicator - ignored in non-multi modes\r
1018         if not set and key indicator changes, a new RTP packet will be forced*/\r
1019         GP_RTP_PCK_KEY_IDX_PER_AU =     (1<<11),\r
1020 };\r
1021 \r
1022 \r
1023 \r
1024 /*\r
1025                 Generic packetization tools - used by track hinters and future live tools\r
1026 */\r
1027 \r
1028 /*currently supported payload types*/\r
1029 enum \r
1030 {\r
1031         /*not defined*/\r
1032         GF_RTP_PAYT_UNKNOWN,\r
1033         /*use generic MPEG-4 transport - RFC 3016 and RFC 3640*/\r
1034         GF_RTP_PAYT_MPEG4,\r
1035         /*use generic MPEG-1/2 video transport - RFC 2250*/\r
1036         GF_RTP_PAYT_MPEG12_VIDEO,\r
1037         /*use generic MPEG-1/2 audio transport - RFC 2250*/\r
1038         GF_RTP_PAYT_MPEG12_AUDIO,\r
1039         /*use H263 transport - RFC 2429*/\r
1040         GF_RTP_PAYT_H263,\r
1041         /*use AMR transport - RFC 3267*/\r
1042         GF_RTP_PAYT_AMR,\r
1043         /*use AMR-WB transport - RFC 3267*/\r
1044         GF_RTP_PAYT_AMR_WB,\r
1045         /*use QCELP transport - RFC 2658*/\r
1046         GF_RTP_PAYT_QCELP,\r
1047         /*use EVRC/SMV transport - RFC 3558*/\r
1048         GF_RTP_PAYT_EVRC_SMV,\r
1049         /*use 3GPP Text transport - no RFC yet, only draft*/\r
1050         GF_RTP_PAYT_3GPP_TEXT,\r
1051         /*use H264 transport - no RFC yet, only draft*/\r
1052         GF_RTP_PAYT_H264_AVC,\r
1053         /*use LATM for AAC-LC*/\r
1054         GF_RTP_PAYT_LATM,\r
1055         /*use 3GPP DIMS format*/\r
1056         GF_RTP_PAYT_3GPP_DIMS,\r
1057         /*use AC3 audio format*/\r
1058         GF_RTP_PAYT_AC3,\r
1059 };\r
1060 \r
1061 \r
1062 \r
1063 /*\r
1064         RTP packetizer\r
1065 */\r
1066 \r
1067 \r
1068 \r
1069 /*\r
1070                 RTP -> SL packetization tool\r
1071         You should ONLY modify the GF_SLHeader while packetizing, all the rest is private\r
1072         to the tool.\r
1073         Also note that AU start/end is automatically updated, therefore you should only\r
1074         set CTS-DTS-OCR-sequenceNumber (which is automatically incremented when spliting a payload)\r
1075         -padding-idle infos\r
1076         SL flags are computed on the fly, but you may wish to modify them in case of \r
1077         packet drop/... at the encoder side\r
1078 \r
1079 */\r
1080 struct __tag_rtp_packetizer\r
1081 {\r
1082         /*input packet sl header cfg. modify only if needed*/\r
1083         GF_SLHeader sl_header;\r
1084 \r
1085         /*\r
1086         \r
1087                 PRIVATE _ DO NOT TOUCH\r
1088         */\r
1089         \r
1090         /*RTP payload type (RFC type, NOT the RTP hdr payT)*/\r
1091         u32 rtp_payt;\r
1092         /*packetization flags*/\r
1093         u32 flags;\r
1094         /*Path MTU size without 12-bytes RTP header*/\r
1095         u32 Path_MTU;\r
1096         /*max packet duration in RTP TS*/\r
1097         u32 max_ptime;\r
1098 \r
1099         /*payload type of RTP packets - only one payload type can be used in GPAC*/\r
1100         u8 PayloadType;\r
1101 \r
1102         /*RTP header of current packet*/\r
1103         GF_RTPHeader rtp_header;\r
1104 \r
1105         /*RTP packet handling callbacks*/\r
1106         void (*OnNewPacket)(void *cbk_obj, GF_RTPHeader *header);\r
1107         void (*OnPacketDone)(void *cbk_obj, GF_RTPHeader *header);\r
1108         void (*OnDataReference)(void *cbk_obj, u32 payload_size, u32 offset_from_orig);\r
1109         void (*OnData)(void *cbk_obj, char *data, u32 data_size, Bool is_header);\r
1110         void *cbk_obj;\r
1111         \r
1112                 /*********************************\r
1113                         MPEG-4 Generic hinting \r
1114                 *********************************/\r
1115 \r
1116         /*SL to RTP map*/\r
1117         GP_RTPSLMap slMap;\r
1118         /*SL conf and state*/\r
1119         GF_SLConfig sl_config;\r
1120 \r
1121         /*set to 1 if firstSL in RTP packet*/\r
1122         Bool first_sl_in_rtp;\r
1123         Bool has_AU_header;\r
1124         /*current info writers*/\r
1125         GF_BitStream *pck_hdr, *payload;\r
1126 \r
1127         /*AU SN of last au*/\r
1128         u32 last_au_sn;\r
1129 \r
1130         /*info for the current packet*/\r
1131         u32 auh_size, bytesInPacket;\r
1132 \r
1133                 /*********************************\r
1134                                 ISMACryp info\r
1135                 *********************************/\r
1136         Bool force_flush, is_encrypted;\r
1137         u64 IV, first_AU_IV;\r
1138         char *key_indicator;\r
1139 \r
1140                 /*********************************\r
1141                                 AVC-H264 info\r
1142                 *********************************/\r
1143         /*AVC non-IDR flag: set if all NAL in current packet are non-IDR (disposable)*/\r
1144         Bool avc_non_idr;\r
1145 \r
1146                 /*********************************\r
1147                                 AC3 info\r
1148                 *********************************/\r
1149         /*ac3 ft flags*/\r
1150         u8 ac3_ft;\r
1151 \r
1152 };\r
1153 \r
1154 /*generic rtp builder (packetizer)*/\r
1155 typedef struct __tag_rtp_packetizer GP_RTPPacketizer;\r
1156 \r
1157 /*creates a new builder\r
1158         @hintType: hint media type, one of the above\r
1159         @flags: hint flags (cf above)\r
1160         @slc: user-given SL config to use. If none specified, default RFC config is used\r
1161         @cbk_obj: callback object passed back in functions\r
1162         @OnNewPacket: callback function starting new RTP packet\r
1163                 @header: rtp header for new packet - note that RTP header flags are not used until PacketDone is called\r
1164         @OnPacketDone: callback function closing current RTP packet\r
1165                 @header: final rtp header for packet\r
1166         @OnDataReference: optional, to call each time data from input buffer is added to current RTP packet. \r
1167                 If not set, data must be added through OnData\r
1168                 @payload_size: size of reference data\r
1169                 @offset_from_orig: start offset in input buffer\r
1170         @OnData: to call each time data is added to current RTP packet (either extra data from payload or\r
1171                 data from input when not using referencing)\r
1172                 @is_head: signal the data added MUST be inserted at the begining of the payload. Otherwise data\r
1173                 is concatenated as received\r
1174 */\r
1175 GP_RTPPacketizer *gf_rtp_builder_new(u32 hintType, \r
1176                                                 GF_SLConfig *slc, \r
1177                                                 u32 flags,\r
1178                                                 void *cbk_obj, \r
1179                                                 void (*OnNewPacket)(void *cbk, GF_RTPHeader *header),\r
1180                                                 void (*OnPacketDone)(void *cbk, GF_RTPHeader *header),\r
1181                                                 void (*OnDataReference)(void *cbk, u32 payload_size, u32 offset_from_orig),\r
1182                                                 void (*OnData)(void *cbk, char *data, u32 data_size, Bool is_head)\r
1183                                         );\r
1184 \r
1185 /*destroy builder*/\r
1186 void gf_rtp_builder_del(GP_RTPPacketizer *builder);\r
1187 \r
1188 /*\r
1189                 init the builder\r
1190         @MaxPayloadSize: maximum payload size of RTP packets (eg MTU minus IP/UDP/RTP headers)\r
1191         @max_ptime: maximum packet duration IN RTP TIMESCALE\r
1192         @StreamType: MPEG-4 system stream type - MUST always be provided for payloads format specifying \r
1193                 audio or video streams\r
1194         @OTI : MPEG-4 system objectTypeIndication - may be 0 if stream is not mpeg4 systems\r
1195 \r
1196                         *** all other params are for MultiSL draft ***\r
1197         \r
1198           @avgSize: average size of an AU. This is not always known (real-time encoding). \r
1199 In this case you should specify a rough compute indicating how many packets could be \r
1200 stored per RTP packet. for ex AAC stereo at 44100 k / 64kbps , one AU ~= 380 bytes\r
1201 so 3 AUs for 1500 MTU is ok - BE CAREFULL: MultiSL adds some SL info on top of the 12\r
1202 byte RTP header so you should specify a smaller size\r
1203 The packetizer will ALWAYS make sure there's no pb storing the packets so specifying \r
1204 more will result in a slight overhead in the SL mapping but the gain to singleSL \r
1205 will still be worth it.\r
1206         -Nota: at init, the packetizer can decide to switch to SingleSL if the average size \r
1207 specified is too close to the PathMTU\r
1208 \r
1209         @maxSize: max size of an AU. If unknown (real-time) set to 0\r
1210         @avgTS: average CTS progression (1000/FPS for video)\r
1211         @maxDTS: maximum DTS offset in case of bidirectional coding. \r
1212         @IV_length: size (in bytes) of IV when ISMACrypted\r
1213         @KI_length: size (in bytes) of key indicator when ISMACrypted\r
1214         @pref_mode: MPEG-4 generic only, specifies the payload mode - can be NULL (mode generic)\r
1215 */\r
1216 \r
1217 void gf_rtp_builder_init(GP_RTPPacketizer *builder, u8 PayloadType, u32 MaxPayloadSize, u32 max_ptime,\r
1218                                            u32 StreamType, u32 OTI, u32 PL_ID,\r
1219                                            u32 avgSize, u32 maxSize, \r
1220                                            u32 avgTS, u32 maxDTS,\r
1221                                            u32 IV_length, u32 KI_length,\r
1222                                            char *pref_mode);\r
1223 \r
1224 /*set frame crypto info*/\r
1225 void gp_rtp_builder_set_cryp_info(GP_RTPPacketizer *builder, u64 IV, char *key_indicator, Bool is_encrypted);\r
1226 /*packetize input buffer\r
1227 @data, @data_size: input buffer\r
1228 @IsAUEnd: set to one if this buffer is the last of the AU\r
1229 @FullAUSize: complete access unit size if known, 0 otherwise\r
1230 @duration: sample duration in rtp timescale (only needed for 3GPP text streams)\r
1231 @descIndex: sample description index (only needed for 3GPP text streams)\r
1232 */\r
1233 GF_Err gf_rtp_builder_process(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize, u32 duration, u8 descIndex);\r
1234 \r
1235 /*format the "fmtp: " attribute for the MPEG-4 generic packetizer. sdpline shall be at least 2000 char*/\r
1236 GF_Err gf_rtp_builder_format_sdp(GP_RTPPacketizer *builder, char *payload_name, char *sdpLine, char *dsi, u32 dsi_size);\r
1237 /*formats SDP payload name and media name - both MUST be at least 20 bytes*/\r
1238 Bool gf_rtp_builder_get_payload_name(GP_RTPPacketizer *builder, char *szPayloadName, char *szMediaName);\r
1239 \r
1240 \r
1241 \r
1242 \r
1243 \r
1244 /*rtp payload flags*/\r
1245 enum\r
1246 {\r
1247         /*AU end was detected (eg next packet is AU start)*/\r
1248         GF_RTP_NEW_AU = (1),\r
1249         /*AMR config*/\r
1250         GF_RTP_AMR_ALIGN = (1<<1),\r
1251         /*for RFC3016, signals bitstream inspection for RAP discovery*/\r
1252         GF_RTP_M4V_CHECK_RAP = (1<<2),\r
1253         /*flag set when unreliable usage of the M bit is detected*/\r
1254         GF_RTP_UNRELIABLE_M = (1<<3),\r
1255 \r
1256         /*AWFULL hack at rtp level to cope with ffmpeg h264 crashes when jumping in stream without IDR*/\r
1257         GF_RTP_AVC_WAIT_RAP = (1<<4),\r
1258         /*ISMACryp stuff*/\r
1259         GF_RTP_HAS_ISMACRYP = (1<<5),\r
1260         GF_RTP_ISMA_SEL_ENC = (1<<6),\r
1261         GF_RTP_ISMA_HAS_KEY_IDX = (1<<7)\r
1262 };\r
1263 \r
1264 /*\r
1265                 SL -> RTP packetization tool\r
1266 \r
1267 */\r
1268 struct __tag_rtp_depacketizer\r
1269 {\r
1270         /*depacketize routine*/\r
1271         void (*depacketize)(struct __tag_rtp_depacketizer *rtp, GF_RTPHeader *hdr, char *payload, u32 size);\r
1272 \r
1273         /*output packet sl header cfg*/\r
1274         GF_SLHeader sl_hdr;\r
1275 \r
1276         /*RTP payload type (RFC type, NOT the RTP hdr payT)*/\r
1277         u32 payt;\r
1278         /*depacketization flags*/\r
1279         u32 flags;\r
1280 \r
1281         /*callback routine*/\r
1282         void (*on_sl_packet)(void *udta, char *payload, u32 size, GF_SLHeader *hdr, GF_Err e);\r
1283         void *udta;\r
1284 \r
1285         /*SL <-> RTP map*/\r
1286         GP_RTPSLMap sl_map;\r
1287         u32 clock_rate;\r
1288 \r
1289         /*inter-packet reconstruction bitstream (for 3GP text and H264)*/\r
1290         GF_BitStream *inter_bs;\r
1291 \r
1292         /*H264/AVC config*/\r
1293         u32 h264_pck_mode;\r
1294         \r
1295         /*3GP text reassembler state*/\r
1296         u8 nb_txt_frag, cur_txt_frag, sidx, txt_len, nb_mod_frag;\r
1297 \r
1298         /*ISMACryp*/\r
1299         u32 isma_scheme;\r
1300         char *key;\r
1301 };\r
1302 \r
1303 /*generic rtp builder (packetizer)*/\r
1304 typedef struct __tag_rtp_depacketizer GF_RTPDepacketizer;\r
1305 \r
1306 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
1307 void gf_rtp_depacketizer_del(GF_RTPDepacketizer *rtp);\r
1308 void gf_rtp_depacketizer_reset(GF_RTPDepacketizer *rtp, Bool full_reset);\r
1309 void gf_rtp_depacketizer_process(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char *payload, u32 size);\r
1310 \r
1311 void gf_rtp_depacketizer_get_slconfig(GF_RTPDepacketizer *rtp, GF_SLConfig *sl);\r
1312 \r
1313 \r
1314 #ifdef __cplusplus\r
1315 }\r
1316 #endif\r
1317 \r
1318 #endif          /*_GF_IETF_H_*/\r
1319 \r