2 * Copyright 2015, Dario Casalinuovo. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 #include <SimpleMediaClient.h>
11 BSimpleMediaClient::BSimpleMediaClient(const char* name
,
12 media_type type
, media_client_kinds kinds
)
14 BMediaClient(name
, type
, kinds
),
22 BSimpleMediaClient::~BSimpleMediaClient()
29 BSimpleMediaClient::BeginInput()
33 BSimpleMediaInput
* input
= new BSimpleMediaInput();
40 BSimpleMediaClient::BeginOutput()
44 BSimpleMediaOutput
* output
= new BSimpleMediaOutput();
45 RegisterOutput(output
);
51 BSimpleMediaClient::SetHook(notify_hook notifyHook
, void* cookie
)
55 fNotifyHook
= notifyHook
;
56 fNotifyCookie
= cookie
;
61 BSimpleMediaClient::HandleStart(bigtime_t performanceTime
)
63 if (fNotifyHook
!= NULL
) {
64 (*fNotifyHook
)(BSimpleMediaClient::fNotifyCookie
,
65 BSimpleMediaClient::B_WILL_START
,
72 BSimpleMediaClient::HandleStop(bigtime_t performanceTime
)
74 if (fNotifyHook
!= NULL
) {
75 (*fNotifyHook
)(BSimpleMediaClient::fNotifyCookie
,
76 BSimpleMediaClient::B_WILL_STOP
,
83 BSimpleMediaClient::HandleSeek(bigtime_t mediaTime
, bigtime_t performanceTime
)
85 if (fNotifyHook
!= NULL
) {
86 (*fNotifyHook
)(BSimpleMediaClient::fNotifyCookie
,
87 BSimpleMediaClient::B_WILL_SEEK
,
88 performanceTime
, mediaTime
);
94 BSimpleMediaClient::FormatSuggestion(media_type type
, int32 quality
,
97 if (fNotifyHook
!= NULL
) {
98 status_t result
= B_ERROR
;
99 (*fNotifyHook
)(BSimpleMediaClient::fNotifyCookie
,
100 BSimpleMediaClient::B_FORMAT_SUGGESTION
,
101 type
, quality
, format
, &result
);
108 void BSimpleMediaClient::_ReservedSimpleMediaClient0() {}
109 void BSimpleMediaClient::_ReservedSimpleMediaClient1() {}
110 void BSimpleMediaClient::_ReservedSimpleMediaClient2() {}
111 void BSimpleMediaClient::_ReservedSimpleMediaClient3() {}
112 void BSimpleMediaClient::_ReservedSimpleMediaClient4() {}
113 void BSimpleMediaClient::_ReservedSimpleMediaClient5() {}
116 BSimpleMediaConnection::BSimpleMediaConnection(media_connection_kinds kinds
)
118 BMediaConnection(kinds
),
126 BSimpleMediaConnection::~BSimpleMediaConnection()
133 BSimpleMediaConnection::SetHooks(process_hook processHook
,
134 notify_hook notifyHook
, void* cookie
)
138 fProcessHook
= processHook
;
139 fNotifyHook
= notifyHook
;
140 fBufferCookie
= cookie
;
145 BSimpleMediaConnection::Cookie() const
149 return fBufferCookie
;
153 BSimpleMediaInput::BSimpleMediaInput()
155 BMediaConnection(B_MEDIA_INPUT
),
156 BSimpleMediaConnection(B_MEDIA_INPUT
),
162 BSimpleMediaInput::~BSimpleMediaInput()
169 BSimpleMediaInput::Connected(const media_format
& format
)
171 if (fNotifyHook
!= NULL
)
172 (*fNotifyHook
)(this, BSimpleMediaConnection::B_INPUT_CONNECTED
);
174 BMediaInput::Connected(format
);
179 BSimpleMediaInput::Disconnected()
181 if (fNotifyHook
!= NULL
)
182 (*fNotifyHook
)(this, BSimpleMediaConnection::B_INPUT_DISCONNECTED
);
184 BMediaConnection::Disconnected();
189 BSimpleMediaInput::HandleBuffer(BBuffer
* buffer
)
193 if (fProcessHook
!= NULL
)
194 (*fProcessHook
)(this, buffer
);
198 BSimpleMediaOutput::BSimpleMediaOutput()
200 BMediaConnection(B_MEDIA_OUTPUT
),
201 BSimpleMediaConnection(B_MEDIA_OUTPUT
),
207 BSimpleMediaOutput::~BSimpleMediaOutput()
214 BSimpleMediaOutput::FormatProposal(media_format
* format
)
216 if (fNotifyHook
!= NULL
) {
217 return (*fNotifyHook
)(this,
218 BSimpleMediaConnection::B_FORMAT_PROPOSAL
, format
);
221 return BMediaOutput::FormatProposal(format
);
226 BSimpleMediaOutput::Connected(const media_format
& format
)
228 if (fNotifyHook
!= NULL
)
229 (*fNotifyHook
)(this, BSimpleMediaConnection::B_OUTPUT_CONNECTED
);
231 BSimpleMediaConnection::Connected(format
);
236 BSimpleMediaOutput::Disconnected()
238 if (fNotifyHook
!= NULL
)
239 (*fNotifyHook
)(this, BSimpleMediaConnection::B_OUTPUT_DISCONNECTED
);
241 BSimpleMediaConnection::Disconnected();