mccdPrintSDP

Prints SDP information stored in the MCC_SDP structure.

Prototype

void mccdPrintSDP ( MCC_SDP * sdp, const char * prefix, int myprintf(const char * format))

Argument

Description

sdp

Pointer to the MCC_SDP structure that contains the SDP message that you want to print.

prefix

(Optional) Pointer to the string to print at the beginning of every new line.

myprintf

A user-defined printf-like function to be used for printing. The standard C printf function may be used instead.

format

(Optional) Pointer to a string of SDP fields to print. Separate the variables with commas. If you do not specify an SDP field, mccdPrintSDP prints all SDP fields in the MCC_SDP structure.

Details

mccdPrintSDP uses a printf-like function to print a generated SDP message.

Examples

The following example prints all SDP fields in the MCC_SDP structure by using mccPrintSDP along with one call to a standard printf function:

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 */
    
    /* 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 following example shows an implementation of mccPrintSDP:

*/
  void mccdPrintSDP ( MCC_SDP * sdp, const char * prefix, 
                      int myprintf(const char * format, ...) )
   {
     MCC_SDP_MEDIA *         media;
     MCC_SDP_FORMAT *        format;
     MCC_SDP_ATTRIBUTE *     attr;
     
     myprintf("%sUser name          : %s\n", prefix, sdp->username ); 
     myprintf("%sSession id         : %" PRIu64 "\n", prefix, sdp->id ); 
     myprintf("%sSession version    : %" PRIu64 "\n", prefix, sdp->version ); 
     myprintf("%sSession name       : %s\n", prefix, sdp->name ); 
     myprintf("%sOrigin             : %s, %s, %s\n", prefix,  
              sdp->origin->nettype, 
              sdp->origin->addrtype,
              sdp->origin->address ); 
     
     if ( sdp->connection )
     {
         myprintf("%sConnection         : %s, %s, %s\n", prefix,
                  sdp->connection->nettype, 
                  sdp->connection->addrtype,
                  sdp->connection->address ); 
     }
     
     for  ( attr = sdp->attr; attr; attr = attr->next )
     {
         if ( attr->value )
             myprintf("%sAttribute    : %s = %s\n", prefix, attr->name, attr->value );
         else
             myprintf("%sAttribute    : %s\n", prefix, attr->name );
     }
     
     for  ( media = sdp->media; media; media = media->next )
     { 
         myprintf("%sMedia            : %s\n",  prefix, media->type );
         myprintf("%s    Port         : %u / %u\n", prefix, media->port, media->count );
         myprintf("%s    Protocol     : %s\n",  prefix, media->protocol );

         for  ( format = media->format; format; format = format->next )
         {
             myprintf("%s    Format   :", prefix );
             
             if ( format->rtpmap == 0 )  
                 myprintf(" %s\n", format->id );
             else if ( format->rtpmap->parameter )
                 myprintf(" %s, %s, %u, %s\n",
                          format->id, format->rtpmap->encoding,
                          format->rtpmap->clockrate, format->rtpmap->parameter );
             else
                 myprintf(" %s, %s, %u\n",
                          format->id, format->rtpmap->encoding,
                          format->rtpmap->clockrate );
             
         }
         
         if ( media->connection )
         {
             myprintf("%s    Connection   %c : %s, %s, %s\n", prefix, 
                      (media->connection == sdp->connection) ? '*' : ' ', 
                      media->connection->nettype,
                      media->connection->addrtype,
                      media->connection->address ); 
         }
         
         for  ( attr = media->attr; attr; attr = attr->next )
         {
             if ( attr->value )
                 myprintf("%s    Attribute  : %s = %s\n", prefix, attr->name,
                 attr->value );
             else
                 myprintf("%s    Attribute  : %s\n", prefix, attr->name );
         }
         
     }  // media  
   }