* Copyright (c) 1999-2000, Eric Moon.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions, and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __Connection_H__
#define __Connection_H__
#include <Debug.h>
#include <MediaNode.h>
#include <String.h>
#include "cortex_defs.h"
__BEGIN_CORTEX_NAMESPACE
class NodeManager;
class NodeGroup;
class NodeRef;
class Connection {
friend class NodeRef;
friend class NodeManager;
public:
enum flag_t {
INTERNAL = 1<<1,
LOCKED = 1<<2
};
public:
virtual ~Connection();
Connection();
Connection(
const Connection& clone);
Connection& operator=(
const Connection& clone);
public:
uint32 id() const { return m_id; }
bool isValid() const { return
m_sourceNode != media_node::null &&
m_destinationNode != media_node::null &&
!m_disconnected; }
media_node_id sourceNode() const { return m_sourceNode.node; }
const media_source& source() const { return m_source; }
const char* outputName() const { return m_outputName.String(); }
media_node_id destinationNode() const { return m_destinationNode.node; }
const media_destination& destination() const { return m_destination; }
const char* inputName() const { return m_inputName.String(); }
const media_format& format() const { return m_format; }
uint32 flags() const { return m_flags; }
status_t getInput(
media_input* outInput) const;
status_t getOutput(
media_output* outOutput) const;
status_t getOutputHint(
const char** outName,
media_format* outFormat) const;
status_t getInputHint(
const char** outName,
media_format* outFormat) const;
const media_format& requestedFormat() const { return m_requestedFormat; }
protected:
Connection(
uint32 id,
media_node srcNode,
const media_source& src,
const char* outputName,
media_node destNode,
const media_destination& dest,
const char* inputName,
const media_format& format,
uint32 flags);
void setOutputHint(
const char* origName,
const media_format& origFormat);
void setInputHint(
const char* origName,
const media_format& origFormat);
void setRequestedFormat(
const media_format& reqFormat);
private:
struct endpoint_hint {
endpoint_hint(const char* _name, const media_format& _format) :
name(_name), format(_format) {}
BString name;
media_format format;
};
bool m_disconnected;
uint32 m_id;
media_node m_sourceNode;
media_source m_source;
BString m_outputName;
endpoint_hint* m_outputHint;
media_node m_destinationNode;
media_destination m_destination;
BString m_inputName;
endpoint_hint* m_inputHint;
media_format m_format;
uint32 m_flags;
media_format m_requestedFormat;
};
__END_CORTEX_NAMESPACE
#endif