RDK Documentation (Open Sourced RDK Components)
Header.hpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 
22 /**
23 * @defgroup hdmicec
24 * @{
25 * @defgroup ccec
26 * @{
27 **/
28 
29 
30 #ifndef HDMI_CCEC_HEADER_BLOCK_
31 #define HDMI_CCEC_HEADER_BLOCK_
32 
33 #include "CCEC.hpp"
34 #include "Assert.hpp"
35 #include "DataBlock.hpp"
36 #include "Operands.hpp"
37 #include "Util.hpp"
38 
39 CCEC_BEGIN_NAMESPACE
40 
41 class Header
42 {
43 public:
44  enum {
45  MAX_LEN = 1,
46  };
47 
48  Header(const LogicalAddress &from, const LogicalAddress &to) : from(from), to(to) {
49  print();
50  };
51 
52  Header(const CECFrame &frame, size_t startPos = 0) {
53  from = LogicalAddress((frame.at(startPos) & 0xF0) >> 4);
54  to = LogicalAddress((frame.at(startPos) & 0x0F) >> 0);
55  }
56 
57  CECFrame &serialize(CECFrame &frame) const {
58  CCEC_LOG( LOG_DEBUG, "Serialing header %s %s \n",from.toString().c_str(),to.toString().c_str());
59  /* serialize to same byte */
60  to.serialize(frame);
61  uint8_t &byte = frame[frame.length() - 1];
62  Assert(byte == to.toInt());
63  byte = from.toInt() << 4 | byte;
64  return frame;
65  }
66 
67  virtual ~Header(void) {};
68 
69  void print(void) const {
70  CCEC_LOG( LOG_DEBUG, "Header : From : %s \n", from.toString().c_str());
71  CCEC_LOG( LOG_DEBUG, "Header : to : %s \n", to.toString().c_str());
72  }
73 
74 
75 public:
76  LogicalAddress from;
77  LogicalAddress to;
78 };
79 
80 
81 CCEC_END_NAMESPACE
82 
83 #endif
84 
85 
86 
87 /** @} */
88 /** @} */
LogicalAddress
Definition: Operands.hpp:409
Header
Definition: Header.hpp:41
CECFrame
Definition: CECFrame.hpp:40
CCEC_LOG
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...
Definition: Util.cpp:120