RDK Documentation (Open Sourced RDK Components)
MessageDecoder.cpp
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 #include "ccec/CECFrame.hpp"
29 #include "ccec/Header.hpp"
30 #include "ccec/Operand.hpp"
31 #include "ccec/Operands.hpp"
32 #include "ccec/MessageProcessor.hpp"
33 #include "ccec/MessageDecoder.hpp"
34 #include "ccec/Exception.hpp"
35 #include "ccec/Util.hpp"
36 
37 CCEC_BEGIN_NAMESPACE
38 
39 void MessageDecoder::decode(const CECFrame &in_)
40 {
41  const int HEADER_OFFSET = 0;
42  const int OPCODE_OFFSET = 1;
43  const int OPRAND_OFFSET = 2;
44 
45  Header header(in_, HEADER_OFFSET);
46 
47  if (in_.length() == 1) {
48  /* This is an Polling Message */
49  processor.process(Polling(), header);
50  return;
51  }
52 
53  CECFrame in = in_.subFrame(OPRAND_OFFSET);
54 
55  try
56  {
57  switch (OpCode(in_, OPCODE_OFFSET).opCode()) {
58  case ACTIVE_SOURCE:
59  processor.process(ActiveSource(in), header);
60  break;
61  case INACTIVE_SOURCE:
62  processor.process(InActiveSource(in), header);
63  break;
64  case IMAGE_VIEW_ON:
65  processor.process(ImageViewOn(), header);
66  break;
67  case TEXT_VIEW_ON:
68  processor.process(TextViewOn(), header);
69  break;
70  case REQUEST_ACTIVE_SOURCE:
71  processor.process(RequestActiveSource(), header);
72  break;
73  case STANDBY:
74  CCEC_LOG( LOG_DEBUG, "Decoding STANDBY\r\n");
75  processor.process(Standby(), header);
76  break;
77  case GET_CEC_VERSION:
78  processor.process(GetCECVersion(), header);
79  break;
80  case CEC_VERSION:
81  processor.process(CECVersion(in), header);
82  break;
83  case SET_MENU_LANGUAGE:
84  processor.process(SetMenuLanguage(in), header);
85  break;
86  case GIVE_OSD_NAME:
87  processor.process(GiveOSDName(), header);
88  break;
89  case GIVE_PHYSICAL_ADDRESS:
90  processor.process(GivePhysicalAddress(), header);
91  break;
92  case REPORT_PHYSICAL_ADDRESS:
93  processor.process(ReportPhysicalAddress(in), header);
94  break;
95  case GIVE_DEVICE_VENDOR_ID:
96  processor.process(GiveDeviceVendorID(), header);
97  break;
98  case ROUTING_CHANGE:
99  processor.process(RoutingChange(in), header);
100  break;
101  case ROUTING_INFORMATION:
102  processor.process(RoutingInformation(in), header);
103  break;
104  case SET_STREAM_PATH:
105  processor.process(SetStreamPath(in), header);
106  break;
107  case GET_MENU_LANGUAGE:
108  processor.process(GetMenuLanguage(), header);
109  break;
110  case DEVICE_VENDOR_ID:
111  processor.process(DeviceVendorID(in), header);
112  break;
113  case VENDOR_COMMAND:
114  //processor.process(VendorCommand(in), header);
115  break;
116  case VENDOR_COMMAND_WITH_ID:
117  //processor.process(VendorCommandWithID(in), header);
118  break;
119  case VENDOR_REMOTE_BUTTON_DOWN:
120  //processor.process(VendorRemoteButtonDown(in), header);
121  break;
122  case VENDOR_REMOTE_BUTTON_UP:
123  //processor.process(VendorRemoteButtonUp(in), header);
124  break;
125  case SET_OSD_STRING:
126  processor.process(SetOSDString(in), header);
127  break;
128  case SET_OSD_NAME:
129  processor.process(SetOSDName(in), header);
130  break;
131  case USER_CONTROL_RELEASED:
132  //processor.process(UserControlReleased(in), header);
133  break;
134  case USER_CONTROL_PRESSED:
135  //processor.process(UserControlPressed(in), header);
136  break;
137  case GIVE_DEVICE_POWER_STATUS:
138  processor.process(GiveDevicePowerStatus(), header);
139  break;
140  case REPORT_POWER_STATUS:
141  processor.process(ReportPowerStatus(in), header);
142  break;
143  case FEATURE_ABORT:
144  processor.process(FeatureAbort(in), header);
145  break;
146  case ABORT:
147  processor.process(Abort(), header);
148  break;
149  case INITIATE_ARC:
150  processor.process(InitiateArc(), header);
151  break;
152  case TERMINATE_ARC:
153  processor.process(TerminateArc(), header);
154  break;
155  case REQUEST_SHORT_AUDIO_DESCRIPTOR:
156  processor.process(RequestShortAudioDescriptor(in), header);
157  break;
158 
159  case REPORT_SHORT_AUDIO_DESCRIPTOR:
160  processor.process(ReportShortAudioDescriptor(in), header);
161  break;
162  case SYSTEM_AUDIO_MODE_REQUEST:
163  processor.process(SystemAudioModeRequest(in), header);
164  break;
165  case SET_SYSTEM_AUDIO_MODE:
166  processor.process(SetSystemAudioMode(in), header);
167  break;
168  case REPORT_AUDIO_STATUS :
169  processor.process(ReportAudioStatus(in), header);
170  break;
171  default:
172  CCEC_LOG( LOG_DEBUG, "Unhandled Message Received \n");
173  OpCode(in_, OPCODE_OFFSET).print();
174  break;
175  }
176  }
177  catch(InvalidParamException &e)
178  {
179  CCEC_LOG( LOG_EXP, "MessageDecoder::decode caught %s \r\n",e.what());
180  }
181  catch(std::exception &e)
182  {
183  CCEC_LOG( LOG_EXP, "MessageDecoder::decode caught an %s \r\n",e.what());
184  in_.hexDump(LOG_EXP);
185  }
186 }
187 
188 CCEC_END_NAMESPACE
189 
190 
191 /** @} */
192 /** @} */
FeatureAbort
Definition: Messages.hpp:369
GetCECVersion
Definition: Messages.hpp:161
SetOSDString
Definition: Messages.hpp:249
GiveOSDName
Definition: Messages.hpp:220
TextViewOn
Definition: Messages.hpp:119
GiveDevicePowerStatus
Definition: Messages.hpp:334
SetOSDName
Definition: Messages.hpp:226
ReportAudioStatus
Definition: Messages.hpp:613
DeviceVendorID
Definition: Messages.hpp:311
GivePhysicalAddress
Definition: Messages.hpp:272
SetSystemAudioMode
Definition: Messages.hpp:591
Header
Definition: Header.hpp:41
Polling
Definition: Messages.hpp:649
ReportShortAudioDescriptor
Definition: Messages.hpp:515
InvalidParamException
Definition: Exception.hpp:90
SetMenuLanguage
Definition: Messages.hpp:190
Standby
Definition: Messages.hpp:155
RoutingInformation
Definition: Messages.hpp:419
ActiveSource
The Message API allows the application to send or receive high-level CEC message construct instead of...
Definition: Messages.hpp:88
GetMenuLanguage
Definition: Messages.hpp:214
SetStreamPath
Definition: Messages.hpp:443
TerminateArc
Definition: Messages.hpp:685
GiveDeviceVendorID
Definition: Messages.hpp:305
ReportPhysicalAddress
Definition: Messages.hpp:278
OpCode
Definition: OpCode.hpp:123
InActiveSource
Definition: Messages.hpp:125
RequestActiveSource
Definition: Messages.hpp:149
RequestShortAudioDescriptor
Definition: Messages.hpp:466
RoutingChange
Definition: Messages.hpp:394
ImageViewOn
Definition: Messages.hpp:112
ReportPowerStatus
Definition: Messages.hpp:340
CECFrame
Definition: CECFrame.hpp:40
InitiateArc
Definition: Messages.hpp:680
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
SystemAudioModeRequest
Definition: Messages.hpp:564
CECVersion
Definition: Messages.hpp:167
Abort
Definition: Messages.hpp:363