source: mediastreamer2/p2pproxy/launcher/src/launcher-tester.c @ 168:78ddc6cb297f

Last change on this file since 168:78ddc6cb297f was 168:78ddc6cb297f, checked in by jehan <jehan@…>, 5 years ago

test c interface

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@171 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

File size: 2.7 KB
Line 
1#include "p2pproxy.h"
2#include <pthread.h>
3#include <unistd.h>
4
5static void * thread_starter(void *args){
6        char* largs[] = {"-seeding-server","-sip", "5058"};
7        p2pproxy_application_start(3,largs);
8        printf("exit from application \n");
9        return NULL;
10}
11
12
13int main(int argc, char **argv) {
14        pthread_t th;
15        printf("starting p2pproxy tester \n");
16        pthread_create(&th,NULL,thread_starter,NULL);
17        sleep(5);
18       
19        if (p2pproxy_application_get_state() == P2PPROXY_CONNECTED) {
20                printf("CONNECTED \n");
21        } else {
22                printf("NOT CONNECTED \n");
23        };
24
25
26        /* account management */
27       
28        if (p2pproxy_accountmgt_createAccount("sip:titi@p2p.linphone.org") != P2PPROXY_NO_ERROR) {
29                printf("cannot create account \n");     
30        }
31       
32       
33        if (p2pproxy_accountmgt_isValidAccount("sip:titi@p2p.linphone.org") != P2PPROXY_ACCOUNTMGT_USER_EXIST) {
34                printf("user not created \n"); 
35        }
36        /* sip proxy  */
37        char string_buffer[256];
38        if (p2pproxy_resourcemgt_lookup_sip_proxy(string_buffer,256,"p2p.linphone.org") != P2PPROXY_NO_ERROR) {
39                printf("cannot get proxy\n");   
40        } else {
41                printf("registrar is [%s]\n",string_buffer);
42        }
43       
44        if (p2pproxy_resourcemgt_revoke_sip_proxy(string_buffer) != P2PPROXY_NO_ERROR) {
45                printf("cannot fulsh  proxy [%s]\n",string_buffer);     
46        }
47
48        if (p2pproxy_resourcemgt_lookup_sip_proxy(string_buffer,256,"toto.linphone.org") != P2PPROXY_RESOURCEMGT_SERVER_NOT_FOUND) {
49                printf("unexpected proxy [%s]\n",string_buffer);       
50        } else {
51                printf("cannot find proxy\n");
52        }
53
54        /* media resource mgt */
55        p2pproxy_resourcemgt_resource_list_t* resource_list;
56        resource_list =  p2pproxy_resourcemgt_new_resource_list();
57        if (resource_list == 0) {
58                printf("cannot allocate p2pproxy_resourcemgt_resource_list_t \n");
59        } else {
60                       
61                if (p2pproxy_resourcemgt_lookup_media_resource(resource_list,"p2p.linphone.org") != P2PPROXY_NO_ERROR) {
62                        printf("cannot get media resource\n"); 
63                } else {
64                        int i;
65                        for (i=0;i<resource_list->size;i++) {
66                                printf("media resource is [%s]\n",resource_list->resource_uri[i]);
67                        }
68                               
69                }
70               
71                if (p2pproxy_resourcemgt_revoke_media_resource(resource_list->resource_uri[0]) != P2PPROXY_NO_ERROR) {
72                        printf("cannot fulsh  media resource [%s]\n",resource_list->resource_uri[0]);   
73                }
74       
75                if (p2pproxy_resourcemgt_lookup_media_resource(resource_list,"p2p.linphone.org") != P2PPROXY_NO_ERROR) {
76                        printf("cannot get media resource\n"); 
77                } else {
78                        int i;
79                        for (i=0;i<resource_list->size;i++) {
80                                printf("media resource is [%s]\n",resource_list->resource_uri[i]);
81                        }
82                               
83                }
84                p2pproxy_resourcemgt_delete_resource_list(resource_list);
85        }
86
87
88
89
90        if (p2pproxy_accountmgt_deleteAccount("sip:titi@p2p.linphone.org") != P2PPROXY_NO_ERROR) {
91                printf("cannot delete account \n");     
92        }
93       
94       
95        p2pproxy_application_stop();
96        pthread_join(th,NULL);
97        return 0;
98}
Note: See TracBrowser for help on using the repository browser.