|
RDK Documentation (Open Sourced RDK Components)
|
31 #include "ccec/CECFrame.hpp"
32 #include "ccec/FrameListener.hpp"
33 #include "ccec/Connection.hpp"
34 #include "ccec/Util.hpp"
35 #include "ccec/Header.hpp"
43 Connection::Connection(
const LogicalAddress &source,
bool opened,
const std::string &name)
44 : name(name), source(source), bus(
Bus::getInstance()), busFrameFilter(this->source), busFrameListener(*this, busFrameFilter)
49 Connection::~Connection(
void) {
64 CCEC_LOG( LOG_DEBUG,
"Connection::open with source [%s]\r\n", source.toString().c_str());
76 frameListeners.clear();
91 frameListeners.push_back(listener);
93 CCEC_LOG( LOG_DEBUG,
"Connection::addFrameListener::done\r\n");
107 frameListeners.remove(listener);
123 CCEC_LOG( LOG_DEBUG,
"Sending out from Connection\r\n");
125 Header header(source, to);
126 header.serialize(fullFrame);
127 fullFrame.append(frame);
128 send(fullFrame, timeout);
143 CCEC_LOG( LOG_DEBUG,
"Sending out from Connection\r\n");
145 Header header(source, to);
146 header.serialize(fullFrame);
147 fullFrame.append(frame);
150 send(fullFrame, timeout, doThrow);
170 Header header(source, to);
171 header.serialize(fullFrame);
172 fullFrame.append(frame);
186 CCEC_LOG( LOG_DEBUG,
"Sending out from Connection with timeout %d ms\r\n", timeout);
191 bus.
send(frame, timeout);
210 CCEC_LOG( LOG_DEBUG,
"Sending out from Connection\r\n");
215 bus.
send(frame, timeout);
234 CCEC_LOG( LOG_DEBUG,
"Polling\r\n");
240 bus.
poll(from, from);
259 CCEC_LOG( LOG_DEBUG,
"Polling\r\n");
285 CCEC_LOG( LOG_DEBUG,
"Sending out from Connection\r\n");
302 bool filtered =
true;
310 (header.to == source)) {
331 if (!filter.isFiltered(frame)) {
332 std::list<FrameListener *>::iterator list_it;
333 for(list_it = connection.frameListeners.begin(); list_it!= connection.frameListeners.end(); list_it++) {
334 CCEC_LOG( LOG_DEBUG,
"connection [%s] frame Listeners notify Listener\r\n", connection.name.c_str());
335 (*list_it)->notify(frame);
354 if (Driver::getInstance().isValidLogicalAddress(source)) {
355 CCEC_LOG( LOG_DEBUG,
"Mathing source to %s\r\n", source.toString().c_str());
357 const uint8_t *buf = frame.getBuffer();
358 CCEC_LOG( LOG_DEBUG,
"Has source to %x\r\n", (buf[0] >> 4) & 0x0F);
360 if (((buf[0] >> 4) & 0x0F) != (source.toInt() & 0x0F)) {
361 CCEC_LOG( LOG_ERROR,
"Altering Initiator to match connection source\r\n");
362 ((uint8_t *)buf)[0] = ((buf[0] & 0x0F) | ((source.toInt() & 0x0F) << 4));
void send(const CECFrame &frame, int timeout, const Throw_e &doThrow)
This function is used to send CEC frame to CEC Bus.
void removeFrameListener(FrameListener *listener)
This function is used to remove the listener.
void ping(const LogicalAddress &from, const LogicalAddress &to, const Throw_e &doThrow)
This function is used to send ping message to the Bus.
void open(void)
Open a connection to receive CEC packets from the bus.
void poll(const LogicalAddress &from, const LogicalAddress &to)
This function is used to poll the logical address and returns the ACK or NACK received from other dev...
void poll(const LogicalAddress &from, const Throw_e &doThrow)
This function is used to send poll message to the Bus.
void sendAsync(const CECFrame &frame)
This function is used to send the CEC frame to physical CEC Bus using asynchronous method.
void addFrameListener(FrameListener *listener)
This function is used to listen for CECFrame, which is a byte stream that contains raw bytes received...
void removeFrameListener(FrameListener *listener)
This function is used to remove the listener information from the queue.
void sendAsync(const CECFrame &frame)
This function is used to keep asynchronously sending the frame by keeping copy of cec frame in the qu...
void sendToAsync(const LogicalAddress &to, const CECFrame &frame)
sends HDMI-CEC frame to CEC Bus using asynchronized method.
void sendTo(const LogicalAddress &to, const CECFrame &frame, int timeout, const Throw_e &doThrow)
This function is used to send CEC frame to CEC Bus.
bool isFiltered(const CECFrame &frame)
Check the filtered is set for this connection.
void matchSource(const CECFrame &frame)
Match the source address and update the logical address for the Connection.
void notify(const CECFrame &frame) const
Notify to the application if CECFrame is received. The CEC frame contains the raw bytes.
void addFrameListener(FrameListener *listener)
This function is used to add new listener for reading frames.
void send(const CECFrame &frame, int timeout=0)
This function is used to write the frame to the driver. If it fails, as it is a synchronous function,...
void ping(const LogicalAddress &from, const LogicalAddress &to)
This function is used to ping devices, to know whether it present and returns the ACK or NACK receive...
void CCEC_LOG(int level, const char *format ...)
This function is used to gets the logs depending on the level of log and print these to standard outp...