Changeset 2058
- Timestamp:
- 10/22/98 16:32:04 (15 years ago)
- Location:
- rat/trunk
- Files:
-
- 7 modified
-
README.mbus (modified) (1 diff)
-
audio.c (modified) (1 diff)
-
mbus_engine.c (modified) (7 diffs)
-
session.c (modified) (3 diffs)
-
ui.c (modified) (5 diffs)
-
ui.h (modified) (1 diff)
-
ui_audiotool.tcl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
rat/trunk/README.mbus
r2057 r2058 180 180 Used in the initialisation process. 181 181 182 tool.rat.interleaving183 182 tool.rat.codec 184 183 tool.rat.codec.supported 185 tool.rat.redundancy186 184 tool.rat.redundancy.supported 187 185 188 186 Control which codecs are used for transmission. Should be replaced 189 by audio.channel.coding, audio.channel.repair,etc.187 by audio.channel.coding, etc. 190 188 191 189 tool.rat.converter -
rat/trunk/audio.c
r2044 r2058 376 376 channel_set_coder(sp, sp->encodings[0]); 377 377 } 378 379 ui_update(sp);380 378 } 381 379 -
rat/trunk/mbus_engine.c
r2057 r2058 696 696 } 697 697 698 static void699 rx_tool_rat_interleaving(char *srce, char *args, session_struct *sp)700 {701 int units, separation, cc_pt;702 char config[80];703 704 UNUSED(srce);705 706 mbus_parse_init(sp->mbus_engine_conf, args);707 if (mbus_parse_int(sp->mbus_engine_conf, &units) &&708 mbus_parse_int(sp->mbus_engine_conf, &separation)) {709 cc_pt = get_cc_pt(sp,"INTERLEAVER");710 sprintf(config, "%d/%d", units, separation);711 debug_msg("config %s\n", config);712 config_channel_coder(sp, cc_pt, config);713 } else {714 printf("mbus: usage \"tool.rat.interleaving <codec> <separation in units>\"\n");715 }716 mbus_parse_done(sp->mbus_engine_conf);717 ui_update_interleaving(sp);718 }719 720 static codec_t*721 validate_redundant_codec(codec_t *primary, codec_t *redundant)722 {723 assert(primary != NULL);724 725 if ((redundant == NULL) || /* passed junk */726 (!codec_compatible(primary, redundant)) || /* passed incompatible codec */727 (redundant->unit_len > primary->unit_len)) { /* passed higher bandwidth codec */728 return primary;729 }730 return redundant;731 }732 733 static void734 rx_tool_rat_redundancy(char *srce, char *args, session_struct *sp)735 {736 char *codec;737 int offset, cc_pt, rpt;738 char config[80];739 codec_t *rcp, *pcp;740 741 UNUSED(srce);742 743 mbus_parse_init(sp->mbus_engine_conf, args);744 if (mbus_parse_str(sp->mbus_engine_conf, &codec) &&745 mbus_parse_int(sp->mbus_engine_conf, &offset)) {746 if (offset<=0) offset = 0;;747 pcp = get_codec_by_pt(sp->encodings[0]);748 rpt = codec_matching(mbus_decode_str(codec), pcp->freq, pcp->channels);749 if (rpt != -1) {750 rcp = get_codec_by_pt(rpt);751 } else {752 /* Specified secondary codec doesn't exist. Make it the same */753 /* as the primary, and hope that's a sensible choice. */754 rcp = pcp;755 }756 assert(rcp != NULL);757 /* Check redundancy makes sense... */758 rcp = validate_redundant_codec(pcp,rcp);759 sprintf(config,"%s/0/%s/%d", pcp->name, rcp->name, offset);760 debug_msg("Configuring redundancy %s\n", config);761 cc_pt = get_cc_pt(sp,"REDUNDANCY");762 config_channel_coder(sp, cc_pt, config);763 } else {764 printf("mbus: usage \"tool.rat.redundancy <codec> <offset in units>\"\n");765 }766 mbus_parse_done(sp->mbus_engine_conf);767 ui_update_redundancy(sp);768 }769 770 698 static void 771 699 rx_tool_rat_codec(char *srce, char *args, session_struct *sp) … … 813 741 sp->encodings[0] = pt; 814 742 ui_update_primary(sp); 815 ui_update_redundancy(sp);816 743 } else { 817 744 /* just register we want to make a change */ … … 919 846 } 920 847 848 static codec_t* 849 validate_redundant_codec(codec_t *primary, codec_t *redundant) 850 { 851 assert(primary != NULL); 852 853 if ((redundant == NULL) || /* passed junk */ 854 (!codec_compatible(primary, redundant)) || /* passed incompatible codec */ 855 (redundant->unit_len > primary->unit_len)) { /* passed higher bandwidth codec */ 856 return primary; 857 } 858 return redundant; 859 } 860 921 861 static void rx_audio_channel_coding(char *srce, char *args, session_struct *sp) 922 862 { 923 char *channel; 863 char *channel, *codec; 864 int units, separation, cc_pt, offset, rpt; 865 char config[80]; 866 codec_t *rcp, *pcp; 924 867 925 868 UNUSED(srce); … … 932 875 } else if (strcmp(channel, "redundant") == 0) { 933 876 channel_set_coder(sp, get_cc_pt(sp, "REDUNDANCY")); 877 if (mbus_parse_str(sp->mbus_engine_conf, &codec) && mbus_parse_int(sp->mbus_engine_conf, &offset)) { 878 if (offset<=0) offset = 0;; 879 pcp = get_codec_by_pt(sp->encodings[0]); 880 rpt = codec_matching(mbus_decode_str(codec), pcp->freq, pcp->channels); 881 if (rpt != -1) { 882 rcp = get_codec_by_pt(rpt); 883 } else { 884 /* Specified secondary codec doesn't exist. Make it the same */ 885 /* as the primary, and hope that's a sensible choice. */ 886 rcp = pcp; 887 } 888 assert(rcp != NULL); 889 /* Check redundancy makes sense... */ 890 rcp = validate_redundant_codec(pcp,rcp); 891 sprintf(config,"%s/0/%s/%d", pcp->name, rcp->name, offset); 892 debug_msg("Configuring redundancy %s\n", config); 893 cc_pt = get_cc_pt(sp,"REDUNDANCY"); 894 config_channel_coder(sp, cc_pt, config); 895 } else { 896 printf("mbus: usage \"audio.channel.coding \"redundant\" <codec> <offset in units>\"\n"); 897 } 934 898 } else if (strcmp(channel, "interleaved") == 0) { 935 channel_set_coder(sp, get_cc_pt(sp, "INTERLEAVER")); 899 cc_pt = get_cc_pt(sp,"INTERLEAVER"); 900 channel_set_coder(sp, cc_pt); 901 if (mbus_parse_int(sp->mbus_engine_conf, &units) && mbus_parse_int(sp->mbus_engine_conf, &separation)) { 902 sprintf(config, "%d/%d", units, separation); 903 config_channel_coder(sp, cc_pt, config); 904 } else { 905 printf("mbus: usage \"audio.channel.coding \"interleaved\" <units> <separation>\"\n"); 906 } 936 907 } else { 937 908 debug_msg("scheme %s not recognized\n", channel); … … 942 913 } 943 914 mbus_parse_done(sp->mbus_engine_conf); 915 ui_update_channel(sp); 944 916 } 945 917 … … 999 971 "tool.rat.converter", 1000 972 "tool.rat.settings", 1001 "tool.rat.interleaving",1002 "tool.rat.redundancy",1003 973 "tool.rat.codec", 1004 974 "tool.rat.sampling", … … 1052 1022 rx_tool_rat_converter, 1053 1023 rx_tool_rat_settings, 1054 rx_tool_rat_interleaving,1055 rx_tool_rat_redundancy,1056 1024 rx_tool_rat_codec, 1057 1025 rx_tool_rat_sampling, -
rat/trunk/session.c
r2044 r2058 409 409 config_channel_coder(sp[s], pt, argv[i+1]); 410 410 channel_set_coder(sp[s], pt); 411 ui_update_ interleaving(sp[s]);411 ui_update_channel(sp[s]); 412 412 } else { 413 413 printf("Can't determine interleaver payload type\n"); … … 426 426 config_channel_coder(sp[s], pt, cfg); 427 427 channel_set_coder(sp[s], pt); 428 ui_update_primary(sp[s]); 428 429 ui_update_channel(sp[s]); 429 ui_update_primary(sp[s]);430 ui_update_redundancy(sp[s]);431 430 i++; 432 431 } … … 484 483 } 485 484 ui_update_primary(sp[s]); 486 ui_update_redundancy(sp[s]);487 485 ui_update_channel(sp[s]); 488 486 i++; -
rat/trunk/ui.c
r2056 r2058 382 382 383 383 void 384 ui_update_interleaving(session_struct *sp)385 {386 int pt, isep, iu;387 char buf[128], *sep=NULL, *units = NULL, *dummy, args[80];388 389 pt = get_cc_pt(sp,"INTERLEAVER");390 if (pt != -1) {391 query_channel_coder(sp, pt, buf, 128);392 dummy = strtok(buf,"/");393 units = strtok(NULL,"/");394 sep = strtok(NULL,"/");395 } else {396 debug_msg("Could not find interleaving channel coder!\n");397 }398 399 if (units != NULL && sep != NULL) {400 iu = atoi(units);401 isep = atoi(sep);402 } else {403 iu = 4;404 isep = 4;405 }406 407 sprintf(args,"%d %d",iu, isep);408 mbus_qmsg(sp->mbus_engine_base, mbus_name_ui, "tool.rat.interleaving", args, TRUE);409 }410 411 void412 384 ui_update_frequency(session_struct *sp) 413 385 { … … 457 429 } 458 430 459 void 431 static void 432 ui_update_interleaving(session_struct *sp) 433 { 434 int pt, isep, iu; 435 char buf[128], *sep=NULL, *units = NULL, *dummy, args[80]; 436 437 pt = get_cc_pt(sp,"INTERLEAVER"); 438 if (pt != -1) { 439 query_channel_coder(sp, pt, buf, 128); 440 dummy = strtok(buf,"/"); 441 units = strtok(NULL,"/"); 442 sep = strtok(NULL,"/"); 443 } else { 444 debug_msg("Could not find interleaving channel coder!\n"); 445 } 446 447 if (units != NULL && sep != NULL) { 448 iu = atoi(units); 449 isep = atoi(sep); 450 } else { 451 iu = 4; 452 isep = 4; 453 } 454 455 sprintf(args,"\"interleaved\" %d %d",iu, isep); 456 mbus_qmsg(sp->mbus_engine_base, mbus_name_ui, "audio.channel.coding", args, TRUE); 457 } 458 459 static void 460 460 ui_update_redundancy(session_struct *sp) 461 461 { … … 495 495 codec_name = mbus_encode_str(codec_name); 496 496 497 args = (char *) xmalloc(strlen(codec_name) + 4);498 sprintf(args," %s %2d", codec_name, ioff);499 assert(strlen(args) < (strlen(codec_name) + 4));500 mbus_qmsg(sp->mbus_engine_base, mbus_name_ui, " tool.rat.redundancy", args, TRUE);497 args = (char *) xmalloc(strlen(codec_name) + 16); 498 sprintf(args,"\"redundant\" %s %2d", codec_name, ioff); 499 assert(strlen(args) < (strlen(codec_name) + 16)); 500 mbus_qmsg(sp->mbus_engine_base, mbus_name_ui, "audio.channel.coding", args, TRUE); 501 501 xfree(codec_name); 502 502 xfree(args); … … 507 507 { 508 508 cc_coder_t *ccp; 509 char *mbes = NULL;510 509 511 510 ccp = get_channel_coder(sp->cc_encoding); 512 assert(ccp != NULL); 513 switch(ccp->name[0]) { 514 case 'V': 515 mbes = mbus_encode_str("none"); 516 break; 517 case 'R': 518 mbes = mbus_encode_str("redundant"); 519 break; 520 case 'I': 521 mbes = mbus_encode_str("interleaved"); 522 break; 523 default: 524 debug_msg("Channel coding failed mapping.\n"); 525 return; 526 } 527 528 mbus_qmsg(sp->mbus_engine_base, mbus_name_ui, "audio.channel.coding", mbes, TRUE); 529 if (mbes) xfree(mbes); 511 if (strcmp(ccp->name, "VANILLA") == 0) { 512 mbus_qmsg(sp->mbus_engine_base, mbus_name_ui, "audio.channel.coding", "\"none\"", TRUE); 513 } else if (strcmp(ccp->name, "REDUNDANCY") == 0) { 514 ui_update_redundancy(sp); 515 } else if (strcmp(ccp->name, "INTERLEAVER") == 0) { 516 ui_update_interleaving(sp); 517 } else { 518 debug_msg("Channel coding failed mapping (%s)\n", ccp->name); 519 abort(); 520 } 530 521 } 531 522 … … 618 609 ui_update_channels(sp); 619 610 ui_update_primary(sp); 620 ui_update_redundancy(sp);621 ui_update_interleaving(sp);622 611 ui_update_channel(sp); 623 612 ui_repair(sp); -
rat/trunk/ui.h
r2055 r2058 69 69 void ui_update_output_port(struct session_tag *sp); 70 70 void ui_update_primary(struct session_tag *sp); 71 void ui_update_redundancy(struct session_tag *sp);72 void ui_update_interleaving(struct session_tag *sp);73 71 void ui_update_channel(struct session_tag *sp) ; 74 72 void ui_update_powermeters(struct session_tag *sp, struct s_mix_info *ms, int elapsed_time); -
rat/trunk/ui_audiotool.tcl
r2057 r2058 159 159 tool.rat.codec {eval mbus_recv_tool.rat.codec $args} 160 160 tool.rat.rate {eval mbus_recv_tool.rat.rate $args} 161 tool.rat.redundancy {eval mbus_recv_tool.rat.redundancy $args}162 tool.rat.interleaving {eval mbus_recv_tool.rat.interleaving $args}163 161 tool.rat.externalise {eval mbus_recv_tool.rat.externalise $args} 164 162 tool.rat.lecture.mode {eval mbus_recv_tool.rat.lecture.mode $args} … … 372 370 } 373 371 374 proc mbus_recv_tool.rat.redundancy {new_codec new_off} { 375 global secenc red_off 376 set secenc $new_codec 377 set red_off $new_off 378 } 379 380 proc mbus_recv_tool.rat.interleaving {units separation} { 381 global int_units int_gap 382 set int_units $units 383 set int_gap $separation 384 } 385 386 proc mbus_recv_audio.channel.coding {channel} { 387 global channel_var 372 proc mbus_recv_audio.channel.coding {channel args} { 373 global channel_var secenc red_off int_units int_gap 388 374 set channel_var $channel 375 switch $channel { 376 redundant { 377 set secenc [lindex $args 0] 378 set red_off [lindex $args 1] 379 } 380 interleaved { 381 set int_units [lindex $args 0] 382 set int_gap [lindex $args 1] 383 } 384 } 389 385 } 390 386 … … 1476 1472 global meter_var sync_var gain volume input_port output_port 1477 1473 global in_mute_var out_mute_var channels freq key key_var 1478 global audio_device1474 global audio_device 1479 1475 1480 1476 set my_cname_enc [mbus_encode_str $my_cname] … … 1488 1484 mbus_send "R" "tool.rat.codec" "[mbus_encode_str $prenc] [mbus_encode_str $channels] [mbus_encode_str $freq]" 1489 1485 mbus_send "R" "tool.rat.rate" $upp 1490 mbus_send "R" "tool.rat.redundancy" "[mbus_encode_str $secenc] $red_off" 1491 mbus_send "R" "tool.rat.interleaving" "$int_gap $int_units" 1492 1493 # channel.code announcement MUST go after config of channel coders communicated 1494 mbus_send "R" "audio.channel.coding" [mbus_encode_str $channel_var] 1486 1487 switch $channel_var { 1488 none {mbus_send "R" "audio.channel.coding" "[mbus_encode_str $channel_var]"} 1489 redundant {mbus_send "R" "audio.channel.coding" "[mbus_encode_str $channel_var] [mbus_encode_str $secenc] $red_off"} 1490 interleaved {mbus_send "R" "audio.channel.coding" "[mbus_encode_str $channel_var] $int_gap $int_units"} 1491 * {error "unknown channel coding scheme $channel_var"} 1492 } 1495 1493 1496 1494 mbus_send "R" "tool.rat.silence" $silence_var
