Changeset 1043:1ca27ba72398 in roaraudio
- Timestamp:
- 12/23/08 09:26:22 (15 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/stream.h
r1032 r1043 58 58 //#define ROAR_FLAG_SYNC 0x08 59 59 60 #define ROAR_SET_FLAG 0 61 #define ROAR_RESET_FLAG 1 62 60 63 struct roar_stream_info { 61 64 int block_size; … … 84 87 int roar_stream_get_info (struct roar_connection * con, struct roar_stream * s, struct roar_stream_info * info); 85 88 89 int roar_stream_set_flags (struct roar_connection * con, struct roar_stream * s, int flags, int reset); 90 86 91 int roar_stream_s2m (struct roar_stream * s, struct roar_message * m); 87 92 int roar_stream_m2s (struct roar_stream * s, struct roar_message * m); -
libroar/stream.c
r964 r1043 289 289 info->codec = data[5]; 290 290 info->flags = data[6]; 291 292 return 0; 293 } 294 295 int roar_stream_set_flags (struct roar_connection * con, struct roar_stream * s, int flags, int reset) { 296 struct roar_message m; 297 uint16_t * data = (uint16_t *) m.data; 298 int i; 299 300 m.cmd = ROAR_CMD_SET_STREAM_PARA; 301 m.stream = s->id; 302 m.datalen = 8; 303 m.pos = 0; 304 305 data[0] = 0; // Version and reserved 306 data[1] = 2; // flags 307 data[2] = reset == ROAR_RESET_FLAG ? ROAR_RESET_FLAG : ROAR_SET_FLAG; 308 data[3] = flags; 309 310 for (i = 0; i < m.datalen/2; i++) { 311 data[i] = ROAR_HOST2NET16(data[i]); 312 } 313 314 if ( roar_req(con, &m, NULL) == -1 ) 315 return -1; 316 317 if ( m.cmd != ROAR_CMD_OK ) 318 return -1; 291 319 292 320 return 0; -
roarclients/roarctl.c
r1032 r1043 379 379 } 380 380 381 int set_flags (struct roar_connection * con, int id, int reset, char * flags) { 382 int f = ROAR_FLAG_NONE; 383 char * c; 384 struct roar_stream s[1]; 385 386 memset(s, 0, sizeof(struct roar_stream)); 387 388 s->id = id; 389 390 c = strtok(flags, ","); 391 while (c != NULL) { 392 if ( !strcmp(c, "meta") ) { 393 f |= ROAR_FLAG_META; 394 } else if ( !strcmp(c, "primary") ) { 395 f |= ROAR_FLAG_PRIMARY; 396 } else { 397 fprintf(stderr, "Error: unknown flag: %s\n", c); 398 return -1; 399 } 400 401 c = strtok(NULL, ","); 402 } 403 404 return roar_stream_set_flags(con, s, f, reset); 405 } 406 381 407 int main (int argc, char * argv[]) { 382 408 struct roar_connection con; … … 513 539 } 514 540 541 } else if ( !strcmp(k, "flag") ) { 542 i++; 543 if ( set_flags(&con, atoi(argv[i]), ROAR_SET_FLAG, argv[i+1]) == -1 ) { 544 fprintf(stderr, "Error: can not set flags\n"); 545 } else { 546 printf("flags changed\n"); 547 } 548 i++; 549 } else if ( !strcmp(k, "unflag") ) { 550 i++; 551 if ( set_flags(&con, atoi(argv[i]), ROAR_RESET_FLAG, argv[i+1]) == -1 ) { 552 fprintf(stderr, "Error: can not reset flags\n"); 553 } else { 554 printf("flags changed\n"); 555 } 556 i++; 515 557 } else if ( !strcmp(k, "metaset") ) { 516 558 i++; -
roard/commands.c
r768 r1043 55 55 {ROAR_CMD_GET_VOL, "GET_VOL", req_on_get_vol}, 56 56 {ROAR_CMD_GET_STREAM_PARA, "GET_STREAM_PARA", req_on_get_stream_para}, 57 {ROAR_CMD_SET_STREAM_PARA, "SET_STREAM_PARA", req_on_set_stream_para}, 57 58 58 59 {ROAR_CMD_ADD_DATA, "ADD_DATA", req_on_add_data}, -
roard/include/req.h
r768 r1043 56 56 57 57 int req_on_get_stream_para (int client, struct roar_message * mes, char * data); 58 int req_on_set_stream_para (int client, struct roar_message * mes, char * data); 58 59 59 60 int req_on_kick (int client, struct roar_message * mes, char * data); -
roard/req.c
r1038 r1043 501 501 } 502 502 503 int req_on_set_stream_para (int client, struct roar_message * mes, char * data) { 504 uint16_t * d = (uint16_t *) mes->data; 505 int i; 506 507 if ( mes->datalen != 8 ) 508 return -1; 509 510 for (i = 0; i < mes->datalen/2; i++) { 511 d[i] = ROAR_NET2HOST16(d[i]); 512 } 513 514 if ( d[0] != 0 || d[1] != 2 ) { 515 ROAR_WARN("req_on_set_stream_para(*): unsupported command version: %i, %i", d[0], d[1]); 516 return -1; 517 } 518 519 mes->cmd = ROAR_CMD_OK; 520 mes->datalen = 0; 521 522 ROAR_WARN("req_on_set_stream_para(*): request seems to be valid"); 523 524 if ( d[2] == ROAR_RESET_FLAG ) { 525 return streams_reset_flag(mes->stream, d[3]); 526 } else { 527 return streams_set_flag(mes->stream, d[3]); 528 } 529 530 return -1; 531 } 532 503 533 int req_on_kick (int client, struct roar_message * mes, char * data) { 504 534 uint16_t * info = (uint16_t *) mes->data; -
roard/streams.c
r1042 r1043 267 267 return -1; 268 268 269 if ( flag & ROAR_FLAG_PRIMARY ) { 270 streams_set_primary(id, 1); 271 flag -= ROAR_FLAG_PRIMARY; 272 } 273 269 274 g_streams[id]->flags |= flag; 270 275 276 if ( flag & ROAR_FLAG_META ) 277 stream_meta_finalize(id); 278 271 279 return 0; 272 280 } … … 275 283 if ( g_streams[id] == NULL ) 276 284 return -1; 285 286 if ( flag & ROAR_FLAG_PRIMARY ) { 287 streams_set_primary(id, 0); 288 flag -= ROAR_FLAG_PRIMARY; 289 } 277 290 278 291 g_streams[id]->flags |= flag;
Note: See TracChangeset
for help on using the changeset viewer.