2 * Copyright 2015, Dario Casalinuovo. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 #include <MediaConnection.h>
8 #include "MediaClientNode.h"
13 BMediaConnection::BMediaConnection(media_connection_kinds kinds
)
23 fConnection
.kinds
= kinds
;
25 //fConnection.client = media_client::null;
29 BMediaConnection::~BMediaConnection()
36 const media_connection
&
37 BMediaConnection::Connection() const
44 BMediaConnection::Client() const
51 BMediaConnection::HasBinding() const
60 BMediaConnection::Binding() const
69 BMediaConnection::SetAcceptedFormat(const media_format
& format
)
73 fConnection
.format
= format
;
78 BMediaConnection::AcceptedFormat() const
82 return fConnection
.format
;
87 BMediaConnection::IsConnected() const
96 BMediaConnection::Disconnect()
100 status_t ret
= fOwner
->_DisconnectConnection(this);
112 BMediaConnection::Release()
116 status_t ret
= fOwner
->_ReleaseConnection(this);
126 BMediaConnection::BufferSize() const
130 switch (fConnection
.format
.type
) {
131 case B_MEDIA_RAW_AUDIO
:
132 return fConnection
.format
.u
.raw_audio
.buffer_size
;
134 case B_MEDIA_RAW_VIDEO
:
135 return fConnection
.format
.u
.raw_video
.display
.bytes_per_row
*
136 fConnection
.format
.u
.raw_video
.display
.line_count
;
145 BMediaConnection::Connected(const media_format
& format
)
152 BMediaConnection::Disconnected()
159 BMediaConnection::GetLatencyRange(bigtime_t
* min
, bigtime_t
* max
) const
169 BMediaConnection::SetLatencyRange(bigtime_t min
, bigtime_t max
)
179 BMediaConnection::_ConnectionRegistered(BMediaClient
* owner
,
180 media_connection_id id
)
184 fConnection
.client
= fOwner
->Client();
186 if (fConnection
.IsOutput()) {
187 fConnection
.source
.port
= fOwner
->fNode
->ControlPort();
188 fConnection
.source
.id
= fConnection
.id
;
190 fConnection
.destination
= media_destination::null
;
192 fConnection
.destination
.port
= fOwner
->fNode
->ControlPort();
193 fConnection
.destination
.id
= fConnection
.id
;
195 fConnection
.source
= media_source::null
;
201 BMediaConnection::_Source() const
203 return fConnection
._Source();
207 const media_destination
&
208 BMediaConnection::_Destination() const
210 return fConnection
._Destination();
214 void BMediaConnection::_ReservedMediaConnection0() {}
215 void BMediaConnection::_ReservedMediaConnection1() {}
216 void BMediaConnection::_ReservedMediaConnection2() {}
217 void BMediaConnection::_ReservedMediaConnection3() {}
218 void BMediaConnection::_ReservedMediaConnection4() {}
219 void BMediaConnection::_ReservedMediaConnection5() {}
220 void BMediaConnection::_ReservedMediaConnection6() {}
221 void BMediaConnection::_ReservedMediaConnection7() {}
222 void BMediaConnection::_ReservedMediaConnection8() {}
223 void BMediaConnection::_ReservedMediaConnection9() {}
224 void BMediaConnection::_ReservedMediaConnection10() {}
227 BMediaInput::BMediaInput()
229 BMediaConnection(B_MEDIA_INPUT
)
234 BMediaInput::~BMediaInput()
241 BMediaInput::FormatChanged(const media_format
& format
)
243 if (!format_is_compatible(format
, AcceptedFormat()))
244 return B_MEDIA_BAD_FORMAT
;
246 SetAcceptedFormat(format
);
253 BMediaInput::HandleBuffer(BBuffer
* buffer
)
261 BMediaInput::_MediaInput() const
263 return Connection()._MediaInput();
267 void BMediaInput::_ReservedMediaInput0() {}
268 void BMediaInput::_ReservedMediaInput1() {}
269 void BMediaInput::_ReservedMediaInput2() {}
270 void BMediaInput::_ReservedMediaInput3() {}
271 void BMediaInput::_ReservedMediaInput4() {}
272 void BMediaInput::_ReservedMediaInput5() {}
273 void BMediaInput::_ReservedMediaInput6() {}
274 void BMediaInput::_ReservedMediaInput7() {}
275 void BMediaInput::_ReservedMediaInput8() {}
276 void BMediaInput::_ReservedMediaInput9() {}
277 void BMediaInput::_ReservedMediaInput10() {}
280 BMediaOutput::BMediaOutput()
282 BMediaConnection(B_MEDIA_OUTPUT
)
287 BMediaOutput::~BMediaOutput()
294 BMediaOutput::IsEnabled() const
303 BMediaOutput::SetEnabled(bool enabled
)
310 BMediaOutput::PrepareToConnect(media_format
* format
)
312 if (!format_is_compatible(AcceptedFormat(), *format
))
315 SetAcceptedFormat(*format
);
322 BMediaOutput::FormatProposal(media_format
* format
)
324 *format
= AcceptedFormat();
330 BMediaOutput::FormatChangeRequested(media_format
* format
)
337 BMediaOutput::SendBuffer(BBuffer
* buffer
)
344 return fOwner
->fNode
->SendBuffer(buffer
, this);
349 BMediaOutput::_MediaOutput() const
351 return Connection()._MediaOutput();
355 void BMediaOutput::_ReservedMediaOutput0() {}
356 void BMediaOutput::_ReservedMediaOutput1() {}
357 void BMediaOutput::_ReservedMediaOutput2() {}
358 void BMediaOutput::_ReservedMediaOutput3() {}
359 void BMediaOutput::_ReservedMediaOutput4() {}
360 void BMediaOutput::_ReservedMediaOutput5() {}
361 void BMediaOutput::_ReservedMediaOutput6() {}
362 void BMediaOutput::_ReservedMediaOutput7() {}
363 void BMediaOutput::_ReservedMediaOutput8() {}
364 void BMediaOutput::_ReservedMediaOutput9() {}
365 void BMediaOutput::_ReservedMediaOutput10() {}