2 * This file is part of the libCEC(R) library.
4 * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
5 * libCEC(R) is an original work, containing original code.
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
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.
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.
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.
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
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/
41 * C interface implementation
44 ICECAdapter
*cec_parser
;
46 int cec_initialise(libcec_configuration
*configuration
)
48 cec_parser
= (ICECAdapter
*) CECInitialise(configuration
);
49 return (cec_parser
!= NULL
) ? 1 : 0;
52 int cec_init_typed(const char *strDeviceName
, cec_device_type_list deviceTypes
)
54 cec_parser
= (ICECAdapter
*) CECInit(strDeviceName
, deviceTypes
);
55 return (cec_parser
!= NULL
) ? 1 : 0;
58 void cec_destroy(void)
61 CECDestroy(cec_parser
);
65 int cec_open(const char *strPort
, uint32_t iTimeout
)
68 return cec_parser
->Open(strPort
, iTimeout
);
78 int cec_enable_callbacks(void *cbParam
, ICECCallbacks
*callbacks
)
81 return cec_parser
->EnableCallbacks(cbParam
, callbacks
) ? 1 : 0;
85 int8_t cec_find_adapters(cec_adapter
*deviceList
, uint8_t iBufSize
, const char *strDevicePath
/* = NULL */)
88 return cec_parser
->FindAdapters(deviceList
, iBufSize
, strDevicePath
);
92 int cec_ping_adapters(void)
95 return cec_parser
->PingAdapter() ? 1 : 0;
99 int cec_start_bootloader(void)
102 return cec_parser
->StartBootloader() ? 1 : 0;
106 int8_t cec_get_min_lib_version(void)
109 return cec_parser
->GetMinLibVersion();
113 int8_t cec_get_lib_version_major(void)
116 return cec_parser
->GetLibVersionMajor();
120 int8_t cec_get_lib_version_minor(void)
123 return cec_parser
->GetLibVersionMinor();
127 int cec_get_next_log_message(cec_log_message
*message
)
130 return cec_parser
->GetNextLogMessage(message
) ? 1 : 0;
134 int cec_get_next_keypress(cec_keypress
*key
)
137 return cec_parser
->GetNextKeypress(key
) ? 1 : 0;
141 int cec_get_next_command(cec_command
*command
)
144 return cec_parser
->GetNextCommand(command
) ? 1 : 0;
148 int cec_transmit(const CEC::cec_command
*data
)
151 return cec_parser
->Transmit(*data
) ? 1 : 0;
155 int cec_set_logical_address(cec_logical_address iLogicalAddress
/* = CECDEVICE_PLAYBACKDEVICE1 */)
158 return cec_parser
->SetLogicalAddress(iLogicalAddress
) ? 1 : 0;
162 int cec_set_physical_address(uint16_t iPhysicalAddress
/* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
165 return cec_parser
->SetPhysicalAddress(iPhysicalAddress
) ? 1 : 0;
169 int cec_power_on_devices(cec_logical_address address
/* = CECDEVICE_TV */)
172 return cec_parser
->PowerOnDevices(address
) ? 1 : 0;
176 int cec_standby_devices(cec_logical_address address
/* = CECDEVICE_BROADCAST */)
179 return cec_parser
->StandbyDevices(address
) ? 1 : 0;
183 int cec_set_active_view(void)
186 return cec_parser
->SetActiveView() ? 1 : 0;
190 int cec_set_active_source(cec_device_type type
)
193 return cec_parser
->SetActiveSource(type
) ? 1 : 0;
197 int cec_set_deck_control_mode(cec_deck_control_mode mode
, int bSendUpdate
) {
199 return cec_parser
->SetDeckControlMode(mode
, bSendUpdate
== 1) ? 1 : 0;
203 int cec_set_deck_info(cec_deck_info info
, int bSendUpdate
) {
205 return cec_parser
->SetDeckInfo(info
, bSendUpdate
== 1) ? 1 : 0;
210 int cec_set_inactive_view(void)
213 return cec_parser
->SetInactiveView() ? 1 : 0;
217 int cec_set_menu_state(cec_menu_state state
, int bSendUpdate
) {
219 return cec_parser
->SetMenuState(state
, bSendUpdate
== 1) ? 1 : 0;
223 int cec_set_osd_string(cec_logical_address iLogicalAddress
, cec_display_control duration
, const char *strMessage
)
226 return cec_parser
->SetOSDString(iLogicalAddress
, duration
, strMessage
) ? 1 : 0;
230 int cec_switch_monitoring(int bEnable
)
233 return cec_parser
->SwitchMonitoring(bEnable
== 1) ? 1 : 0;
237 cec_version
cec_get_device_cec_version(cec_logical_address iLogicalAddress
)
240 return cec_parser
->GetDeviceCecVersion(iLogicalAddress
);
241 return CEC_VERSION_UNKNOWN
;
244 int cec_get_device_menu_language(cec_logical_address iLogicalAddress
, cec_menu_language
*language
)
247 return cec_parser
->GetDeviceMenuLanguage(iLogicalAddress
, language
) ? 1 : 0;
251 uint64_t cec_get_device_vendor_id(cec_logical_address iLogicalAddress
)
254 return cec_parser
->GetDeviceVendorId(iLogicalAddress
);
258 uint16_t cec_get_device_physical_address(cec_logical_address iLogicalAddress
)
261 return cec_parser
->GetDevicePhysicalAddress(iLogicalAddress
);
265 cec_logical_address
cec_get_active_source(void)
268 return cec_parser
->GetActiveSource();
269 return CECDEVICE_UNKNOWN
;
272 int cec_is_active_source(cec_logical_address iAddress
)
275 return cec_parser
->IsActiveSource(iAddress
);
279 cec_power_status
cec_get_device_power_status(cec_logical_address iLogicalAddress
)
282 return cec_parser
->GetDevicePowerStatus(iLogicalAddress
);
283 return CEC_POWER_STATUS_UNKNOWN
;
286 int cec_poll_device(cec_logical_address iLogicalAddress
)
289 return cec_parser
->PollDevice(iLogicalAddress
) ? 1 : 0;
293 cec_logical_addresses
cec_get_active_devices(void)
295 cec_logical_addresses addresses
;
298 addresses
= cec_parser
->GetActiveDevices();
302 int cec_is_active_device(cec_logical_address iAddress
)
305 return cec_parser
->IsActiveDevice(iAddress
) ? 1 : 0;
309 int cec_is_active_device_type(cec_device_type type
)
312 return cec_parser
->IsActiveDeviceType(type
) ? 1 : 0;
316 int cec_set_hdmi_port(cec_logical_address iBaseDevice
, uint8_t iPort
)
319 return cec_parser
->SetHDMIPort(iBaseDevice
, iPort
) ? 1 : 0;
323 int cec_volume_up(int bSendRelease
)
326 return cec_parser
->VolumeUp(bSendRelease
== 1);
330 int cec_volume_down(int bSendRelease
)
333 return cec_parser
->VolumeDown(bSendRelease
== 1);
337 int cec_mute_audio(int bSendRelease
)
340 return cec_parser
->MuteAudio(bSendRelease
== 1);
344 int cec_send_keypress(cec_logical_address iDestination
, cec_user_control_code key
, int bWait
)
347 return cec_parser
->SendKeypress(iDestination
, key
, bWait
== 1) ? 1 : 0;
351 int cec_send_key_release(cec_logical_address iDestination
, int bWait
)
354 return cec_parser
->SendKeyRelease(iDestination
, bWait
== 1) ? 1 : 0;
358 cec_osd_name
cec_get_device_osd_name(cec_logical_address iAddress
)
361 retVal
.device
= iAddress
;
365 retVal
= cec_parser
->GetDeviceOSDName(iAddress
);
370 int cec_enable_physical_address_detection(void)
372 return cec_parser
? (cec_parser
->EnablePhysicalAddressDetection() ? 1 : 0) : -1;
375 int cec_set_stream_path_logical(CEC::cec_logical_address iAddress
)
377 return cec_parser
? (cec_parser
->SetStreamPath(iAddress
) ? 1 : 0) : -1;
380 int cec_set_stream_path_physical(uint16_t iPhysicalAddress
)
382 return cec_parser
? (cec_parser
->SetStreamPath(iPhysicalAddress
) ? 1 : 0) : -1;
385 cec_logical_addresses
cec_get_logical_addresses(void)
387 cec_logical_addresses addr
;
390 addr
= cec_parser
->GetLogicalAddresses();
394 int cec_get_current_configuration(libcec_configuration
*configuration
)
396 return cec_parser
? (cec_parser
->GetCurrentConfiguration(configuration
) ? 1 : 0) : -1;
399 int cec_can_persist_configuration(void)
401 return cec_parser
? (cec_parser
->CanPersistConfiguration() ? 1 : 0) : -1;
404 int cec_persist_configuration(libcec_configuration
*configuration
)
406 return cec_parser
? (cec_parser
->PersistConfiguration(configuration
) ? 1 : 0) : -1;
409 int cec_set_configuration(libcec_configuration
*configuration
)
411 return cec_parser
? (cec_parser
->SetConfiguration(configuration
) ? 1 : 0) : -1;
414 void cec_rescan_devices(void)
417 cec_parser
->RescanActiveDevices();
420 int cec_is_libcec_active_source(void)
422 return cec_parser
? (cec_parser
->IsLibCECActiveSource() ? 1 : 0) : -1;
425 int cec_get_device_information(const char *strPort
, CEC::libcec_configuration
*config
, uint32_t iTimeoutMs
)
427 return cec_parser
? (cec_parser
->GetDeviceInformation(strPort
, config
, iTimeoutMs
) ? 1 : 0) : -1;
430 const char * cec_get_lib_info(void)
432 return cec_parser
? cec_parser
->GetLibInfo() : NULL
;
435 void cec_init_video_standalone(void)
438 cec_parser
->InitVideoStandalone();