2 * Copyright (c) 1999-2000, Eric Moon.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions, and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include "Connection.h"
36 #include "NodeManager.h"
40 #include "ExportContext.h"
41 #include "MediaFormatIO.h"
42 #include "xml_export_utils.h"
47 // -------------------------------------------------------- //
49 __USE_CORTEX_NAMESPACE
51 // -------------------------------------------------------- //
53 // -------------------------------------------------------- //
55 Connection::~Connection() {
57 // PRINT(("~Connection(): '%s'->'%s'\n",
58 // outputName(), inputName()));
61 if(m_outputHint
) delete m_outputHint
;
62 if(m_inputHint
) delete m_inputHint
;
65 Connection::Connection() :
71 Connection::Connection(
74 const media_source
& src
,
75 const char* outputName
,
77 const media_destination
& dest
,
78 const char* inputName
,
79 const media_format
& format
,
82 m_disconnected(false),
84 m_sourceNode(srcNode
),
86 m_outputName(outputName
),
88 m_destinationNode(destNode
),
90 m_inputName(inputName
),
96 m_requestedFormat
.type
= B_MEDIA_NO_TYPE
;
99 Connection::Connection(
100 const Connection
& clone
) {
104 Connection
& Connection::operator=(
105 const Connection
& clone
) {
107 m_disconnected
= clone
.m_disconnected
;
109 m_sourceNode
= clone
.m_sourceNode
;
110 m_source
= clone
.m_source
;
111 m_outputName
= clone
.m_outputName
;
112 m_outputHint
= (clone
.m_outputHint
?
114 clone
.m_outputHint
->name
.String(),
115 clone
.m_outputHint
->format
) :
117 m_destinationNode
= clone
.m_destinationNode
;
118 m_destination
= clone
.m_destination
;
119 m_inputName
= clone
.m_inputName
;
120 m_inputHint
= (clone
.m_inputHint
?
122 clone
.m_inputHint
->name
.String(),
123 clone
.m_inputHint
->format
) :
125 m_format
= clone
.m_format
;
126 m_flags
= clone
.m_flags
;
127 m_requestedFormat
= clone
.m_requestedFormat
;
132 // input/output access [e.moon 14oct99]
134 status_t
Connection::getInput(
135 media_input
* outInput
) const {
140 outInput
->node
= m_destinationNode
;
141 strcpy(outInput
->name
, m_inputName
.String());
142 outInput
->format
= format();
143 outInput
->source
= m_source
;
144 outInput
->destination
= m_destination
;
149 status_t
Connection::getOutput(
150 media_output
* outOutput
) const {
155 outOutput
->node
= m_sourceNode
;
156 strcpy(outOutput
->name
, m_outputName
.String());
157 outOutput
->format
= format();
158 outOutput
->source
= m_source
;
159 outOutput
->destination
= m_destination
;
165 status_t
Connection::getOutputHint(
166 const char** outName
,
167 media_format
* outFormat
) const {
170 return B_NOT_ALLOWED
;
171 *outName
= m_outputHint
->name
.String();
172 *outFormat
= m_outputHint
->format
;
176 status_t
Connection::getInputHint(
177 const char** outName
,
178 media_format
* outFormat
) const {
181 return B_NOT_ALLOWED
;
182 *outName
= m_inputHint
->name
.String();
183 *outFormat
= m_inputHint
->format
;
188 void Connection::setOutputHint(
189 const char* origName
,
190 const media_format
& origFormat
) {
192 if(m_outputHint
) delete m_outputHint
;
193 m_outputHint
= new endpoint_hint(origName
, origFormat
);
196 void Connection::setInputHint(
197 const char* origName
,
198 const media_format
& origFormat
) {
200 if(m_inputHint
) delete m_inputHint
;
201 m_inputHint
= new endpoint_hint(origName
, origFormat
);
205 void Connection::setRequestedFormat(
206 const media_format
& reqFormat
) {
207 m_requestedFormat
= reqFormat
;
210 // END -- Connection.cpp --