Class LibCecSharp
- Namespace
- CecSharp
- Assembly
- LibCecSharp.dll
Create a LibCecSharp instance and pass the configuration as argument. Then call Open() to open a connection to the adapter. Close() closes the connection.
libCEC can send commands to other devices on the CEC bus via the methods on this class, and all commands that libCEC receives are sent back to the application via the callback methods on CecCallbackMethods.
This is the pure-C# implementation that binds the native C API (include/cecc.h) over P/Invoke, so it runs on every platform the native library loads on. It replaces the Windows-only C++/CLI wrapper.
public class LibCecSharp : IDisposable
- Inheritance
-
LibCecSharp
- Implements
- Inherited Members
Constructors
LibCecSharp(CecCallbackMethods, LibCECConfiguration)
Create a new LibCecSharp instance.
public LibCecSharp(CecCallbackMethods callbacks, LibCECConfiguration config)
Parameters
callbacksCecCallbackMethodsconfigLibCECConfiguration
Methods
CanSaveConfiguration()
Check whether the CEC adapter can save a configuration.
public bool CanSaveConfiguration()
Returns
Close()
Close the connection to the CEC adapter.
public void Close()
DisableCallbacks()
public void DisableCallbacks()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
EnableCallbacks()
public void EnableCallbacks()
~LibCecSharp()
protected ~LibCecSharp()
FindAdapters(string)
Try to find all connected CEC adapters.
public CecAdapter[] FindAdapters(string path)
Parameters
pathstring
Returns
GetActiveDevices()
Get the logical addresses of the devices that are active on the bus.
public CecLogicalAddresses GetActiveDevices()
Returns
GetActiveSource()
Get the logical address of the device that is currently the active source.
public CecLogicalAddress GetActiveSource()
Returns
GetAdapterProductId()
Get the (virtual) USB product id.
public ushort GetAdapterProductId()
Returns
GetAdapterVendorId()
Get the (virtual) USB vendor id.
public ushort GetAdapterVendorId()
Returns
GetCurrentConfiguration(LibCECConfiguration)
Get libCEC's current configuration.
public bool GetCurrentConfiguration(LibCECConfiguration configuration)
Parameters
configurationLibCECConfiguration
Returns
GetDeviceCecVersion(CecLogicalAddress)
Get the CEC version of the device with the given logical address.
public CecVersion GetDeviceCecVersion(CecLogicalAddress logicalAddress)
Parameters
logicalAddressCecLogicalAddress
Returns
GetDeviceInformation(string, LibCECConfiguration, uint)
Get information about the given CEC adapter.
public bool GetDeviceInformation(string port, LibCECConfiguration configuration, uint timeoutMs)
Parameters
portstringconfigurationLibCECConfigurationtimeoutMsuint
Returns
GetDeviceMenuLanguage(CecLogicalAddress)
Get the menu language of the device with the given logical address.
public string GetDeviceMenuLanguage(CecLogicalAddress logicalAddress)
Parameters
logicalAddressCecLogicalAddress
Returns
GetDeviceOSDName(CecLogicalAddress)
Get the OSD name of a device on the CEC bus.
public string GetDeviceOSDName(CecLogicalAddress logicalAddress)
Parameters
logicalAddressCecLogicalAddress
Returns
GetDevicePhysicalAddress(CecLogicalAddress)
Get the physical address of the device with the given logical address.
public ushort GetDevicePhysicalAddress(CecLogicalAddress address)
Parameters
addressCecLogicalAddress
Returns
GetDevicePowerStatus(CecLogicalAddress)
Get the power status of the device with the given logical address.
public CecPowerStatus GetDevicePowerStatus(CecLogicalAddress logicalAddress)
Parameters
logicalAddressCecLogicalAddress
Returns
GetDeviceVendorId(CecLogicalAddress)
Get the vendor ID of the device with the given logical address.
public CecVendorId GetDeviceVendorId(CecLogicalAddress logicalAddress)
Parameters
logicalAddressCecLogicalAddress
Returns
GetLibInfo()
Get a string with information about how libCEC was compiled.
public string GetLibInfo()
Returns
GetLogicalAddresses()
Get the list of logical addresses that libCEC is controlling.
public CecLogicalAddresses GetLogicalAddresses()
Returns
GetStats()
Get statistics about traffic on the CEC line.
public CecAdapterStats GetStats()
Returns
InitVideoStandalone()
Initialise the host on which libCEC is running. On the RPi this calls bcm_host_init(). Should be called directly after construction and before Open().
public void InitVideoStandalone()
IsActiveDevice(CecLogicalAddress)
Check whether a device is active on the bus.
public bool IsActiveDevice(CecLogicalAddress logicalAddress)
Parameters
logicalAddressCecLogicalAddress
Returns
IsActiveDeviceType(CecDeviceType)
Check whether a device of the given type is active on the bus.
public bool IsActiveDeviceType(CecDeviceType type)
Parameters
typeCecDeviceType
Returns
IsActiveSource(CecLogicalAddress)
Check whether a device is currently the active source on the CEC bus.
public bool IsActiveSource(CecLogicalAddress logicalAddress)
Parameters
logicalAddressCecLogicalAddress
Returns
IsLibCECActiveSource()
Check whether libCEC is the active source on the bus.
public bool IsLibCECActiveSource()
Returns
MuteAudio()
Send a mute keypress to an audiosystem if it's present.
public byte MuteAudio()
Returns
Open(string, int)
Open a connection to the CEC adapter.
public bool Open(string strPort, int iTimeoutMs)
Parameters
Returns
PhysicalAddressToString(ushort)
public string PhysicalAddressToString(ushort physicalAddress)
Parameters
physicalAddressushort
Returns
PingAdapter()
Send a ping command to the adapter, to check if it's responding.
public bool PingAdapter()
Returns
PollDevice(CecLogicalAddress)
Send a POLL message to a device, to check if it's present and responding.
public bool PollDevice(CecLogicalAddress logicalAddress)
Parameters
logicalAddressCecLogicalAddress
Returns
PowerOnDevices(CecLogicalAddress)
Power on the given CEC capable devices.
public bool PowerOnDevices(CecLogicalAddress logicalAddress)
Parameters
logicalAddressCecLogicalAddress
Returns
RescanActiveDevices()
Tell libCEC to poll for active devices on the bus.
public void RescanActiveDevices()
SendKeyRelease(CecLogicalAddress, bool)
Send a key release to a device on the CEC bus.
public bool SendKeyRelease(CecLogicalAddress destination, bool wait)
Parameters
destinationCecLogicalAddresswaitbool
Returns
SendKeypress(CecLogicalAddress, CecUserControlCode, bool)
Send a keypress to a device on the CEC bus.
public bool SendKeypress(CecLogicalAddress destination, CecUserControlCode key, bool wait)
Parameters
destinationCecLogicalAddresskeyCecUserControlCodewaitbool
Returns
SetActiveSource(CecDeviceType)
Change the active source to a device type handled by libCEC.
public bool SetActiveSource(CecDeviceType type)
Parameters
typeCecDeviceType
Returns
SetConfiguration(LibCECConfiguration)
Change libCEC's configuration.
public bool SetConfiguration(LibCECConfiguration configuration)
Parameters
configurationLibCECConfiguration
Returns
SetDeckControlMode(CecDeckControlMode, bool)
Change the deck control mode, if this adapter is a playback or recording device.
public bool SetDeckControlMode(CecDeckControlMode mode, bool sendUpdate)
Parameters
modeCecDeckControlModesendUpdatebool
Returns
SetDeckInfo(CecDeckInfo, bool)
Change the deck info, if this adapter is a playback or recording device.
public bool SetDeckInfo(CecDeckInfo info, bool sendUpdate)
Parameters
infoCecDeckInfosendUpdatebool
Returns
SetHDMIPort(CecLogicalAddress, byte)
Change the active HDMI port.
public bool SetHDMIPort(CecLogicalAddress address, byte port)
Parameters
addressCecLogicalAddressportbyte
Returns
SetInactiveView()
Broadcast a message that this device is no longer the active source.
public bool SetInactiveView()
Returns
SetLogicalAddress(CecLogicalAddress)
Change the logical address of the CEC adapter (debugging only).
public bool SetLogicalAddress(CecLogicalAddress logicalAddress)
Parameters
logicalAddressCecLogicalAddress
Returns
SetMenuState(CecMenuState, bool)
Change the menu state.
public bool SetMenuState(CecMenuState state, bool sendUpdate)
Parameters
stateCecMenuStatesendUpdatebool
Returns
SetOSDString(CecLogicalAddress, CecDisplayControl, string)
Display a message on the device with the given logical address.
public bool SetOSDString(CecLogicalAddress logicalAddress, CecDisplayControl duration, string message)
Parameters
logicalAddressCecLogicalAddressdurationCecDisplayControlmessagestring
Returns
SetPhysicalAddress(ushort)
Change the physical address (HDMI port) of the CEC adapter.
public bool SetPhysicalAddress(ushort physicalAddress)
Parameters
physicalAddressushort
Returns
SetStreamPath(CecLogicalAddress)
Set the stream path to the device on the given logical address.
public bool SetStreamPath(CecLogicalAddress address)
Parameters
addressCecLogicalAddress
Returns
SetStreamPath(ushort)
Set the stream path to the device on the given physical address.
public bool SetStreamPath(ushort physicalAddress)
Parameters
physicalAddressushort
Returns
StandbyDevices(CecLogicalAddress)
Put the given CEC capable devices in standby mode.
public bool StandbyDevices(CecLogicalAddress logicalAddress)
Parameters
logicalAddressCecLogicalAddress
Returns
StartBootloader()
Start the bootloader of the CEC adapter. Closes the connection when successful.
public bool StartBootloader()
Returns
SwitchMonitoring(bool)
Enable or disable monitoring mode, for debugging purposes.
public bool SwitchMonitoring(bool enable)
Parameters
enablebool
Returns
ToString(CecAudioStatus)
public string ToString(CecAudioStatus status)
Parameters
statusCecAudioStatus
Returns
ToString(CecDeckControlMode)
public string ToString(CecDeckControlMode iMode)
Parameters
iModeCecDeckControlMode
Returns
ToString(CecDeckInfo)
public string ToString(CecDeckInfo status)
Parameters
statusCecDeckInfo
Returns
ToString(CecLogicalAddress)
public string ToString(CecLogicalAddress iAddress)
Parameters
iAddressCecLogicalAddress
Returns
ToString(CecMenuState)
public string ToString(CecMenuState iState)
Parameters
iStateCecMenuState
Returns
ToString(CecOpcode)
public string ToString(CecOpcode opcode)
Parameters
opcodeCecOpcode
Returns
ToString(CecPowerStatus)
public string ToString(CecPowerStatus iState)
Parameters
iStateCecPowerStatus
Returns
ToString(CecSystemAudioStatus)
public string ToString(CecSystemAudioStatus mode)
Parameters
modeCecSystemAudioStatus
Returns
ToString(CecVendorId)
public string ToString(CecVendorId iVendorId)
Parameters
iVendorIdCecVendorId
Returns
ToString(CecVersion)
public string ToString(CecVersion iVersion)
Parameters
iVersionCecVersion
Returns
Transmit(CecCommand)
Transmit a raw CEC command over the CEC line.
public bool Transmit(CecCommand command)
Parameters
commandCecCommand
Returns
VersionToString(uint)
public string VersionToString(uint version)
Parameters
versionuint
Returns
VolumeDown(bool)
Send a volume down keypress to an audiosystem if it's present.
public byte VolumeDown(bool sendRelease)
Parameters
sendReleasebool
Returns
VolumeUp(bool)
Send a volume up keypress to an audiosystem if it's present.
public byte VolumeUp(bool sendRelease)
Parameters
sendReleasebool