#include <stdio.h>
#include <freesdp/parser.h>
fsdp_error_t
do_parse(const char *, size_t);
fsdp_error_t
do_parse(const char *text, size_t len)
{
fsdp_description_t *dsc = NULL;
fsdp_error_t result;
unsigned int i = 0;
dsc = fsdp_description_new();
printf(" Starting to parse...\n");
result = fsdp_parse(text,dsc);
if ( result == FSDPE_OK )
printf(" completed succesfully!\n");
else
printf(" failed with error code %d: %s.\n",result,fsdp_strerror(result));
printf(" The owner of the session seems to be \"%s\".\n",
fsdp_get_owner_username(dsc));
printf(" The session is called \"%s\"\n",fsdp_get_name(dsc));
printf(" and is described as \"%s\".\n",fsdp_get_information(dsc));
printf(" It consists of %u media streams.\n",fsdp_get_media_count(dsc));
for (i = 0; i < fsdp_get_media_count(dsc); i++ )
printf(" the media announcement number %d has %d rtpmap attributes\n",
i + 1,
fsdp_get_media_rtpmap_count(fsdp_get_media(dsc,i)));
fsdp_description_delete(dsc);
return result;
}
int main(int argc, char *argv[])
{
const int MAX_SIZE = 5000;
char text[MAX_SIZE], *filename = NULL;
size_t size = MAX_SIZE;
FILE *file = NULL;
fsdp_error_t result;
if ( argc == 2 ) {
filename = argv[1];
} else {
filename = "rfc-example.sdp";
}
if ( (file = fopen(filename,"r")) ) {
size = fread(text,1,size,file);
result = do_parse(text,size);
printf(" Parsed a %d octets long SDP description.\n Result: %d\n",
size,result);
fclose(file);
} else {
printf("Could not open file.\n");
}
return 0;
}