Use mccdPrintSDP to print the SDP message stored in the MCC_SDP structure. The mccPrintSDP function uses a printf-like user-provided function to perform the printing. If you want to print to STOUT, you can use the standard C printf function as a parameter.
The following example creates an SDP message and then prints the entire SDP message from the MCC_SDP_CONTEXT_W context. For an example of printing specific SDP fields in an SDP message, see mccdPrintSDP.
MCC_SDP_CONTEXT_W context, *pc = &context;
MCC_SDP * sdp;
uint32_t error;
char sdpData[1024]; /* Buffer to write SDP to */
char buffer[1024]; /* Buffer to create MCC_SDP structure in */
/* Write SDP into sdpData */
mccdSdpInit ( pc, sdpData, sizeof(sdpData) );
mccdSdpAddSessionIP4 ( pc, "user", 123, 124, "127.0.0.1" );
mccdSdpAddConnIP4 ( pc, "192.168.0.1" );
mccdSdpAddMediaBegin ( pc, MCCSDP_MEDIA_AUDIO, 8000, 0, "RTP/AVP" );
mccdSdpAddMediaFormat ( pc, "0" );
mccdSdpAddMediaFormat ( pc, "8" );
mccdSdpAddMediaEnd ( pc );
mccdSdpAddInformation ( pc, "My audio stream" );
mccdSdpAddRtpmap ( pc, "0", "PCMU", 8000, 0 );
mccdSdpAddRtpmap ( pc, "8", "PCMA", 8000, 0 );
/* Read generated SDP into MCC_SDP */
sdp = mccdReadSDP( sdpData, mccdSdpGetLength(pc), buffer, sizeof(buffer), &error );
if ( sdp == 0 )
{
printf("ERROR: failed to process SDP: %d\n", error);
return;
}
/* Print read SDP */
printf("Generated SDP message:\n");
mccdPrintSDP( sdp, "", printf );
The example produces the following formatted SDP output:
Generated SDP message:
User name : user
Session id : 123
Session version : 124
Session name : -
Origin : IN, IP4, 127.0.0.1
Connection : IN, IP4, 192.168.0.1
Media : audio
Port : 8000 / 0
Protocol : RTP/AVP
Format : 0, PCMU, 8000
Format : 8, PCMA, 8000
Connection * : IN, IP4, 192.168.0.1