Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <stdio.h>
00013 #include <string.h>
00014 #include <libplayerc/playerc.h>
00015
00016 int main(int argc, const char **argv)
00017 {
00018 const char *host;
00019 int port;
00020 playerc_client_t *client;
00021
00022 host = "localhost";
00023 port = 6665;
00024
00025 printf( "Attempting to connect to a Player server on %s:%d\n",
00026 host, port );
00027
00028
00029 client = playerc_client_create(NULL, host, port);
00030 if (playerc_client_connect(client) != 0)
00031 {
00032 puts( "Failed. Quitting." );
00033 return -1;
00034 }
00035
00036 puts( "Connected. Running tests." );
00037
00038
00039 playerc_opaque_t *audio = playerc_opaque_create(client, 0);
00040 if (playerc_opaque_subscribe(audio, PLAYER_OPEN_MODE))
00041 return -1;
00042
00043 int i;
00044 for( i = 0; i < 1000; i++)
00045 {
00046
00047 if (playerc_client_peek(client, 100) > 0)
00048 playerc_client_read(client);
00049
00050
00051 if (audio->data_count>0)
00052 {
00053
00054 printf("%s\n", audio->data);
00055
00056
00057 audio->data_count=0;
00058 }
00059
00060
00061 if ( i % 20 == 0 )
00062 {
00063
00064 player_opaque_data_t audio_msg;
00065 char *temp_str="Hello World!";
00066 sprintf((char *) audio_msg.data, "%s", temp_str);
00067 audio_msg.data_count=strlen(temp_str)+1;
00068
00069 playerc_opaque_cmd(audio, &audio_msg);
00070 }
00071
00072 }
00073
00074 playerc_opaque_unsubscribe(audio);
00075 playerc_opaque_destroy(audio);
00076
00077 return 0;
00078
00079
00080 puts( "Disconnecting" );
00081
00082 playerc_client_disconnect(client);
00083 playerc_client_destroy(client);
00084
00085 puts( "Done." );
00086 return 0;
00087 }