Changeset 605:f1450dcc5dc5 in roaraudio


Ignore:
Timestamp:
08/19/08 19:42:00 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added a lot basic code to roarshout

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarshout.c

    r600 r605  
    44 
    55#ifdef ROAR_HAVE_LIBSHOUT 
     6#include <shout/shout.h> 
    67 
    7 #define BUFSIZE 1024 
     8#define BUFSIZE 2048 
    89 
    910void usage (void) { 
     
    2930 char * server   = NULL; 
    3031 char * k; 
    31  char * s_server = NULL; 
     32 char * s_server = "localhost"; 
    3233 char * s_mount  = "/roar.ogg"; 
    3334 char * s_pw     = "hackme"; 
     
    3637 int    i; 
    3738 char buf[BUFSIZE]; 
     39 shout_t * shout; 
    3840 
    3941 for (i = 1; i < argc; i++) { 
     
    6062 } 
    6163 
    62  if ( (fh = roar_simple_monitor(rate, channels, bits, codec, server, "roarmon")) == -1 ) { 
     64 shout_init(); 
     65 
     66 if (!(shout = shout_new())) { 
     67  ROAR_ERR("Can not clreate shout object"); 
     68  return 1; 
     69 } 
     70 
     71 if (shout_set_host(shout, s_server) != SHOUTERR_SUCCESS) { 
     72  ROAR_ERR("Error setting hostname: %s", shout_get_error(shout)); 
     73  return 1; 
     74 } 
     75 
     76 if (shout_set_protocol(shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) { 
     77  ROAR_ERR("Error setting protocol: %s", shout_get_error(shout)); 
     78  return 1; 
     79 } 
     80 
     81 if (shout_set_port(shout, s_port) != SHOUTERR_SUCCESS) { 
     82  ROAR_ERR("Error setting port: %s", shout_get_error(shout)); 
     83  return 1; 
     84 } 
     85 
     86 if (shout_set_password(shout, s_pw) != SHOUTERR_SUCCESS) { 
     87  ROAR_ERR("Error setting password: %s", shout_get_error(shout)); 
     88  return 1; 
     89 } 
     90 
     91 if (shout_set_mount(shout, s_mount) != SHOUTERR_SUCCESS) { 
     92  ROAR_ERR("Error setting mount: %s", shout_get_error(shout)); 
     93  return 1; 
     94 } 
     95 
     96 if (shout_set_user(shout, "source") != SHOUTERR_SUCCESS) { 
     97  ROAR_ERR("Error setting user: %s", shout_get_error(shout)); 
     98  return 1; 
     99 } 
     100 
     101 if (shout_set_format(shout, SHOUT_FORMAT_OGG) != SHOUTERR_SUCCESS) { 
     102  ROAR_ERR("Error setting format: %s", shout_get_error(shout)); 
     103  return 1; 
     104 } 
     105 
     106 if ( (fh = roar_simple_monitor(rate, channels, bits, codec, server, "roarshout")) == -1 ) { 
    63107  fprintf(stderr, "Error: can not start monetoring\n"); 
    64108  return 1; 
    65109 } 
    66110 
     111 if (shout_open(shout) != SHOUTERR_SUCCESS) { 
     112  ROAR_ERR("Can not open connection via libshout!"); 
     113  return -1; 
     114 } 
     115 
    67116 while((i = read(fh, buf, BUFSIZE))) 
    68   if (write(1, buf, i) != i) 
     117  if (shout_send(shout, buf, i) != SHOUTERR_SUCCESS) 
    69118   break; 
    70119 
    71120 roar_simple_close(fh); 
     121 
     122 shout_sync(shout); 
     123 
     124 shout_close(shout); 
     125 
     126 shout_shutdown(); 
    72127 
    73128 return 0; 
Note: See TracChangeset for help on using the changeset viewer.