Isle
Loading...
Searching...
No Matches
mxmediapresenter.cpp
Go to the documentation of this file.
1#include "mxmediapresenter.h"
2
4#include "mxautolock.h"
6#include "mxdssubscriber.h"
7#include "mxmisc.h"
9#include "mxstreamchunk.h"
10#include "mxtimer.h"
11
15
16// FUNCTION: LEGO1 0x100b54e0
18{
19 this->m_subscriber = NULL;
20 this->m_loopingChunks = NULL;
22 this->m_currentChunk = NULL;
23}
24
25// FUNCTION: LEGO1 0x100b54f0
26void MxMediaPresenter::Destroy(MxBool p_fromDestructor)
27{
28 {
30
33 }
34
35 if (m_subscriber) {
36 delete m_subscriber;
37 }
38
41 }
42
43 if (m_loopingChunks) {
45 MxStreamChunk* chunk;
46
47 while (cursor.Next(chunk)) {
48 chunk->Release();
49 }
50
51 delete m_loopingChunks;
52 }
53
54 Init();
55 }
56
57 if (!p_fromDestructor) {
59 }
60}
61
62// FUNCTION: LEGO1 0x100b5650
64{
65 MxStreamChunk* chunk = NULL;
66
67 if (m_subscriber) {
68 chunk = m_subscriber->PeekData();
69
70 if (chunk && chunk->GetChunkFlags() & DS_CHUNK_BIT3) {
74 chunk = NULL;
76 }
77 }
78
79 return chunk;
80}
81
82// FUNCTION: LEGO1 0x100b56b0
84{
85 MxStreamChunk* chunk = NULL;
86
87 if (m_subscriber) {
88 chunk = m_subscriber->PopData();
89
90 if (chunk && chunk->GetChunkFlags() & DS_CHUNK_BIT3) {
93 chunk = NULL;
95 }
96 }
97
98 return chunk;
99}
100
101// FUNCTION: LEGO1 0x100b5700
103{
104 MxResult result = FAILURE;
106
107 if (MxPresenter::StartAction(p_controller, p_action) == SUCCESS) {
111
113 goto done;
114 }
115 }
116
117 if (p_controller) {
119
120 if (!m_subscriber ||
121 m_subscriber->Create(p_controller, p_action->GetObjectId(), p_action->GetUnknown24()) != SUCCESS) {
122 goto done;
123 }
124 }
125
126 result = SUCCESS;
127 }
128
129done:
130 return result;
131}
132
133// FUNCTION: LEGO1 0x100b5bc0
135{
137
138 if (!m_action) {
139 return;
140 }
141
143
147 }
148 else {
149 MxDSAction* action = m_action;
151
152 if (m_subscriber) {
153 delete m_subscriber;
155 }
156
157 if (action && action->GetOrigin()) {
159 action->GetOrigin(),
161 );
162 }
163 }
164}
165
166// FUNCTION: LEGO1 0x100b5d10
168{
170
171 CurrentChunk();
172
173 return MxPresenter::Tickle();
174}
175
176// FUNCTION: LEGO1 0x100b5d90
178{
179 if (!m_currentChunk) {
181
182 if (m_currentChunk) {
187 }
190
191 if (!IsEnabled()) {
194 }
195 }
196 }
197 }
198}
199
200// FUNCTION: LEGO1 0x100b5e10
202{
203 if (IsEnabled() && !m_currentChunk) {
207 }
208 }
209
210 if (m_currentChunk) {
211 MxLong time = m_currentChunk->GetTime();
212 if (time <= m_action->GetElapsedTime() % m_action->GetLoopCount()) {
214 }
215 }
216 else {
219 }
220 }
221 }
222}
223
224// FUNCTION: LEGO1 0x100b5ef0
226{
228 EndAction();
229}
230
231// FUNCTION: LEGO1 0x100b5f10
232// FUNCTION: BETA10 0x101366e9
234{
235 MxStreamChunk* chunk = new MxStreamChunk;
236
237 MxU32 length = p_chunk->GetLength();
238 chunk->SetLength(length);
239 chunk->SetData(new MxU8[length]);
240 chunk->SetTime(p_chunk->GetTime());
241
242 memcpy(chunk->GetData(), p_chunk->GetData(), chunk->GetLength());
243 m_loopingChunks->Append(chunk);
244}
245
246// FUNCTION: LEGO1 0x100b6030
247// FUNCTION: BETA10 0x10136814
249{
250 if (IsEnabled() != p_enable) {
251 MxPresenter::Enable(p_enable);
252
253 if (p_enable) {
254 MxLong time = Timer()->GetTime();
255 m_action->SetUnknown90(time);
257 }
258 else {
261 }
264 }
265 }
266}
virtual MxBool VTable0x64(undefined4 p_undefined)
[AI] Delegated state/mode checking.
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
MxU32 GetFlags()
[AI] Returns the flag field for this action (bitmask).
Definition: mxdsaction.h:177
MxLong GetStartTime() const
[AI] Gets the nominal start time for the action, as loaded or scheduled.
Definition: mxdsaction.h:198
MxS32 GetLoopCount()
[AI] Returns the loop count for this action.
Definition: mxdsaction.h:203
virtual void SetUnknown90(MxLong p_unk0x90)
[AI] Set unknown value at offset 0x90, used as baseline in GetElapsedTime.
Definition: mxdsaction.cpp:60
void SetFlags(MxU32 p_flags)
[AI] Sets the flag bitmask controlling action logic (enabled, looping, etc).
Definition: mxdsaction.h:183
virtual MxLong GetDuration()
[AI] Gets the duration for which this action is intended to run.
Definition: mxdsaction.cpp:39
virtual MxLong GetElapsedTime()
[AI] Gets elapsed time for this action since the last time field 0x90 was set.
Definition: mxdsaction.cpp:159
MxCore * GetOrigin()
[AI] Returns a pointer to the "origin" core object, which may be used to localize the action.
Definition: mxdsaction.h:259
@ c_looping
[AI] Action or media should repeat in a loop [AI]
Definition: mxdsaction.h:21
@ c_world
[AI] Action is described in world-space coordinates [AI]
Definition: mxdsaction.h:27
@ c_bit7
[AI] Unknown - possibly reserved [AI]
Definition: mxdsaction.h:26
MxU32 GetLength()
[AI] Returns the length in bytes of the data payload. [AI]
Definition: mxdschunk.h:105
void Release()
[AI] Releases (deletes) data payload if present, regardless of flags; call to explicitly free memory ...
Definition: mxdschunk.h:111
MxLong GetTime()
[AI] Returns the time (timestamp or tick) associated with this chunk. [AI]
Definition: mxdschunk.h:102
void SetData(MxU8 *p_data)
[AI] Sets the pointer to the raw payload data (may or may not be owned by chunk object).
Definition: mxdschunk.h:93
MxU8 * GetData()
[AI] Returns a pointer to the start of the data payload. [AI]
Definition: mxdschunk.h:108
MxU16 GetChunkFlags()
[AI] Returns the chunk's flag bitfield. [AI]
Definition: mxdschunk.h:96
void SetLength(MxU32 p_length)
[AI] Sets the payload data length for this chunk.
Definition: mxdschunk.h:89
void SetTime(MxLong p_time)
[AI] Sets the time (timestamp/tick/frame) associated with this chunk.
Definition: mxdschunk.h:85
MxS16 GetUnknown24()
[AI] Returns the unknown 0x24 value (may be data version or usage state). [AI]
Definition: mxdsobject.h:136
MxU32 GetObjectId()
[AI] Returns the object id numeric value.
Definition: mxdsobject.h:130
[AI] Handles the receipt, queuing, and batch management of data chunks streamed by a MxStreamControll...
MxResult Create(MxStreamController *p_controller, MxU32 p_objectId, MxS16 p_unk0x48)
[AI] Initializes subscription to a streaming controller, sets identifiers, and establishes chunk curs...
MxStreamChunk * PopData()
[AI] Pops the next available pending data chunk for consumption, moving it to the consumed list.
void FreeDataChunk(MxStreamChunk *p_chunk)
[AI] Frees (deletes) a data chunk if it's found in the consumed data list; also forcibly deletes sing...
MxStreamChunk * PeekData()
[AI] Returns but does not remove the first pending data chunk ("peek" operation).
[AI] Notification parameter marking the end of an action, specialization of MxActionNotificationParam...
MxBool Next()
[AI]
void Reset()
[AI]
Definition: mxlist.h:269
void Append(T p_obj)
[AI]
Definition: mxlist.h:100
[AI] Abstract base class for presenters that play back continuous media streams such as video or audi...
MxStreamChunk * CurrentChunk()
[AI] Returns a pointer to the current data chunk at the head of the stream, without consuming it.
MxStreamChunk * NextChunk()
[AI] Returns the next data chunk in the stream, removing it from the stream queue.
void Init()
[AI] Initializes all member variables to a known default state (NULL pointers, etc).
void Destroy() override
[AI] Cleans up internal resources and resets the presenter to an uninitialized state.
void EndAction() override
[AI] Ends the media playback action, releasing all resources, notifying listeners if necessary.
void RepeatingTickle() override
[AI] Per-frame update while looping/repeating over known chunks.
MxResult Tickle() override
[AI] Advances the presenter's state and media stream, if any, by tickling (i.e., updating) components...
void Enable(MxBool p_enable) override
[AI] Enables or disables media stream playback and transitions state as needed.
void DoneTickle() override
[AI] Per-frame update for the "done" state; transitions this presenter to idle and ends the action.
MxStreamChunkList * m_loopingChunks
[AI] Linked list of all chunks available for looping/repeating playback.
void StreamingTickle() override
[AI] Per-frame update when streaming the media stream.
virtual void LoopChunk(MxStreamChunk *p_chunk)
[AI] Adds a chunk to the looping chunk list, making it available for repeated playback.
MxStreamChunkListCursor * m_loopingChunkCursor
[AI] Cursor used to iterate through the loopingChunk list during repeat mode.
MxDSSubscriber * m_subscriber
[AI] Subscriber that provides the stream data (e.g., audio/video chunks) for this presenter.
MxStreamChunk * m_currentChunk
[AI] Currently active data chunk for playback or processing.
MxResult StartAction(MxStreamController *, MxDSAction *) override
[AI] Begins a new media playback action, wiring up the stream and chunk lists as needed.
MxResult Send(MxCore *p_listener, const MxNotificationParam &p_param)
[AI] Queues a notification to be sent to a specific registered listener.
virtual void SetTickleState(TickleState p_tickleState)
[AI] Forces the tickle state, advancing to the requested lifecycle stage.
Definition: mxpresenter.h:100
virtual void EndAction()
[AI] Terminates the current action, notifies listeners and resets state.
Definition: mxpresenter.cpp:59
void ProgressTickleState(TickleState p_tickleState)
[AI] Helper for advancing the presenter's tickle state and updating transition history.
Definition: mxpresenter.h:72
virtual void Enable(MxBool p_enable)
[AI] Enables or disables this presenter (controls action flags accordingly).
MxBool IsEnabled()
[AI] Returns whether this presenter is logically enabled (based on the associated action's flags).
virtual MxResult StartAction(MxStreamController *, MxDSAction *)
[AI] Initiates presenter for a new action, setting up context and state.
Definition: mxpresenter.cpp:45
MxDSAction * m_action
[AI] The associated action currently being presented by this presenter.
Definition: mxpresenter.h:211
MxResult Tickle() override
[AI] Main tickle handler, called periodically to progress presenter's internal state.
@ e_repeating
[AI] Presentation is repeating (e.g., looping media).
Definition: mxpresenter.h:28
@ e_done
[AI] Completed processing the current action.
Definition: mxpresenter.h:30
@ e_idle
[AI] Not processing an action.
Definition: mxpresenter.h:24
@ e_freezing
[AI] Temporarily suspending updates or playback.
Definition: mxpresenter.h:29
MxCriticalSection m_criticalSection
[AI] Thread synchronization for presenter state and data.
Definition: mxpresenter.h:214
MxCompositePresenter * m_compositePresenter
[AI] Owner composite presenter, if any.
Definition: mxpresenter.h:217
virtual void Destroy()
[AI] Resets presenter state or cleans up resources after completion/removal.
Definition: mxpresenter.h:87
[AI] Cursor for iterating over a MxStreamChunkList.
[AI] A list for managing collections of pointers to MxStreamChunk objects, used for organizing and ma...
[AI] Represents a streamable chunk of data, typically sourced from a media buffer and designed for no...
Definition: mxstreamchunk.h:19
[AI] Controller for streaming and managing multimedia resources and actions during gameplay.
MxLong GetTime()
Returns the current timer value in ms, depending on running state.
Definition: mxtimer.h:50
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
Definition: legotypes.h:34
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
#define AUTOLOCK(CS)
[AI] Macro for automatic locking using the MxAutoLock class. This macro instantiates an MxAutoLock ob...
Definition: mxautolock.h:5
#define DS_CHUNK_END_OF_STREAM
[AI] Flag bit indicating this chunk is the last in its stream.
Definition: mxdschunk.h:14
#define DS_CHUNK_BIT3
[AI] Unknown bit flag, marked as BIT3 in decompilation.
Definition: mxdschunk.h:18
MxTimer * Timer()
[AI] Returns the global simulation timer.
Definition: mxmisc.cpp:33
MxNotificationManager * NotificationManager()
[AI] Returns the notification manager for system-wide state/update notifications.
Definition: mxmisc.cpp:17
@ c_notificationEndAction
[AI] Indicates the end of an action [AI]
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
int MxLong
[AI]
Definition: mxtypes.h:83
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
unsigned int MxU32
[AI]
Definition: mxtypes.h:32