Speaker:Ying-shun Date:2006/11/27 RTP Library Speaker:Ying-shun Date:2006/11/27
Outline Organization of files Functions - Examples Sample demo References
Organization of the files (1/2) The project is composed of ten files - RTP.c:Sources of the functions of the bookshop. Functions intended for the users of the bookshop - RTP.h:Contains the total structures of the project - Config.h :It contains the symbols of the bookshop - Proto.h:Prototypes of all the functions of the project - Network.c:Sources of functions networks of the bookshop
Organization of the files (2/2) - Network.h:Structures networks of the bookshop - Hdr_Builder.c :Sources of the functions used for the construction of heading RTP. - Macros.h:All the macros project contains - Types.h:Declaration of the types specific to the bookshop
RTP header
Functions(1) Init_Socket(void); int Close_Socket(void); - Initialize the use of the socket int Close_Socket(void); - Close the use of the socket
Functions(2) int RTP_Create(context *the_context) - This function creates a context and adds to the list of the contexts. - A context is a structure containing all the variables of session related to the data flow transmitted by the means of protocol RTP - The RTP_Create function () assigns to the pointer the_context the number context in the list . EX: context_list [4] - >pt = 0
Structure of context typedef struct { int context_num; /* Number of context - sending/ reception */ u_int32 my_ssrc; /* Number SSRC - sending/ reception */ u_int32 sending_pkt_count; /* A number of packages sent - sending/ reception */ u_int32 sending_octet_count; /* A number of bytes sent sending reception */ u_int8 version; /* Version of the protocol - reception */ u_int8 marker; /* Marker flag - reception */ u_int8 padding; /* Length of the padding - reception */ u_int8 CSRClen; /* A number of elements CSRC - sending/reception */ u_int8 pt; /* Type of Payload - sending/ reception */ u_int32 *CSRCList; /* List CSRC sending reception */ u_int32 my_previous_ssrc; /* Currently not used */ u_int32 init_RTP_timestamp; /* Initial value of the timestamp - sending/reception */ u_int32 RTP_timestamp; /* Current value of the timestamp - reception */ u_int32 time_elapsed; /* Time passed since the sending beginning reception */ u_int16 init_seq_no; /* Initial number of sequence - sending reception */ u_int16 seq_no; /* Current number of sequence - sending/ reception */ rtp_ext *hdr_extension; /* Extension of the heading - sending/ reception */ void *conx_data; /* Data networks */ } sess_context_t;
Functions(3) int RTP_Destroy (context cid) - Destroyed the context thus the number is indicated by cid. u_int32 Get_Period_us(u_int8 pt) - Get the period of incrementing of the timestamp according to the type of payload.
Functions(4) int RTP_Add_Send_Addr (context cid, tank *addr, u_int16 port, u_int8 ttl) - Add a recipient to for the next sendings of packages. cid:Number of the context obtained using the RTP_Create function (). addr:Address IP of the target machine. port:Port of the target machine. ttl : Time To Life
Functions(5) int RTP_Send(context cid, u_int32 tsinc, u_int8 marker, u_int16 pti, u_int8 *payload, int len) - Add heading RTP to a package and sends it to all the recipients of the list . cid : Number of the context obtained using the RTP_Create function (). tsinc : Value whose timestamp must be incremented. marker : Value of the flag marker. pti: Type of payload. payload: Contents of the package to be sent. len : Length of the package to be sent.
Example 1 Run Rtp_Example_Send Use ethereal to observe RTP package
Functions(6) int RTP_Receive(context cid, int fd, char *payload, int *len, struct sockaddr *sin) - Parse package RTP to extract heading RTP, and assigns the value to the Context structure.Turn over (0) if heading RTP could not be parser, if not turns over (1) if the operation it passed well cid : Structure context of RTP, who must be initialized with the RTP_create function (), and destroyed with RTP_destroy (). fd : Indentifiant of the socket. payload : Contents of the received package. len : Cut payload. sin :Contents of information of the connection of the customer.
Example 2 Run Rtp_Example_Receiver Observe the package information received in receiver Fetch the information of payload to payload.txt
Sample demo Sender uses RTP package to convey test.wav to receiver Fetch the information(binary) of payload to payload.wav
References http://burns79.free.fr/ http://www.networksorcery.com/enp/protocol/rtp.htm