00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <stdio.h>
00021 #include <freesdp/parser.h>
00022
00023 fsdp_error_t
00024 do_parse(const char *, size_t);
00025
00030 fsdp_error_t
00031 do_parse(const char *text, size_t len)
00032 {
00033 fsdp_description_t *dsc = NULL;
00034 fsdp_error_t result;
00035 unsigned int i = 0;
00036
00037
00038 dsc = fsdp_description_new();
00039
00040
00041 printf(" Starting to parse...\n");
00042 result = fsdp_parse(text,dsc);
00043
00044 if ( result == FSDPE_OK )
00045 printf(" completed succesfully!\n");
00046 else
00047 printf(" failed with error code %d: %s.\n",result,fsdp_strerror(result));
00048
00049
00050 printf(" The owner of the session seems to be \"%s\".\n",
00051 fsdp_get_owner_username(dsc));
00052 printf(" The session is called \"%s\"\n",fsdp_get_name(dsc));
00053 printf(" and is described as \"%s\".\n",fsdp_get_information(dsc));
00054 printf(" It consists of %u media streams.\n",fsdp_get_media_count(dsc));
00055
00056 for (i = 0; i < fsdp_get_media_count(dsc); i++ )
00057 printf(" the media announcement number %d has %d rtpmap attributes\n",
00058 i + 1,
00059 fsdp_get_media_rtpmap_count(fsdp_get_media(dsc,i)));
00060
00061 printf(" the description has %d unknown session level attributes:\n",
00062 fsdp_get_unidentified_attributes_count(dsc));
00063
00064 for (i = 0; i < fsdp_get_unidentified_attribute_count(dsc); i++ ) {
00065 printf(" #%d: %s\n",i+1,fsdp_get_unidentified_attribute(dsc,i));
00066 }
00067
00068
00069 fsdp_description_delete(dsc);
00070
00071
00072 return result;
00073 }
00074
00075 int main(int argc, char *argv[])
00076 {
00077 const int MAX_SIZE = 5000;
00078 char text[MAX_SIZE], *filename = NULL;
00079 size_t size = MAX_SIZE;
00080 FILE *file = NULL;
00081 fsdp_error_t result;
00082
00083 if ( argc == 2 ) {
00084 filename = argv[1];
00085 } else {
00086 filename = "rfc-example.sdp";
00087 }
00088
00089 if ( (file = fopen(filename,"r")) ) {
00090 size = fread(text,1,size,file);
00091
00092 result = do_parse(text,size);
00093 printf(" Parsed a %d octets long SDP description.\n Result: %d\n",
00094 size,result);
00095 fclose(file);
00096 } else {
00097 printf("Could not open file.\n");
00098 }
00099 return 0;
00100 }