1 /*
2 * mb-play.h --
3 *
4 * MediaBoard Playback header
5 *
6 * Copyright (c) 1997-2002 The Regents of the University of California.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * A. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 * B. Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * C. Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
22 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 * @(#) $Header: /usr/mash/src/repository/mash/mash-1/archive/mb-play.h,v 1.13 2002/02/03 03:09:26 lim Exp $
34 */
35
36 #ifndef MASH_MB_PLAY_H
37 #define MASH_MB_PLAY_H
38
39
40 #include "archive/archive-stream.h"
41 #include "archive/mb-archive.h"
42 #include "mb/mb-obj.h"
43
44
45 class MBPlaybackRcvr;
46
47
48 class MBPlaybackStream : public PlaybackStream {
49 public:
50 MBPlaybackStream()
51 : PlaybackStream(), rcvr_(NULL), firstTime_(TRUE), endTS_(0) {}
52 virtual ~MBPlaybackStream() { }
53
54 void attach(MBPlaybackRcvr *rcvr) { rcvr_ = rcvr; }
55
56
57 virtual void LTS_Speed();
58 virtual void LTS_Reference();
59
60 virtual void Clip(timeval start, timeval end);
61 // obtain the timeout value for the next event
62 // returns: FALSE when I'm done
63 virtual int NextEvent(timeval &logical);
64 virtual void DoEvent(); // do the next event
65
66 private:
67 int ReadRecord();
68
69
70 MBPlaybackRcvr *rcvr_;
71 Bool firstTime_;
72 u_int32_t endTS_;
73
74 struct StreamState {
75 StreamState()
76 : pPage(NULL), seqno(1), sseq(0), eseq(0),
77 pb(NULL), bufferLen(0) {
78 // set seqno > eseq, so that when NextEvent()
79 // is called for the first time, it goes out
80 // and fetches the next record
81 }
82
83 MBPageObject *pPage;
84 u_int32_t seqno, sseq, eseq;
85 DataBuffer buffer;
86 Byte *pb;
87 int bufferLen;
88 };
89 StreamState state;
90
91 };
92
93
94 class MBPlaybackRcvr : public MBBaseRcvr {
95 public:
96 MBPlaybackRcvr(MBBaseMgr *pMgr, const SrcId &srcId)
97 : MBBaseRcvr(pMgr, srcId), stream_(NULL), bytesSent_(0) { }
98 ~MBPlaybackRcvr() { }
99
100 void attach(MBPlaybackStream *stream) {
101 stream_ = stream;
102 }
103
104 private:
105 virtual int executeCmd(MBCmd * /*pCmd*/, MBPageObject * /*pPage*/,
106 const MBTime& /*oldTime*/,
107 const MBTime& /*newTime*/)
108 {
109 // don't do anything!
110 return MB_EXE_OK;
111 }
112 virtual int handleCmd(MBCmd *pCmd, MBPageObject *pPage,
113 const MBTime& oldTime, const MBTime& newTime);
114 Bool Dispatch(MBCmd *pCmd, MBPageObject *pPage);
115
116 MBPlaybackStream *stream_;
117 u_int32_t bytesSent_;
118 friend class MBPlaybackStream;
119 };
120
121
122
123 class MBPlaybackMgr : public MBBaseMgr {
124 public:
125 MBPlaybackMgr()
126 : MBBaseMgr(), sources_(NULL), nextADUIdx_(NULL),
127 fillSAIdx_(NULL) { }
128 ~MBPlaybackMgr() {
129 // FIXME: need to delete all sources!
130 }
131 // virtual SRM_AppMgr functions
132 virtual int next_ADU(u_char *db, int len, srm_src &id,
133 int &pkt_type, int &next);
134 int create_srm_source(int argc, const char * const *artgv);
135
136 private:
137 virtual void handle_reply(Byte * /*pb*/, int /*len*/) { }
138 virtual int periodic_update(Byte *pb);
139
140 virtual Bool isVisible(const PageId &/*pgId*/) {
141 // all pages are considered "visible", so SRM can make a
142 // repair-request if it needs one
143 return TRUE;
144 }
145
146 virtual void activity(MBPageObject* /*pPage*/,
147 MBCmd* /*pCmd*/) {}
148
149 virtual MBBaseRcvr *NewReceiver(const SrcId &srcId, Bool isLocal) {
150 if (isLocal==FALSE) {
151 // we wish to ignore all remote receivers!
152 return NULL;
153 }
154 else {
155 return new MBPlaybackRcvr(this, srcId);
156 }
157
158 }
159
160 virtual MBPageObject *NewPageObject(const PageId &pageId,
161 Bool /*newPage*/) {
162 return new MBPageObject(this, pageId);
163 }
164
165 List<SRM_Source> *sources_;
166 ListIndex nextADUIdx_, fillSAIdx_;
167 };
168
169
170
171 #endif /* MASH_MB_PLAY_H */
172
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.