SinisterSdpGenerator - The SDP generator routines
#include <SDP/SDP_Generator.h> int main(void) { SDP_Generator *generator = SDP_NewGenerator(); SDP_GenProtocolVersionField(generator, 1); SDP_GenOwnerField( generator, "username", "session_id", "IN", "IP4", "127.0.0.1" ); SDP_GenSessionNameField(generator, "Some session"); SDP_GenInformationField(generator, "This is short description"); ... SDP_SaveGeneratedOutput(generator, "description.sdp"); }
This document describes the SinisterSdp generator routines. These routines enable you programmatically generate SDP session descriptions, as well as spit out descriptions encapsulated by an SDP_Description struct into a string or file.
char *SDP_OutputDescriptionsToString(SDP_Description *descriptions);
This function outputs every single SDP_Description struct in the linked list to a dynamically allocated string.
If no error occurs, it returns a pointer to the dynamically allocated string. Otherwise, it returns a NULL pointer. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to output the descriptions to the string.
char *SDP_OutputDescriptionToString(SDP_Description *description);
This function outputs a single SDP_Description struct to a dynamically allocated string and returns a pointer to it.
If no error occurs, it returns a pointer to the dynamically allocated string. Otherwise, it returns a NULL pointer. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to output the description to the string.
int SDP_OutputDescriptionsToFile( SDP_Description * descriptions, const char * filename );
This function outputs every SDP_Description struct in the link list to a file. If the file specified does not exist, it will be created. If it does exist, then anything in it will be overwritten.
This function returns true if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to output the descriptions to the specified file. SDP_ERR_FILE_OPEN_FAILED - The file you specified could not be opened.
A pointer to an SDP_Description struct.
A pointer to a string containing the name of the file to write to.
int SDP_OutputDescriptionToFile( SDP_Description * description, const char * filename );
This function outputs a single SDP_Description struct to a file. If the file specified does not exist, it will be created. If it does exist, then anything in it will be overwritten.
This function returns true if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to output the description to the specified file. SDP_ERR_FILE_OPEN_FAILED - The file you specified could not be opened.
A pointer to an SDP_Description struct.
A pointer to a string containing the name of the file to write to.
SDP_Generator *SDP_NewGenerator(void);
This function creates a new SDP generator.
If no error occurs, it returns a pointer to the newly-created SDP_Generator struct. Otherwise, it returns a NULL pointer instead. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There wasn't enough memeory available to create the generator.
None.
int SDP_GenProtocolVersionField( SDP_Generator * generator, int protocol_version );
This function generates a "v" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "v" field.
int SDP_GenOwnerField( SDP_Generator * generator, const char * username, const char * session_id, const char * session_version, const char * network_type, const char * address_type, const char * address );
This function generates an "o" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "o" field.
A pointer to the SDP_Generator struct.
A pointer to a string containing the username.
A pointer to a string containing the session ID.
A pointer to a string containing the session version number.
A pointer to a string containing the network type (e.g., "IN" for Internet).
A pointer to a string containing the address type (e.g., "IP4" for IPv4).
A pointer to a string containing the address.
int SDP_GenFromOwner( SDP_Generator * generator, SDP_Owner * owner );
This function generates an "o" field from an SDP_Owner struct.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "o" field.
int SDP_GenSessionNameField( SDP_Generator * generator, const char * session_name );
This function generates an "s" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "s" field.
A pointer to the SDP_Generator struct.
A pointer to a string containing the name of the session.
int SDP_GenInformationField( SDP_Generator * generator, const char * information );
This fucntion generates an "i" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "i" field.
A pointer to the SDP_Generator struct.
A pointer to a string containing a short description of the session.
int SDP_GenURIField( SDP_Generator * generator, const char * uri );
This function generates a "u" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "u" field.
A pointer to the SDP_Generator struct.
A pointer to a string containing the URI of the session.
int SDP_GenEmailContactField( SDP_Generator * generator, const char * address, const char * name );
This function generates an "e" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "e" field.
A pointer to the SDP_Generator struct.
A pointer to a string containing the email address.
A pointer to a string containing the name of the person who uses that email address.
int SDP_GenFromEmailContacts( SDP_Generator * generator, SDP_EmailContact * email_contacts );
This function generates "e" fields from each SDP_EmailContact struct in the linked list.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "e" fields.
A pointer to the SDP_Generator struct.
A pointer to an SDP_EmailContact struct.
int SDP_GenFromEmailContact( SDP_Generator * generator, SDP_EmailContact * email_contact );
This function generates a single "e" field from a single SDP_EmailContact struct.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "e" field.
A pointer to the SDP_Generator struct.
A pointer to the SDP_EmailContact struct.
int SDP_GenPhoneContactField( SDP_Generator * generator, const char * number, const char * name );
This function generates a "p" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "p" field.
A pointer to the SDP_Generator struct.
A pointer to a string containing the phone number.
A pointer to a string containing the name of the person who can be reached at that phone number.
int SDP_GenFromPhoneContacts( SDP_Generator * generator, SDP_PhoneContact * phone_contacts );
This function generates "p" fields from every SDP_PhoneContact struct in the linked list.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "p" fields.
A pointer to the SDP_Generator struct.
A pointer to an SDP_PhoneContact struct.
int SDP_GenFromPhoneContact( SDP_Generator * generator, SDP_PhoneContact * phone_contact );
This function generates a "p" field from a single SDP_PhoneContact struct.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "p" field.
A pointer to the SDP_Generator struct.
A pointer to an SDP_PhoneContact struct.
int SDP_GenConnectionField( SDP_Generator * generator, const char * network_type, const char * address_type, const char * address, int ttl, int total_addresses );
This function generates a "c" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "c" field.
A pointer to the SDP_Generator struct.
A pointer to a string containing the network type (e.g., "IN" for Internet).
A pointer to a string containing the address type (e.g., "IP4" for Internet Protocol version 4).
A pointer to a string containing the address.
Time To Live.
Counting up from "address", how many addresses are there available.
int SDP_GenFromConnection( SDP_Generator * generator, SDP_Connection * connection );
This function generates a "c" field from an SDP_Connection struct.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "c" field.
int SDP_GenBandwidthField( SDP_Generator * generator, const char * modifier, long value );
This function generates a "b" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "c" field.
A pointer to the SDP_Generator struct.
A pointer to a string containing the bandwidth modifier (e.g., "CT" for Conference Total).
A pointer to a string contianing the bandwidth value.
int SDP_GenFromBandwidth( SDP_Generator * generator, SDP_Bandwidth * bandwidth );
This function generates a "b" field from an SDP_Bandwidth struct.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "c" field.
int SDP_GenSessionPlayTimeField( SDP_Generator * generator, time_t start_time, time_t end_time );
This function generates a "t" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "t" field.
A pointer to the SDP_Generator struct.
A time_t value of when the session starts.
A time_t value of when the session ends.
int SDP_GenFromSessionPlayTimes( SDP_Generator * generator, SDP_SessionPlayTime * session_play_times );
This function generates a "t" field and any requisite "r" feilds for each SDP_SessionPlayTime struct in the linked list.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "t" fields or "r" fields.
A pointer to the SDP_Generator struct.
A pointer to SDP_SessionPlayTime struct.
int SDP_GenFromSessionPlayTime( SDP_Generator * generator, SDP_SessionPlayTime * session_play_time );
This function generates a single "t" field and any requisite "r" fields from a SDP_SessionPlayTime struct.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "t" field or "r" fields.
A pointer to the SDP_Generator struct.
A pointer to a SDP_SessionPlayTime struct.
int SDP_GenRepeatTimeField( SDP_Generator * generator, const char * repeat_interval, const char * active_duration, const char * repeat_offsets );
This function generates an "r" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "r" field.
A pointer to the SDP_Generator struct.
A pointer to a string containing the repeat interval as a number by itself (meaning in seconds) or postfixed with the letter "m" (meaning in minutes), "h" (meaning in hours), or "d" (meaning in days).
A pointer to a string containing the active duration of the session as a number by itself (meaning in seconds) or postfixed with the letter "m" (meaning in minutes), "h" (meaning in hours), or "d" (meaning in days).
A string containing one or more repeat offsets seperated by spaces.
int SDP_GenFromRepeatTimes( SDP_Generator * generator, SDP_RepeatTime * repeat_times );
This function generates "r" fields from each SDP_RepeatTime struct in the linked list.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "r" fields.
int SDP_GenFromRepeatTime( SDP_Generator * generator, SDP_RepeatTime * repeat_time );
This function generates an "r" field from an SDP_RepeatTime struct.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "r" field.
A pointer to the SDP_Generator struct.
A pointer to the SDP_RepeatTime strcut.
int SDP_GenZoneAdjustmentsField( SDP_Generator * generator, int total_adjustments, ... );
This function generates a "z" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "z" field.
A pointer to the SDP_Generator struct.
The number of time-zone adjustment pairs to expect.
The remaining arguments come in pairs. The first is the time (as a time_t value) of when some type of zone adjustment is to occur. The second is the adjustment itself in the form of a string comprised of a positive or negative number followed by a the letter "m" (meaning minutes), "h" (meaning hours), or "d" (meaning days):
SDP_GenZoneAdjustmentsField(generator, 2, some_time, "-1h", some_other_time, "-2h" );
Each time value will be converted from OS time to Network Protocol Time.
int SDP_GenFromZoneAdjustments( SDP_Generator * generator, SDP_ZoneAdjustment * zone_adjustments );
Stub description documentation.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "z" field.
A pointer to the SDP_Generator struct.
A pointer to an SDP_ZoneAdjustments struct.
int SDP_GenEncryptionField( SDP_Generator * generator, const char * method, const char * key );
This function generates a "k" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "e" field.
A pointer to the SDP_Generator struct.
A pointer to a string containing the encryption method.
A pointer to a string containing the encyption key.
int SDP_GenFromEncryption( SDP_Generator * generator, SDP_Encryption * encryption );
This function generates a "k" field from an SDP_Encryption struct.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "k" field.
int SDP_GenAttributeField( SDP_Generator * generator, const char * name, const char * value );
This function generates an "a" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "a" field.
A pointer to the SDP_Generator struct.
A pointer to a string containing the name of the attribute.
A pointer to a string containing the value of the attribute.
int SDP_GenFromAttributes( SDP_Generator * generator, SDP_Attribute * attributes );
This function generates "a" fields from every SDP_Attribute struct in the linked list.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "a" fields.
int SDP_GenFromAttribute( SDP_Generator * generator, SDP_Attribute * attribute );
This function generates an "a" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "a" field.
int SDP_GenMediaDescriptionField( SDP_Generator * generator, const char * media_type, const char * port, const char * transport_protocol, const char * formats );
This function generates an "m" field.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "m" field.
A pointer to the SDP_Generator struct.
A pointer to a string containing the media type.
A pointer to a string containing the port number with an optional number of other usable ports for UDP multicasts.
A pointer to a string containing the transport protocol (e.g., "RTP/AVP").
A pointer to a string containing media formats separated by spaces.
int SDP_GenFromMediaDescriptions( SDP_Generator * generator, SDP_MediaDescription * media_descriptions );
This function generates "m" fields and any other requisite fields from each SDP_MediaDescription in the linked list.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_OUT_OF_MEMORY - There isn't enough memory available to generate the "m" fields.
A pointer to the SDP_Generator struct.
A pointer to an SDP_MediaDescription struct.
int SDP_GenFromMediaDescription( SDP_Generator * generator, SDP_MediaDescription * media_description );
This function generates an "m" field and any related fields from an SDP_MediaDescription struct.
char *SDP_GetGeneratedOutput(SDP_Generator *generator);
This function returns a pointer to the generator's buffer. If you want to modify the this or use it after calling SDP_DestroyGenerator(), use strdup() or some comparable function to copy it.
int SDP_SaveGeneratedOutput( SDP_Generator * generator, const char * filename );
This function outputs the generator buffer to a file. If the file specified doesn't already exist, then it will be created. If it does exist, then anything in it will be overwritten.
It returns ture if no error occurs, false otherwise. Call SDP_GetLastError() for extended error information. The possible error codes returned are:
SDP_ERR_FILE_OPEN_FAILED - The file you specified could not be opened.
A pointer to the SDP_Generator struct.
A pointer to a string containing the name of the file to write to.
void SDP_DestroyGenerator(SDP_Generator *generator);
This function destroys an SDP generator, returning its memory to the system.
Bugs in this package can be reported and monitored using sourceforge.net: http://sourceforge.net/tracker/?atid=644250&group_id=106387&func=browse
You can also email me directly: <william_g_davis at users dot sourceforge dot net>.
Copyright 2004 by William G. Davis.
This library is free software released under the terms of the GNU Lesser General Public License (LGPL), the full terms of which can be found in the "COPYING" file that comes with the distribution.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.