RDK Documentation (Open Sourced RDK Components)
MessageEncoder.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 * @defgroup hdmicec
23 * @{
24 * @defgroup ccec
25 * @{
26 **/
27 
28 
29 #ifndef HDMI_CCEC_MESSAGE_ENCODER_H_
30 #define HDMI_CCEC_MESSAGE_ENCODER_H_
31 
32 #include "CCEC.hpp"
33 #include "ccec/CECFrame.hpp"
34 #include "DataBlock.hpp"
35 #include "OpCode.hpp"
36 #include "Header.hpp"
37 
38 CCEC_BEGIN_NAMESPACE
39 
40 /**
41  * @brief High-level messages are encoded by the MessageEncoder into raw bytes and placed in a CECFrame.
42  *
43  * A CECFrame is then sent out via an opened connection.
44  * @ingroup HDMI_CEC_MSG_N_FRAME_CLASSES
45  */
47 
48 public:
49  MessageEncoder(void) {};
50  ~MessageEncoder(void) {};
51 
52 
53  static CECFrame & encode(const Header &h, const DataBlock &m, CECFrame &out)
54  {
55  h.serialize(out);
56  return encode(m, out);
57  }
58 
59  static CECFrame encode(const Header &h, const DataBlock &m)
60  {
61  CECFrame out;
62  h.serialize(out);
63  return encode(m, out);
64  }
65 
66  static CECFrame & encode(const DataBlock &m, CECFrame &out)
67  {
68  OpCode(m.opCode()).serialize(out);
69  m.serialize(out);
70  return out;
71  }
72 
73  static CECFrame encode(const DataBlock &m) {
74  CECFrame out;
75  return encode(m, out);
76  }
77 };
78 
79 CCEC_END_NAMESPACE
80 #endif
81 
82 
83 /** @} */
84 /** @} */
Header
Definition: Header.hpp:41
MessageEncoder
High-level messages are encoded by the MessageEncoder into raw bytes and placed in a CECFrame.
Definition: MessageEncoder.hpp:46
OpCode
Definition: OpCode.hpp:123
CECFrame
Definition: CECFrame.hpp:40
DataBlock
Definition: DataBlock.hpp:45