7 Copyright (c) 1997 by Be Incorporated. All Rights Reserved.
11 #ifndef _MEDIA_MODULE_H
12 #define _MEDIA_MODULE_H
17 typedef double mk_time
;
18 typedef double mk_rate
;
19 typedef void (*mk_deferred_call
)(void*);
21 #define B_UNDEFINED_MK_TIME ((mk_time) -1)
23 enum transport_status
{
29 enum channel_selector
{
31 B_VIDEO_MONITOR_CHANNEL
,
32 B_AUDIO_FRONT_CHANNEL
,
33 B_AUDIO_CENTER_CHANNEL
,
36 B_AUDIO_MONITOR_CHANNEL
,
51 virtual ~BMediaEvent() {};
52 virtual mk_time
Start() = 0;
53 virtual mk_time
Duration();
54 virtual bigtime_t
CaptureTime();
61 virtual ~BEventStream();
63 virtual mk_time
Start();
64 virtual void SetStart(mk_time
);
65 virtual mk_time
Duration();
66 virtual void SetDuration(mk_time
);
67 virtual BMediaEvent
* GetEvent(BMediaChannel
* channel
) = 0;
68 virtual BMediaEvent
* PeekEvent(BMediaChannel
* channel
,
69 mk_time asap
= 0) = 0;
70 virtual status_t
SeekToTime(BMediaChannel
* channel
,
79 class BMediaRenderer
{
81 BMediaRenderer(const char* name
= NULL
, int32 priority
= B_NORMAL_PRIORITY
);
82 virtual ~BMediaRenderer();
85 virtual mk_time
Latency();
86 virtual BTransport
* Transport();
87 virtual void SetTransport(BTransport
*);
88 virtual mk_time
Start();
89 virtual mk_time
Duration();
90 virtual BTimeBase
* TimeBase();
94 virtual void WakeUp();
95 virtual void TransportChanged(mk_time time
, mk_rate rate
,
96 transport_status status
);
97 virtual void StreamChanged();
99 virtual void OpenReceived();
100 virtual void CloseReceived();
101 virtual void WakeUpReceived();
102 virtual void TransportChangedReceived(mk_time time
, mk_rate rate
,
103 transport_status status
);
104 virtual void StreamChangedReceived();
107 static int32
_LoopThread(void* arg
);
110 thread_id fLoopThread
;
115 transport_status fTCStatus
;
119 BTransport
* fTransport
;
126 virtual ~BTransport();
128 virtual BTimeBase
* TimeBase();
129 virtual void SetTimeBase(BTimeBase
*);
130 virtual BList
* Renderers();
131 virtual void AddRenderer(BMediaRenderer
*);
132 virtual bool RemoveRenderer(BMediaRenderer
*);
133 virtual transport_status
Status();
134 virtual void SetStatus(transport_status
);
135 virtual mk_time
PerformanceTime();
136 virtual mk_rate
PerformanceRate();
137 virtual mk_time
TimeOffset();
138 virtual void SetTimeOffset(mk_time
);
139 virtual mk_time
MaximumLatency();
140 virtual mk_time
PerformanceStart();
141 virtual mk_time
PerformanceEnd();
143 virtual void Close();
144 virtual void TransportChanged();
145 virtual void TimeSkipped();
146 virtual void RequestWakeUp(mk_time
, BMediaRenderer
*);
147 virtual void SeekToTime(mk_time
);
148 virtual BMediaChannel
* GetChannel(int32 selector
);
151 BTimeBase
* fTimeBase
;
154 BLocker fChannelListLock
;
155 transport_status fStatus
;
162 BTimeBase(mk_rate rate
= 1.0);
163 virtual ~BTimeBase();
165 virtual BList
* Transports();
166 virtual void AddTransport(BTransport
*);
167 virtual bool RemoveTransport(BTransport
*);
168 virtual void TimeSkipped();
169 virtual status_t
CallAt(mk_time time
, mk_deferred_call function
, void* arg
);
170 virtual mk_time
Time();
171 virtual mk_rate
Rate();
172 virtual mk_time
TimeAt(bigtime_t system_time
);
173 virtual bigtime_t
SystemTimeAt(mk_time time
);
174 virtual void Sync(mk_time time
, bigtime_t system_time
);
175 virtual bool IsAbsolute();
178 static int32
_SnoozeThread(void* arg
);
182 BList fDeferredCalls
;
187 mk_time fSnoozeUntil
;
188 thread_id fSnoozeThread
;
192 class BMediaChannel
{
194 BMediaChannel(mk_rate rate
,
195 BMediaRenderer
* renderer
= NULL
,
196 BEventStream
* source
= NULL
);
197 virtual ~BMediaChannel();
199 virtual BMediaRenderer
* Renderer();
200 virtual void SetRenderer(BMediaRenderer
*);
201 virtual BEventStream
* Source();
202 virtual void SetSource(BEventStream
*);
203 virtual mk_rate
Rate();
204 virtual void SetRate(mk_rate
);
206 status_t
LockWithTimeout(bigtime_t
);
207 void UnlockChannel();
208 virtual void StreamChanged();
212 BMediaRenderer
* fRenderer
;
213 BEventStream
* fSource
;
214 BLocker fChannelLock
;