win32: sync project files and fixed compilation warnings.
[deb_libcec.git] / src / lib / CECClient.h
CommitLineData
004b8382
LOK
1#pragma once
2/*
3 * This file is part of the libCEC(R) library.
4 *
5 * libCEC(R) is Copyright (C) 2011-2012 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#include "../../include/cectypes.h"
35#include "platform/threads/mutex.h"
36#include "platform/util/buffer.h"
37
38#include "devices/CECBusDevice.h"
39
40namespace CEC
41{
42 class CCECProcessor;
43
44 class CCECClient
45 {
46 public:
47 CCECClient(CCECProcessor *processor, const libcec_configuration *configuration);
48 virtual ~CCECClient(void);
49
50 // methods for registration in CCECProcessor
51 bool Initialise(void);
52 void OnUnregister(void) { SetRegistered(false); SetInitialised(false); }
53 bool IsInitialised(void);
54 void SetInitialised(bool bSetTo);
55 bool IsRegistered(void);
56 void SetRegistered(bool bSetTo);
57 CCECBusDevice * GetPrimaryDevice(void);
58 CCECPlaybackDevice *GetPlaybackDevice(void);
59 bool FindLogicalAddresses(void);
60 bool ChangeDeviceType(cec_device_type from, cec_device_type to);
61 CCECBusDevice * GetDeviceByType(const cec_device_type type) const;
62
63 // client-specific part of ICECAdapter
64 bool EnableCallbacks(void *cbParam, ICECCallbacks *callbacks);
65 bool GetNextLogMessage(cec_log_message *message);
66 bool GetNextKeypress(cec_keypress *key);
67 bool GetNextCommand(cec_command *command);
68 bool Transmit(const cec_command &data);
69 bool SetLogicalAddress(cec_logical_address iLogicalAddress);
70 bool SetPhysicalAddress(uint16_t iPhysicalAddress);
71 bool SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort, bool bForce = false);
72 bool SendPowerOnDevices(cec_logical_address address = CECDEVICE_TV);
73 bool SendStandbyDevices(cec_logical_address address = CECDEVICE_BROADCAST);
74 bool SendSetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED);
75 bool SendSetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate = true);
76 bool SendSetDeckInfo(cec_deck_info info, bool bSendUpdate = true);
77 bool SendSetInactiveView(void);
78 bool SendSetMenuState(cec_menu_state state, bool bSendUpdate = true);
79 bool SendSetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage);
80 cec_version GetDeviceCecVersion(cec_logical_address iAddress);
81 bool GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language);
82 uint64_t GetDeviceVendorId(cec_logical_address iAddress);
83 cec_power_status GetDevicePowerStatus(cec_logical_address iAddress);
84 uint16_t GetDevicePhysicalAddress(cec_logical_address iAddress);
85 uint8_t SendVolumeUp(bool bSendRelease = true);
86 uint8_t SendVolumeDown(bool bSendRelease = true);
87 uint8_t SendMuteAudio(void);
88 bool SendKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait = true);
89 bool SendKeyRelease(cec_logical_address iDestination, bool bWait = true);
90 cec_osd_name GetDeviceOSDName(cec_logical_address iAddress);
91
92 // configuration
93 libcec_configuration *GetConfiguration(void) { return &m_configuration; }
94 bool GetCurrentConfiguration(libcec_configuration *configuration);
95 bool SetConfiguration(const libcec_configuration *configuration);
96
97 // callbacks
98 void AddCommand(const cec_command &command);
99 int MenuStateChanged(const cec_menu_state newState);
100 void Alert(const libcec_alert type, const libcec_parameter &param);
101 void AddLog(const cec_log_message &message);
102 void AddKey(void);
103 void AddKey(const cec_keypress &key);
104 void SetCurrentButton(cec_user_control_code iButtonCode);
105 void CheckKeypressTimeout(void);
106 void ConfigurationChanged(const libcec_configuration &config);
107
108 protected:
109 cec_logical_address FindLogicalAddressRecordingDevice(void);
110 cec_logical_address FindLogicalAddressTuner(void);
111 cec_logical_address FindLogicalAddressPlaybackDevice(void);
112 cec_logical_address FindLogicalAddressAudioSystem(void);
113
114 CCECProcessor * m_processor;
115 libcec_configuration m_configuration;
116 bool m_bInitialised;
117 bool m_bRegistered;
118 PLATFORM::CMutex m_mutex;
119 PLATFORM::SyncedBuffer<cec_log_message> m_logBuffer;
120 PLATFORM::CMutex m_logMutex;
121 PLATFORM::SyncedBuffer<cec_keypress> m_keyBuffer;
122 PLATFORM::SyncedBuffer<cec_command> m_commandBuffer;
123 cec_user_control_code m_iCurrentButton;
124 int64_t m_buttontime;
125 };
126}