RDK Documentation (Open Sourced RDK Components)
setResolution.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 /**
23 * @defgroup devicesettings
24 * @{
25 * @defgroup sample
26 * @{
27 **/
28 
29 
30 #include <iostream>
31 #include "host.hpp"
32 #include "videoOutputPort.hpp"
33 #include "videoOutputPortType.hpp"
34 //#include "videoOutputPortConfig.hpp"
35 #include "videoResolution.hpp"
36 #include "videoDFC.hpp"
37 #include "manager.hpp"
38 #include "dsUtl.h"
39 #include "dsError.h"
40 #include "list.hpp"
41 #include <exception>
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <unistd.h>
45 #include <string.h>
46 
47 #include "libIBus.h"
48 #include "dsMgr.h"
49 
50 void _DisplResolutionHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len);
51 
52 int main(int argc, char *argv[])
53 {
54 
55  int i =0;
56 
57  if (argc != 4) {
58  printf("%s : <Ports - HDMI, Component> <Port Index - 0, 1..> <Resolution Settings - 480i, 720p, 1080i>\r\n", argv[0]);
59  return 0;
60  }
61 
62  char *portType = argv[1];
63  char *portId = argv[2];
64  char *resolution = argv[3];
65 
66  printf("%s : %s : %s : %s :\r\n", argv[0],argv[1],argv[2],argv[3]);
67 
68  IARM_Bus_Init("SampleDSClient");
70 
71  IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,
73  _DisplResolutionHandler);
74 
76 
77  try {
78 
79  device::VideoOutputPort vPort = device::Host::getInstance().getVideoOutputPort(std::string(portType).append(portId));
80  printf("Resolution Read is %s : \r\n",vPort.getResolution().getName().c_str());
81  vPort.setResolution(resolution);
82  }
83  catch (const std::exception e) {
84  printf("Exception caught\r\n");
85  }
86 
87  while(++i < 2) {
88  printf("SampleDSClient Hearbeat\r\n");
89  sleep(2);
90  }
91 
92 
95  IARM_Bus_Term();
96 
97  return 0;
98 }
99 
100 
101 void _DisplResolutionHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
102 {
103  if (strcmp(owner,IARM_BUS_DSMGR_NAME) == 0)
104  {
105  printf("_DisplResolutionHandler called %d ......... \r\n",eventId);
106  switch (eventId) {
108  {
110  int width = 0,height=0;
111  width = eventData->data.resn.width;
112  height = eventData->data.resn.height;
113  printf("Resolution data is %d : %d \r\n",width,height);
114  }
115  break;
116  default:
117  break;
118  }
119  }
120 }
121 
122 
123 /** @} */
124 /** @} */
IARM_Bus_Term
IARM_Result_t IARM_Bus_Term(void)
This API is used to terminate the IARM-Bus library.
device::VideoOutputPort
Class extending enumerable to implement the videoooutputport interface.
Definition: videoOutputPort.hpp:59
manager.hpp
It contains class referenced by manager.cpp file.
IARM_Bus_RegisterEventHandler
IARM_Result_t IARM_Bus_RegisterEventHandler(const char *ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler)
This API register to listen to event and provide the callback function for event notification....
Definition: iarmMgrMocks.cpp:43
dsError.h
Device Settings HAL error codes.
dsUtl.h
Device Settings HAL utilities.
device::VideoOutputPort::getResolution
const VideoResolution & getResolution()
This API is used to get the current video resolution output from the video output port....
Definition: videoOutputPort.cpp:293
IARM_Bus_Disconnect
IARM_Result_t IARM_Bus_Disconnect(void)
This API disconnect Application from IARM Bus so the application will not receive any IARM event or R...
videoOutputPortType.hpp
It contains structures and class referenced by the videoOutputportTypes.cpp file.
device::Manager::Initialize
static void Initialize()
This API is used to initialize the Device Setting module. Each API should be called by any client of ...
Definition: manager.cpp:97
videoResolution.hpp
It contains class and structure refrenced by the videoResolution.cpp file.
libIBus.h
RDK IARM-Bus API Declarations.
IARM_BUS_DSMGR_EVENT_RES_POSTCHANGE
@ IARM_BUS_DSMGR_EVENT_RES_POSTCHANGE
Definition: dsMgr.h:48
device::DSConstant::getName
virtual const std::string & getName() const
This function is used to the get the data member name.
Definition: dsConstant.hpp:141
videoOutputPort.hpp
It contains class and structure refrenced by the videooutputport.cpp file.
device::Manager::DeInitialize
static void DeInitialize()
This API is used to deinitialize the device settings module. DeInitialize() must be called to release...
Definition: manager.cpp:138
device::Host::getVideoOutputPort
VideoOutputPort & getVideoOutputPort(const std::string &name)
This API is used to get the reference to the video output port by its name. The name of the port must...
Definition: host.cpp:350
device::Host::getInstance
static Host & getInstance(void)
This API is used to get a reference to the single instance of the Host object.
Definition: host.cpp:88
device::VideoOutputPort::setResolution
void setResolution(const std::string &resolution, bool persist=true, bool isIgnoreEdid=false)
This API is used to set the output resolution of the port by ID or its Name. The specified resolution...
Definition: videoOutputPort.cpp:457
IARM_Bus_Connect
IARM_Result_t IARM_Bus_Connect(void)
This API is used to connect application to the IARM bus daemon. After connected, the application can ...
Definition: iarmMgrMocks.cpp:33
IARM_Bus_Init
IARM_Result_t IARM_Bus_Init(const char *name)
This API is used to initialize the IARM-Bus library.
Definition: iarmMgrMocks.cpp:38
videoDFC.hpp
This file defines VideoDFC class for managing video decoder format conversion types.
_DSMgr_EventData_t
Definition: dsMgr.h:81