1 # mb-record.tcl --
2 #
3 # FIXME: This file needs a description here.
4 #
5 # Copyright (c) 1997-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/recorder/mb-record.tcl,v 1.20 2002/02/03 04:25:14 lim Exp $
32
33
34 # MB_Manager/Record isn't implemented yet.
35 #
36 #import SRMAgent ArchiveSession/Record \
37 # ArchiveSession/Record/Mediaboard AddressBlock \
38 # MB_Manager/Record ArchiveStream/Record
39
40 import SRMAgent ArchiveSession/Record \
41 ArchiveSession/Record/Mediaboard AddressBlock \
42 ArchiveStream/Record
43
44 # Implements recording functionality for the mediaboard application.
45 # Eventually, there should be a SRM recorder which specializes to
46 # mediaboard.
47 # Status: Beta
48 # Author: Yatin Chawathe
49
50 # MB_Manager/Record isn't implemented yet.
51 #
52 #Class ArchiveSession/Record/Mediaboard \
53 # -superclass {ArchiveSession/Record MB_Manager/Record}
54 Class ArchiveSession/Record/Mediaboard \
55 -superclass {ArchiveSession/Record}
56 Class ArchiveSession/Record/SRM -superclass ArchiveSession/Record/Mediaboard
57
58 ArchiveSession/Record/Mediaboard instproc init { media addr } {
59 $self next $media
60 $self instvar session_ sm_ agent_
61
62 set agent_ [new SRMAgent 0xFFFFFF]
63 set session_ [$agent_ create-session $self $self]
64
65 $self reset $addr
66 $self attach_session $session_
67
68 # global mb
69 # set mb(debug) [new Debug $self 0]
70 }
71
72
73 ArchiveSession/Record/Mediaboard instproc destroy { } {
74 $self instvar agent_
75 delete $agent_
76 $self next
77 }
78
79
80 ArchiveSession/Record/Mediaboard instproc reset { addr } {
81 $self instvar session_ agent_
82 set had_network [$agent_ have_network]
83 set ab [new AddressBlock $addr]
84 $agent_ reset $ab
85 delete $ab
86 set net [$agent_ set network_]
87 [$net data-net] loopback 1
88 [$net ctrl-net] loopback 1
89
90 # do this for the first time only
91 if !$had_network {
92 $session_ start_timers
93 }
94 }
95
96
97 ArchiveSession/Record/Mediaboard instproc srm_session { } {
98 return [$self set session_]
99 }
100
101
102 ArchiveSession/Record/Mediaboard instproc srm_source_mgr { } {
103 return [$self set sm_]
104 }
105
106
107 ArchiveSession/Record/Mediaboard instproc new_source { src } {
108 }
109
110
111 ArchiveStream/Record/Mediaboard instproc init { session } {
112 $self next $session
113 $self init_file_header
114
115 # schedule a timer for every 2 seconds to write the header
116 $self set after_id_ [after 2000 "$self do_periodic"]
117 }
118
119
120 ArchiveStream/Record/Mediaboard instproc destroy { } {
121 $self instvar after_id_
122 if [info exists after_id_] {
123 after cancel $after_id_
124 unset after_id_
125 }
126 $self next
127 }
128
129
130 ArchiveStream/Record/Mediaboard private do_periodic { } {
131 # write the headers to the data and index files (do so only if
132 # something has changed)
133 $self write_headers
134 $self set after_id_ [after 2000 "$self do_periodic"]
135 }
136
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.