# sd startup script # #--------------------------------------------------------------------- # # sd will invoke: # start_session when the user asks to 'open' (start) a session # create_session just after the user creates a new session # heard_session when announcement for a session is first heard # delete_session when the user or a timeout deletes a session # # When any of the above are invoked, the global array sd_sess # contains all the information about the session to be started: # sd_sess(name) # sd_sess(description) # sd_sess(address) # sd_sess(ttl) # sd_sess(creator) # sd_sess(creator_id) # sd_sess(source_id) # sd_sess(arrival_time) # sd_sess(start_time) # sd_sess(end_time) # sd_sess(attributes) (list of session attributes) # sd_sess(media) (list of media names) # # For each media name there is an array containing the information # about that media: # sd_$media(port) # sd_$media(conf_id) # sd_$media(attributes) (list of media attributes) # # Media and session attributes are strings of the form "name" or # "name:value". # # Some global state information is available in array sd_priv: # sd_priv(audio) (= 0 if audio disabled with -a) # sd_priv(video) (= 0 if video disabled with -v) # sd_priv(whiteboard) (= 0 if wb disabled with -w) # This version of ~/.sd.tcl is modified to support vic video. # # - vic is used (in nv/ivs compatability mode) instead of nv, ivs # or telesia. vic is also used, of course, in its `native' rtp v2 # mode for sessions of type "vic". # # - the audio startup is modified to establish a 'session bus' between # vat & vic for sessions where both audio & video are specified. # this allows the 'voice switched' window mode in vic to work. # # -- Van Jacobson & Steve McCanne # Tue Nov 29 06:11:41 PST 1994 # # further modifications: # - Invoke nevot_icc if the RTP option is applied or use_nevot is 1 # - Allow for -r flag, specified by RTP option (this should # be an exclusive option list like fmt:, but that wouldn't be # backwards-compatible). # # -- Lutz Henckel, Henning Schulzrinne, Bernd Deffner set ipc_chan 0 proc get_channel { confid } { global ipc_tab ipc_chan if { [info exists ipc_tab($confid)] } { return $ipc_tab($confid) } incr ipc_chan if { $ipc_chan > 300 } { set ipc_chan 1 } set ipc_tab($confid) $ipc_chan return $ipc_chan } proc start_session {} { global sd_sess sd_priv mosaic # start up Mosaic if there is a URL in the description. if {[regexp {[a-zA-Z]+://[^ ]+} $sd_sess(description) url]} { foreach process [split [exec ps -g] "\n" ] { if {[regexp "(\[0-9]+).*$mosaic" $process junk pid]} { break } } if {[info exists pid]} { set mctrl [open "/tmp/Mosaic.$pid" w] puts $mctrl goto puts $mctrl $url close $mctrl exec kill -30 $pid exec rm /tmp/Mosaic.$pid } else { exec $mosaic $url & } } # invoke the appropriate start proc for each of the media # if such a proc exists and that media is enabled. foreach m $sd_sess(media) { if { [llength [info proc start_$m]] && $sd_priv($m) } { start_$m } } } proc start_audio {} { global sd_sess sd_audio sd_video set audiofmt "" set packetfmt "-n" set mode "-c" foreach a $sd_audio(attributes) { case $a { fmt:* { set audiofmt [string range $a 4 end] } vt { set packetfmt "-v" } rtp { set packetfmt "-r" } } } set confaddr [format "%s/%s/%s/%s/%s" $sd_sess(address) \ $sd_audio(port) $sd_audio(conf_id) $audiofmt $sd_sess(ttl)] global nevot_icc vat use_nevot if {[lsearch $sd_sess(media) video] >= 0} { # session supports also video set chan [get_channel $sd_sess(address)/$sd_video(port)] if {$use_nevot || $packetfmt=="-r"} { exec $nevot_icc -I $chan -C $sd_sess(name) $packetfmt \ $mode $confaddr & } else { exec $vat -C $sd_sess(name) -N "Bernd Deffner (GMD FOKUS)" \ $packetfmt $mode $confaddr & } } else { # only audio if {$use_nevot || $packetfmt=="-r"} { exec $nevot_icc -C $sd_sess(name) $packetfmt $mode \ $confaddr & } else { exec $vat -C $sd_sess(name) -N "Bernd Deffner (GMD FOKUS)" \ $packetfmt $mode $confaddr & } } } proc start_video {} { global sd_sess sd_video use_ivs set videofmt "vic" foreach a $sd_video(attributes) { case $a { fmt:* { set videofmt [string range $a 4 end] } } } case $videofmt { vic { global vic if {[lsearch $sd_sess(media) audio] >= 0} { set chan [get_channel $sd_sess(address)/$sd_video(port)] exec nice $vic -I $chan -A $videofmt -t $sd_sess(ttl) \ -C $sd_sess(name) -N "Bernd Deffner (GMD FOKUS)" \ $sd_sess(address)/$sd_video(port) & } else { exec nice $vic -A $videofmt -t $sd_sess(ttl) \ -C $sd_sess(name) -N "Bernd Deffner(GMDFOKUS)" \ $sd_sess(address)/$sd_video(port) & } return } nv { global nv exec $nv -ttl $sd_sess(ttl) $sd_sess(address) \ $sd_video(port) -name "Bernd Deffner (GMD FOKUS)" & return } telesia { global telesia exec $telesia -I $sd_sess(address)/$sd_video(port) \ -P -T $sd_sess(ttl) & return } ivs { if { $use_ivs } { global ivs exec nice $ivs -a -r -T $sd_sess(ttl) \ $sd_sess(address)/$sd_video(port) & return } } jpg { global imm exec nice $imm -p $sd_video(port) -I $sd_sess(address) - -ttl $sd_sess(ttl) -n $sd_sess(name) & return } default { puts "sd: unknown video format: $videofmt" return } } } proc start_whiteboard {} { global sd_sess sd_whiteboard wb set orient -l set recvonly +r foreach a $sd_whiteboard(attributes) { case $a { orient:portrait { set orient -p } orient:landscape { set orient -l } orient:seascape { set orient +l } recvonly { set recvonly -r } } } exec $wb -t $sd_sess(ttl) -C wb:$sd_sess(name) $orient \ -N "Bernd Deffner (GMD FOKUS)" \ $recvonly $sd_sess(address)/$sd_whiteboard(port) & } proc create_session {} { } proc heard_session {} { } proc delete_session {} { } # set up media option menus for new session window. set sd_menu(audio) "fmt: pcm idvi gsm lpc4\nvt\nrtp" set sd_menu(video) "fmt: vic nv ivs telesia mmc" set sd_menu(whiteboard) "orient: portrait landscape seascape\nrecvonly" # set up the command names set vat vat set nv nv set vic vic set ivs ivs set wb wb set imm imm set mosaic netscape set telesia telesia set use_ivs 1 set nevot_icc "nevot_icc" # invoke always nevot instead of vat if use_nevot equals 1 set use_nevot 1