1 # archive-system-mon.tcl --
2 #
3 # FIXME: This file needs a description here.
4 #
5 # Copyright (c) 1999-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/archive/archive-system-mon.tcl,v 1.4 2002/02/03 04:25:07 lim Exp $
32
33
34 import ArchiveSystem/Record Observer Observable
35
36 # Used in distribued recording and any other applications which need
37 # notification of recording quality
38 Class ArchiveSystem/Record/Monitored -superclass {ArchiveSystem/Record Observer Observable}
39
40 # Notification from rtp-record that a new stream has appeared
41 ArchiveSystem/Record/Monitored public new_stream { stream } {
42
43 $self instvar streams_ threshold_
44
45 lappend streams_ $stream
46 $stream attach_observer $self
47 if { [info exists threshold_] } {
48 # Ask to be notified if the error rate rises above threshold
49 $stream set_trigger $threshold_ 1
50 }
51
52 }
53
54 ArchiveSystem/Record/Monitored public record_rtp_session { spec media tag } {
55 $self instvar sessions_
56
57 $self next $spec $media $tag
58 set session [lindex $sessions_ end]
59 $session attach_observer $self
60 }
61
62 ArchiveSystem/Record/Monitored public record_program { program tag } {
63
64 $self instvar program_
65
66 set program_ $program
67 $self next $program $tag
68
69 }
70
71 # Called from Aries
72 ArchiveSystem/Record/Monitored public get_ssd {} {
73 $self instvar sessions_ streams_
74
75 set erlist ""
76 # Do we need to id the session too?
77 if [info exists streams_] {
78 foreach s $streams_ {
79 set er [$s error_rate]
80 set stream_ssrc [$s ssrc]
81 #puts "ER: $er SSRC: $stream_ssrc"
82 set erlist "$stream_ssrc $er\n$erlist"
83 }
84 }
85 #puts "%%%%%%%%%%%%%%%%%%%%%%%"
86 #puts $erlist
87 #puts "%%%%%%%%%%%%%%%%%%%%%%%"
88 return $erlist
89 }
90
91
92 # Called by application to set an error threshold for notification
93 # threshold is checked in rtp-record.cc. Used to trigger distributed
94 # recording
95 ArchiveSystem/Record/Monitored public set_thresh {thresh} {
96 $self instvar threshold_
97
98 set threshold_ $thresh
99
100 }
101
102 # Called from rtp-record.cc. location should be the nearest platform to
103 # the source.
104 ArchiveSystem/Record/Monitored public loc {location ssrc} {
105 $self instvar loc_
106 set loc_($ssrc) $location
107 }
108
109 # Called from rtp-record.cc. Fallen below the thresh set in set_thresh.
110 ArchiveSystem/Record/Monitored public below_thresh {ssrc} {
111 $self instvar streams_ program_ threshold_ loc_
112
113 if [info exists streams_] {
114 foreach s $streams_ {
115 set stream_ssrc [$s ssrc]
116 # Need to know which stream notified us
117 if {$stream_ssrc == $ssrc && [info exists loc_($ssrc)]} {
118 $self notify_observers higher_quality $program_ $loc_($ssrc)
119 $s set_trigger $threshold_ 1
120 }
121 }
122 }
123 }
124
125
126 # Called from rtp-record.cc. Risen above the thresh set in set_thresh.
127 ArchiveSystem/Record/Monitored public above_thresh {ssrc} {
128 $self instvar streams_ program_ threshold_ loc_
129
130 if [info exists streams_] {
131 foreach s $streams_ {
132 set stream_ssrc [$s ssrc]
133 # Need to know which stream notified us
134 if {$stream_ssrc == $ssrc && [info exists loc_($ssrc)]} {
135
136 $self notify_observers low_quality $program_ $loc_($ssrc)
137 $s set_trigger $threshold_ 0
138 }
139 }
140 }
141 }
142
143
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.