diff --git a/.gitignore b/.gitignore index 4afa9b4..d1a8053 100644 --- a/.gitignore +++ b/.gitignore @@ -19,8 +19,8 @@ install_manifest.txt Makefile */*/Makefile */*/*/Makefile -*/*/WPEFramework*Config.cmake -*/*/WPEFramework*ConfigVersion.cmake +*/*/Thunder*Config.cmake +*/*/Thunder*ConfigVersion.cmake *.pc *.so.* *.so diff --git a/CMakeLists.txt b/CMakeLists.txt index f9629b1..eff7e13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ cmake_minimum_required(VERSION 3.3) project(Libraries) -find_package(WPEFramework) +find_package(Thunder) if (BUILD_REFERENCE) add_definitions (-DBUILD_REFERENCE=${BUILD_REFERENCE}) diff --git a/Source/asconnector/CMakeLists.txt b/Source/asconnector/CMakeLists.txt index 1de7910..1cdb138 100755 --- a/Source/asconnector/CMakeLists.txt +++ b/Source/asconnector/CMakeLists.txt @@ -16,8 +16,8 @@ find_package( systemd REQUIRED ) find_package( udev REQUIRED ) Find Library for Tracing and JSON -find_package(WPEFramework REQUIRED) -find_package(WPEFrameworkMessaging REQUIRED) +find_package(Thunder REQUIRED) +find_package(ThunderMessaging REQUIRED) # We require C++14 set( CMAKE_CXX_STANDARD 14 ) @@ -62,7 +62,7 @@ add_executable( target_link_libraries( - WPEFrameworkProtocols::WPEFrameworkProtocols + ThunderProtocols::ThunderProtocols ${SYSTEMD_LIBRARIES} diff --git a/Source/bluetooth/BluetoothUtils.cpp b/Source/bluetooth/BluetoothUtils.cpp index 0fab4ea..60d387a 100644 --- a/Source/bluetooth/BluetoothUtils.cpp +++ b/Source/bluetooth/BluetoothUtils.cpp @@ -19,7 +19,7 @@ #include "BluetoothUtils.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { @@ -215,4 +215,4 @@ void BtUtilsBaswap(bdaddr_t* dst, const bdaddr_t* src) } // namespace Bluetooth -} // namespace WPEFramework +} // namespace Thunder diff --git a/Source/bluetooth/BluetoothUtils.h b/Source/bluetooth/BluetoothUtils.h index e164f67..28ee13a 100644 --- a/Source/bluetooth/BluetoothUtils.h +++ b/Source/bluetooth/BluetoothUtils.h @@ -21,7 +21,7 @@ #include "Module.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { @@ -58,4 +58,4 @@ inline void BtUtilsHciFilterSetPtype(int t, struct hci_filter *f) } // namespace Bluetooth -} // namespace WPEFramework +} // namespace Thunder diff --git a/Source/bluetooth/CMakeLists.txt b/Source/bluetooth/CMakeLists.txt index 45aac58..38bd6f9 100644 --- a/Source/bluetooth/CMakeLists.txt +++ b/Source/bluetooth/CMakeLists.txt @@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.3) -find_package(WPEFramework) +find_package(Thunder) find_package(${NAMESPACE}Core REQUIRED) find_package(${NAMESPACE}Messaging REQUIRED) find_package(CompileSettingsDebug CONFIG REQUIRED) diff --git a/Source/bluetooth/Definitions.cpp b/Source/bluetooth/Definitions.cpp index c7b1bbd..76e2550 100644 --- a/Source/bluetooth/Definitions.cpp +++ b/Source/bluetooth/Definitions.cpp @@ -19,7 +19,7 @@ #include "Module.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { @@ -113,5 +113,5 @@ namespace Bluetooth { return (pos->text != nullptr ? pos->text : _T("reserved")); } -} } // namespace WPEFramework::Bluetooth +} } // namespace Thunder::Bluetooth diff --git a/Source/bluetooth/HCISocket.cpp b/Source/bluetooth/HCISocket.cpp index 2e50e64..834bd00 100644 --- a/Source/bluetooth/HCISocket.cpp +++ b/Source/bluetooth/HCISocket.cpp @@ -19,7 +19,7 @@ #include "HCISocket.h" -namespace WPEFramework { +namespace Thunder { ENUM_CONVERSION_BEGIN(Bluetooth::Address::type) { Bluetooth::Address::BREDR_ADDRESS, _TXT(_T("bredr")) }, diff --git a/Source/bluetooth/HCISocket.h b/Source/bluetooth/HCISocket.h index ff46b86..908c28f 100644 --- a/Source/bluetooth/HCISocket.h +++ b/Source/bluetooth/HCISocket.h @@ -23,7 +23,7 @@ #include "UUID.h" #include "BluetoothUtils.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { @@ -1308,4 +1308,4 @@ POP_WARNING() } // namespace Bluetooth -} // namespace WPEFramework +} // namespace Thunder diff --git a/Source/bluetooth/UUID.cpp b/Source/bluetooth/UUID.cpp index e562db2..41a590f 100644 --- a/Source/bluetooth/UUID.cpp +++ b/Source/bluetooth/UUID.cpp @@ -19,7 +19,7 @@ #include "UUID.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/UUID.h b/Source/bluetooth/UUID.h index 86edc3c..740086d 100644 --- a/Source/bluetooth/UUID.h +++ b/Source/bluetooth/UUID.h @@ -21,7 +21,7 @@ #include "Module.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/audio/AVDTPProfile.cpp b/Source/bluetooth/audio/AVDTPProfile.cpp index e12669a..d716ef7 100644 --- a/Source/bluetooth/audio/AVDTPProfile.cpp +++ b/Source/bluetooth/audio/AVDTPProfile.cpp @@ -20,7 +20,7 @@ #include "Module.h" #include "AVDTPProfile.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/audio/AVDTPProfile.h b/Source/bluetooth/audio/AVDTPProfile.h index ccee18b..83e66d1 100644 --- a/Source/bluetooth/audio/AVDTPProfile.h +++ b/Source/bluetooth/audio/AVDTPProfile.h @@ -22,7 +22,7 @@ #include "Module.h" #include "AVDTPSocket.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/audio/AVDTPSocket.cpp b/Source/bluetooth/audio/AVDTPSocket.cpp index 29b36dd..2335b93 100644 --- a/Source/bluetooth/audio/AVDTPSocket.cpp +++ b/Source/bluetooth/audio/AVDTPSocket.cpp @@ -20,7 +20,7 @@ #include "Module.h" #include "AVDTPSocket.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/audio/AVDTPSocket.h b/Source/bluetooth/audio/AVDTPSocket.h index ffee2b8..ccd6f46 100644 --- a/Source/bluetooth/audio/AVDTPSocket.h +++ b/Source/bluetooth/audio/AVDTPSocket.h @@ -22,7 +22,7 @@ #include "Module.h" #include "DataRecord.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/audio/CMakeLists.txt b/Source/bluetooth/audio/CMakeLists.txt index e1d400d..2bb8f18 100644 --- a/Source/bluetooth/audio/CMakeLists.txt +++ b/Source/bluetooth/audio/CMakeLists.txt @@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.3) -find_package(WPEFramework) +find_package(Thunder) find_package(${NAMESPACE}Core REQUIRED) find_package(${NAMESPACE}Messaging REQUIRED) find_package(CompileSettingsDebug CONFIG REQUIRED) diff --git a/Source/bluetooth/audio/DataRecord.h b/Source/bluetooth/audio/DataRecord.h index e9b4928..f1b7434 100644 --- a/Source/bluetooth/audio/DataRecord.h +++ b/Source/bluetooth/audio/DataRecord.h @@ -24,7 +24,7 @@ #include -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/audio/IAudioCodec.h b/Source/bluetooth/audio/IAudioCodec.h index 2912183..804dcdc 100644 --- a/Source/bluetooth/audio/IAudioCodec.h +++ b/Source/bluetooth/audio/IAudioCodec.h @@ -21,7 +21,7 @@ #include "Module.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/audio/IAudioContentProtection.h b/Source/bluetooth/audio/IAudioContentProtection.h index 1dcf2fd..43456c8 100644 --- a/Source/bluetooth/audio/IAudioContentProtection.h +++ b/Source/bluetooth/audio/IAudioContentProtection.h @@ -21,7 +21,7 @@ #include "Module.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/audio/RTPSocket.h b/Source/bluetooth/audio/RTPSocket.h index 714e31f..c57b384 100644 --- a/Source/bluetooth/audio/RTPSocket.h +++ b/Source/bluetooth/audio/RTPSocket.h @@ -22,7 +22,7 @@ #include "Module.h" #include "IAudioCodec.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/audio/SDPProfile.cpp b/Source/bluetooth/audio/SDPProfile.cpp index 3ceaa03..99a4368 100644 --- a/Source/bluetooth/audio/SDPProfile.cpp +++ b/Source/bluetooth/audio/SDPProfile.cpp @@ -22,7 +22,7 @@ #include "SDPSocket.h" #include "SDPProfile.h" -namespace WPEFramework { +namespace Thunder { ENUM_CONVERSION_BEGIN(Bluetooth::SDP::ClassID::id) { Bluetooth::SDP::ClassID::Undefined, _TXT("(undefined)") }, diff --git a/Source/bluetooth/audio/SDPProfile.h b/Source/bluetooth/audio/SDPProfile.h index ec799e8..fb100e2 100644 --- a/Source/bluetooth/audio/SDPProfile.h +++ b/Source/bluetooth/audio/SDPProfile.h @@ -25,7 +25,7 @@ #include -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/audio/SDPSocket.cpp b/Source/bluetooth/audio/SDPSocket.cpp index 5b1d3c6..da353b9 100644 --- a/Source/bluetooth/audio/SDPSocket.cpp +++ b/Source/bluetooth/audio/SDPSocket.cpp @@ -20,7 +20,7 @@ #include "Module.h" #include "SDPSocket.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/audio/SDPSocket.h b/Source/bluetooth/audio/SDPSocket.h index 2892f01..1b2c4a6 100644 --- a/Source/bluetooth/audio/SDPSocket.h +++ b/Source/bluetooth/audio/SDPSocket.h @@ -22,7 +22,7 @@ #include "Module.h" #include "DataRecord.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { @@ -910,4 +910,4 @@ namespace SDP { } // namespace Bluetooth -} // namespace WPEFramework +} // namespace Thunder diff --git a/Source/bluetooth/audio/codecs/SBC.cpp b/Source/bluetooth/audio/codecs/SBC.cpp index 8178afb..a40b17e 100644 --- a/Source/bluetooth/audio/codecs/SBC.cpp +++ b/Source/bluetooth/audio/codecs/SBC.cpp @@ -23,7 +23,7 @@ #include -namespace WPEFramework { +namespace Thunder { ENUM_CONVERSION_BEGIN(Bluetooth::A2DP::SBC::preset) { Bluetooth::A2DP::SBC::COMPATIBLE, _TXT("Compatible") }, diff --git a/Source/bluetooth/audio/codecs/SBC.h b/Source/bluetooth/audio/codecs/SBC.h index 0d57bff..aada5cf 100644 --- a/Source/bluetooth/audio/codecs/SBC.h +++ b/Source/bluetooth/audio/codecs/SBC.h @@ -23,7 +23,7 @@ #include "../IAudioCodec.h" #include "../DataRecord.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { diff --git a/Source/bluetooth/drivers/BCM43XX.cpp b/Source/bluetooth/drivers/BCM43XX.cpp index d8955d0..437cbe2 100644 --- a/Source/bluetooth/drivers/BCM43XX.cpp +++ b/Source/bluetooth/drivers/BCM43XX.cpp @@ -21,7 +21,7 @@ #include #include -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { @@ -372,22 +372,22 @@ namespace Bluetooth { uint32_t _baudRate; }; } -} // namespace WPEFramework::Bluetooth +} // namespace Thunder::Bluetooth #ifdef __cplusplus extern "C" { #endif -WPEFramework::Bluetooth::Broadcom43XX* g_driver = nullptr; +Thunder::Bluetooth::Broadcom43XX* g_driver = nullptr; const char* construct_bluetooth_driver(const char* input) { const char* result = "Driver already loaded."; if (g_driver == nullptr) { - WPEFramework::Bluetooth::Broadcom43XX::Config config; + Thunder::Bluetooth::Broadcom43XX::Config config; config.FromString(input); - WPEFramework::Bluetooth::Broadcom43XX* driver = new WPEFramework::Bluetooth::Broadcom43XX(config); + Thunder::Bluetooth::Broadcom43XX* driver = new Thunder::Bluetooth::Broadcom43XX(config); result = driver->Initialize(); diff --git a/Source/bluetooth/drivers/SerialDriver.h b/Source/bluetooth/drivers/SerialDriver.h index 2c441e6..9d726c4 100644 --- a/Source/bluetooth/drivers/SerialDriver.h +++ b/Source/bluetooth/drivers/SerialDriver.h @@ -19,7 +19,7 @@ #include "../Module.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { @@ -53,7 +53,7 @@ namespace Bluetooth { public: // // Exchange holds a definitions of a request and a response for the communication with the - // HCI. See WPEFramework/Source/core/StreamTypeKeyValue.h for more details. + // HCI. See Thunder/Source/core/StreamTypeKeyValue.h for more details. // struct Exchange { @@ -471,4 +471,4 @@ namespace Bluetooth { Core::SerialPort::FlowControl _flowControl; }; } -} // namespace WPEFramework::Bluetooth +} // namespace Thunder::Bluetooth diff --git a/Source/bluetooth/gatt/CMakeLists.txt b/Source/bluetooth/gatt/CMakeLists.txt index bde98ab..4c30065 100644 --- a/Source/bluetooth/gatt/CMakeLists.txt +++ b/Source/bluetooth/gatt/CMakeLists.txt @@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.3) -find_package(WPEFramework) +find_package(Thunder) find_package(${NAMESPACE}Core REQUIRED) find_package(${NAMESPACE}Messaging REQUIRED) find_package(CompileSettingsDebug CONFIG REQUIRED) diff --git a/Source/bluetooth/gatt/GATTProfile.cpp b/Source/bluetooth/gatt/GATTProfile.cpp index bded52a..385c1a2 100644 --- a/Source/bluetooth/gatt/GATTProfile.cpp +++ b/Source/bluetooth/gatt/GATTProfile.cpp @@ -19,7 +19,7 @@ #include "GATTProfile.h" -namespace WPEFramework { +namespace Thunder { ENUM_CONVERSION_BEGIN(Bluetooth::GATTProfile::Service::Characteristic::Descriptor::type) @@ -322,5 +322,5 @@ ENUM_CONVERSION_BEGIN(Bluetooth::GATTProfile::Service::type) ENUM_CONVERSION_END(Bluetooth::GATTProfile::Service::type) -} // namespace WPEFramework +} // namespace Thunder diff --git a/Source/bluetooth/gatt/GATTProfile.h b/Source/bluetooth/gatt/GATTProfile.h index f893147..d014ac9 100644 --- a/Source/bluetooth/gatt/GATTProfile.h +++ b/Source/bluetooth/gatt/GATTProfile.h @@ -22,7 +22,7 @@ #include "Module.h" #include "GATTSocket.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { @@ -879,5 +879,5 @@ namespace Bluetooth { } // namespace Bluetooth -} // namespace WPEFramework +} // namespace Thunder diff --git a/Source/bluetooth/gatt/GATTSocket.cpp b/Source/bluetooth/gatt/GATTSocket.cpp index e4685d5..b71ce74 100644 --- a/Source/bluetooth/gatt/GATTSocket.cpp +++ b/Source/bluetooth/gatt/GATTSocket.cpp @@ -19,7 +19,7 @@ #include "GATTSocket.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { @@ -353,4 +353,4 @@ bool GATTSocket::Security(const uint8_t level) } // namespace Bluetooth -} // namespace WPEFramework +} // namespace Thunder diff --git a/Source/bluetooth/gatt/GATTSocket.h b/Source/bluetooth/gatt/GATTSocket.h index 0722abd..9cad937 100644 --- a/Source/bluetooth/gatt/GATTSocket.h +++ b/Source/bluetooth/gatt/GATTSocket.h @@ -21,7 +21,7 @@ #include "Module.h" -namespace WPEFramework { +namespace Thunder { namespace Bluetooth { @@ -905,4 +905,4 @@ namespace Bluetooth { } // namespace Bluetooth -} // namespace WPEFramework +} // namespace Thunder diff --git a/Source/broadcast/CMakeLists.txt b/Source/broadcast/CMakeLists.txt index 11d1e8d..334aa9d 100644 --- a/Source/broadcast/CMakeLists.txt +++ b/Source/broadcast/CMakeLists.txt @@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.3) -find_package(WPEFramework) +find_package(Thunder) find_package(${NAMESPACE}Core REQUIRED) find_package(CompileSettingsDebug CONFIG REQUIRED) diff --git a/Source/broadcast/Definitions.cpp b/Source/broadcast/Definitions.cpp index 9c2aba7..48e301e 100644 --- a/Source/broadcast/Definitions.cpp +++ b/Source/broadcast/Definitions.cpp @@ -19,7 +19,7 @@ #include "Definitions.h" -namespace WPEFramework { +namespace Thunder { ENUM_CONVERSION_BEGIN(Broadcast::ITuner::DTVStandard) { Broadcast::ITuner::DVB, _TXT("DVB") }, @@ -71,4 +71,4 @@ ENUM_CONVERSION_BEGIN(Broadcast::Modulation) { Broadcast::QAM4096, _TXT("QAM4096") }, ENUM_CONVERSION_END(Broadcast::Modulation) -} // namespace WPEFramework +} // namespace Thunder diff --git a/Source/broadcast/Definitions.h b/Source/broadcast/Definitions.h index 4ddf7e4..e7d2635 100644 --- a/Source/broadcast/Definitions.h +++ b/Source/broadcast/Definitions.h @@ -22,7 +22,7 @@ #include "Module.h" -namespace WPEFramework { +namespace Thunder { namespace Broadcast { @@ -367,6 +367,6 @@ namespace Broadcast { }; } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif // __BROADCAST_DEFINITIONS_H diff --git a/Source/broadcast/Descriptors.h b/Source/broadcast/Descriptors.h index aa1ade5..8d8c066 100644 --- a/Source/broadcast/Descriptors.h +++ b/Source/broadcast/Descriptors.h @@ -23,7 +23,7 @@ #include "Definitions.h" #include "MPEGDescriptor.h" -namespace WPEFramework { +namespace Thunder { namespace Broadcast { namespace DVB { namespace Descriptors { @@ -224,6 +224,6 @@ namespace Broadcast { } } } -} // namespace WPEFramework::Broadcast::DVB::Descriptors +} // namespace Thunder::Broadcast::DVB::Descriptors #endif // DESCRIPTORS_H diff --git a/Source/broadcast/EIT.h b/Source/broadcast/EIT.h index 719198a..4bdc331 100644 --- a/Source/broadcast/EIT.h +++ b/Source/broadcast/EIT.h @@ -35,7 +35,7 @@ // ---- Class Definition ---- -namespace WPEFramework { +namespace Thunder { namespace Broadcast { namespace DVB { @@ -198,6 +198,6 @@ namespace Broadcast { } // namespace DVB } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif // DVB_EIT_TABLE_H diff --git a/Source/broadcast/Implementation/V4L/Tuner.cpp b/Source/broadcast/Implementation/V4L/Tuner.cpp index d25d920..0048bb5 100644 --- a/Source/broadcast/Implementation/V4L/Tuner.cpp +++ b/Source/broadcast/Implementation/V4L/Tuner.cpp @@ -35,11 +35,11 @@ // -------------------------------------------------------------------- // SOURCE: https://linuxtv.org/downloads/v4l-dvb-apis/uapi/dvb // -------------------------------------------------------------------- -namespace WPEFramework { +namespace Thunder { namespace Broadcast { struct conversion_entry { - int from; // WPEFramework Broadcast/ITuner value + int from; // Thunder Broadcast/ITuner value int to; // LinuxDVB API value }; @@ -838,4 +838,4 @@ POP_WARNING() } } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder diff --git a/Source/broadcast/MPEGDescriptor.h b/Source/broadcast/MPEGDescriptor.h index 950bcde..f416337 100644 --- a/Source/broadcast/MPEGDescriptor.h +++ b/Source/broadcast/MPEGDescriptor.h @@ -33,7 +33,7 @@ // ---- Class Definition ---- -namespace WPEFramework { +namespace Thunder { namespace Broadcast { namespace MPEG { class EXTERNAL Descriptor { @@ -175,6 +175,6 @@ namespace Broadcast { } // namespace MPEG } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif //__MPEGDESCRIPTORS_H diff --git a/Source/broadcast/MPEGSection.h b/Source/broadcast/MPEGSection.h index 0833160..ac67325 100644 --- a/Source/broadcast/MPEGSection.h +++ b/Source/broadcast/MPEGSection.h @@ -33,7 +33,7 @@ // ---- Class Definition ---- -namespace WPEFramework { +namespace Thunder { namespace Broadcast { namespace MPEG { class EXTERNAL Section { @@ -278,6 +278,6 @@ namespace Broadcast { } // namespace MPEG } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif // __MPEGSECTION_H diff --git a/Source/broadcast/MPEGTable.h b/Source/broadcast/MPEGTable.h index 06bacee..9bc233d 100644 --- a/Source/broadcast/MPEGTable.h +++ b/Source/broadcast/MPEGTable.h @@ -35,7 +35,7 @@ // ---- Class Definition ---- -namespace WPEFramework { +namespace Thunder { namespace Broadcast { namespace MPEG { class EXTERNAL PAT { @@ -276,6 +276,6 @@ namespace Broadcast { } // namespace MPEG } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif // __MPEGTABLE_ diff --git a/Source/broadcast/NIT.h b/Source/broadcast/NIT.h index 99dea55..5a51d5a 100644 --- a/Source/broadcast/NIT.h +++ b/Source/broadcast/NIT.h @@ -35,7 +35,7 @@ // ---- Class Definition ---- -namespace WPEFramework { +namespace Thunder { namespace Broadcast { namespace DVB { @@ -187,6 +187,6 @@ namespace Broadcast { } // namespace DVB } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif // DVB_NIT_TABLE_H diff --git a/Source/broadcast/Networks.h b/Source/broadcast/Networks.h index 1e12b32..a49f819 100644 --- a/Source/broadcast/Networks.h +++ b/Source/broadcast/Networks.h @@ -25,7 +25,7 @@ #include "NIT.h" #include "ProgramTable.h" -namespace WPEFramework { +namespace Thunder { namespace Broadcast { @@ -361,6 +361,6 @@ namespace Broadcast { }; } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif // NETWORKS_ADMINISTRATOR_H diff --git a/Source/broadcast/ProgramTable.cpp b/Source/broadcast/ProgramTable.cpp index be244dd..bf9b423 100644 --- a/Source/broadcast/ProgramTable.cpp +++ b/Source/broadcast/ProgramTable.cpp @@ -19,7 +19,7 @@ #include "ProgramTable.h" -namespace WPEFramework { +namespace Thunder { namespace Broadcast { @@ -99,4 +99,4 @@ namespace Broadcast { } } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder diff --git a/Source/broadcast/ProgramTable.h b/Source/broadcast/ProgramTable.h index b225fa1..f042d1d 100644 --- a/Source/broadcast/ProgramTable.h +++ b/Source/broadcast/ProgramTable.h @@ -23,7 +23,7 @@ #include "Definitions.h" #include "MPEGTable.h" -namespace WPEFramework { +namespace Thunder { namespace Broadcast { @@ -175,6 +175,6 @@ namespace Broadcast { }; } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif diff --git a/Source/broadcast/SDT.h b/Source/broadcast/SDT.h index e5aca3a..2a1a650 100644 --- a/Source/broadcast/SDT.h +++ b/Source/broadcast/SDT.h @@ -35,7 +35,7 @@ // ---- Class Definition ---- -namespace WPEFramework { +namespace Thunder { namespace Broadcast { namespace DVB { @@ -198,6 +198,6 @@ namespace Broadcast { } // namespace DVB } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif // DVB_SDT_TABLE_H diff --git a/Source/broadcast/Schedule.h b/Source/broadcast/Schedule.h index ee9476c..935805f 100644 --- a/Source/broadcast/Schedule.h +++ b/Source/broadcast/Schedule.h @@ -24,7 +24,7 @@ #include "Descriptors.h" #include "EIT.h" -namespace WPEFramework { +namespace Thunder { namespace Broadcast { @@ -213,6 +213,6 @@ namespace Broadcast { }; } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif // SCHEDULE_ADMINISTRATOR_H diff --git a/Source/broadcast/Services.h b/Source/broadcast/Services.h index 025f9f5..2dca943 100644 --- a/Source/broadcast/Services.h +++ b/Source/broadcast/Services.h @@ -24,7 +24,7 @@ #include "Descriptors.h" #include "SDT.h" -namespace WPEFramework { +namespace Thunder { namespace Broadcast { @@ -324,6 +324,6 @@ namespace Broadcast { }; } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif // SERVICE_ADMINISTRATOR_H diff --git a/Source/broadcast/TDT.h b/Source/broadcast/TDT.h index b8ff198..f8cfb6b 100644 --- a/Source/broadcast/TDT.h +++ b/Source/broadcast/TDT.h @@ -35,7 +35,7 @@ // ---- Class Definition ---- -namespace WPEFramework { +namespace Thunder { namespace Broadcast { namespace DVB { @@ -135,6 +135,6 @@ namespace Broadcast { } // namespace DVB } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif // DVB_TDT_TABLE_H diff --git a/Source/broadcast/TimeDate.h b/Source/broadcast/TimeDate.h index daf7203..51c7a31 100644 --- a/Source/broadcast/TimeDate.h +++ b/Source/broadcast/TimeDate.h @@ -24,7 +24,7 @@ #include "Descriptors.h" #include "TDT.h" -namespace WPEFramework { +namespace Thunder { namespace Broadcast { @@ -222,6 +222,6 @@ namespace Broadcast { }; } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif // TIMEDATE_ADMINISTRATOR_H diff --git a/Source/broadcast/TunerAdministrator.cpp b/Source/broadcast/TunerAdministrator.cpp index 2cbfb76..e33ab74 100644 --- a/Source/broadcast/TunerAdministrator.cpp +++ b/Source/broadcast/TunerAdministrator.cpp @@ -19,7 +19,7 @@ #include "TunerAdministrator.h" -namespace WPEFramework { +namespace Thunder { namespace Broadcast { @@ -41,4 +41,4 @@ namespace Broadcast { } } -} // namespace WPEFramework::Broadcast +} // namespace Thunder::Broadcast diff --git a/Source/broadcast/TunerAdministrator.h b/Source/broadcast/TunerAdministrator.h index 83fe3f9..55a9549 100644 --- a/Source/broadcast/TunerAdministrator.h +++ b/Source/broadcast/TunerAdministrator.h @@ -23,7 +23,7 @@ #include "Definitions.h" #include "MPEGTable.h" -namespace WPEFramework { +namespace Thunder { namespace Broadcast { @@ -187,6 +187,6 @@ namespace Broadcast { }; } // namespace Broadcast -} // namespace WPEFramework +} // namespace Thunder #endif // TUNER_ADMINISTRATOR_H diff --git a/Source/broadcast/cmake/FindNEXUS.cmake b/Source/broadcast/cmake/FindNEXUS.cmake deleted file mode 120000 index f77db7f..0000000 --- a/Source/broadcast/cmake/FindNEXUS.cmake +++ /dev/null @@ -1 +0,0 @@ -../../../cmake/FindNEXUS.cmake \ No newline at end of file diff --git a/Source/broadcast/cmake/FindNEXUS.cmake b/Source/broadcast/cmake/FindNEXUS.cmake new file mode 100644 index 0000000..2d18741 --- /dev/null +++ b/Source/broadcast/cmake/FindNEXUS.cmake @@ -0,0 +1,83 @@ +# - Try to find Broadcom Nexus. +# Once done this will define +# NEXUS_FOUND - System has Nexus +# NEXUS::NEXUS - The Nexus library +# +# Copyright (C) 2019 Metrological B.V +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS +# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +find_path(LIBNEXUS_INCLUDE nexus_config.h + PATH_SUFFIXES refsw) + +find_library(LIBNEXUS_LIBRARY nexus) + +if(EXISTS "${LIBNEXUS_LIBRARY}") + find_library(LIBB_OS_LIBRARY b_os) + find_library(LIBNEXUS_CLIENT_LIBRARY nexus_client) + find_library(LIBNXCLIENT_LIBRARY nxclient) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(NEXUS DEFAULT_MSG LIBNEXUS_INCLUDE LIBNEXUS_LIBRARY) + mark_as_advanced(LIBNEXUS_INCLUDE LIBNEXUS_LIBRARY) + + if(NEXUS_FOUND AND NOT TARGET NEXUS::NEXUS) + add_library(NEXUS::NEXUS UNKNOWN IMPORTED) + set_target_properties(NEXUS::NEXUS PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + INTERFACE_INCLUDE_DIRECTORIES "${LIBNEXUS_INCLUDE}" + ) + + if(NOT EXISTS "${LIBNEXUS_CLIENT_LIBRARY}") + message(STATUS "Nexus in Proxy mode") + set_target_properties(NEXUS::NEXUS PROPERTIES + IMPORTED_LOCATION "${LIBNEXUS_LIBRARY}" + ) + else() + message(STATUS "Nexus in Client mode") + set_target_properties(NEXUS::NEXUS PROPERTIES + IMPORTED_LOCATION "${LIBNEXUS_CLIENT_LIBRARY}" + ) + endif() + + if(NOT EXISTS "${LIBNXCLIENT_LIBRARY}") + set_target_properties(NEXUS::NEXUS PROPERTIES + INTERFACE_COMPILE_DEFINITIONS NO_NXCLIENT + ) + endif() + + if(EXISTS "${LIBB_OS_LIBRARY}") + set_target_properties(NEXUS::NEXUS PROPERTIES + IMPORTED_LINK_INTERFACE_LIBRARIES "${LIBB_OS_LIBRARY}" + ) + endif() + endif() + set_target_properties(NEXUS::NEXUS PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "PLATFORM_BRCM" + ) +else() + if(NEXUS_FIND_REQUIRED) + message(FATAL_ERROR "LIBNEXUS_LIBRARY not available") + elseif(NOT NEXUS_FIND_QUIETLY) + message(STATUS "LIBNEXUS_LIBRARY not available") + endif() +endif() \ No newline at end of file diff --git a/Source/broadcast/test/BroadcastTester.cpp b/Source/broadcast/test/BroadcastTester.cpp index 535abc6..7d72404 100644 --- a/Source/broadcast/test/BroadcastTester.cpp +++ b/Source/broadcast/test/BroadcastTester.cpp @@ -24,7 +24,7 @@ #include MODULE_NAME_DECLARATION(BUILD_REFERENCE) -using namespace WPEFramework; +using namespace Thunder; void printHelp(){ printf("Keys to use:\n"); @@ -157,7 +157,7 @@ int main(int /* argc */, const char** /* argv */) } while (keyPress != 'Q'); // Clear the factory we created.. - WPEFramework::Core::Singleton::Dispose(); + Thunder::Core::Singleton::Dispose(); printf("\nLeaving the test App !!!\n"); diff --git a/Source/compositorbuffer/CMakeLists.txt b/Source/compositorbuffer/CMakeLists.txt new file mode 100644 index 0000000..a3790c9 --- /dev/null +++ b/Source/compositorbuffer/CMakeLists.txt @@ -0,0 +1,57 @@ +# If not stated otherwise in this file or this component's LICENSE file the +# following copyright and licenses apply: +# +# Copyright 2022 Metrological +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +project(CompositorBufferType LANGUAGES CXX) + +cmake_minimum_required(VERSION 3.12) + +find_package(Thunder) + +project_version(1.0.0) + +set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME}) + +message("Setup ${MODULE_NAME} v${PROJECT_VERSION}") + +option(INSTALL_EXAMPLES "Install the examples." ON) + +find_package(${NAMESPACE}Core REQUIRED) + +add_library(${MODULE_NAME} INTERFACE) +add_library(${MODULE_NAME}::${MODULE_NAME} ALIAS ${MODULE_NAME}) + +target_include_directories(${MODULE_NAME} INTERFACE + $ + $) + +target_compile_features(${MODULE_NAME} INTERFACE cxx_std_11) + +install(TARGETS ${MODULE_NAME} EXPORT ${MODULE_NAME}Targets) + +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/compositorbuffer/CompositorBufferType.h + DESTINATION include/${NAMESPACE}/compositorbuffer) + +include(HeaderOnlyInstall) + +HeaderOnlyInstallPackageConfig(TARGET ${MODULE_NAME} + NAME ${MODULE_NAME} + VERSION ${PROJECT_VERSION} + DESCRIPTION "Header only library for creating and using compositor buffers.") + +HeaderOnlyInstallCMakeConfig(TARGET ${MODULE_NAME} TREAT_AS_NORMAL) + +add_subdirectory(example) diff --git a/Source/compositorbuffer/example/CMakeLists.txt b/Source/compositorbuffer/example/CMakeLists.txt new file mode 100644 index 0000000..8f6898a --- /dev/null +++ b/Source/compositorbuffer/example/CMakeLists.txt @@ -0,0 +1,39 @@ +# If not stated otherwise in this file or this component's LICENSE file the +# following copyright and licenses apply: +# +# Copyright 2022 Metrological +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +find_package(Thunder) + +find_package(${NAMESPACE}Definitions REQUIRED) +find_package(${NAMESPACE}Core REQUIRED) +find_package(${NAMESPACE}PrivilegedRequest REQUIRED) +find_package(CompileSettingsDebug REQUIRED) + +add_executable(cb-test main.cpp) + +target_link_libraries(cb-test PRIVATE + CompileSettingsDebug::CompileSettingsDebug + ${NAMESPACE}Definitions::${NAMESPACE}Definitions + ${NAMESPACE}Core::${NAMESPACE}Core + ${NAMESPACE}PrivilegedRequest::${NAMESPACE}PrivilegedRequest + ${NAMESPACE}CompositorBufferType::${NAMESPACE}CompositorBufferType) + +if(INSTALL_EXAMPLES) + install(TARGETS cb-test DESTINATION bin) +endif() + + + diff --git a/Source/compositorbuffer/example/main.cpp b/Source/compositorbuffer/example/main.cpp new file mode 100644 index 0000000..6a5c2b6 --- /dev/null +++ b/Source/compositorbuffer/example/main.cpp @@ -0,0 +1,303 @@ +/** + * If not stated otherwise in this file or this component's LICENSE + * file the following copyright and licenses apply: + * + * Copyright 2022 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ +#include + +using namespace Thunder; + +MODULE_NAME_ARCHIVE_DECLARATION +namespace Test { + +const char* descriptors[] = { + _T("/tmp/buffer1.txt"), + _T("/tmp/buffer2.txt"), +}; + +const char bridgeConnector[] = _T("/tmp/connector"); + +class CompositorBuffer : public Thunder::Compositor::CompositorBufferType<4>, public Core::IReferenceCounted { +private: + using BaseClass = Thunder::Compositor::CompositorBufferType<4>; + +protected: + CompositorBuffer(const string& callsign, const uint32_t id, + const uint32_t width, const uint32_t height, + const uint32_t format, const uint64_t modifier, + const Exchange::ICompositionBuffer::DataType type) + : BaseClass(callsign, id, width, height, format, modifier, type) + { + + printf("Constructing server buffer.\n"); + + for (uint8_t index = 0; index < (sizeof(descriptors) / sizeof(const char*)); index++) { + Core::File file(string(descriptors[index])); + if (file.Create(Core::File::USER_READ | Core::File::USER_WRITE) == true) { + BaseClass::Add(static_cast(file), 0xAAAA + index, 0x5555 + index); + printf("Opening: [%d] -> name: %s\n", static_cast(file), descriptors[index]); + } + } + // Let's start monitoring the CompositorBuffer to detect changes + Core::ResourceMonitor::Instance().Register(*this); + } + +public: + CompositorBuffer() = delete; + CompositorBuffer(CompositorBuffer&&) = delete; + CompositorBuffer(const CompositorBuffer&) = delete; + CompositorBuffer& operator=(const CompositorBuffer&) = delete; + + static Core::ProxyType Create(const string& callsign, const uint32_t width, const uint32_t height, const Exchange::ICompositionBuffer::DataType type) + { + static uint32_t id = 1; + uint32_t identifier = Core::InterlockedIncrement(id); + return (_map.Instance(callsign, callsign, identifier, width, height, 0xAA, 0x55, type)); + } + static Core::ProxyType Find(const string& callsign) + { + return (_map.Find(callsign)); + } + ~CompositorBuffer() override + { + // Let's stop monitoring the CompositorBuffer to detect changes + Core::ResourceMonitor::Instance().Unregister(*this); + printf("Destructing server buffer.\n"); + } + +public: + // Methods still to be implemented.... + void Render() override + { + printf("We need to do our magic here :-)\n"); + } + +private: + static Core::ProxyMapType _map; +}; + +/* static */ Core::ProxyMapType CompositorBuffer::_map; + +class ClientBuffer : public Thunder::Compositor::CompositorBufferType<4>, public Core::IReferenceCounted { +private: + using BaseClass = Thunder::Compositor::CompositorBufferType<4>; + +protected: + ClientBuffer(const uint32_t id, Core::PrivilegedRequest::Container& descriptors) + : BaseClass(id, descriptors) + { + } + +public: + ClientBuffer() = delete; + ClientBuffer(ClientBuffer&&) = delete; + ClientBuffer(const ClientBuffer&) = delete; + ClientBuffer& operator=(const ClientBuffer&) = delete; + + static Exchange::ICompositionBuffer* Create(const uint32_t id, Core::PrivilegedRequest::Container& descriptors) + { + Core::ProxyType element(Core::ProxyType::Create(id, descriptors)); + Exchange::ICompositionBuffer* result = &(*element); + result->AddRef(); + return (result); + } + +public: + // Methods still to be implemented.... + void Render() override + { + ASSERT(false); + } +}; + +class Dispatcher : public Core::PrivilegedRequest { +public: + Dispatcher(Dispatcher&&) = delete; + Dispatcher(const Dispatcher&) = delete; + Dispatcher& operator=(const Dispatcher&) = delete; + + Dispatcher() = default; + ~Dispatcher() override = default; + + void Add(const uint32_t id, Thunder::Compositor::CompositorBufferType<4>& buffer) + { + _id = id; + _buffer = &buffer; + } + void Remove(const uint32_t id) + { + if (_id == id) { + _id = 0; + _buffer = nullptr; + } + } + uint8_t Service(const uint32_t id, const uint8_t maxSize, int container[]) override + { + if ((id == _id) && (_buffer != nullptr)) { + uint8_t result = _buffer->Descriptors(maxSize, container); + + if (result > 0) { + printf("Handing out: %d descriptors: [", result); + for (uint8_t index = 0; index < (result - 1); index++) { + printf("%d,", container[index]); + } + printf("%d]\n", container[result - 1]); + } + return (result); + } + return 0; + } + +private: + uint32_t _id; + Thunder::Compositor::CompositorBufferType<4>* _buffer; +}; + +} // namespace Test + +bool server = false; +uint32_t bufferId = 0; + +bool ParseOptions(int argc, const char** argv) +{ + int index = 1; + bool showHelp = false; + + while ((index < argc) && (showHelp == false)) { + + if (strcmp(argv[index], "-server") == 0) { + server = true; + } else if (strcmp(argv[index], "-b") == 0) { + + if (((index + 1) < argc) && (argv[index + 1][0] != '-')) { + + index++; + bufferId = atoi(argv[index]); + } + } else { + showHelp = true; + } + index++; + } + + if (showHelp == true) { + printf("Test passing filedescriptos and information over a process boundary.\n"); + printf("%s [-server] [-b ]\n", argv[0]); + printf(" -server Act as a server.\n"); + printf(" -b Act as a client and get the buffer associated with this number.\n"); + } + + return (showHelp == false); +} + +int main(int argc, const char* argv[]) +{ + { + TCHAR element; + ParseOptions(argc, argv); + printf("Running as: [%s]\n", server ? _T("server") : _T("client")); + Test::Dispatcher bridge; + Core::ProxyType serverBuffer; + + Exchange::ICompositionBuffer* buffer = nullptr; + + if (server == true) { + serverBuffer = Test::CompositorBuffer::Create(_T("TestCall"), 1024, 1080, Exchange::ICompositionBuffer::TYPE_RAW); + buffer = &(*serverBuffer); + bridge.Open(string(Test::bridgeConnector)); + printf("Server has created a buffer, known as: [%d]\n", bufferId); + bridge.Add(bufferId, *serverBuffer); + } else { + printf("Client instantiated to get information of buffer: [%d]\n", bufferId); + } + + do { + printf("\n>"); + element = toupper(getchar()); + + switch (element) { + case 'O': + if (buffer == nullptr) { + Core::PrivilegedRequest::Container descriptors; + printf("Get the buffer interface, Sesame open:\n"); + if (bridge.Request(1000, string(Test::bridgeConnector), bufferId, descriptors) == Core::ERROR_NONE) { + printf("Got the buffer on client side.\n"); + buffer = Test::ClientBuffer::Create(bufferId, descriptors); + } else { + printf("Failed to get the buffer.\n"); + } + } else if (server == false) { + printf("Where done, we put it all in, close the vault, Sesame close:\n"); + buffer = nullptr; + } + break; + case 'I': + if (buffer == nullptr) { + printf("There are no buffers\n"); + } else { + printf("Buffer info:\n"); + printf("==========================================\n"); + printf("Width: %d\n", buffer->Width()); + printf("Height: %d\n", buffer->Height()); + printf("Format: %d\n", buffer->Format()); + printf("Type: %d\n", buffer->Type()); + Thunder::Compositor::CompositorBufferType<4>* info = dynamic_cast*>(buffer); + if (info != nullptr) { + printf("Dirty: %s\n", info->IsDirty() ? _T("true") : _T("false")); + } + } + break; + case 'W': + if (buffer == nullptr) { + printf("There are no buffers\n"); + } else { + Exchange::ICompositionBuffer::IIterator* planes = buffer->Planes(10); + + if (planes != nullptr) { + printf("Iterating ove the planes to write:\n"); + while (planes->Next() == true) { + Exchange::ICompositionBuffer::IPlane* plane = planes->Plane(); + ASSERT(plane != nullptr); + int fd = static_cast(plane->Accessor()); + printf("Writing to [%d]:\n", fd); + ::write(fd, "Hello World !!!\n", 16); + ::fsync(fd); + } + } + + buffer->Completed(true); + } + break; + case 'Q': + break; + case '?': + printf("Options available:\n"); + printf("=======================================================================\n"); + printf(" Open/Close the buffer.\n"); + printf(" Information of the buffer.\n"); + printf(" Write a the number in a file.\n"); + printf(" Have no clue what I can do, tell me.\n"); + break; + default: + break; + } + } while (element != 'Q'); + } + + Core::Singleton::Dispose(); + + return EXIT_SUCCESS; +} diff --git a/Source/compositorbuffer/include/compositorbuffer/CompositorBufferType.h b/Source/compositorbuffer/include/compositorbuffer/CompositorBufferType.h new file mode 100644 index 0000000..25f0f3d --- /dev/null +++ b/Source/compositorbuffer/include/compositorbuffer/CompositorBufferType.h @@ -0,0 +1,515 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2022 Metrological B.V. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#ifndef MODULE_NAME +#define MODULE_NAME Compositor_BufferType +#endif + +#include +#include + +#include + +#include +#include + +namespace Thunder { + +namespace Compositor { + + template + class CompositorBufferType : public Exchange::ICompositionBuffer, public Core::IResource { + private: + /*** + * We need a 64bit according: https://github.com/torvalds/linux/blob/v6.1/fs/eventfd.c#L275 + */ + using EventFrame = uint64_t; + + // We need some shared space for data to exchange, and to create a lock.. + class SharedStorage { + private: + struct PlaneStorage { + uint32_t _stride; + uint32_t _offset; + }; + + public: + void* operator new(size_t stAllocateBlock, int fd) + { + void* result = ::mmap(nullptr, stAllocateBlock, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + return (result != MAP_FAILED ? result : nullptr); + } + // Somehow Purify gets lost if we do not delete it, overide the delete operator + void operator delete(void* stAllocateBlock) + { + ::munmap(stAllocateBlock, sizeof(struct SharedStorage)); + } + + public: + SharedStorage(SharedStorage&&) = delete; + SharedStorage(const SharedStorage&) = delete; + SharedStorage& operator=(const SharedStorage&) = delete; + + // FIXME: + // Do not initialize members for now, this constructor is called after a mmap in the + // placement new operator above. Initializing them now will reset the original values + // of the buffer metadata. + SharedStorage(){}; + + SharedStorage(const uint32_t width, const uint32_t height, const uint32_t format, const uint64_t modifier, const Exchange::ICompositionBuffer::DataType type) + : _width(width) + , _height(height) + , _format(format) + , _modifier(modifier) + , _type(type) + , _dirty() + , _copyOfDirty(false) + { + if (::pthread_mutex_init(&_mutex, nullptr) != 0) { + // That will be the day, if this fails... + ASSERT(false); + } + } + ~SharedStorage() + { +#ifdef __WINDOWS__ + ::CloseHandle(&(_mutex)); +#else + ::pthread_mutex_destroy(&(_mutex)); +#endif + } + + public: + uint32_t Width() const + { + return (_width); + } + uint32_t Height() const + { + return (_height); + } + uint32_t Format() const + { + return (_format); + } + uint32_t Modifier() const + { + return (_modifier); + } + uint32_t Stride(const uint8_t index) const + { // Bytes per row for a plane [(bit-per-pixel/8) * width] + return (_planes[index]._stride); + } + uint32_t Offset(const uint8_t index) const + { // Offset of the plane from where the pixel data starts in the buffer. + return (_planes[index]._offset); + } + void Add(uint8_t index, const uint32_t stride, const uint32_t offset) + { + _planes[index]._stride = stride; + _planes[index]._offset = offset; + } + bool Dirty() + { + _copyOfDirty = false; + return (_dirty.test_and_set() == false); + } + bool IsDirty() + { + return (_copyOfDirty); + } + void Set() + { + _dirty.clear(); + _copyOfDirty = true; + } + Exchange::ICompositionBuffer::DataType Type() const + { + return _type; + } + uint32_t Lock(uint32_t timeout) + { + timespec structTime; + +#ifdef __WINDOWS__ + return (::WaitForSingleObjectEx(&_mutex, timeout, FALSE) == WAIT_OBJECT_0 ? Core::ERROR_NONE : Core::ERROR_TIMEDOUT); +#else + clock_gettime(CLOCK_MONOTONIC, &structTime); + structTime.tv_nsec += ((timeout % 1000) * 1000 * 1000); /* remainder, milliseconds to nanoseconds */ + structTime.tv_sec += (timeout / 1000) + (structTime.tv_nsec / 1000000000); /* milliseconds to seconds */ + structTime.tv_nsec = structTime.tv_nsec % 1000000000; + int result = pthread_mutex_timedlock(&_mutex, &structTime); + return (result == 0 ? Core::ERROR_NONE : Core::ERROR_TIMEDOUT); +#endif + } + uint32_t Unlock() + { +#ifdef __WINDOWS__ + ::LeaveCriticalSection(&_mutex); +#else + pthread_mutex_unlock(&_mutex); +#endif + return (Core::ERROR_NONE); + } + + private: + uint32_t _width; + uint32_t _height; + uint32_t _format; + uint64_t _modifier; + Exchange::ICompositionBuffer::DataType _type; + PlaneStorage _planes[PLANES]; +#ifdef __WINDOWS__ + CRITICAL_SECTION _mutex; +#else + pthread_mutex_t _mutex; +#endif + std::atomic_flag _dirty; + bool _copyOfDirty; + }; + + class Iterator : public Exchange::ICompositionBuffer::IIterator { + private: + class PlaneImplementation : public Exchange::ICompositionBuffer::IPlane { + public: + PlaneImplementation(PlaneImplementation&&) = delete; + PlaneImplementation(const PlaneImplementation&) = delete; + PlaneImplementation& operator=(const PlaneImplementation&) = delete; + + PlaneImplementation() + : _parent(nullptr) + , _index(-1) + { + } + ~PlaneImplementation() override = default; + + public: + void Define(CompositorBufferType& parent, const uint8_t index) + { + _parent = &parent; + _index = index; + } + buffer_id Accessor() const override + { // Access to the actual data. + ASSERT(_parent != nullptr); + return (_parent->Accessor(_index)); + } + uint32_t Stride() const override + { // Bytes per row for a plane [(bit-per-pixel/8) * width] + ASSERT(_parent != nullptr); + ASSERT(_parent->_storage != nullptr); + return (_parent->_storage->Stride(_index)); + } + uint32_t Offset() const override + { // Offset of the plane from where the pixel data starts in the buffer. + ASSERT(_parent != nullptr); + ASSERT(_parent->_storage != nullptr); + return (_parent->_storage->Offset(_index)); + } + + private: + CompositorBufferType* _parent; + uint8_t _index; + }; + + public: + Iterator() = delete; + Iterator(Iterator&&) = delete; + Iterator(const Iterator&) = delete; + Iterator& operator=(const Iterator&) = delete; + + Iterator(CompositorBufferType& parent) + : _parent(parent) + { + // Fill our elements + for (uint8_t index = 0; index < PLANES; index++) { + _planes[index].Define(_parent, index); + } + + Reset(); + } + ~Iterator() override = default; + + public: + bool IsValid() const override + { + return ((_position > 0) && (_position <= _parent.Planes())); + } + void Reset() override + { + _position = 0; + } + bool Next() override + { + if (_position <= _parent.Planes()) { + _position++; + } + return (IsValid()); + } + IPlane* Plane() override + { + ASSERT(IsValid() == true); + return (&(_planes[_position - 1])); + } + + private: + CompositorBufferType& _parent; + PlaneImplementation _planes[PLANES]; + uint8_t _position; + }; + + public: + CompositorBufferType() = delete; + CompositorBufferType(const CompositorBufferType&) = delete; + CompositorBufferType& operator=(const CompositorBufferType&) = delete; + + CompositorBufferType(const string& callsign, const uint32_t id, const uint32_t width, const uint32_t height, const uint32_t format, const uint64_t modifier, const Exchange::ICompositionBuffer::DataType type) + : _id(id) + , _planeCount(0) + , _iterator(*this) + , _virtualFd(-1) + , _eventFd(-1) + , _storage(nullptr) + { + string definition = _T("NotifiableBuffer") + callsign; + _virtualFd = ::memfd_create(definition.c_str(), MFD_ALLOW_SEALING | MFD_CLOEXEC); + if (_virtualFd != -1) { + int length = sizeof(struct SharedStorage); + + /* Size the file as specified by our struct. */ + if (::ftruncate(_virtualFd, length) != -1) { + /* map that file to a memory area we can directly access as a memory mapped file */ + _storage = new (_virtualFd) SharedStorage(width, height, format, modifier, type); + if (_storage != nullptr) { + _eventFd = ::eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK | EFD_SEMAPHORE); + } + } + } + } + CompositorBufferType(const uint32_t id, Core::PrivilegedRequest::Container& descriptors) + : _id(id) + , _planeCount(0) + , _iterator(*this) + , _virtualFd(-1) + , _eventFd(-1) + , _storage(nullptr) + { + ASSERT(descriptors.size() >= 3); + + if (descriptors.size() >= 3) { + Core::PrivilegedRequest::Container::iterator index(descriptors.begin()); + + _virtualFd = index->Move(); + index++; + + ASSERT(_virtualFd != -1); + + _storage = new (_virtualFd) SharedStorage(); + if (_storage == nullptr) { + ::close(_virtualFd); + } else { + _eventFd = index->Move(); + index++; + + ASSERT(_eventFd != -1); + + while ((index != descriptors.end()) && (_planeCount < PLANES)) { + _planes[_planeCount] = index->Move(); + index++; + _planeCount++; + } + } + } + } + ~CompositorBufferType() override + { + if (_eventFd != -1) { + ::close(_eventFd); + _eventFd = -1; + + ASSERT(_storage != nullptr); + } + if (_storage != nullptr) { + delete _storage; + _storage = nullptr; + } + if (_virtualFd != -1) { + ::close(_virtualFd); + _virtualFd = -1; + } + + // Close all the FileDescriptors handed over to us for the planes. + for (uint8_t index = 0; index < _planeCount; index++) { + ::close(_planes[index]); + } + } + + public: + bool IsValid() const + { + return (_eventFd != -1); + } + uint8_t Descriptors(const uint8_t maxSize, int container[]) const + { + ASSERT(IsValid() == true); + ASSERT(maxSize > 2); + uint8_t result = 0; + + if (maxSize > 2) { + container[0] = _virtualFd; + container[1] = _eventFd; + uint8_t count = std::min(_planeCount, static_cast(maxSize - 2)); + for (uint8_t index = 0; (index < count); index++) { + container[index + 2] = _planes[index]; + } + result = 2 + count; + } + return (result); + } + + // + // Implementation of Core::IResource + // ----------------------------------------------------------------- + handle Descriptor() const override + { + return (_eventFd); + } + uint16_t Events() override + { + return (POLLIN); + } + void Handle(const uint16_t events) override + { + EventFrame value; + + if (((events & POLLIN) != 0) && (::read(_eventFd, &value, sizeof(EventFrame)) == sizeof(EventFrame))) { + if (_storage->Dirty() == true) { + Render(); + } + } + } + + // + // Implementation of Exchange::ICompositionBuffer + // ----------------------------------------------------------------- + // Wait time in milliseconds. + IIterator* Planes(const uint32_t waitTimeInMs) override + { // Access to the buffer planes. + if (Lock(waitTimeInMs) == Core::ERROR_NONE) { + _iterator.Reset(); + return (&_iterator); + } + return (nullptr); + } + virtual uint32_t Completed(const bool dirty) + { + Unlock(); + if (dirty == true) { + EventFrame value = 1; + _storage->Set(); + size_t result = ::write(_eventFd, &value, sizeof(value)); + return (result != sizeof(value) ? Core::ERROR_ILLEGAL_STATE : Core::ERROR_NONE); + } + return (Core::ERROR_NONE); + } + + uint32_t Identifier() const override + { + return (_id); + } + uint32_t Width() const override + { // Width of the allocated buffer in pixels + ASSERT(_storage != nullptr); + return (_storage->Width()); + } + uint32_t Height() const override + { // Height of the allocated buffer in pixels + ASSERT(_storage != nullptr); + return (_storage->Height()); + } + uint32_t Format() const override + { // Layout of a pixel according the fourcc format + ASSERT(_storage != nullptr); + return (_storage->Format()); + } + uint64_t Modifier() const override + { // Pixel arrangement in the buffer, used to optimize for hardware + ASSERT(_storage != nullptr); + return (_storage->Modifier()); + } + Exchange::ICompositionBuffer::DataType Type() const override + { + ASSERT(_storage != nullptr); + return (_storage->Type()); + } + uint8_t Planes() const + { + return (_planeCount); + } + bool IsDirty() const + { + ASSERT(_storage != nullptr); + return (_storage->IsDirty()); + } + + protected: + void Add(int fd, const uint32_t stride, const uint32_t offset) + { + ASSERT(fd > 0); + ASSERT((_planeCount + 1) <= PLANES); + _storage->Add(_planeCount, stride, offset); + _planes[_planeCount] = ::dup(fd); + _planeCount++; + } + + private: + buffer_id Accessor(const uint8_t index) const + { // Access to the actual data. + ASSERT(index < _planeCount); + return (_planes[index]); + } + uint32_t Lock(const uint32_t timeout) + { + return (_storage->Lock(timeout)); + } + uint32_t Unlock() + { + return (_storage->Unlock()); + } + + private: + uint32_t _id; + uint8_t _planeCount; + Iterator _iterator; + + // We need a descriptor that is pointing to the virtual memory (shared memory) + int _virtualFd; + + // We need a descriptor we can wait for and that can be signalled + int _eventFd; + + // From the virtual memory we can map the shared data to a memory area in "our" process. + SharedStorage* _storage; + + int _planes[PLANES]; + }; + +} +}