Changeset 3956:3f62a7d00c0c in roaraudio


Ignore:
Timestamp:
06/25/10 03:34:15 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added --proto-profile and --list-profiles

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libroar/socket.c

    r3901 r3956  
    541541 
    542542 ROAR_DBG("roar_socket_open(*): type=%s, host='%s', port=%i", 
    543              type == ROAR_SOCKET_TYPE_UNIX ? "UNIX" : "INET", host, port); 
     543             type == ROAR_SOCKET_TYPE_UNIX ? "UNIX" : "???", host, port); 
    544544 
    545545 if ( type == ROAR_SOCKET_TYPE_DECNET ) { 
     
    592592#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6) 
    593593 
    594   ROAR_DBG("roar_socket_open(*) = ?"); 
     594  ROAR_DBG("roar_socket_open(*): type=INET|INET6, host='%s', port=%i", host, port); 
    595595 
    596596  roar_socket_win32_init(); // we need to do this early as gethostbyname() requires this. 
     597 
     598  ROAR_DBG("roar_socket_open(*): type=INET|INET6, host='%s', port=%i", host, port); 
    597599 
    598600  if ( (he = gethostbyname(host)) == NULL ) { 
  • roard/roard.c

    r3954 r3956  
    181181        "     --proto-aiprofile PROFILE\n" 
    182182        "                       - Sets the audio profile for socket\n"  
     183        "     --proto-profile P - Set profile for listen socket\n" 
    183184        "     --list-proto      - List supported protocols\n" 
     185        "     --list-profiles   - List supported profiles for --proto-profile\n" 
    184186        "     --new-sock        - Parameters for new socket follows\n" 
    185187#ifdef ROAR_HAVE_LIBSLP 
     
    337339} 
    338340 
     341#ifdef ROAR_SUPPORT_LISTEN 
     342static struct _listen_profile { 
     343 const char * name; 
     344 int          type; 
     345 int          port; 
     346 const char * sockaddr; 
     347 int          proto; 
     348 int          dir; 
     349 const char * aiprofile; 
     350 const char * desc; 
     351} _g_listen_profiles[] = { 
     352 // TODO: convert port numbers into consts! 
     353 
     354 // RoarAudio: 
     355 {"roar-gsock",     ROAR_SOCKET_TYPE_UNIX,   0,                 "/tmp/roar",        ROAR_PROTO_ROARAUDIO, -1, NULL, NULL}, 
     356 {"roar-tcp",       ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_PORT, "localhost",        ROAR_PROTO_ROARAUDIO, -1, NULL, NULL}, 
     357 {"roar-tcp-pub",   ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_PORT, "0.0.0.0",          ROAR_PROTO_ROARAUDIO, -1, NULL, NULL}, 
     358 {"roar-dnet",      ROAR_SOCKET_TYPE_DECNET, 0,                 "::roar",           ROAR_PROTO_ROARAUDIO, -1, NULL, NULL}, 
     359 
     360 // EsounD: 
     361 {"esd-unix",       ROAR_SOCKET_TYPE_UNIX,   0,                 "/tmp/.esd/socket", ROAR_PROTO_ESOUND,    -1, NULL, NULL}, 
     362 {"esd-tcp",        ROAR_SOCKET_TYPE_TCP,    16001,             "localhost",        ROAR_PROTO_ESOUND,    -1, NULL, NULL}, 
     363 {"esd-tcp-pub",    ROAR_SOCKET_TYPE_TCP,    16001,             "0.0.0.0",          ROAR_PROTO_ESOUND,    -1, NULL, NULL}, 
     364 
     365 // RSound: 
     366 {"rsound-tcp",     ROAR_SOCKET_TYPE_TCP,    12345,             "localhost",        ROAR_PROTO_RSOUND,    -1, NULL, NULL}, 
     367 {"rsound-tcp-pub", ROAR_SOCKET_TYPE_TCP,    12345,             "0.0.0.0",          ROAR_PROTO_RSOUND,    -1, NULL, NULL}, 
     368 {"rsound-dnet",    ROAR_SOCKET_TYPE_DECNET, 0,                 "::rsound",         ROAR_PROTO_RSOUND,    -1, NULL, NULL}, 
     369 {NULL, -1, -1, NULL, -1, -1, NULL, NULL} 
     370}; 
     371 
     372void listen_listen_profiles (void) { 
     373 struct _listen_profile * p; 
     374 char * type; 
     375 int i; 
     376 
     377 printf("Name           Type    Addrress         Port    Protocol  Dir        Audio Profile - Description\n"); 
     378 printf("------------------------------------------------------------------------------------------------\n"); 
     379      //roar-tcp-pub 0.0.0.0       16002   RoarAudio unknown    (null) - (null) 
     380 
     381 for (i = 0; (p = &(_g_listen_profiles[i]))->name != NULL; i++) { 
     382  switch (p->type) { 
     383   case ROAR_SOCKET_TYPE_UNIX:   type = "UNIX";   break; 
     384   case ROAR_SOCKET_TYPE_TCP:    type = "TCP";    break; 
     385   case ROAR_SOCKET_TYPE_DECNET: type = "DECnet"; break; 
     386   default: 
     387     type = "unknown"; 
     388    break; 
     389  } 
     390  printf("%-14s %-7s %-16s %-7i %-9s %-10s %-13s - %s\n", 
     391           p->name, 
     392           type, 
     393           p->sockaddr, p->port, 
     394           roar_proto2str(p->proto), 
     395           roar_dir2str(p->dir), p->aiprofile == NULL ? "" : p->aiprofile, 
     396           p->desc == NULL ? "" : p->desc); 
     397 } 
     398} 
     399 
     400int get_listen_profile (const char * name, 
     401                        int * port, char ** sockaddr, int * type, 
     402                        int * proto, 
     403                        int * dir, struct roar_audio_info * info) { 
     404 static char buf[1024]; 
     405 struct _listen_profile * p; 
     406 int i; 
     407 
     408 for (i = 0; (p = &(_g_listen_profiles[i]))->name != NULL; i++) { 
     409  if ( !strcasecmp(p->name, name) ) { 
     410   *port     = p->port; 
     411 
     412   strcpy(buf, p->sockaddr); 
     413   *sockaddr = buf; 
     414 
     415   *proto    = p->proto; 
     416   *dir      = p->dir; 
     417 
     418   if ( p->aiprofile != NULL ) { 
     419    if ( roar_profile2info(info, p->aiprofile) == -1 ) { 
     420     ROAR_ERR("Unknown audio profile: %s", p->aiprofile); 
     421     return -1; 
     422    } 
     423   } 
     424   return 0; 
     425  } 
     426 } 
     427 
     428 return -1; 
     429} 
     430#endif 
     431 
    339432int add_listen (char * addr, int port, int sock_type, char * user, char * group, int proto, int dir, struct roar_audio_info * info) { 
    340433#if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX) 
     
    14841577   } 
    14851578#endif 
     1579  } else if ( strcmp(k, "--list-profiles") == 0 ) { 
     1580#ifdef ROAR_SUPPORT_LISTEN 
     1581   listen_listen_profiles(); 
     1582   return 0; 
     1583#endif 
     1584  } else if ( strcmp(k, "--proto-profile") == 0 ) { 
     1585#ifdef ROAR_SUPPORT_LISTEN 
     1586   if ( get_listen_profile(argv[++i], &port, &sock_addr, &sock_type, &sock_proto, &sock_dir, &sock_info) == -1 ) { 
     1587    ROAR_ERR("Unknown listen profile: %s", argv[i]); 
     1588    return 1; 
     1589   } 
     1590#endif 
    14861591 
    14871592 
Note: See TracChangeset for help on using the changeset viewer.