Sample Startup File for sd


# $Id /home/irb/elkner/RCS/.sd.tcl,v 1.3 1996/01/03 21:30:15 elkner Exp elkner $ (IRB)
#
# NOTE: This file is provided for reference purposes.  The code
#       shown here is compiled into sd.  DON'T use this as your
#     sd startup file (~/.sd.tcl).
#
# tcl 'hooks' invoked when sd takes some action on a session.
#
# 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)
 
 
proc start_audio {} {
        global sd_sess sd_audio
        set audiofmt ""
        set packetfmt "-n"
        foreach a $sd_audio(attributes) {
                case $a {
                        fmt:* { set audiofmt [string range $a 4 end] }
                        vt  { set packetfmt "-v" }
                }
        }
        set confaddr [format "%s/%s/%s/%s/%s" $sd_sess(address) \
                $sd_audio(port) $sd_audio(conf_id) $audiofmt $sd_sess(ttl)]
 
        global vat
        exec $vat -C $sd_sess(name) $packetfmt $confaddr &
}

proc start_video {} {
    global sd_sess sd_video
    set videofmt "h261"
    foreach a $sd_video(attributes) {
	case $a {
	    fmt:* { set videofmt [string range $a 4 end] }
	}
    }
    switch -regexp $videofmt {
	(vic | nvdct | cellb | jpeg | h261 | bvc) {
	    global vic
	    exec $vic -C $sd_sess(name) -t $sd_sess(ttl) \
		    $sd_sess(address)/$sd_video(port) &
	}    
	nv {
	    global nv
	    exec nv -ttl $sd_sess(ttl) $sd_sess(address) \
		    $sd_video(port) $sd_video(conf_id) &
	}
	ivs {
	    global ivs
	    exec $ivs -t $sd_sess(ttl) \
		    $sd_sess(address)/$sd_video(port) &
	}
	jpg | imm {
	    global imm
	    exec $imm -p $sd_video(port) -I $sd_sess(address) \
		    -ttl $sd_sess(ttl) -n $sd_sess(name) &
	}
    }
}

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 -C wb:$sd_sess(name) -t $sd_sess(ttl) $orient \
	    $recvonly -P 100000 $sd_sess(address)/$sd_whiteboard(port) &
}
 
# set up media option menus for new session window.
set sd_menu(video) "fmt: nv nvdct cellb jpeg h261 bvc vic ivs"
set sd_menu(audio) "fmt: pcm pcm2 pcm4 dvi dvi2 dvi4 gsm lpc4\nvt"
set sd_menu(whiteboard) "orient: portrait landscape seascape\nrecvonly"

# set up the command names
set imm imm
set vic vic
set vat vat
set nv nv
set wb wb