cec: added optional logical and physical address parameters to LoadLibCec()/cec_init...
[deb_libcec.git] / src / lib / CECParserC.cpp
CommitLineData
abbca718
LOK
1/*
2 * This file is part of the libCEC(R) library.
3 *
4 * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved.
5 * libCEC(R) is an original work, containing original code.
6 *
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
8 *
9 * This program is dual-licensed; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 *
23 *
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
26 *
27 * For more information contact:
28 * Pulse-Eight Licensing <license@pulse-eight.com>
29 * http://www.pulse-eight.com/
30 * http://www.pulse-eight.net/
31 */
32
33#include "CECParser.h"
34
35using namespace CEC;
36using namespace std;
37
38/*!
39 * C interface implementation
40 */
41//@{
42ICECDevice *cec_parser;
43
df7339c6 44bool cec_init(const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */, int iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
abbca718 45{
df7339c6 46 cec_parser = (ICECDevice *) CECCreate(strDeviceName, iLogicalAddress, iPhysicalAddress);
abbca718
LOK
47 return (cec_parser != NULL);
48}
49
50bool cec_close(void)
51{
52 delete cec_parser;
53 cec_parser = NULL;
54 return true;
55}
56
57bool cec_open(const char *strPort, int iTimeout)
58{
59 if (cec_parser)
60 return cec_parser->Open(strPort, iTimeout);
61 return false;
62}
63
64bool cec_ping(void)
65{
66 if (cec_parser)
67 return cec_parser->Ping();
68 return false;
69}
70
71bool cec_start_bootloader(void)
72{
73 if (cec_parser)
74 return cec_parser->StartBootloader();
75 return false;
76}
77
78bool cec_power_off_devices(cec_logical_address address /* = CECDEVICE_BROADCAST */)
79{
80 if (cec_parser)
81 return cec_parser->PowerOffDevices(address);
82 return false;
83}
84
85bool cec_power_on_devices(cec_logical_address address /* = CECDEVICE_BROADCAST */)
86{
87 if (cec_parser)
88 return cec_parser->PowerOnDevices(address);
89 return false;
90}
91
92bool cec_standby_devices(cec_logical_address address /* = CECDEVICE_BROADCAST */)
93{
94 if (cec_parser)
95 return cec_parser->StandbyDevices(address);
96 return false;
97}
98
99bool cec_set_active_view(void)
100{
101 if (cec_parser)
102 return cec_parser->SetActiveView();
103 return false;
104}
105
106bool cec_set_inactive_view(void)
107{
108 if (cec_parser)
109 return cec_parser->SetInactiveView();
110 return false;
111}
112
113bool cec_get_next_log_message(cec_log_message *message)
114{
115 if (cec_parser)
116 return cec_parser->GetNextLogMessage(message);
117 return false;
118}
119
120bool cec_get_next_keypress(cec_keypress *key)
121{
122 if (cec_parser)
123 return cec_parser->GetNextKeypress(key);
124 return false;
125}
126
127bool cec_transmit(const CEC::cec_frame &data, bool bWaitForAck /* = true */, int64_t iTimeout /* = 2000 */)
128{
129 if (cec_parser)
130 return cec_parser->Transmit(data, bWaitForAck, iTimeout);
131 return false;
132}
133
134bool cec_set_ack_mask(uint16_t ackmask)
135{
136 if (cec_parser)
137 return cec_parser->SetAckMask((cec_logical_address) ackmask);
138 return false;
139}
140
141int cec_get_min_version(void)
142{
143 if (cec_parser)
144 return cec_parser->GetMinVersion();
145 return -1;
146}
147
148int cec_get_lib_version(void)
149{
150 if (cec_parser)
151 return cec_parser->GetLibVersion();
152 return -1;
153}
154
155int cec_find_devices(vector<cec_device> &deviceList, const char *strDevicePath /* = NULL */)
156{
157 if (cec_parser)
158 return cec_parser->FindDevices(deviceList, strDevicePath);
159 return -1;
160}
161
162//@}