~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/indiva/services/ive/ive-application.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 # ive-application.tcl --
  2 #
  3 #   Application class for indiva video encoder.
  4 #
  5 # Copyright (c) 1996-2002 The Regents of the University of California.
  6 # All rights reserved.
  7 #
  8 # Redistribution and use in source and binary forms, with or without
  9 # modification, are permitted provided that the following conditions are met:
 10 #
 11 # A. Redistributions of source code must retain the above copyright notice,
 12 #    this list of conditions and the following disclaimer.
 13 # B. Redistributions in binary form must reproduce the above copyright notice,
 14 #    this list of conditions and the following disclaimer in the documentation
 15 #    and/or other materials provided with the distribution.
 16 # C. Neither the names of the copyright holders nor the names of its
 17 #    contributors may be used to endorse or promote products derived from this
 18 #    software without specific prior written permission.
 19 #
 20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 23 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 #
 31 # @(#) $Header: /usr/mash/src/repository/mash/mash-1/tcl/indiva/services/ive/ive-application.tcl,v 1.5 2002/07/18 23:06:37 weitsang Exp $
 32 
 33 import IndivaServiceApplication
 34 import IVEVideoAgent
 35 import IVEService
 36 
 37 Class IVEApplication -superclass IndivaServiceApplication
 38 
 39 #---------------------------------------------------------------------
 40 # Class:
 41 #   IVEApplication init
 42 # Description:
 43 #   Initialize the IVE application by creating a video agent and a 
 44 #   indiva service.
 45 #---------------------------------------------------------------------
 46 # There are two ways ive can be executed.  It can either run and transmit
 47 # immediately (if "-transmit 1" is given) or run and wait for "start"
 48 # RPC call.  In either case, we create an IVEVideoAgent and an
 49 # IVEService. If we want to transmit immediately, we call the "start"
 50 # RPC call on IVEService ourselves.  Note that we passed in $dest and 
 51 # $fmt twice, first into IVEVideoAgent, then override it in IVEService.  
 52 # This is because the way VideoAgent's and VideoPipeline's API are designed.  
 53 # You cannot create new agent without address and cannot open device 
 54 # without format.
 55 #
 56 IVEApplication instproc init { argv } {
 57     set o [$self options]
 58     $self init_args $o
 59     $self init_resources $o
 60     $self next $argv "ive"
 61     
 62     set dest [$self get_option dest]
 63     set dev  [$self get_option device]
 64     set port [$self get_option port]
 65     set fmt  [$self get_option format]
 66 
 67     $self instvar agent_ 
 68     set agent_ [new IVEVideoAgent $self $dest $dev $port $fmt]
 69 
 70     if {[$self get_option transmit]} {
 71         set service [$self new_service]
 72         set norm [$self get_option norm]
 73         set q    [$self get_option q]
 74         set fps  [$self get_option fps]
 75         set bps  [$self get_option bps]
 76         $service start $dest $fmt $norm $q $fps $bps
 77     }
 78 
 79     $self on_exit "$agent_ shutdown"
 80 }
 81 
 82 IVEApplication instproc init_args { o } {
 83     $o add_default dest "224.4.4.4/4444"
 84     $o add_default format "h261"
 85     $o add_default size "qcif"
 86     $o add_default quality "80"
 87     $o add_default bps "128000"
 88     $o add_default fps "15"
 89     $o add_default device ""  
 90     $o add_default port ""
 91     $o add_default norm "ntsc"
 92     $o add_default transmit ""
 93     $o add_default cname "ive:[pid]@[info hostname]"
 94     $o add_default rtpName "Indiva Video Encoder"
 95     $o add_default rtpEmail "indiva@[info hostname]"
 96 }
 97 
 98 IVEApplication instproc init_resources { o } {
 99     $o register_option -dest dest
100     $o register_option -fmt  format
101     $o register_option -size size
102     $o register_option -q    quality
103     $o register_option -bps  bps
104     $o register_option -fps  fps
105     $o register_option -dev  device
106     $o register_option -port port
107     $o register_option -norm norm
108     $o register_option -transmit transmit
109     $o register_option -rtpname rtpName
110     $o register_option -rtpemail rtpEmail
111 }
112 
113 
114 IVEApplication instproc new_service {} {
115     $self instvar service_ manager_ agent_
116     if {[info exists manager_]} {
117         set s [new IVEService $agent_ $manager_]
118     } else {
119         set s [new IVEService $agent_ ""]
120     }
121     set service_([$s service_id]) $s
122     return $s
123 }
124 
125 
126 IVEApplication instproc get_service {agent_id} {
127     $self instvar service_
128     if [info exists service_($agent_id)] {
129         return $service_($agent_id)
130     } else {
131         return ""
132     }
133 }
134 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.