libCEC 8.1.0
C / C++ API — control CEC-capable HDMI devices
Loading...
Searching...
No Matches
cec.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This file is part of the libCEC(R) library.
4 *
5 * libCEC(R) is Copyright (C) 2011-2015 Pulse-Eight Limited. All rights reserved.
6 * libCEC(R) is an original work, containing original code.
7 *
8 * libCEC(R) is a trademark of Pulse-Eight Limited.
9 *
10 * This program is dual-licensed; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 *
24 *
25 * Alternatively, you can license this library under a commercial license,
26 * please contact Pulse-Eight Licensing for more information.
27 *
28 * For more information contact:
29 * Pulse-Eight Licensing <license@pulse-eight.com>
30 * http://www.pulse-eight.com/
31 * http://www.pulse-eight.net/
32 */
33
34#ifndef CECEXPORTS_H_
35#define CECEXPORTS_H_
36
37#include "cectypes.h"
38#include <string>
39
40namespace CEC
41{
54 {
55 public:
56 virtual ~ICECAdapter() {};
59
66 virtual bool Open(const char *strPort, uint32_t iTimeoutMs = 10000) = 0;
67
71 virtual void Close(void) = 0;
72
77 virtual bool PingAdapter(void) = 0;
78
83 virtual bool StartBootloader(void) = 0;
85
91 virtual bool Transmit(const cec_command &data) = 0;
92
99
105 virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS) = 0;
106
113
120
127
134 virtual bool SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate = true) = 0;
135
142 virtual bool SetDeckInfo(cec_deck_info info, bool bSendUpdate = true) = 0;
143
148 virtual bool SetInactiveView(void) = 0;
149
156 virtual bool SetMenuState(cec_menu_state state, bool bSendUpdate = true) = 0;
157
165 virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage) = 0;
166
172 virtual bool SwitchMonitoring(bool bEnable) = 0;
173
180
186 virtual std::string GetDeviceMenuLanguage(cec_logical_address iLogicalAddress) = 0;
187
193 virtual uint32_t GetDeviceVendorId(cec_logical_address iLogicalAddress) = 0;
194
201
207 virtual bool PollDevice(cec_logical_address iLogicalAddress) = 0;
208
213
219 virtual bool IsActiveDevice(cec_logical_address iLogicalAddress) = 0;
220
226 virtual bool IsActiveDeviceType(cec_device_type type) = 0;
227
233 virtual uint8_t VolumeUp(bool bSendRelease = true) = 0;
234
240 virtual uint8_t VolumeDown(bool bSendRelease = true) = 0;
241
242#if CEC_LIB_VERSION_MAJOR >= 5
247 virtual uint8_t MuteAudio(void) = 0;
248#endif
249
257 virtual bool SendKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait = false) = 0;
258
265 virtual bool SendKeyRelease(cec_logical_address iDestination, bool bWait = false) = 0;
266
272 virtual std::string GetDeviceOSDName(cec_logical_address iAddress) = 0;
273
279
285 virtual bool IsActiveSource(cec_logical_address iLogicalAddress) = 0;
286
292 virtual bool SetStreamPath(cec_logical_address iLogicalAddress) = 0;
293
299 virtual bool SetStreamPath(uint16_t iPhysicalAddress) = 0;
300
305
311 virtual bool GetCurrentConfiguration(libcec_configuration *configuration) = 0;
312
318 virtual bool SetConfiguration(const libcec_configuration *configuration) = 0;
319
323#if CEC_LIB_VERSION_MAJOR >= 5
324 virtual bool CanSaveConfiguration(void) = 0;
325#else
326 virtual bool CanPersistConfiguration(void) = 0;
327
334 virtual bool PersistConfiguration(libcec_configuration *configuration) = 0;
335#endif
336
340 virtual void RescanActiveDevices(void) = 0;
341
345 virtual bool IsLibCECActiveSource(void) = 0;
346
354 virtual bool GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs = 10000) = 0;
355
356#if CEC_LIB_VERSION_MAJOR >= 5
363 virtual bool SetCallbacks(ICECCallbacks *callbacks, void *cbParam) = 0;
364
369 virtual bool DisableCallbacks(void) = 0;
370#else
378 virtual bool EnableCallbacks(void *cbParam, ICECCallbacks *callbacks) = 0;
379#endif
380
387 virtual bool SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort) = 0;
388
394 virtual uint16_t GetDevicePhysicalAddress(cec_logical_address iLogicalAddress) = 0;
395
399 virtual const char *GetLibInfo(void) = 0;
400
410 virtual void InitVideoStandalone(void) = 0;
411
415 virtual uint16_t GetAdapterVendorId(void) const = 0;
416
420 virtual uint16_t GetAdapterProductId(void) const = 0;
421
422 virtual const char* ToString(const cec_menu_state state) = 0;
423 virtual const char* ToString(const cec_version version) = 0;
424 virtual const char* ToString(const cec_power_status status) = 0;
425 virtual const char* ToString(const cec_logical_address address) = 0;
426 virtual const char* ToString(const cec_deck_control_mode mode) = 0;
427 virtual const char* ToString(const cec_deck_info status) = 0;
428 virtual const char* ToString(const cec_opcode opcode) = 0;
429 virtual const char* ToString(const cec_system_audio_status mode) = 0;
430 virtual const char* ToString(const cec_audio_status status) = 0;
431 virtual const char* ToString(const cec_vendor_id vendor) { return VendorIdToString((uint32_t)vendor); }
432 virtual const char* ToString(const cec_device_type type) = 0;
433 virtual const char* ToString(const cec_user_control_code key) = 0;
434 virtual const char* ToString(const cec_adapter_type type) = 0;
435 virtual std::string VersionToString(uint32_t version) = 0;
436 virtual void PrintVersion(uint32_t version, char* buf, size_t bufSize) = 0;
437 virtual const char* VendorIdToString(uint32_t vendor) = 0;
438
443 virtual uint8_t AudioToggleMute(void) = 0;
444
449 virtual uint8_t AudioMute(void) = 0;
450
455 virtual uint8_t AudioUnmute(void) = 0;
456
461 virtual uint8_t AudioStatus(void) = 0;
462
471 virtual int8_t DetectAdapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath = nullptr, bool bQuickScan = false) = 0;
472
478 virtual cec_command CommandFromString(const char* strCommand) = 0;
479
485 virtual bool AudioEnable(bool enable) = 0;
486
491 virtual uint8_t SystemAudioModeStatus(void) = 0;
492
493#if CEC_LIB_VERSION_MAJOR >= 5
494 virtual bool GetStats(struct cec_adapter_stats* stats) = 0;
495#endif
496 };
497};
498
502extern "C" DECLSPEC void CECDestroy(CEC::ICECAdapter *instance);
503
509extern "C" DECLSPEC CEC::ICECAdapter* CECInitialise(CEC::libcec_configuration *configuration);
510
515extern "C" DECLSPEC bool CECStartBootloader(void);
516
517#endif /* CECEXPORTS_H_ */
CEC::ICECAdapter * CECInitialise(CEC::libcec_configuration *configuration)
Load the CEC adapter library.
void CECDestroy(CEC::ICECAdapter *instance)
Unload the CEC adapter library.
bool CECStartBootloader(void)
Try to connect to the adapter and send the "start bootloader" command, without initialising libCEC an...
#define CEC_DEFAULT_PHYSICAL_ADDRESS
default physical address 1.0.0.0, HDMI port 1
Definition cectypes.h:69
To create a new libCEC instance, call CECInitialise() and pass the configuration as argument.
Definition cec.h:54
virtual const char * ToString(const cec_deck_control_mode mode)=0
virtual const char * ToString(const cec_version version)=0
virtual std::string GetDeviceMenuLanguage(cec_logical_address iLogicalAddress)=0
Get the menu language of the device with the given logical address.
virtual const char * ToString(const cec_menu_state state)=0
virtual bool SetMenuState(cec_menu_state state, bool bSendUpdate=true)=0
Change the menu state.
virtual bool SetStreamPath(cec_logical_address iLogicalAddress)=0
Sets the stream path to the device on the given logical address.
virtual uint16_t GetAdapterVendorId(void) const =0
virtual const char * GetLibInfo(void)=0
virtual bool PingAdapter(void)=0
Sends a ping command to the adapter, to check if it's responding.
virtual bool Transmit(const cec_command &data)=0
Transmit a raw CEC command over the CEC line.
virtual bool SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate=true)=0
Change the deck control mode, if this adapter is registered as playback or recording device.
virtual bool SendKeyRelease(cec_logical_address iDestination, bool bWait=false)=0
Send a key release to a device on the CEC bus.
virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress=CECDEVICE_PLAYBACKDEVICE1)=0
Change the logical address on the CEC bus of the CEC adapter.
virtual const char * ToString(const cec_logical_address address)=0
virtual const char * ToString(const cec_power_status status)=0
virtual bool SetActiveSource(cec_device_type type=CEC_DEVICE_TYPE_RESERVED)=0
Change the active source to a device type handled by libCEC.
virtual int8_t DetectAdapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath=nullptr, bool bQuickScan=false)=0
Try to find all connected CEC adapters.
virtual bool StandbyDevices(cec_logical_address address=CECDEVICE_BROADCAST)=0
Put the given CEC capable devices in standby mode.
virtual bool IsLibCECActiveSource(void)=0
virtual const char * ToString(const cec_user_control_code key)=0
virtual cec_logical_address GetActiveSource(void)=0
Get the logical address of the device that is currently the active source on the CEC bus.
virtual const char * VendorIdToString(uint32_t vendor)=0
virtual uint8_t VolumeDown(bool bSendRelease=true)=0
Sends a volume down keypress to an audiosystem if it's present.
virtual uint8_t AudioUnmute(void)=0
Mute the AVR (if connected)
virtual uint8_t AudioMute(void)=0
Mute the AVR (if present)
virtual bool IsActiveDeviceType(cec_device_type type)=0
Check whether a device of the given type is active on the bus.
virtual void PrintVersion(uint32_t version, char *buf, size_t bufSize)=0
virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress=0x1000)=0
Change the physical address (HDMI port) of the CEC adapter.
virtual cec_version GetDeviceCecVersion(cec_logical_address iLogicalAddress)=0
Get the CEC version of the device with the given logical address.
virtual cec_command CommandFromString(const char *strCommand)=0
Create a new cec_command from a string.
virtual bool GetStats(struct cec_adapter_stats *stats)=0
virtual std::string GetDeviceOSDName(cec_logical_address iAddress)=0
Get the OSD name of a device on the CEC bus.
virtual bool SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort)=0
Changes the active HDMI port.
virtual bool AudioEnable(bool enable)=0
Enable or disable system audio mode.
virtual uint16_t GetAdapterProductId(void) const =0
virtual uint32_t GetDeviceVendorId(cec_logical_address iLogicalAddress)=0
Get the vendor ID of the device with the given logical address.
virtual std::string VersionToString(uint32_t version)=0
virtual bool SendKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait=false)=0
Send a keypress to a device on the CEC bus.
virtual void Close(void)=0
Close the connection to the CEC adapter.
virtual cec_logical_addresses GetActiveDevices(void)=0
virtual uint8_t MuteAudio(void)=0
Toggles the mute status of an audiosystem, if it's present.
virtual cec_logical_addresses GetLogicalAddresses(void)=0
virtual bool DisableCallbacks(void)=0
Disable all callbacks.
virtual bool CanSaveConfiguration(void)=0
virtual bool SetConfiguration(const libcec_configuration *configuration)=0
Change libCEC's configuration.
virtual const char * ToString(const cec_deck_info status)=0
virtual bool StartBootloader(void)=0
Start the bootloader of the CEC adapter.
virtual uint8_t AudioToggleMute(void)=0
Toggle the mute status of the AVR (if present)
virtual bool SetCallbacks(ICECCallbacks *callbacks, void *cbParam)=0
Set and enable the callback methods.
virtual const char * ToString(const cec_device_type type)=0
virtual bool GetCurrentConfiguration(libcec_configuration *configuration)=0
Get libCEC's current configuration.
virtual const char * ToString(const cec_vendor_id vendor)
Definition cec.h:431
virtual bool IsActiveDevice(cec_logical_address iLogicalAddress)=0
Check whether a device is active on the bus.
virtual bool PowerOnDevices(cec_logical_address address=CECDEVICE_TV)=0
Power on the given CEC capable devices.
virtual bool SetStreamPath(uint16_t iPhysicalAddress)=0
Sets the stream path to the device on the given physical address.
virtual uint8_t AudioStatus(void)=0
Get the current audio status (if an AVR is connected)
virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage)=0
Display a message on the device with the given logical address.
virtual ~ICECAdapter()
Definition cec.h:56
virtual uint16_t GetDevicePhysicalAddress(cec_logical_address iLogicalAddress)=0
Get the physical address of the device with the given logical address.
virtual const char * ToString(const cec_opcode opcode)=0
virtual bool Open(const char *strPort, uint32_t iTimeoutMs=10000)=0
Open a connection to the CEC adapter.
virtual void RescanActiveDevices(void)=0
Tell libCEC to poll for active devices on the bus.
virtual const char * ToString(const cec_system_audio_status mode)=0
virtual bool PollDevice(cec_logical_address iLogicalAddress)=0
Sends a POLL message to a device, to check if it's present and responding.
virtual const char * ToString(const cec_audio_status status)=0
virtual uint8_t VolumeUp(bool bSendRelease=true)=0
Sends a volume up keypress to an audiosystem if it's present.
virtual const char * ToString(const cec_adapter_type type)=0
virtual void InitVideoStandalone(void)=0
Calling this method will initialise the host on which libCEC is running.
virtual bool SetInactiveView(void)=0
Broadcast a message that notifies connected CEC capable devices that this device is no longer the act...
virtual cec_power_status GetDevicePowerStatus(cec_logical_address iLogicalAddress)=0
Get the power status of the device with the given logical address.
virtual bool SwitchMonitoring(bool bEnable)=0
Enable or disable monitoring mode, for debugging purposes.
virtual bool IsActiveSource(cec_logical_address iLogicalAddress)=0
Check whether a device is currently the active source on the CEC bus.
virtual bool SetDeckInfo(cec_deck_info info, bool bSendUpdate=true)=0
Change the deck info, if this adapter is a playback or recording device.
virtual uint8_t SystemAudioModeStatus(void)=0
Get the current system audio mode status (if an AVR is connected)
virtual bool GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs=10000)=0
Get information about the given CEC adapter.
Definition cec.h:41
cec_vendor_id
Definition cectypes.h:883
cec_deck_info
Definition cectypes.h:434
cec_system_audio_status
Definition cectypes.h:575
cec_power_status
Definition cectypes.h:510
cec_opcode
Definition cectypes.h:786
cec_adapter_type
Definition cectypes.h:917
cec_menu_state
Definition cectypes.h:485
cec_audio_status
Definition cectypes.h:391
cec_logical_address
Definition cectypes.h:764
@ CECDEVICE_BROADCAST
Definition cectypes.h:782
@ CECDEVICE_TV
Definition cectypes.h:766
@ CECDEVICE_PLAYBACKDEVICE1
Definition cectypes.h:770
cec_display_control
Definition cectypes.h:464
cec_user_control_code
Definition cectypes.h:664
cec_version
Definition cectypes.h:406
cec_device_type
Definition cectypes.h:454
@ CEC_DEVICE_TYPE_RESERVED
Definition cectypes.h:457
cec_deck_control_mode
Definition cectypes.h:426