diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index ebd57b5f7..000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,5 +0,0 @@ -# These owners will be the default owners for everything in -# the repo. Unless a later match takes precedence, -# @global-owner1 and @global-owner2 will be requested for -# review when someone opens a pull request. -* @rdkcentral/rdke_ghec_entinputoutput_maintainer diff --git a/.github/workflows/L1-tests.yml b/.github/workflows/L1-tests.yml deleted file mode 100755 index 259d11b77..000000000 --- a/.github/workflows/L1-tests.yml +++ /dev/null @@ -1,641 +0,0 @@ -name: L1-tests - -on: - push: - branches: [ main, develop, 'sprint/**', 'release/**', 'topic/RDK*' ] - pull_request: - branches: [ main, develop, 'sprint/**', 'release/**', 'topic/RDK*' ] - -env: - BUILD_TYPE: Debug - THUNDER_REF: "R4.4.1" - INTERFACES_REF: "develop" - AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME}} - AUTOMATICS_PASSCODE: ${{ secrets. AUTOMATICS_PASSCODE}} - -jobs: - L1-tests: - name: Build and run unit tests - runs-on: ubuntu-22.04 - strategy: - matrix: - compiler: [ gcc, clang ] - coverage: [ with-coverage, without-coverage ] - exclude: - - compiler: clang - coverage: with-coverage - - compiler: clang - coverage: without-coverage - - compiler: gcc - coverage: without-coverage - - steps: - - name: Set up cache - # Cache Thunder/ThunderInterfaces. - # https://github.com/actions/cache - # https://docs.github.com/en/rest/actions/cache - # Modify the key if changing the list. - if: ${{ !env.ACT }} - id: cache - uses: actions/cache@v3 - with: - path: | - thunder/build/Thunder - thunder/build/entservices-apis - thunder/build/ThunderTools - thunder/install - !thunder/install/etc/WPEFramework/plugins - !thunder/install/usr/bin/RdkServicesTest - !thunder/install/usr/include/gmock - !thunder/install/usr/include/gtest - !thunder/install/usr/lib/libgmockd.a - !thunder/install/usr/lib/libgmock_maind.a - !thunder/install/usr/lib/libgtestd.a - !thunder/install/usr/lib/libgtest_maind.a - !thunder/install/usr/lib/cmake/GTest - !thunder/install/usr/lib/pkgconfig/gmock.pc - !thunder/install/usr/lib/pkgconfig/gmock_main.pc - !thunder/install/usr/lib/pkgconfig/gtest.pc - !thunder/install/usr/lib/pkgconfig/gtest_main.pc - !thunder/install/usr/lib/wpeframework/plugins - key: ${{ runner.os }}-${{ env.THUNDER_REF }}-${{ env.INTERFACES_REF }}-4 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - run: pip install jsonref - - - name: Set up CMake - uses: jwlawson/actions-setup-cmake@v1.13 - with: - cmake-version: '3.16.x' - - - name: Install packages - run: > - sudo apt update - && - sudo apt install -y libsqlite3-dev libcurl4-openssl-dev valgrind lcov clang libsystemd-dev libboost-all-dev libwebsocketpp-dev meson libcunit1 libcunit1-dev curl protobuf-compiler-grpc libgrpc-dev libgrpc++-dev - - - name: Install GStreamer - run: | - sudo apt update - sudo apt install -y libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev - - - name: Build trower-base64 - run: | - if [ ! -d "trower-base64" ]; then - git clone https://github.com/xmidt-org/trower-base64.git - fi - cd trower-base64 - meson setup --warnlevel 3 --werror build - ninja -C build - sudo ninja -C build install - - - name: Checkout Thunder - if: steps.cache.outputs.cache-hit != 'true' - uses: actions/checkout@v3 - with: - repository: rdkcentral/Thunder - path: Thunder - ref: ${{env.THUNDER_REF}} - - - name: Checkout ThunderTools - if: steps.cache.outputs.cache-hit != 'true' - uses: actions/checkout@v3 - with: - repository: rdkcentral/ThunderTools - path: ThunderTools - ref: R4.4.3 - - - name: Checkout entservices-testframework - uses: actions/checkout@v3 - with: - repository: rdkcentral/entservices-testframework - path: entservices-testframework - ref: develop - token: ${{ secrets.RDKCM_RDKE }} - - - name: Checkout entservices-inputoutput - uses: actions/checkout@v3 - with: - path: entservices-inputoutput - - - name: Apply patches ThunderTools - run: | - cd $GITHUB_WORKSPACE/ThunderTools - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/00010-R4.4-Add-support-for-project-dir.patch - cd - - - - name: Build ThunderTools - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake -G Ninja - -S "$GITHUB_WORKSPACE/ThunderTools" - -B build/ThunderTools - -DEXCEPTIONS_ENABLE=ON - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DGENERIC_CMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - && - cmake --build build/ThunderTools -j8 - && - cmake --install build/ThunderTools - - - name: Apply patches Thunder - run: | - cd $GITHUB_WORKSPACE/Thunder - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/Use_Legact_Alt_Based_On_ThunderTools_R4.4.3.patch - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/error_code_R4_4.patch - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/1004-Add-support-for-project-dir.patch - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/RDKEMW-733-Add-ENTOS-IDS.patch - cd - - - - name: Build Thunder - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake -G Ninja - -S "$GITHUB_WORKSPACE/Thunder" - -B build/Thunder - -DMESSAGING=ON - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DGENERIC_CMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DBUILD_TYPE=Debug - -DBINDING=127.0.0.1 - -DPORT=55555 - -DEXCEPTIONS_ENABLE=ON - && - cmake --build build/Thunder -j8 - && - cmake --install build/Thunder - - - name: Checkout entservices-apis - if: steps.cache.outputs.cache-hit != 'true' - uses: actions/checkout@v3 - with: - repository: rdkcentral/entservices-apis - path: entservices-apis - ref: ${{env.INTERFACES_REF}} - #token : ${{ secrets.RDKCM_RDKE }} - run: rm -rf $GITHUB_WORKSPACE/entservices-apis/jsonrpc/DTV.json - - - - name: Build entservices-apis - run: > - cmake -G Ninja - -S "$GITHUB_WORKSPACE/entservices-apis" - -B build/entservices-apis - -DEXCEPTIONS_ENABLE=ON - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - && - cmake --build build/entservices-apis -j8 - && - cmake --install build/entservices-apis - - - name: Generate external headers - # Empty headers to mute errors - run: > - cd "$GITHUB_WORKSPACE/entservices-testframework/Tests/" - && - mkdir -p - headers - headers/audiocapturemgr - headers/rdk/ds - headers/rdk/iarmbus - headers/rdk/iarmmgrs-hal - headers/rdk/halif/ - headers/rdk/halif/deepsleep-manager - headers/ccec/drivers - headers/ccec/host - headers/network - headers/proc - && - cd headers - && - touch - audiocapturemgr/audiocapturemgr_iarm.h - ccec/drivers/CecIARMBusMgr.h - ccec/FrameListener.hpp - ccec/Connection.hpp - ccec/Assert.hpp - ccec/Messages.hpp - ccec/MessageDecoder.hpp - ccec/MessageProcessor.hpp - ccec/CECFrame.hpp - ccec/MessageEncoder.hpp - ccec/host/RDK.hpp - rdk/ds/audioOutputPort.hpp - rdk/ds/compositeIn.hpp - rdk/ds/dsDisplay.h - rdk/ds/dsError.h - rdk/ds/dsMgr.h - rdk/ds/dsTypes.h - rdk/ds/dsUtl.h - rdk/ds/exception.hpp - rdk/ds/hdmiIn.hpp - rdk/ds/host.hpp - rdk/ds/list.hpp - rdk/ds/manager.hpp - rdk/ds/sleepMode.hpp - rdk/ds/videoDevice.hpp - rdk/ds/videoOutputPort.hpp - rdk/ds/videoOutputPortConfig.hpp - rdk/ds/videoOutputPortType.hpp - rdk/ds/videoResolution.hpp - rdk/ds/frontPanelIndicator.hpp - rdk/ds/frontPanelConfig.hpp - rdk/ds/frontPanelTextDisplay.hpp - rdk/iarmbus/libIARM.h - rdk/iarmbus/libIBus.h - rdk/iarmbus/libIBusDaemon.h - rdk/halif/deepsleep-manager/deepSleepMgr.h - rdk/iarmmgrs-hal/mfrMgr.h - rdk/iarmmgrs-hal/sysMgr.h - network/wifiSrvMgrIarmIf.h - network/netsrvmgrIarm.h - libudev.h - rfcapi.h - rbus.h - dsRpc.h - motionDetector.h - telemetry_busmessage_sender.h - maintenanceMGR.h - pkg.h - secure_wrapper.h - wpa_ctrl.h - proc/readproc.h - systemaudioplatform.h - gdialservice.h - gdialservicecommon.h - && - cp -r /usr/include/gstreamer-1.0/gst /usr/include/glib-2.0/* /usr/lib/x86_64-linux-gnu/glib-2.0/include/* /usr/local/include/trower-base64/base64.h . - - - name: Set clang toolchain - if: ${{ matrix.compiler == 'clang' }} - run: echo "TOOLCHAIN_FILE=$GITHUB_WORKSPACE/entservices-testframework/Tests/clang.cmake" >> $GITHUB_ENV - - - name: Set gcc/with-coverage toolchain - if: ${{ matrix.compiler == 'gcc' && matrix.coverage == 'with-coverage' && !env.ACT }} - run: echo "TOOLCHAIN_FILE=$GITHUB_WORKSPACE/entservices-testframework/Tests/gcc-with-coverage.cmake" >> $GITHUB_ENV - - - name: Build mocks - run: > - cmake - -S "$GITHUB_WORKSPACE/entservices-testframework/Tests/mocks" - -B build/mocks - -DBUILD_SHARED_LIBS=ON - -DRDK_SERVICES_L1_TEST=ON - -DUSE_THUNDER_R4=ON - -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - -DCMAKE_CXX_FLAGS=" - -fprofile-arcs - -ftest-coverage - -DEXCEPTIONS_ENABLE=ON - -DUSE_THUNDER_R4=ON - -DTHUNDER_VERSION=4 - -DTHUNDER_VERSION_MAJOR=4 - -DTHUNDER_VERSION_MINOR=4 - -DRDK_SERVICES_L1_TEST - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/audiocapturemgr - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmbus - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmmgrs-hal - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/ccec/drivers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/network - -I $GITHUB_WORKSPACE/entservices-testframework/Tests - -I $GITHUB_WORKSPACE/Thunder/Source - -I $GITHUB_WORKSPACE/Thunder/Source/core - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/devicesettings.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Iarm.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Rfc.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/RBus.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Telemetry.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Udev.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/maintenanceMGR.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/pkg.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/secure_wrappermock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/wpa_ctrl_mock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/readprocMockInterface.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/gdialservice.h - --coverage - -Wall -Wno-unused-result -Wno-deprecated-declarations -Wno-error=format= - -Wl,-wrap,system -Wl,-wrap,popen -Wl,-wrap,syslog -Wl,-wrap,v_secure_system -Wl,-wrap,v_secure_popen -Wl,-wrap,v_secure_pclose -Wl,-wrap,unlink -Wl,-wrap,v_secure_system -Wl,-wrap,pclose -Wl,-wrap,setmntent -Wl,-wrap,getmntent - -DENABLE_TELEMETRY_LOGGING - -DUSE_IARMBUS - -DENABLE_SYSTEM_GET_STORE_DEMO_LINK - -DENABLE_DEEP_SLEEP - -DENABLE_SET_WAKEUP_SRC_CONFIG - -DENABLE_THERMAL_PROTECTION - -DUSE_DRM_SCREENCAPTURE - -DHAS_API_SYSTEM - -DHAS_API_POWERSTATE - -DHAS_RBUS - -DENABLE_DEVICE_MANUFACTURER_INFO" - && - cmake --build build/mocks -j8 - && - cmake --install build/mocks - - - name: Build entservices-inputoutput - run: > - cmake -G Ninja - -S "$GITHUB_WORKSPACE/entservices-inputoutput" - -B build/entservices-inputoutput - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DCMAKE_CXX_FLAGS=" - -fprofile-arcs - -ftest-coverage - -DEXCEPTIONS_ENABLE=ON - -DUSE_THUNDER_R4=ON - -DTHUNDER_VERSION=4 - -DTHUNDER_VERSION_MAJOR=4 - -DTHUNDER_VERSION_MINOR=4 - -DRDK_SERVICES_L1_TEST - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/audiocapturemgr - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmbus - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmmgrs-hal - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/ccec/drivers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/network - -I $GITHUB_WORKSPACE/entservices-testframework/Tests - -I $GITHUB_WORKSPACE/Thunder/Source - -I $GITHUB_WORKSPACE/Thunder/Source/core - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/devicesettings.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Iarm.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Rfc.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/RBus.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Telemetry.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Udev.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/maintenanceMGR.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/pkg.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/secure_wrappermock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/wpa_ctrl_mock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/readprocMockInterface.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/gdialservice.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/HdmiCec.h - --coverage - -Wall -Wno-unused-result -Wno-deprecated-declarations -Wno-error=format= - -Wl,-wrap,system -Wl,-wrap,popen -Wl,-wrap,syslog -Wl,-wrap,v_secure_system -Wl,-wrap,v_secure_popen -Wl,-wrap,v_secure_pclose -Wl,-wrap,unlink - -DENABLE_TELEMETRY_LOGGING - -DUSE_IARMBUS - -DENABLE_SYSTEM_GET_STORE_DEMO_LINK - -DENABLE_DEEP_SLEEP - -DENABLE_SET_WAKEUP_SRC_CONFIG - -DENABLE_THERMAL_PROTECTION - -DUSE_DRM_SCREENCAPTURE - -DHAS_API_SYSTEM - -DHAS_API_POWERSTATE - -DHAS_RBUS - -DENABLE_DEVICE_MANUFACTURER_INFO" - -DCOMCAST_CONFIG=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_DS=ON - -DCMAKE_DISABLE_FIND_PACKAGE_IARMBus=ON - -DCMAKE_DISABLE_FIND_PACKAGE_Udev=ON - -DCMAKE_DISABLE_FIND_PACKAGE_RFC=ON - -DCMAKE_DISABLE_FIND_PACKAGE_RBus=ON - -DCMAKE_DISABLE_FIND_PACKAGE_CEC=ON - -DCMAKE_BUILD_TYPE=Debug - -DDS_FOUND=ON - -DHAS_FRONT_PANEL=ON - -DRDK_SERVICES_L1_TEST=ON - -DPLUGIN_HDCPPROFILE=ON - -DPLUGIN_HDMICECSOURCE=ON - -DPLUGIN_HDMICECSINK=ON - -DUSE_THUNDER_R4=ON - -DHIDE_NON_EXTERNAL_SYMBOLS=OFF - && - cmake --build build/entservices-inputoutput -j8 - && - cmake --install build/entservices-inputoutput - - - name: Build entservices-testframework - run: > - cmake -G Ninja - -S "$GITHUB_WORKSPACE/entservices-testframework" - -B build/entservices-testframework - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DCMAKE_CXX_FLAGS=" - -fprofile-arcs - -ftest-coverage - -DEXCEPTIONS_ENABLE=ON - -DUSE_THUNDER_R4=ON - -DTHUNDER_VERSION=4 - -DTHUNDER_VERSION_MAJOR=4 - -DTHUNDER_VERSION_MINOR=4 - -DRDK_SERVICES_L1_TEST - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/audiocapturemgr - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmbus - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmmgrs-hal - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/ccec/drivers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/network - -I $GITHUB_WORKSPACE/entservices-inputoutput/helpers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests - -I $GITHUB_WORKSPACE/Thunder/Source - -I $GITHUB_WORKSPACE/Thunder/Source/core - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/devicesettings.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Iarm.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Rfc.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/RBus.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Telemetry.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Udev.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/maintenanceMGR.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/pkg.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/secure_wrappermock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/wpa_ctrl_mock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/readprocMockInterface.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/gdialservice.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/HdmiCec.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/thunder/Communicator.h - --coverage - -Wall -Wno-unused-result -Wno-deprecated-declarations -Wno-error=format= - -Wl,-wrap,system -Wl,-wrap,popen -Wl,-wrap,syslog - -DENABLE_TELEMETRY_LOGGING - -DUSE_IARMBUS - -DENABLE_SYSTEM_GET_STORE_DEMO_LINK - -DENABLE_DEEP_SLEEP - -DENABLE_SET_WAKEUP_SRC_CONFIG - -DENABLE_THERMAL_PROTECTION - -DUSE_DRM_SCREENCAPTURE - -DHAS_API_SYSTEM - -DHAS_API_POWERSTATE - -DHAS_RBUS - -DENABLE_DEVICE_MANUFACTURER_INFO" - -DCOMCAST_CONFIG=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_DS=ON - -DCMAKE_DISABLE_FIND_PACKAGE_IARMBus=ON - -DCMAKE_DISABLE_FIND_PACKAGE_Udev=ON - -DCMAKE_DISABLE_FIND_PACKAGE_RFC=ON - -DCMAKE_DISABLE_FIND_PACKAGE_RBus=ON - -DCMAKE_DISABLE_FIND_PACKAGE_CEC=ON - -DCMAKE_BUILD_TYPE=Debug - -DDS_FOUND=ON - -DPLUGIN_HDCPPROFILE=ON - -DPLUGIN_HDMICECSOURCE=ON - -DPLUGIN_HDMICECSINK=ON - -DRDK_SERVICES_L1_TEST=ON - -DUSE_THUNDER_R4=ON - -DHIDE_NON_EXTERNAL_SYMBOLS=OFF - && - cmake --build build/entservices-testframework -j8 - && - cmake --install build/entservices-testframework - - - name: Set up files - run: > - sudo mkdir -p -m 777 - /tmp/test/testApp/etc/apps - /opt/persistent - /opt/secure - /opt/secure/reboot - /opt/secure/persistent - /opt/secure/persistent/System - /opt/logs - /lib/rdk - /run/media/sda1/logs/PreviousLogs - /run/sda1/UsbTestFWUpdate - /run/sda1/UsbProdFWUpdate - /run/sda2 - /var/run/wpa_supplicant - /tmp/bus/usb/devices/100-123 - /tmp/bus/usb/devices/101-124 - /tmp/block/sda/device - /tmp/block/sdb/device - /dev/disk/by-id - /dev - && - if [ ! -f mknod /dev/sda c 240 0 ]; then mknod /dev/sda c 240 0; fi && - if [ ! -f mknod /dev/sda1 c 240 0 ]; then mknod /dev/sda1 c 240 0; fi && - if [ ! -f mknod /dev/sda2 c 240 0 ]; then mknod /dev/sda2 c 240 0; fi && - if [ ! -f mknod /dev/sdb c 240 0 ]; then mknod /dev/sdb c 240 0; fi && - if [ ! -f mknod /dev/sdb1 c 240 0 ]; then mknod /dev/sdb1 c 240 0; fi && - if [ ! -f mknod /dev/sdb2 c 240 0 ]; then mknod /dev/sdb2 c 240 0; fi - && - sudo touch - /tmp/test/testApp/etc/apps/testApp_package.json - /opt/rdk_maintenance.conf - /opt/persistent/timeZoneDST - /opt/standbyReason.txt - /opt/tmtryoptout - /opt/fwdnldstatus.txt - /opt/dcm.properties - /etc/device.properties - /etc/dcm.properties - /etc/authService.conf - /version.txt - /run/media/sda1/logs/PreviousLogs/logFile.txt - /run/sda1/HSTP11MWR_5.11p5s1_VBN_sdy.bin - /run/sda1/UsbTestFWUpdate/HSTP11MWR_3.11p5s1_VBN_sdy.bin - /run/sda1/UsbProdFWUpdate/HSTP11MWR_4.11p5s1_VBN_sdy.bin - /lib/rdk/getMaintenanceStartTime.sh - /tmp/opkg.conf - /tmp/bus/usb/devices/100-123/serial - /tmp/bus/usb/devices/101-124/serial - /tmp/block/sda/device/vendor - /tmp/block/sda/device/model - /tmp/block/sdb/device/vendor - /tmp/block/sdb/device/model - && - sudo chmod -R 777 - /opt/rdk_maintenance.conf - /opt/persistent/timeZoneDST - /opt/standbyReason.txt - /opt/tmtryoptout - /opt/fwdnldstatus.txt - /opt/dcm.properties - /etc/device.properties - /etc/dcm.properties - /etc/authService.conf - /version.txt - /lib/rdk/getMaintenanceStartTime.sh - /tmp/opkg.conf - /tmp/bus/usb/devices/100-123/serial - /tmp/block/sda/device/vendor - /tmp/block/sda/device/model - /tmp/bus/usb/devices/101-124/serial - /tmp/block/sdb/device/vendor - /tmp/block/sdb/device/model - && - cd /dev/disk/by-id/ - && - sudo ln -s ../../sda /dev/disk/by-id/usb-Generic_Flash_Disk_B32FD507-0 - && - sudo ln -s ../../sdb /dev/disk/by-id/usb-JetFlash_Transcend_16GB_UEUIRCXT-0 - && - ls -l /dev/disk/by-id/usb-Generic_Flash_Disk_B32FD507-0 - && - ls -l /dev/disk/by-id/usb-JetFlash_Transcend_16GB_UEUIRCXT-0 - - - name: Run unit tests without valgrind - run: > - PATH=$GITHUB_WORKSPACE/install/usr/bin:${PATH} - LD_LIBRARY_PATH=$GITHUB_WORKSPACE/install/usr/lib:$GITHUB_WORKSPACE/install/usr/lib/wpeframework/plugins:${LD_LIBRARY_PATH} - GTEST_OUTPUT="json:$(pwd)/rdkL1TestResults.json" - RdkServicesL1Test && - cp -rf $(pwd)/rdkL1TestResults.json $GITHUB_WORKSPACE/rdkL1TestResultsWithoutValgrind.json && - rm -rf $(pwd)/rdkL1TestResults.json - - - name: Run unit tests with valgrind - if: ${{ !env.ACT }} - run: > - PATH=$GITHUB_WORKSPACE/install/usr/bin:${PATH} - LD_LIBRARY_PATH=$GITHUB_WORKSPACE/install/usr/lib:$GITHUB_WORKSPACE/install/usr/lib/wpeframework/plugins:${LD_LIBRARY_PATH} - GTEST_OUTPUT="json:$(pwd)/rdkL1TestResults.json" - valgrind - --tool=memcheck - --log-file=valgrind_log - --leak-check=yes - --show-reachable=yes - --track-fds=yes - --fair-sched=try - RdkServicesL1Test && - cp -rf $(pwd)/rdkL1TestResults.json $GITHUB_WORKSPACE/rdkL1TestResultsWithValgrind.json && - rm -rf $(pwd)/rdkL1TestResults.json - - - name: Generate coverage - if: ${{ matrix.coverage == 'with-coverage' && !env.ACT }} - run: > - cp $GITHUB_WORKSPACE/entservices-testframework/Tests/L1Tests/.lcovrc_l1 ~/.lcovrc - && - lcov -c - -o coverage.info - -d build/entservices-inputoutput - && - lcov - -r coverage.info - '/usr/include/*' - '*/build/entservices-inputoutput/_deps/*' - '*/install/usr/include/*' - '*/Tests/headers/*' - '*/Tests/mocks/*' - '*/Tests/L1Tests/tests/*' - '*/Thunder/*' - -o filtered_coverage.info - && - genhtml - -o coverage - -t "entservices-inputoutput coverage" - filtered_coverage.info - - - name: Upload artifacts - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: artifacts - path: | - coverage/ - valgrind_log - rdkL1TestResultsWithoutValgrind.json - rdkL1TestResultsWithValgrind.json - if-no-files-found: warn - diff --git a/.github/workflows/L2-tests.yml b/.github/workflows/L2-tests.yml deleted file mode 100755 index 7224e70b6..000000000 --- a/.github/workflows/L2-tests.yml +++ /dev/null @@ -1,577 +0,0 @@ -name: L2-tests - -#enable the workflow incase of any plugin/testcase changes -#Add "Tests/L2Tests" subdirectory in CMakeLists.txt, when enabling L2Tests -on: - workflow_dispatch: - -env: - BUILD_TYPE: Debug - THUNDER_REF: "R4.4.1" - INTERFACES_REF: "develop" - AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME}} - AUTOMATICS_PASSCODE: ${{ secrets. AUTOMATICS_PASSCODE}} - -jobs: - L2-tests: - name: Build and run L2 tests - runs-on: ubuntu-22.04 - strategy: - matrix: - compiler: [ gcc, clang ] - coverage: [ with-coverage, without-coverage ] - exclude: - - compiler: clang - coverage: with-coverage - - compiler: clang - coverage: without-coverage - - compiler: gcc - coverage: without-coverage - - steps: - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - run: pip install jsonref - - - name: Set up CMake - uses: jwlawson/actions-setup-cmake@v1.13 - with: - cmake-version: '3.16.x' - - - name: Install packages - run: > - sudo apt update - && - sudo apt install -y libsqlite3-dev libcurl4-openssl-dev valgrind lcov clang libsystemd-dev libboost-all-dev libwebsocketpp-dev meson libcunit1 libcunit1-dev curl protobuf-compiler-grpc libgrpc-dev libgrpc++-dev - # && - # apt-get install -y coreutils mtools dosfstools - - - name: Install GStreamer - run: | - sudo apt update - sudo apt install -y libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev - - - name: Build trevor-base64 - run: | - if [ ! -d "trower-base64" ]; then - git clone https://github.com/xmidt-org/trower-base64.git - fi - cd trower-base64 - meson setup --warnlevel 3 --werror build - ninja -C build - sudo ninja -C build install - - - name: Checkout Thunder - uses: actions/checkout@v3 - with: - repository: rdkcentral/Thunder - path: Thunder - ref: ${{env.THUNDER_REF}} - - - name: Checkout ThunderTools - uses: actions/checkout@v3 - with: - repository: rdkcentral/ThunderTools - path: ThunderTools - ref: R4.4.3 - - - name: Checkout entservices-inputoutput - uses: actions/checkout@v3 - with: - path: entservices-inputoutput - - - name: Checkout entservices-testframework - uses: actions/checkout@v3 - with: - repository: rdkcentral/entservices-testframework - path: entservices-testframework - ref: develop - token: ${{ secrets.RDKCM_RDKE }} - - - name: Apply patches ThunderTools - run: | - cd $GITHUB_WORKSPACE/ThunderTools - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/00010-R4.4-Add-support-for-project-dir.patch - cd - - - - name: Build ThunderTools - run: > - cmake - -S "$GITHUB_WORKSPACE/ThunderTools" - -B build/ThunderTools - -DEXCEPTIONS_ENABLE=ON - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DGENERIC_CMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - && - cmake --build build/ThunderTools -j8 - && - cmake --install build/ThunderTools - - - name: Apply patches Thunder - run: | - cd $GITHUB_WORKSPACE/Thunder - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/Use_Legact_Alt_Based_On_ThunderTools_R4.4.3.patch - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/error_code_R4_4.patch - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/1004-Add-support-for-project-dir.patch - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/RDKEMW-733-Add-ENTOS-IDS.patch - cd - - - name: Build Thunder - run: > - cmake - -S "$GITHUB_WORKSPACE/Thunder" - -B build/Thunder - -DMESSAGING=ON - -DHIDE_NON_EXTERNAL_SYMBOLS=OFF - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DBUILD_TYPE=${{env.BUILD_TYPE}} - -DBINDING=127.0.0.1 - -DPORT=9998 - -DEXCEPTIONS_ENABLE=ON - && - cmake --build build/Thunder -j8 - && - cmake --install build/Thunder - - - name: Checkout entservices-apis - uses: actions/checkout@v3 - with: - repository: rdkcentral/entservices-apis - path: entservices-apis - ref: ${{env.INTERFACES_REF}} - run: rm -rf $GITHUB_WORKSPACE/entservices-apis/jsonrpc/DTV.json - - - name: Build entservices-apis - run: > - cmake - -S "$GITHUB_WORKSPACE/entservices-apis" - -B build/entservices-apis - -DEXCEPTIONS_ENABLE=ON - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - && - cmake --build build/entservices-apis -j8 - && - cmake --install build/entservices-apis - - - name: Generate external headers - # Empty headers to mute errors - run: > - cd "$GITHUB_WORKSPACE/entservices-testframework/Tests/" - && - mkdir -p - headers - headers/rdk/ds - headers/rdk/iarmbus - headers/rdk/iarmmgrs-hal - headers/systemservices - headers/systemservices/proc - && - cd headers - && - touch - rdk/ds/host.hpp - rdk/ds/videoOutputPort.hpp - rdk/ds/videoOutputPortType.hpp - rdk/ds/videoOutputPortConfig.hpp - rdk/ds/videoResolution.hpp - rdk/ds/audioOutputPort.hpp - rdk/ds/audioOutputPortType.hpp - rdk/ds/sleepMode.hpp - rdk/ds/frontPanelConfig.hpp - rdk/ds/frontPanelTextDisplay.hpp - rdk/ds/hdmiIn.hpp - rdk/ds/compositeIn.hpp - rdk/ds/audioOutputPortConfig.hpp - rdk/ds/exception.hpp - rdk/ds/dsError.h - rdk/ds/dsMgr.h - rdk/ds/manager.hpp - rdk/ds/dsTypes.h - rdk/ds/dsUtl.h - rdk/iarmbus/libIARM.h - rdk/iarmbus/libIBus.h - rdk/iarmbus/libIBusDaemon.h - rdk/iarmmgrs-hal/mfrMgr.h - rdk/iarmmgrs-hal/sysMgr.h - rdk/iarmbus/iarmUtil.h - rfcapi.h - rbus.h - libudev.h - systemservices/proc/readproc.h - systemservices/secure_wrapper.h - systemaudioplatform.h - maintenanceMGR.h - pkg.h - btmgr.h - tvError.h - tvTypes.h - tvTypesODM.h - tvSettings.h - tvSettingsExtODM.h - tvSettingsODM.h - tvTypesODM.h - tr181api.h - list.hpp - dsDisplay.h - rdk/ds/AudioStereoMode.hpp - rdk/ds/VideoDFC.hpp - dsRpc.h - && - cp -r /usr/include/gstreamer-1.0/gst /usr/include/glib-2.0/* /usr/lib/x86_64-linux-gnu/glib-2.0/include/* /usr/local/include/trower-base64/base64.h . - - - name: Set clang toolchain - if: ${{ matrix.compiler == 'clang' }} - run: echo "TOOLCHAIN_FILE=$GITHUB_WORKSPACE/entservices-testframework/Tests/clang.cmake" >> $GITHUB_ENV - - - name: Set gcc/with-coverage toolchain - if: ${{ matrix.compiler == 'gcc' && matrix.coverage == 'with-coverage' && !env.ACT }} - run: echo "TOOLCHAIN_FILE=$GITHUB_WORKSPACE/entservices-testframework/Tests/gcc-with-coverage.cmake" >> $GITHUB_ENV - - - name: Build mocks - run: > - cmake - -S "$GITHUB_WORKSPACE/entservices-testframework/Tests/mocks" - -B build/mocks - -DBUILD_SHARED_LIBS=ON - -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - -DCMAKE_CXX_FLAGS=" - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers" - && - cmake --build build/mocks -j8 - && - cmake --install build/mocks - - - name: Build entservices-inputoutput - run: > - cmake - -S "$GITHUB_WORKSPACE/entservices-inputoutput" - -B build/entservices-inputoutput - -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DHIDE_NON_EXTERNAL_SYMBOLS=OFF - -DCMAKE_CXX_FLAGS=" - -DEXCEPTIONS_ENABLE=ON - -fprofile-arcs - -ftest-coverage - -DUSE_THUNDER_R4=ON - -DTHUNDER_VERSION=4 - -DTHUNDER_VERSION_MAJOR=4 - -DTHUNDER_VERSION_MINOR=4 - -DDEVICE_TYPE=AVOutputTV - -DPLUGIN_PERSISTENTSTORE_PATH="/tmp/secure/persistent/rdkservicestore" - -DPLUGIN_PERSISTENTSTORE_LEGACYPATH="/tmp/persistent/rdkservicestore" - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmbus - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmmgrs-hal - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/systemservices - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/systemservices/proc - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/devicesettings.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Iarm.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Rfc.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/RBus.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Udev.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Wraps.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/maintenanceMGR.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/pkg.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/secure_wrappermock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/wpa_ctrl_mock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/readprocMockInterface.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/btmgr.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/tr181api.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/tvSettings.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/tvError.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/tvSettingsExtODM.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/tvSettingsODM.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/tvTypes.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/videoOutputPortType.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/videoOutputPortConfig.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/videoResolution.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/sleepMode.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/frontPanelConfig.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/frontPanelTextDisplay.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/audioOutputPortType.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/frontPanelConfig.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/frontPanelTextDisplay.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/manager.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/audioOutputPortConfig.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmbus/iarmUtil.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/systemaudioplatform.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/list.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/dsDisplay.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/AudioStereoMode.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/VideoDFC.hpp - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/dsRpc.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/dsError.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds/dsUtl.h - -Werror -Wall -Wno-unused-result -Wno-deprecated-declarations -Wno-error=format= - -DUSE_IARMBUS - -DRDK_SERVICE_L2_TEST - -DDISABLE_SECURITY_TOKEN - -DENABLE_THERMAL_PROTECTION" - -DPLUGIN_PERSISTENTSTORE_PATH="/tmp/secure/persistent/rdkservicestore" - -DPLUGIN_PERSISTENTSTORE_LEGACYPATH="/tmp/persistent/rdkservicestore" - -DCOMCAST_CONFIG=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_DS=ON - -DCMAKE_DISABLE_FIND_PACKAGE_IARMBus=ON - -DCMAKE_DISABLE_FIND_PACKAGE_Udev=ON - -DCMAKE_DISABLE_FIND_PACKAGE_RFC=ON - -DCMAKE_DISABLE_FIND_PACKAGE_RBus=ON - -DPLUGIN_AVINPUT=OFF - -DPLUGIN_AVOUTPUT=OFF - -DAVOUTPUT_TV=OFF - -DUSE_THUNDER_R4=ON - -DPLUGIN_L2Tests=ON - -DRDK_SERVICE_L2_TEST=ON - -DDS_FOUND=ON - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - && - cmake --build build/entservices-inputoutput -j8 - && - cmake --install build/entservices-inputoutput - - - name: Build entservices-testframework - run: > - cmake - -S "$GITHUB_WORKSPACE/entservices-testframework" - -B build/entservices-testframework - -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DHIDE_NON_EXTERNAL_SYMBOLS=OFF - -DCMAKE_CXX_FLAGS=" - -DEXCEPTIONS_ENABLE=ON - -fprofile-arcs - -ftest-coverage - -DUSE_THUNDER_R4=ON - -DTHUNDER_VERSION=4 - -DTHUNDER_VERSION_MAJOR=4 - -DTHUNDER_VERSION_MINOR=4 - -DDEVICE_TYPE=AVOutputTV - -DPLUGIN_PERSISTENTSTORE_PATH="/tmp/secure/persistent/rdkservicestore" - -DPLUGIN_PERSISTENTSTORE_LEGACYPATH="/tmp/persistent/rdkservicestore" - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmbus - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmmgrs-hal - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/systemservices - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/systemservices/proc - -I $GITHUB_WORKSPACE/entservices-deviceanddisplay/helpers - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/devicesettings.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Iarm.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Rfc.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/RBus.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Udev.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Wraps.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/maintenanceMGR.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/pkg.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/secure_wrappermock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/wpa_ctrl_mock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/readprocMockInterface.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/btmgr.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/tr181api.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/tvSettings.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/tvError.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/tvSettingsExtODM.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/tvSettingsODM.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/tvTypes.h - -Werror -Wall -Wno-unused-result -Wno-deprecated-declarations -Wno-error=format= - -DUSE_IARMBUS - -DRDK_SERVICE_L2_TEST - -DDISABLE_SECURITY_TOKEN - -DENABLE_THERMAL_PROTECTION" - -DPLUGIN_PERSISTENTSTORE_PATH="/tmp/secure/persistent/rdkservicestore" - -DPLUGIN_PERSISTENTSTORE_LEGACYPATH="/tmp/persistent/rdkservicestore" - -DCOMCAST_CONFIG=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_DS=ON - -DCMAKE_DISABLE_FIND_PACKAGE_IARMBus=ON - -DCMAKE_DISABLE_FIND_PACKAGE_Udev=ON - -DCMAKE_DISABLE_FIND_PACKAGE_RFC=ON - -DCMAKE_DISABLE_FIND_PACKAGE_RBus=ON - -DPLUGIN_AVINPUT=OFF - -DPLUGIN_AVOUTPUT=OFF - -DAVOUTPUT_TV=OFF - -DUSE_THUNDER_R4=ON - -DPLUGIN_L2Tests=ON - -DRDK_SERVICE_L2_TEST=ON - -DDS_FOUND=ON - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - -DPLUGIN_ANALYTICS_SIFT_BACKEND=ON - -DPLUGIN_ANALYTICS_SIFT_2_0_ENABLED="true" - -DPLUGIN_ANALYTICS_SIFT_MAX_RANDOMISATION_WINDOW_TIME=15 - -DPLUGIN_ANALYTICS_SIFT_STORE_PATH="/tmp/AnalyticsSiftStore" - -DPLUGIN_ANALYTICS_SIFT_URL="127.0.0.1:12345" - -DPLUGIN_ANALYTICS_EVENTS_MAP="/tmp/AnalyticsEventsMap.json" - && - cmake --build build/entservices-testframework -j8 - && - cmake --install build/entservices-testframework - - - name: Set up files - run: > - sudo mkdir -p -m 777 - /opt/persistent - /opt/secure - /opt/secure/reboot - /opt/secure/persistent - /opt/secure/persistent/System - /tmp/secure/persistent - /tmp/persistent - /tmp/persistent/rdkservicestore - /opt/logs - /lib/rdk - /run/media/sda1/logs/PreviousLogs - /run/media/sda2/logs/PreviousLogs - /run/sda1/UsbTestFWUpdate - /run/sda1/UsbProdFWUpdate - /run/media/sda1/Logs - /run/sda2 - /tmp/bus/usb/devices/100-123 - /tmp/bus/usb/devices/101-124 - /tmp/block/sda/device - /tmp/block/sdb/device - /dev/disk/by-id - /dev && - if [ ! -f mknod /dev/sda c 240 0 ]; then mknod /dev/sda c 240 0; fi && - if [ ! -f mknod /dev/sda1 c 240 0 ]; then mknod /dev/sda1 c 240 0; fi && - if [ ! -f mknod /dev/sda2 c 240 0 ]; then mknod /dev/sda2 c 240 0; fi && - if [ ! -f mknod /dev/sdb c 240 0 ]; then mknod /dev/sdb c 240 0; fi && - if [ ! -f mknod /dev/sdb1 c 240 0 ]; then mknod /dev/sdb1 c 240 0; fi && - if [ ! -f mknod /dev/sdb2 c 240 0 ]; then mknod /dev/sdb2 c 240 0; fi - && - sudo touch - /opt/standbyReason.txt - /opt/tmtryoptout - /opt/fwdnldstatus.txt - /opt/dcm.properties - /etc/device.properties - /etc/dcm.properties - /etc/authService.conf - /version.txt - /run/media/sda1/logs/PreviousLogs/logFile.txt - /run/media/sda1/logs/test.txt - /run/media/sda1/logs/test.png - /run/media/sda1/logs/test.docx - /run/media/sda2/logs/test.txt - /run/media/sda2/logs/test.png - /run/media/sda1/Logs/5C3400F15492_Logs_12-05-22-10-41PM.tgz - /run/sda1/HSTP11MWR_5.11p5s1_VBN_sdy.bin - /run/sda1/UsbTestFWUpdate/HSTP11MWR_3.11p5s1_VBN_sdy.bin - /run/sda1/UsbProdFWUpdate/HSTP11MWR_4.11p5s1_VBN_sdy.bin - /lib/rdk/getMaintenanceStartTime.sh - /tmp/opkg.conf - /tmp/system_service_temp.conf - /tmp/secure/persistent/rdkservicestore - /tmp/bus/usb/devices/100-123/serial - /tmp/bus/usb/devices/101-124/serial - /tmp/block/sda/device/vendor - /tmp/block/sda/device/model - /tmp/block/sdb/device/vendor - /tmp/block/sdb/device/model - && - sudo chmod -R 777 - /opt/standbyReason.txt - /opt/tmtryoptout - /opt/fwdnldstatus.txt - /opt/dcm.properties - /etc/device.properties - /etc/dcm.properties - /etc/authService.conf - /version.txt - /lib/rdk/getMaintenanceStartTime.sh - /tmp/opkg.conf - /tmp/system_service_temp.conf - /tmp/persistent/rdkservicestore - /tmp/secure/persistent/rdkservicestore - /tmp/bus/usb/devices/100-123/serial - /tmp/block/sda/device/vendor - /tmp/block/sda/device/model - /tmp/bus/usb/devices/101-124/serial - /tmp/block/sdb/device/vendor - /tmp/block/sdb/device/model - && - cd /dev/disk/by-id/ - && - sudo ln -s ../../sda /dev/disk/by-id/usb-Generic_Flash_Disk_B32FD507-0 - && - sudo ln -s ../../sdb /dev/disk/by-id/usb-JetFlash_Transcend_16GB_UEUIRCXT-0 - && - ls -l /dev/disk/by-id/usb-Generic_Flash_Disk_B32FD507-0 - && - ls -l /dev/disk/by-id/usb-JetFlash_Transcend_16GB_UEUIRCXT-0 - - - name: Download pact_verifier_cli - run: | - export PATH="$GITHUB_WORKSPACE/install/usr/bin:${PATH}" - $GITHUB_WORKSPACE/entservices-testframework/Tests/L2Tests/pact/install-verifier-cli.sh - - - name: Run unit tests without valgrind - run: > - PATH=$GITHUB_WORKSPACE/install/usr/bin:${PATH} - LD_LIBRARY_PATH=$GITHUB_WORKSPACE/install/usr/lib:$GITHUB_WORKSPACE/install/usr/lib/wpeframework/plugins:${LD_LIBRARY_PATH} - RdkServicesL2Test && - cp -rf $(pwd)/rdkL2TestResults.json $GITHUB_WORKSPACE/rdkL2TestResultsWithoutValgrind.json && - rm -rf $(pwd)/rdkL2TestResults.json - - - name: Run unit tests with valgrind - if: ${{ !env.ACT }} - run: > - PATH=$GITHUB_WORKSPACE/install/usr/bin:${PATH} - LD_LIBRARY_PATH=$GITHUB_WORKSPACE/install/usr/lib:$GITHUB_WORKSPACE/install/usr/lib/wpeframework/plugins:${LD_LIBRARY_PATH} - valgrind - --tool=memcheck - --log-file=valgrind_log - --leak-check=yes - --show-reachable=yes - --track-fds=yes - --fair-sched=try - RdkServicesL2Test && - cp -rf $(pwd)/rdkL2TestResults.json $GITHUB_WORKSPACE/rdkL2TestResultsWithValgrind.json && - rm -rf $(pwd)/rdkL2TestResults.json - - - name: Generate coverage - if: ${{ matrix.coverage == 'with-coverage' && !env.ACT }} - run: > - cp $GITHUB_WORKSPACE/entservices-testframework/Tests/L2Tests/.lcovrc_l2 ~/.lcovrc - && - lcov -c - -o coverage.info - -d build/ - && - lcov - -r coverage.info - '/usr/include/*' - '*/build/entservices-inputoutput/_deps/*' - '*/build/entservices-entservices-testframework/_deps/*' - '*/install/usr/include/*' - '*/Tests/headers/*' - '*/Tests/mocks/*' - '*/Tests/L2Tests/*' - '*/sqlite/*' - -o filtered_coverage.info - && - genhtml - -o coverage - -t "entservices-inputoutput coverage" - filtered_coverage.info - - - name: Upload artifacts - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: artifacts - path: | - coverage/ - valgrind_log - rdkL2TestResultsWithoutValgrind.json - rdkL2TestResultsWithValgrind.json - if-no-files-found: warn - diff --git a/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml b/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml deleted file mode 100644 index 3cf44781c..000000000 --- a/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Fossid Stateless Diff Scan - -on: pull_request - -jobs: - call-fossid-workflow: - uses: rdkcentral/build_tools_workflows/.github/workflows/fossid_integration_stateless_diffscan.yml@develop - secrets: - FOSSID_CONTAINER_USERNAME: ${{ secrets.FOSSID_CONTAINER_USERNAME }} - FOSSID_CONTAINER_PASSWORD: ${{ secrets.FOSSID_CONTAINER_PASSWORD }} - FOSSID_HOST_USERNAME: ${{ secrets.FOSSID_HOST_USERNAME }} - FOSSID_HOST_TOKEN: ${{ secrets.FOSSID_HOST_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/manual-ci.yml b/.github/workflows/manual-ci.yml deleted file mode 100644 index 7081556fd..000000000 --- a/.github/workflows/manual-ci.yml +++ /dev/null @@ -1,32 +0,0 @@ -# This is a basic workflow that is manually triggered - -name: Manual workflow - -# Controls when the action will run. Workflow runs when manually triggered using the UI -# or API. -on: - workflow_dispatch: - # Inputs the workflow accepts. - inputs: - name: - # Friendly description to be shown in the UI instead of 'name' - description: 'Type of test : [Sanity, Quick, L1, L2]' - # Default value if no value is explicitly provided - default: 'Sanity' - # Input has to be provided for the workflow to run - required: true - # The data type of the input - type: string - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "greet" - greet: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Runs a single command using the runners shell - - name: Run CI tests - run: echo "Executing ${{ inputs.name }}" diff --git a/.github/workflows/native_full_build.yml b/.github/workflows/native_full_build.yml deleted file mode 100644 index 27b4b0cfe..000000000 --- a/.github/workflows/native_full_build.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Build Component in Native Environment - -on: - push: - branches: [ main, 'sprint/**', 'release/**', develop ] - pull_request: - branches: [ main, 'sprint/**', 'release/**', topic/RDK*, develop ] - -jobs: - build-entservices-on-pr: - name: Build entservices-inputoutput component in github rdkcentral - runs-on: ubuntu-latest - container: - image: ghcr.io/rdkcentral/docker-rdk-ci:latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: native build - run: | - sh -x build_dependencies.sh - sh -x cov_build.sh - env: - GITHUB_TOKEN: ${{ secrets.RDKCM_RDKE }} \ No newline at end of file diff --git a/.github/workflows/update-changelog-and-api-version.yml b/.github/workflows/update-changelog-and-api-version.yml deleted file mode 100644 index 61fdb94c4..000000000 --- a/.github/workflows/update-changelog-and-api-version.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: update changelog and api version - -on: - push: - branches: [ main, 'release/**' ] - paths-ignore: ['docs/**', 'Tests/**', 'Tools/**', '.github/**'] - - pull_request: - branches: [ main, 'release/**' ] - paths-ignore: ['docs/**', 'Tests/**', 'Tools/**', '.github/**'] - - -jobs: - build: - runs-on: ubuntu-latest # windows-latest | macos-latest - name: Check if changelog and api version were updated - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - - - name: Get changed files using defaults - id: changed-files - uses: rdkcentral/tj-actions_changed-files@v19 - - - name: Run step when a CHANGELOG.md didn't change - uses: actions/github-script@v3 - if: ${{ !contains(steps.changed-files.outputs.all_changed_files, 'CHANGELOG.md') }} - with: - script: | - core.setFailed('CHANGELOG.md should be modified') diff --git a/AVInput/AVInput.conf.in b/AVInput/AVInput.conf.in deleted file mode 100644 index 556edab0a..000000000 --- a/AVInput/AVInput.conf.in +++ /dev/null @@ -1,4 +0,0 @@ -precondition = ["Platform"] -callsign = "org.rdk.AVInput" -autostart = "false" -startuporder = "@PLUGIN_AVINPUT_STARTUPORDER@" diff --git a/AVInput/AVInput.config b/AVInput/AVInput.config deleted file mode 100644 index e7226db52..000000000 --- a/AVInput/AVInput.config +++ /dev/null @@ -1,7 +0,0 @@ -set (autostart false) -set (preconditions Platform) -set (callsign org.rdk.AVInput) - -if(PLUGIN_AVINPUT_STARTUPORDER) -set (startuporder ${PLUGIN_AVINPUT_STARTUPORDER}) -endif() diff --git a/AVInput/AVInput.cpp b/AVInput/AVInput.cpp deleted file mode 100644 index 8c71c7a63..000000000 --- a/AVInput/AVInput.cpp +++ /dev/null @@ -1,1522 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2020 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 "AVInput.h" -#include "dsMgr.h" -#include "hdmiIn.hpp" -#include "compositeIn.hpp" - -#include "UtilsJsonRpc.h" -#include "UtilsIarm.h" -#include "host.hpp" - -#include "exception.hpp" -#include -#include - -#define API_VERSION_NUMBER_MAJOR 1 -#define API_VERSION_NUMBER_MINOR 7 -#define API_VERSION_NUMBER_PATCH 1 - -#define HDMI 0 -#define COMPOSITE 1 -#define AV_HOT_PLUG_EVENT_CONNECTED 0 -#define AV_HOT_PLUG_EVENT_DISCONNECTED 1 -#define AVINPUT_METHOD_NUMBER_OF_INPUTS "numberOfInputs" -#define AVINPUT_METHOD_GET_INPUT_DEVICES "getInputDevices" -#define AVINPUT_METHOD_WRITE_EDID "writeEDID" -#define AVINPUT_METHOD_READ_EDID "readEDID" -#define AVINPUT_METHOD_READ_RAWSPD "getRawSPD" -#define AVINPUT_METHOD_READ_SPD "getSPD" -#define AVINPUT_METHOD_SET_EDID_VERSION "setEdidVersion" -#define AVINPUT_METHOD_GET_EDID_VERSION "getEdidVersion" -#define AVINPUT_METHOD_SET_EDID_ALLM_SUPPORT "setEdid2AllmSupport" -#define AVINPUT_METHOD_GET_EDID_ALLM_SUPPORT "getEdid2AllmSupport" -#define AVINPUT_METHOD_GET_HDMI_COMPATIBILITY_VERSION "getHdmiVersion" -#define AVINPUT_METHOD_SET_MIXER_LEVELS "setMixerLevels" -#define AVINPUT_METHOD_START_INPUT "startInput" -#define AVINPUT_METHOD_STOP_INPUT "stopInput" -#define AVINPUT_METHOD_SCALE_INPUT "setVideoRectangle" -#define AVINPUT_METHOD_CURRENT_VIDEO_MODE "currentVideoMode" -#define AVINPUT_METHOD_CONTENT_PROTECTED "contentProtected" -#define AVINPUT_METHOD_SUPPORTED_GAME_FEATURES "getSupportedGameFeatures" -#define AVINPUT_METHOD_GAME_FEATURE_STATUS "getGameFeatureStatus" - -#define AVINPUT_EVENT_ON_DEVICES_CHANGED "onDevicesChanged" -#define AVINPUT_EVENT_ON_SIGNAL_CHANGED "onSignalChanged" -#define AVINPUT_EVENT_ON_STATUS_CHANGED "onInputStatusChanged" -#define AVINPUT_EVENT_ON_VIDEO_MODE_UPDATED "videoStreamInfoUpdate" -#define AVINPUT_EVENT_ON_GAME_FEATURE_STATUS_CHANGED "gameFeatureStatusUpdate" -#define AVINPUT_EVENT_ON_AVI_CONTENT_TYPE_CHANGED "aviContentTypeUpdate" - -static bool isAudioBalanceSet = false; -static int planeType = 0; - -using namespace std; -int getTypeOfInput(string sType) -{ - int iType = -1; - if (strcmp (sType.c_str(), "HDMI") == 0) - iType = HDMI; - else if (strcmp (sType.c_str(), "COMPOSITE") ==0) - iType = COMPOSITE; - else - throw "Invalide type of INPUT, please specify HDMI/COMPOSITE"; - return iType; -} - -namespace WPEFramework { -namespace { - - static Plugin::Metadata metadata( - // Version (Major, Minor, Patch) - API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH, - // Preconditions - {}, - // Terminations - {}, - // Controls - {} - ); -} - -namespace Plugin { - -SERVICE_REGISTRATION(AVInput, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); - -AVInput* AVInput::_instance = nullptr; - -AVInput::AVInput() - : PluginHost::JSONRPC() -{ - RegisterAll(); -} - -AVInput::~AVInput() -{ - UnregisterAll(); -} - -const string AVInput::Initialize(PluginHost::IShell * /* service */) -{ - AVInput::_instance = this; - InitializeIARM(); - - return (string()); -} - -void AVInput::Deinitialize(PluginHost::IShell * /* service */) -{ - DeinitializeIARM(); - AVInput::_instance = nullptr; -} - -string AVInput::Information() const -{ - return (string()); -} - -void AVInput::InitializeIARM() -{ - if (Utils::IARM::init()) { - IARM_Result_t res; - IARM_CHECK(IARM_Bus_RegisterEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, - dsAVEventHandler)); - IARM_CHECK(IARM_Bus_RegisterEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, - dsAVSignalStatusEventHandler)); - IARM_CHECK(IARM_Bus_RegisterEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, - dsAVStatusEventHandler)); - IARM_CHECK(IARM_Bus_RegisterEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, - dsAVVideoModeEventHandler)); - IARM_CHECK(IARM_Bus_RegisterEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, - dsAVGameFeatureStatusEventHandler)); - IARM_CHECK(IARM_Bus_RegisterEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG, - dsAVEventHandler)); - IARM_CHECK(IARM_Bus_RegisterEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS, - dsAVSignalStatusEventHandler)); - IARM_CHECK(IARM_Bus_RegisterEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_STATUS, - dsAVStatusEventHandler)); - IARM_CHECK(IARM_Bus_RegisterEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_VIDEO_MODE_UPDATE, - dsAVVideoModeEventHandler)); - IARM_CHECK(IARM_Bus_RegisterEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE, - dsAviContentTypeEventHandler)); - } -} - -void AVInput::DeinitializeIARM() -{ - if (Utils::IARM::isConnected()) { - IARM_Result_t res; - IARM_CHECK(IARM_Bus_RemoveEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, dsAVEventHandler)); - IARM_CHECK(IARM_Bus_RemoveEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, dsAVSignalStatusEventHandler)); - IARM_CHECK(IARM_Bus_RemoveEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, dsAVStatusEventHandler)); - IARM_CHECK(IARM_Bus_RemoveEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, dsAVVideoModeEventHandler)); - IARM_CHECK(IARM_Bus_RemoveEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, dsAVGameFeatureStatusEventHandler)); - IARM_CHECK(IARM_Bus_RemoveEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG, dsAVEventHandler)); - IARM_CHECK(IARM_Bus_RemoveEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS, dsAVSignalStatusEventHandler)); - IARM_CHECK(IARM_Bus_RemoveEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_STATUS, dsAVStatusEventHandler)); - IARM_CHECK(IARM_Bus_RemoveEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_VIDEO_MODE_UPDATE, dsAVVideoModeEventHandler)); - IARM_CHECK(IARM_Bus_RemoveEventHandler( - IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE, dsAviContentTypeEventHandler)); - } -} - -void AVInput::RegisterAll() -{ - Register(_T(AVINPUT_METHOD_NUMBER_OF_INPUTS), &AVInput::endpoint_numberOfInputs, this); - Register(_T(AVINPUT_METHOD_CURRENT_VIDEO_MODE), &AVInput::endpoint_currentVideoMode, this); - Register(_T(AVINPUT_METHOD_CONTENT_PROTECTED), &AVInput::endpoint_contentProtected, this); - Register(_T(AVINPUT_METHOD_GET_INPUT_DEVICES), &AVInput::getInputDevicesWrapper, this); - Register(_T(AVINPUT_METHOD_WRITE_EDID), &AVInput::writeEDIDWrapper, this); - Register(_T(AVINPUT_METHOD_READ_EDID), &AVInput::readEDIDWrapper, this); - Register(_T(AVINPUT_METHOD_READ_RAWSPD), &AVInput::getRawSPDWrapper, this); - Register(_T(AVINPUT_METHOD_READ_SPD), &AVInput::getSPDWrapper, this); - Register(_T(AVINPUT_METHOD_SET_EDID_VERSION), &AVInput::setEdidVersionWrapper, this); - Register(_T(AVINPUT_METHOD_GET_EDID_VERSION), &AVInput::getEdidVersionWrapper, this); - Register(_T(AVINPUT_METHOD_SET_MIXER_LEVELS), &AVInput::setMixerLevels, this); - Register(_T(AVINPUT_METHOD_SET_EDID_ALLM_SUPPORT), &AVInput::setEdid2AllmSupportWrapper, this); - Register(_T(AVINPUT_METHOD_GET_EDID_ALLM_SUPPORT), &AVInput::getEdid2AllmSupportWrapper, this); - Register(_T(AVINPUT_METHOD_GET_HDMI_COMPATIBILITY_VERSION), &AVInput::getHdmiVersionWrapper, this); - Register(_T(AVINPUT_METHOD_START_INPUT), &AVInput::startInput, this); - Register(_T(AVINPUT_METHOD_STOP_INPUT), &AVInput::stopInput, this); - Register(_T(AVINPUT_METHOD_SCALE_INPUT), &AVInput::setVideoRectangleWrapper, this); - Register(_T(AVINPUT_METHOD_SUPPORTED_GAME_FEATURES), &AVInput::getSupportedGameFeatures, this); - Register(_T(AVINPUT_METHOD_GAME_FEATURE_STATUS), &AVInput::getGameFeatureStatusWrapper, this); - m_primVolume = DEFAULT_PRIM_VOL_LEVEL; - m_inputVolume = DEFAULT_INPUT_VOL_LEVEL; -} - -void AVInput::UnregisterAll() -{ - Unregister(_T(AVINPUT_METHOD_NUMBER_OF_INPUTS)); - Unregister(_T(AVINPUT_METHOD_CURRENT_VIDEO_MODE)); - Unregister(_T(AVINPUT_METHOD_CONTENT_PROTECTED)); - Unregister(_T(AVINPUT_METHOD_GET_INPUT_DEVICES)); - Unregister(_T(AVINPUT_METHOD_WRITE_EDID)); - Unregister(_T(AVINPUT_METHOD_READ_EDID)); - Unregister(_T(AVINPUT_METHOD_READ_RAWSPD)); - Unregister(_T(AVINPUT_METHOD_READ_SPD)); - Unregister(_T(AVINPUT_METHOD_SET_EDID_VERSION)); - Unregister(_T(AVINPUT_METHOD_GET_EDID_VERSION)); - Unregister(_T(AVINPUT_METHOD_START_INPUT)); - Unregister(_T(AVINPUT_METHOD_STOP_INPUT)); - Unregister(_T(AVINPUT_METHOD_SCALE_INPUT)); - Unregister(_T(AVINPUT_METHOD_SUPPORTED_GAME_FEATURES)); - Unregister(_T(AVINPUT_METHOD_GAME_FEATURE_STATUS)); -} - -void setResponseArray(JsonObject& response, const char* key, const vector& items) -{ - JsonArray arr; - for(auto& i : items) arr.Add(JsonValue(i)); - - response[key] = arr; - - string json; - response.ToString(json); - LOGINFO("%s: result json %s\n", __FUNCTION__, json.c_str()); -} - -uint32_t AVInput::endpoint_numberOfInputs(const JsonObject ¶meters, JsonObject &response) -{ - LOGINFOMETHOD(); - - bool success = false; - - auto result = numberOfInputs(success); - if (success) { - response[_T("numberOfInputs")] = result; - } - - returnResponse(success); -} - -uint32_t AVInput::endpoint_currentVideoMode(const JsonObject ¶meters, JsonObject &response) -{ - LOGINFOMETHOD(); - - bool success = false; - - auto result = currentVideoMode(success); - if (success) { - response[_T("currentVideoMode")] = result; - } - - returnResponse(success); -} - -uint32_t AVInput::endpoint_contentProtected(const JsonObject ¶meters, JsonObject &response) -{ - LOGINFOMETHOD(); - - // "Ths is the way it's done in Service Manager" - response[_T("isContentProtected")] = true; - - returnResponse(true); -} - -int AVInput::numberOfInputs(bool &success) -{ - int result = 0; - - try { - result = device::HdmiInput::getInstance().getNumberOfInputs(); - success = true; - } - catch (...) { - LOGERR("Exception caught"); - success = false; - } - - return result; -} - -string AVInput::currentVideoMode(bool &success) -{ - string result; - - try { - result = device::HdmiInput::getInstance().getCurrentVideoMode(); - success = true; - } - catch (...) { - LOGERR("Exception caught"); - success = false; - } - - return result; -} - - -uint32_t AVInput::startInput(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - - string sPortId = parameters["portId"].String(); - string sType = parameters["typeOfInput"].String(); - bool audioMix = parameters["requestAudioMix"].Boolean(); - int portId = 0; - int iType = 0; - planeType = 0; //planeType = 0 - primary, 1 - secondary video plane type - bool topMostPlane = parameters["topMost"].Boolean(); - LOGINFO("topMost value in thunder: %d\n",topMostPlane); - if (parameters.HasLabel("portId") && parameters.HasLabel("typeOfInput")) - { - try { - portId = stoi(sPortId); - iType = getTypeOfInput (sType); - if (parameters.HasLabel("plane")){ - string sPlaneType = parameters["plane"].String(); - planeType = stoi(sPlaneType); - if(!(planeType == 0 || planeType == 1))// planeType has to be primary(0) or secondary(1) - { - LOGWARN("planeType is invalid\n"); - returnResponse(false); - } - } - }catch (...) { - LOGWARN("Invalid Arguments"); - returnResponse(false); - } - } - else { - LOGWARN("Required parameters are not passed"); - returnResponse(false); - } - - try - { - if (iType == HDMI) { - device::HdmiInput::getInstance().selectPort(portId,audioMix,planeType,topMostPlane); - } - else if(iType == COMPOSITE) { - device::CompositeInput::getInstance().selectPort(portId); - } - } - catch (const device::Exception& err) { - LOG_DEVICE_EXCEPTION1(std::to_string(portId)); - returnResponse(false); - } - returnResponse(true); -} - -uint32_t AVInput::stopInput(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - - string sType = parameters["typeOfInput"].String(); - int iType = 0; - - if (parameters.HasLabel("typeOfInput")) - try { - iType = getTypeOfInput (sType); - }catch (...) { - LOGWARN("Invalid Arguments"); - returnResponse(false); - } - else { - LOGWARN("Required parameters are not passed"); - returnResponse(false); - } - - try - { - planeType = -1; - if (isAudioBalanceSet){ - device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_PRIMARY,MAX_PRIM_VOL_LEVEL); - device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_SYSTEM,DEFAULT_INPUT_VOL_LEVEL); - isAudioBalanceSet = false; - } - if (iType == HDMI) { - device::HdmiInput::getInstance().selectPort(-1); - } - else if (iType == COMPOSITE) { - device::CompositeInput::getInstance().selectPort(-1); - } - } - catch (const device::Exception& err) { - LOGWARN("AVInputService::stopInput Failed"); - returnResponse(false); - } - returnResponse(true); -} - -uint32_t AVInput::setVideoRectangleWrapper(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - - bool result = true; - if (!parameters.HasLabel("x") && !parameters.HasLabel("y")) { - result = false; - LOGWARN("please specif coordinates (x,y)"); - } - - if (!parameters.HasLabel("w") && !parameters.HasLabel("h")) { - result = false; - LOGWARN("please specify window width and height (w,h)"); - } - - if (!parameters.HasLabel("typeOfInput")) { - result = false; - LOGWARN("please specify type of input HDMI/COMPOSITE"); - } - - if (result) { - int x = 0; - int y = 0; - int w = 0; - int h = 0; - int t = 0; - string sType; - - try { - if (parameters.HasLabel("x")) { - x = parameters["x"].Number(); - } - if (parameters.HasLabel("y")) { - y = parameters["y"].Number(); - } - if (parameters.HasLabel("w")) { - w = parameters["w"].Number(); - } - if (parameters.HasLabel("h")) { - h = parameters["h"].Number(); - } - if (parameters.HasLabel("typeOfInput")) { - sType = parameters["typeOfInput"].String(); - t = getTypeOfInput (sType); - } - } - catch (...) { - LOGWARN("Invalid Arguments"); - returnResponse(false); - } - - result = setVideoRectangle(x, y, w, h, t); - if (false == result) { - LOGWARN("AVInputService::setVideoRectangle Failed"); - returnResponse(false); - } - returnResponse(true); - } - returnResponse(false); -} - -bool AVInput::setVideoRectangle(int x, int y, int width, int height, int type) -{ - bool ret = true; - - try - { - if (type == HDMI) { - device::HdmiInput::getInstance().scaleVideo(x, y, width, height); - } - else { - device::CompositeInput::getInstance().scaleVideo(x, y, width, height); - } - } - catch (const device::Exception& err) { - ret = false; - } - - return ret; -} - -uint32_t AVInput::getInputDevicesWrapper(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - - if (parameters.HasLabel("typeOfInput")) { - string sType = parameters["typeOfInput"].String(); - int iType = 0; - try { - iType = getTypeOfInput (sType); - }catch (...) { - LOGWARN("Invalid Arguments"); - returnResponse(false); - } - response["devices"] = getInputDevices(iType); - } - else { - JsonArray listHdmi = getInputDevices(HDMI); - JsonArray listComposite = getInputDevices(COMPOSITE); - for (int i = 0; i < listComposite.Length(); i++) { - listHdmi.Add(listComposite.Get(i)); - } - response["devices"] = listHdmi; - } - returnResponse(true); -} - -uint32_t AVInput::writeEDIDWrapper(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - - string sPortId = parameters["portId"].String(); - int portId = 0; - std::string message; - - if (parameters.HasLabel("portId") && parameters.HasLabel("message")) { - portId = stoi(sPortId); - message = parameters["message"].String(); - } - else { - LOGWARN("Required parameters are not passed"); - returnResponse(false); - } - - writeEDID(portId, message); - returnResponse(true); -} - -uint32_t AVInput::readEDIDWrapper(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - - string sPortId = parameters["portId"].String(); - int portId = 0; - try { - portId = stoi(sPortId); - }catch (...) { - LOGWARN("Invalid Arguments"); - returnResponse(false); - } - - string edid = readEDID (portId); - if (edid.empty()) { - returnResponse(false); - } - else { - response["EDID"] = edid; - returnResponse(true); - } -} - -JsonArray AVInput::getInputDevices(int iType) -{ - JsonArray list; - try - { - int num = 0; - if (iType == HDMI) { - num = device::HdmiInput::getInstance().getNumberOfInputs(); - } - else if (iType == COMPOSITE) { - num = device::CompositeInput::getInstance().getNumberOfInputs(); - } - if (num > 0) { - int i = 0; - for (i = 0; i < num; i++) { - //Input ID is aleays 0-indexed, continuous number starting 0 - JsonObject hash; - hash["id"] = i; - std::stringstream locator; - if (iType == HDMI) { - locator << "hdmiin://localhost/deviceid/" << i; - hash["connected"] = device::HdmiInput::getInstance().isPortConnected(i); - } - else if (iType == COMPOSITE) { - locator << "cvbsin://localhost/deviceid/" << i; - hash["connected"] = device::CompositeInput::getInstance().isPortConnected(i); - } - hash["locator"] = locator.str(); - LOGWARN("AVInputService::getInputDevices id %d, locator=[%s], connected=[%d]", i, hash["locator"].String().c_str(), hash["connected"].Boolean()); - list.Add(hash); - } - } - } - catch (const std::exception &e) { - LOGWARN("AVInputService::getInputDevices Failed"); - } - return list; -} - -void AVInput::writeEDID(int portId, std::string message) -{ -} - -std::string AVInput::readEDID(int iPort) -{ - vector edidVec({'u','n','k','n','o','w','n' }); - string edidbase64 = ""; - try { - vector edidVec2; - device::HdmiInput::getInstance().getEDIDBytesInfo (iPort, edidVec2); - edidVec = edidVec2;//edidVec must be "unknown" unless we successfully get to this line - - //convert to base64 - uint16_t size = min(edidVec.size(), (size_t)numeric_limits::max()); - - LOGWARN("AVInput::readEDID size:%d edidVec.size:%zu", size, edidVec.size()); - if(edidVec.size() > (size_t)numeric_limits::max()) { - LOGERR("Size too large to use ToString base64 wpe api"); - return edidbase64; - } - Core::ToString((uint8_t*)&edidVec[0], size, true, edidbase64); - } - catch (const device::Exception& err) { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return edidbase64; -} - -/** - * @brief This function is used to translate HDMI/COMPOSITE input hotplug to - * deviceChanged event. - * - * @param[in] input Number of input port integer. - * @param[in] connection status of input port integer. - */ -void AVInput::AVInputHotplug( int input , int connect, int type) -{ - LOGWARN("AVInputHotplug [%d, %d, %d]", input, connect, type); - - JsonObject params; - params["devices"] = getInputDevices(type); - sendNotify(AVINPUT_EVENT_ON_DEVICES_CHANGED, params); -} - -/** - * @brief This function is used to translate HDMI/COMPOSITE input signal change to - * signalChanged event. - * - * @param[in] port HDMI/COMPOSITE In port id. - * @param[in] signalStatus signal status of HDMI/COMPOSITE In port. - */ -void AVInput::AVInputSignalChange( int port , int signalStatus, int type) -{ - LOGWARN("AVInputSignalStatus [%d, %d, %d]", port, signalStatus, type); - - JsonObject params; - params["id"] = port; - std::stringstream locator; - if (type == HDMI) { - locator << "hdmiin://localhost/deviceid/" << port; - } - else { - locator << "cvbsin://localhost/deviceid/" << port; - } - params["locator"] = locator.str(); - /* values of dsHdmiInSignalStatus_t and dsCompInSignalStatus_t are same - Hence used only HDMI macro for case statement */ - switch (signalStatus) { - case dsHDMI_IN_SIGNAL_STATUS_NOSIGNAL: - params["signalStatus"] = "noSignal"; - break; - - case dsHDMI_IN_SIGNAL_STATUS_UNSTABLE: - params["signalStatus"] = "unstableSignal"; - break; - - case dsHDMI_IN_SIGNAL_STATUS_NOTSUPPORTED: - params["signalStatus"] = "notSupportedSignal"; - break; - - case dsHDMI_IN_SIGNAL_STATUS_STABLE: - params["signalStatus"] = "stableSignal"; - break; - - default: - params["signalStatus"] = "none"; - break; - } - sendNotify(AVINPUT_EVENT_ON_SIGNAL_CHANGED, params); -} - -/** - * @brief This function is used to translate HDMI/COMPOSITE input status change to - * inputStatusChanged event. - * - * @param[in] port HDMI/COMPOSITE In port id. - * @param[bool] isPresented HDMI/COMPOSITE In presentation started/stopped. - */ -void AVInput::AVInputStatusChange( int port , bool isPresented, int type) -{ - LOGWARN("avInputStatus [%d, %d, %d]", port, isPresented, type); - - JsonObject params; - params["id"] = port; - std::stringstream locator; - if (type == HDMI) { - locator << "hdmiin://localhost/deviceid/" << port; - } - else if (type == COMPOSITE) { - locator << "cvbsin://localhost/deviceid/" << port; - } - params["locator"] = locator.str(); - - if(isPresented) { - params["status"] = "started"; - } - else { - params["status"] = "stopped"; - } - params["plane"] = planeType; - sendNotify(AVINPUT_EVENT_ON_STATUS_CHANGED, params); -} - -/** - * @brief This function is used to translate HDMI input video mode change to - * videoStreamInfoUpdate event. - * - * @param[in] port HDMI In port id. - * @param[dsVideoPortResolution_t] video resolution data - */ -void AVInput::AVInputVideoModeUpdate( int port , dsVideoPortResolution_t resolution, int type) -{ - LOGWARN("AVInputVideoModeUpdate [%d]", port); - - JsonObject params; - params["id"] = port; - std::stringstream locator; - if(type == HDMI){ - - locator << "hdmiin://localhost/deviceid/" << port; - switch(resolution.pixelResolution) { - - case dsVIDEO_PIXELRES_720x480: - params["width"] = 720; - params["height"] = 480; - break; - - case dsVIDEO_PIXELRES_720x576: - params["width"] = 720; - params["height"] = 576; - break; - - case dsVIDEO_PIXELRES_1280x720: - params["width"] = 1280; - params["height"] = 720; - break; - - case dsVIDEO_PIXELRES_1920x1080: - params["width"] = 1920; - params["height"] = 1080; - break; - - case dsVIDEO_PIXELRES_3840x2160: - params["width"] = 3840; - params["height"] = 2160; - break; - - case dsVIDEO_PIXELRES_4096x2160: - params["width"] = 4096; - params["height"] = 2160; - break; - - default: - params["width"] = 1920; - params["height"] = 1080; - break; - } - params["progressive"] = (!resolution.interlaced); - } - else if(type == COMPOSITE) - { - locator << "cvbsin://localhost/deviceid/" << port; - switch(resolution.pixelResolution) { - case dsVIDEO_PIXELRES_720x480: - params["width"] = 720; - params["height"] = 480; - break; - case dsVIDEO_PIXELRES_720x576: - params["width"] = 720; - params["height"] = 576; - break; - default: - params["width"] = 720; - params["height"] = 576; - break; - } - - params["progressive"] = false; - } - - params["locator"] = locator.str(); - switch(resolution.frameRate) { - case dsVIDEO_FRAMERATE_24: - params["frameRateN"] = 24000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_25: - params["frameRateN"] = 25000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_30: - params["frameRateN"] = 30000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_50: - params["frameRateN"] = 50000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_60: - params["frameRateN"] = 60000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_23dot98: - params["frameRateN"] = 24000; - params["frameRateD"] = 1001; - break; - - case dsVIDEO_FRAMERATE_29dot97: - params["frameRateN"] = 30000; - params["frameRateD"] = 1001; - break; - - case dsVIDEO_FRAMERATE_59dot94: - params["frameRateN"] = 60000; - params["frameRateD"] = 1001; - break; - - default: - params["frameRateN"] = 60000; - params["frameRateD"] = 1000; - break; - } - - sendNotify(AVINPUT_EVENT_ON_VIDEO_MODE_UPDATED, params); -} - -void AVInput::dsAviContentTypeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) -{ - if(!AVInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_content_type.port; - int avi_content_type = eventData->data.hdmi_in_content_type.aviContentType; - LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE event port: %d, Content Type : %d", hdmi_in_port,avi_content_type); - - AVInput::_instance->hdmiInputAviContentTypeChange(hdmi_in_port, avi_content_type); - } -} - -void AVInput::hdmiInputAviContentTypeChange( int port , int content_type) -{ - JsonObject params; - params["id"] = port; - params["aviContentType"] = content_type; - sendNotify(AVINPUT_EVENT_ON_AVI_CONTENT_TYPE_CHANGED, params); -} - -void AVInput::dsAVEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) -{ - if(!AVInput::_instance) - return; - - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG == eventId) { - int hdmiin_hotplug_port = eventData->data.hdmi_in_connect.port; - int hdmiin_hotplug_conn = eventData->data.hdmi_in_connect.isPortConnected; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG event data:%d", hdmiin_hotplug_port); - AVInput::_instance->AVInputHotplug(hdmiin_hotplug_port, hdmiin_hotplug_conn ? AV_HOT_PLUG_EVENT_CONNECTED : AV_HOT_PLUG_EVENT_DISCONNECTED, HDMI); - } - else if (IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG == eventId) { - int compositein_hotplug_port = eventData->data.composite_in_connect.port; - int compositein_hotplug_conn = eventData->data.composite_in_connect.isPortConnected; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG event data:%d", compositein_hotplug_port); - AVInput::_instance->AVInputHotplug(compositein_hotplug_port, compositein_hotplug_conn ? AV_HOT_PLUG_EVENT_CONNECTED : AV_HOT_PLUG_EVENT_DISCONNECTED, COMPOSITE); - } -} - -void AVInput::dsAVSignalStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) -{ - if(!AVInput::_instance) - return; - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS == eventId) { - int hdmi_in_port = eventData->data.hdmi_in_sig_status.port; - int hdmi_in_signal_status = eventData->data.hdmi_in_sig_status.status; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS event port: %d, signal status: %d", hdmi_in_port,hdmi_in_signal_status); - AVInput::_instance->AVInputSignalChange(hdmi_in_port, hdmi_in_signal_status, HDMI); - } - else if (IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS == eventId) { - int composite_in_port = eventData->data.composite_in_sig_status.port; - int composite_in_signal_status = eventData->data.composite_in_sig_status.status; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS event port: %d, signal status: %d", composite_in_port,composite_in_signal_status); - AVInput::_instance->AVInputSignalChange(composite_in_port, composite_in_signal_status, COMPOSITE); - } -} - -void AVInput::dsAVStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) -{ - if(!AVInput::_instance) - return; - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS == eventId) { - int hdmi_in_port = eventData->data.hdmi_in_status.port; - bool hdmi_in_status = eventData->data.hdmi_in_status.isPresented; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS event port: %d, started: %d", hdmi_in_port,hdmi_in_status); - AVInput::_instance->AVInputStatusChange(hdmi_in_port, hdmi_in_status, HDMI); - } - else if (IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_STATUS == eventId) { - int composite_in_port = eventData->data.composite_in_status.port; - bool composite_in_status = eventData->data.composite_in_status.isPresented; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_STATUS event port: %d, started: %d", composite_in_port,composite_in_status); - AVInput::_instance->AVInputStatusChange(composite_in_port, composite_in_status, COMPOSITE); - } -} - -void AVInput::dsAVVideoModeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) -{ - if(!AVInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE == eventId) { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_video_mode.port; - dsVideoPortResolution_t resolution = {}; - resolution.pixelResolution = eventData->data.hdmi_in_video_mode.resolution.pixelResolution; - resolution.interlaced = eventData->data.hdmi_in_video_mode.resolution.interlaced; - resolution.frameRate = eventData->data.hdmi_in_video_mode.resolution.frameRate; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE event port: %d, pixelResolution: %d, interlaced : %d, frameRate: %d \n", hdmi_in_port,resolution.pixelResolution, resolution.interlaced, resolution.frameRate); - AVInput::_instance->AVInputVideoModeUpdate(hdmi_in_port, resolution,HDMI); - } - else if (IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_VIDEO_MODE_UPDATE == eventId) { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int composite_in_port = eventData->data.composite_in_video_mode.port; - dsVideoPortResolution_t resolution = {}; - resolution.pixelResolution = eventData->data.composite_in_video_mode.resolution.pixelResolution; - resolution.interlaced = eventData->data.composite_in_video_mode.resolution.interlaced; - resolution.frameRate = eventData->data.composite_in_video_mode.resolution.frameRate; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_VIDEO_MODE_UPDATE event port: %d, pixelResolution: %d, interlaced : %d, frameRate: %d \n", composite_in_port,resolution.pixelResolution, resolution.interlaced, resolution.frameRate); - AVInput::_instance->AVInputVideoModeUpdate(composite_in_port, resolution,COMPOSITE); - } -} - -void AVInput::dsAVGameFeatureStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) -{ - if(!AVInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_allm_mode.port; - bool allm_mode = eventData->data.hdmi_in_allm_mode.allm_mode; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS event port: %d, ALLM Mode: %d", hdmi_in_port,allm_mode); - - AVInput::_instance->AVInputALLMChange(hdmi_in_port, allm_mode); - } -} - -void AVInput::AVInputALLMChange( int port , bool allm_mode) -{ - JsonObject params; - params["id"] = port; - params["gameFeature"] = "ALLM"; - params["mode"] = allm_mode; - - sendNotify(AVINPUT_EVENT_ON_GAME_FEATURE_STATUS_CHANGED, params); -} - -uint32_t AVInput::getSupportedGameFeatures(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - vector supportedFeatures; - try - { - device::HdmiInput::getInstance().getSupportedGameFeatures (supportedFeatures); - for (size_t i = 0; i < supportedFeatures.size(); i++) - { - LOGINFO("Supported Game Feature [%zu]: %s\n",i,supportedFeatures.at(i).c_str()); - } - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION0(); - } - - if (supportedFeatures.empty()) { - returnResponse(false); - } - else { - setResponseArray(response, "supportedGameFeatures", supportedFeatures); - returnResponse(true); - } -} - -uint32_t AVInput::getGameFeatureStatusWrapper(const JsonObject& parameters, JsonObject& response) -{ - string sGameFeature = ""; - string sPortId = parameters["portId"].String(); - int portId = 0; - - LOGINFOMETHOD(); - if (parameters.HasLabel("portId") && parameters.HasLabel("gameFeature")) - { - try { - portId = stoi(sPortId); - sGameFeature = parameters["gameFeature"].String(); - }catch (...) { - LOGWARN("Invalid Arguments"); - returnResponse(false); - } - } - else { - LOGWARN("Required parameters are not passed"); - returnResponse(false); - } - - if (strcmp (sGameFeature.c_str(), "ALLM") == 0) - { - bool allm = getALLMStatus(portId); - LOGWARN("AVInput::getGameFeatureStatusWrapper ALLM MODE:%d", allm); - response["mode"] = allm; - } - else - { - LOGWARN("AVInput::getGameFeatureStatusWrapper Mode is not supported. Supported mode: ALLM"); - returnResponse(false); - } - returnResponse(true); -} - -bool AVInput::getALLMStatus(int iPort) -{ - bool allm = false; - - try - { - device::HdmiInput::getInstance().getHdmiALLMStatus (iPort, &allm); - LOGWARN("AVInput::getALLMStatus ALLM MODE: %d", allm); - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return allm; -} - -uint32_t AVInput::getRawSPDWrapper(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - - string sPortId = parameters["portId"].String(); - int portId = 0; - if (parameters.HasLabel("portId")) - { - try { - portId = stoi(sPortId); - }catch (...) { - LOGWARN("Invalid Arguments"); - returnResponse(false); - } - } - else { - LOGWARN("Required parameters are not passed"); - returnResponse(false); - } - - string spdInfo = getRawSPD (portId); - response["HDMISPD"] = spdInfo; - if (spdInfo.empty()) { - returnResponse(false); - } - else { - returnResponse(true); - } -} - -uint32_t AVInput::getSPDWrapper(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - - string sPortId = parameters["portId"].String(); - int portId = 0; - if (parameters.HasLabel("portId")) - { - try { - portId = stoi(sPortId); - }catch (...) { - LOGWARN("Invalid Arguments"); - returnResponse(false); - } - } - else { - LOGWARN("Required parameters are not passed"); - returnResponse(false); - } - - string spdInfo = getSPD (portId); - response["HDMISPD"] = spdInfo; - if (spdInfo.empty()) { - returnResponse(false); - } - else { - returnResponse(true); - } -} - -std::string AVInput::getRawSPD(int iPort) -{ - LOGINFO("AVInput::getSPDInfo"); - vector spdVect({'u','n','k','n','o','w','n' }); - std::string spdbase64 = ""; - try { - LOGWARN("AVInput::getSPDInfo"); - vector spdVect2; - device::HdmiInput::getInstance().getHDMISPDInfo(iPort, spdVect2); - spdVect = spdVect2;//edidVec must be "unknown" unless we successfully get to this line - - //convert to base64 - uint16_t size = min(spdVect.size(), (size_t)numeric_limits::max()); - - LOGWARN("AVInput::getSPD size:%d spdVec.size:%zu", size, spdVect.size()); - - if(spdVect.size() > (size_t)numeric_limits::max()) { - LOGERR("Size too large to use ToString base64 wpe api"); - return spdbase64; - } - - LOGINFO("------------getSPD: "); - for (size_t itr =0; itr < spdVect.size(); itr++) { - LOGINFO("%02X ", spdVect[itr]); - } - Core::ToString((uint8_t*)&spdVect[0], size, false, spdbase64); - } - catch (const device::Exception& err) { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return spdbase64; -} - -std::string AVInput::getSPD(int iPort) -{ - LOGINFO("AVInput::getSPDInfo"); - vector spdVect({'u','n','k','n','o','w','n' }); - std::string spdbase64 = ""; - try { - LOGWARN("AVInput::getSPDInfo"); - vector spdVect2; - device::HdmiInput::getInstance().getHDMISPDInfo(iPort, spdVect2); - spdVect = spdVect2;//edidVec must be "unknown" unless we successfully get to this line - - //convert to base64 - uint16_t size = min(spdVect.size(), (size_t)numeric_limits::max()); - - LOGWARN("AVInput::getSPD size:%d spdVec.size:%zu", size, spdVect.size()); - - if(spdVect.size() > (size_t)numeric_limits::max()) { - LOGERR("Size too large to use ToString base64 wpe api"); - return spdbase64; - } - - LOGINFO("------------getSPD: "); - for (size_t itr =0; itr < spdVect.size(); itr++) { - LOGINFO("%02X ", spdVect[itr]); - } - if (spdVect.size() > 0) { - struct dsSpd_infoframe_st pre; - memcpy(&pre,spdVect.data(),sizeof(struct dsSpd_infoframe_st)); - - char str[200] = {0}; - snprintf(str, sizeof(str), "Packet Type:%02X,Version:%u,Length:%u,vendor name:%s,product des:%s,source info:%02X", - pre.pkttype,pre.version,pre.length,pre.vendor_name,pre.product_des,pre.source_info); - spdbase64 = str; - } - } - catch (const device::Exception& err) { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return spdbase64; -} - -uint32_t AVInput::setMixerLevels(const JsonObject& parameters, JsonObject& response) -{ - returnIfParamNotFound(parameters, "primaryVolume"); - returnIfParamNotFound(parameters, "inputVolume"); - - int primVol = 0, inputVol = 0; - try { - primVol = parameters["primaryVolume"].Number(); - inputVol = parameters["inputVolume"].Number() ; - } catch(...) { - LOGERR("Incompatible params passed !!!\n"); - response["success"] = false; - returnResponse(false); - } - - if( (primVol >=0) && (inputVol >=0) ) { - m_primVolume = primVol; - m_inputVolume = inputVol; - } - else { - LOGERR("Incompatible params passed !!!\n"); - response["success"] = false; - returnResponse(false); - } - if(m_primVolume > MAX_PRIM_VOL_LEVEL) { - LOGWARN("Primary Volume greater than limit. Set to MAX_PRIM_VOL_LEVEL(100) !!!\n"); - m_primVolume = MAX_PRIM_VOL_LEVEL; - } - if(m_inputVolume > DEFAULT_INPUT_VOL_LEVEL) { - LOGWARN("INPUT Volume greater than limit. Set to DEFAULT_INPUT_VOL_LEVEL(100) !!!\n"); - m_inputVolume = DEFAULT_INPUT_VOL_LEVEL; - } - - LOGINFO("GLOBAL primary Volume=%d input Volume=%d \n",m_primVolume , m_inputVolume ); - - try{ - - device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_PRIMARY,primVol); - device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_SYSTEM,inputVol); - } - catch(...){ - LOGWARN("Not setting SoC volume !!!\n"); - returnResponse(false); - } - isAudioBalanceSet = true; - returnResponse(true); -} - -int setEdid2AllmSupport(int portId, bool allmSupport) -{ - bool ret = true; - try - { - device::HdmiInput::getInstance().setEdid2AllmSupport (portId, allmSupport); - LOGWARN("AVInput - allmsupport:%d", allmSupport); - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(portId)); - ret = false; - } -return ret; -} - -uint32_t AVInput::setEdid2AllmSupportWrapper(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - - returnIfParamNotFound(parameters, "portId"); - returnIfParamNotFound(parameters, "allmSupport"); - - int portId = 0; - string sPortId = parameters["portId"].String(); - bool allmSupport = parameters["allmSupport"].Boolean(); - - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - bool result = setEdid2AllmSupport(portId, allmSupport); - if(result == true) - { - returnResponse(true); - } - else - { - returnResponse(false); - } - -} - -bool getEdid2AllmSupport(int portId,bool *allmSupportValue) -{ - bool ret = true; - try - { - device::HdmiInput::getInstance().getEdid2AllmSupport (portId, allmSupportValue); - LOGINFO("AVInput - getEdid2AllmSupport:%d", *allmSupportValue); - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(portId)); - ret = false; - } - return ret; -} - -uint32_t AVInput::getEdid2AllmSupportWrapper(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - string sPortId = parameters["portId"].String(); - - int portId = 0; - bool allmSupport = true; - returnIfParamNotFound(parameters, "portId"); - - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - bool result = getEdid2AllmSupport(portId, &allmSupport); - if(result == true) - { - response["allmSupport"] = allmSupport; - returnResponse(true); - } - else - { - returnResponse(false); - } -} - -uint32_t AVInput::setEdidVersionWrapper(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - string sPortId = parameters["portId"].String(); - int portId = 0; - string sVersion = ""; - if (parameters.HasLabel("portId") && parameters.HasLabel("edidVersion")) - { - try { - portId = stoi(sPortId); - sVersion = parameters["edidVersion"].String(); - }catch (...) { - LOGWARN("Invalid Arguments"); - returnResponse(false); - } - } - else { - LOGWARN("Required parameters are not passed"); - returnResponse(false); - } - - int edidVer = -1; - if (strcmp (sVersion.c_str(), "HDMI1.4") == 0) { - edidVer = HDMI_EDID_VER_14; - } - else if (strcmp (sVersion.c_str(), "HDMI2.0") == 0) { - edidVer = HDMI_EDID_VER_20; - } - - if (edidVer < 0) { - returnResponse(false); - } - bool result = setEdidVersion (portId, edidVer); - if (result == false) { - returnResponse(false); - } - else { - returnResponse(true); - } -} - -uint32_t AVInput::getHdmiVersionWrapper(const JsonObject& parameters, JsonObject& response) -{ - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - string sPortId = parameters["portId"].String(); - int portId = 0; - - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - dsHdmiMaxCapabilityVersion_t hdmiCapVersion = HDMI_COMPATIBILITY_VERSION_14; - - try { - device::HdmiInput::getInstance().getHdmiVersion(portId, &(hdmiCapVersion)); - LOGWARN("AVInput::getHdmiVersion Hdmi Version:%d", hdmiCapVersion); - } - catch (const device::Exception& err) { - LOG_DEVICE_EXCEPTION1(std::to_string(portId)); - returnResponse(false); - } - - - switch ((int)hdmiCapVersion){ - case HDMI_COMPATIBILITY_VERSION_14: - response["HdmiCapabilityVersion"] = "1.4"; - break; - case HDMI_COMPATIBILITY_VERSION_20: - response["HdmiCapabilityVersion"] = "2.0"; - break; - case HDMI_COMPATIBILITY_VERSION_21: - response["HdmiCapabilityVersion"] = "2.1"; - break; - } - - - if(hdmiCapVersion == HDMI_COMPATIBILITY_VERSION_MAX) - { - returnResponse(false); - }else{ - returnResponse(true); - } -} - -int AVInput::setEdidVersion(int iPort, int iEdidVer) -{ - bool ret = true; - try { - device::HdmiInput::getInstance().setEdidVersion (iPort, iEdidVer); - LOGWARN("AVInput::setEdidVersion EDID Version:%d", iEdidVer); - } - catch (const device::Exception& err) { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - ret = false; - } - return ret; -} - -uint32_t AVInput::getEdidVersionWrapper(const JsonObject& parameters, JsonObject& response) -{ - string sPortId = parameters["portId"].String(); - int portId = 0; - - LOGINFOMETHOD(); - if (parameters.HasLabel("portId")) - { - try { - portId = stoi(sPortId); - } - catch (...) { - LOGWARN("Invalid Arguments"); - returnResponse(false); - } - } - else { - LOGWARN("Required parameters are not passed"); - returnResponse(false); - } - - int edidVer = getEdidVersion (portId); - switch (edidVer) { - case HDMI_EDID_VER_14: - response["edidVersion"] = "HDMI1.4"; - break; - case HDMI_EDID_VER_20: - response["edidVersion"] = "HDMI2.0"; - break; - } - - if (edidVer < 0) { - returnResponse(false); - } - else { - returnResponse(true); - } -} - -int AVInput::getEdidVersion(int iPort) -{ - int edidVersion = -1; - - try { - device::HdmiInput::getInstance().getEdidVersion (iPort, &edidVersion); - LOGWARN("AVInput::getEdidVersion EDID Version:%d", edidVersion); - } - catch (const device::Exception& err) { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return edidVersion; -} - -} // namespace Plugin -} // namespace WPEFramework diff --git a/AVInput/AVInput.h b/AVInput/AVInput.h deleted file mode 100644 index 22b618277..000000000 --- a/AVInput/AVInput.h +++ /dev/null @@ -1,123 +0,0 @@ -/** - * If not stated otherwise in this file or this component's LICENSE - * file the following copyright and licenses apply: - * - * Copyright 2020 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. - **/ - -#pragma once - -#include "Module.h" -#include "libIBus.h" -#include "dsTypes.h" - -#define DEFAULT_PRIM_VOL_LEVEL 25 -#define MAX_PRIM_VOL_LEVEL 100 -#define DEFAULT_INPUT_VOL_LEVEL 100 - -namespace WPEFramework { -namespace Plugin { - -class AVInput: public PluginHost::IPlugin, public PluginHost::JSONRPC -{ -private: - AVInput(const AVInput &) = delete; - AVInput &operator=(const AVInput &) = delete; - -public: - AVInput(); - virtual ~AVInput(); - - BEGIN_INTERFACE_MAP(AVInput) - INTERFACE_ENTRY(PluginHost::IPlugin) - INTERFACE_ENTRY(PluginHost::IDispatcher) - END_INTERFACE_MAP - - int m_primVolume; - int m_inputVolume; //Player Volume -public: - // IPlugin methods - // ------------------------------------------------------------------------------------------------------- - virtual const string Initialize(PluginHost::IShell *service) override; - virtual void Deinitialize(PluginHost::IShell *service) override; - virtual string Information() const override; - -protected: - void InitializeIARM(); - void DeinitializeIARM(); - - void RegisterAll(); - void UnregisterAll(); - - uint32_t endpoint_numberOfInputs(const JsonObject ¶meters, JsonObject &response); - uint32_t endpoint_currentVideoMode(const JsonObject ¶meters, JsonObject &response); - uint32_t endpoint_contentProtected(const JsonObject ¶meters, JsonObject &response); - -private: - static int numberOfInputs(bool &success); - static string currentVideoMode(bool &success); - - //Begin methods - uint32_t getInputDevicesWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t writeEDIDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t readEDIDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getRawSPDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getSPDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setEdidVersionWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getEdidVersionWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setEdid2AllmSupportWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getEdid2AllmSupportWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t startInput(const JsonObject& parameters, JsonObject& response); - uint32_t stopInput(const JsonObject& parameters, JsonObject& response); - uint32_t setVideoRectangleWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getSupportedGameFeatures(const JsonObject& parameters, JsonObject& response); - uint32_t getGameFeatureStatusWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setMixerLevels(const JsonObject& parameters, JsonObject& response); - uint32_t getHdmiVersionWrapper(const JsonObject& parameters, JsonObject& response); - //End methods - - JsonArray getInputDevices(int iType); - void writeEDID(int deviceId, std::string message); - std::string readEDID(int iPort); - std::string getRawSPD(int iPort); - std::string getSPD(int iPort); - int setEdidVersion(int iPort, int iEdidVer); - int getEdidVersion(int iPort); - bool setVideoRectangle(int x, int y, int width, int height, int type); - bool getALLMStatus(int iPort); - - void AVInputHotplug(int input , int connect, int type); - static void dsAVEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void AVInputSignalChange( int port , int signalStatus, int type); - static void dsAVSignalStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void AVInputStatusChange( int port , bool isPresented, int type); - static void dsAVStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void AVInputVideoModeUpdate( int port , dsVideoPortResolution_t resolution,int type); - static void dsAVVideoModeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void AVInputALLMChange( int port , bool allmMode); - static void dsAVGameFeatureStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInputAviContentTypeChange(int port, int content_type); - static void dsAviContentTypeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); -public: - static AVInput* _instance; -}; - -} // namespace Plugin -} // namespace WPEFramework diff --git a/AVInput/CHANGELOG.md b/AVInput/CHANGELOG.md deleted file mode 100644 index 6c8c2ac29..000000000 --- a/AVInput/CHANGELOG.md +++ /dev/null @@ -1,31 +0,0 @@ -# Changelog - -All notable changes to this RDK Service will be documented in this file. - -* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. - -* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: - * **Added** for new features. - * **Changed** for changes in existing functionality. - * **Deprecated** for soon-to-be removed features. - * **Removed** for now removed features. - * **Fixed** for any bug fixes. - * **Security** in case of vulnerabilities. - -* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. - -## [1.7.1] - 2025-02-17 -### Changed -- Added support for handling the videoStreamInfoUpdate for composite Input. - -## [1.7.0] - 2025-02-17 -### Added -- Added support for Getting the Maximum HDMI Compatibility version for the given port. - -## [1.0.0] - 2025-02-17 -### Added -- Add CHANGELOG - -### Change -- Reset API version to 1.0.0 -- Change README to inform how to update changelog and API version diff --git a/AVInput/CMakeLists.txt b/AVInput/CMakeLists.txt deleted file mode 100644 index 2df53ee4b..000000000 --- a/AVInput/CMakeLists.txt +++ /dev/null @@ -1,74 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -set(PLUGIN_NAME AVInput) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) - -find_package(${NAMESPACE}Plugins REQUIRED) - -if (USE_THUNDER_R4) - find_package(${NAMESPACE}COM REQUIRED) -else () - find_package(${NAMESPACE}Protocols REQUIRED) -endif (USE_THUNDER_R4) - -set(PLUGIN_AVINPUT_STARTUPORDER "" CACHE STRING "To configure startup order of AVInput plugin") - -add_library(${MODULE_NAME} SHARED - AVInput.cpp - Module.cpp - ) - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -if (RDK_SERVICE_L2_TEST) - find_library(TESTMOCKLIB_LIBRARIES NAMES TestMocklib) - if (TESTMOCKLIB_LIBRARIES) - message ("linking mock libraries ${TESTMOCKLIB_LIBRARIES} library") - target_link_libraries(${MODULE_NAME} PRIVATE ${TESTMOCKLIB_LIBRARIES}) - else (TESTMOCKLIB_LIBRARIES) - message ("Require ${TESTMOCKLIB_LIBRARIES} library") - endif (TESTMOCKLIB_LIBRARIES) -endif (RDK_SERVICES_L2_TEST) - -target_compile_definitions(${MODULE_NAME} PRIVATE MODULE_NAME=Plugin_${PLUGIN_NAME}) - -target_include_directories(${MODULE_NAME} PRIVATE ../helpers) - -if (USE_THUNDER_R4) -target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}COM::${NAMESPACE}COM) -else () -target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Protocols::${NAMESPACE}Protocols) -endif (USE_THUNDER_R4) - -find_package(DS) -find_package(IARMBus) - -target_include_directories(${MODULE_NAME} PRIVATE ${DS_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PRIVATE ../helpers) - -set_source_files_properties(AVInput.cpp PROPERTIES COMPILE_FLAGS "-fexceptions") - -target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${DS_LIBRARIES} ) - -install(TARGETS ${MODULE_NAME} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -write_config(${PLUGIN_NAME}) diff --git a/AVInput/Module.cpp b/AVInput/Module.cpp deleted file mode 100644 index 69ecca053..000000000 --- a/AVInput/Module.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2020 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 "Module.h" - -MODULE_NAME_DECLARATION(BUILD_REFERENCE) diff --git a/AVInput/Module.h b/AVInput/Module.h deleted file mode 100644 index f4fd32cd1..000000000 --- a/AVInput/Module.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2020 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. -**/ - -#pragma once -#ifndef MODULE_NAME -#define MODULE_NAME Plugin_AVInput -#endif - -#include -#include - -#undef EXTERNAL -#define EXTERNAL diff --git a/AVInput/README.md b/AVInput/README.md deleted file mode 100644 index 56e99d2f7..000000000 --- a/AVInput/README.md +++ /dev/null @@ -1,35 +0,0 @@ ------------------ -# AVInput - -## Versions -`org.rdk.AVInput.1` - -## Methods: -``` -curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "org.rdk.AVInput.1.getApiVersionNumber"}' http://127.0.0.1:9998/jsonrpc -curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "org.rdk.AVInput.1.numberOfInputs"}' http://127.0.0.1:9998/jsonrpc -curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "org.rdk.AVInput.1.currentVideoMode"}' http://127.0.0.1:9998/jsonrpc -curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "org.rdk.AVInput.1.contentProtected"}' http://127.0.0.1:9998/jsonrpc -``` -## Responses -``` -{"jsonrpc":"2.0","id":3,"result":{"version":1,"success":true}} -{"jsonrpc":"2.0","id":3,"result":{"numberOfInputs":1,"success":true}] -{"jsonrpc":"2.0","id":3,"result":{"currentVideoMode":"unknownp","success":true}} -{"jsonrpc":"2.0","id":3,"result":{"isContentProtected":true,"success":true}} -``` - -## Events -``` -onAVInputActive -onAVInputInactive -``` -## Events logged -``` -onAVInputActive: Notify onAVInputActive {"url":"avin://input0"} -onAVInputInactive: Notify onAVInputInactive {"url":"avin://input0"} -``` - -## Full Reference -https://wiki.rdkcentral.com/display/RDK/AV+Input - diff --git a/AVOutput/AVOutput.conf.in b/AVOutput/AVOutput.conf.in deleted file mode 100644 index 2cf253343..000000000 --- a/AVOutput/AVOutput.conf.in +++ /dev/null @@ -1,4 +0,0 @@ -precondition = ["Platform"] -callsign = "org.rdk.AVOutput" -autostart = "false" -startuporder = "@PLUGIN_AVOUTPUT_STARTUPORDER@" diff --git a/AVOutput/AVOutput.config b/AVOutput/AVOutput.config deleted file mode 100644 index a8e381d41..000000000 --- a/AVOutput/AVOutput.config +++ /dev/null @@ -1,19 +0,0 @@ -# If not stated otherwise in this file or this component's LICENSE file the -# following copyright and licenses apply: -# -# Copyright 2024 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. - -set (autostart true) -set (callsign "org.rdk.AVOutput") diff --git a/AVOutput/AVOutput.cpp b/AVOutput/AVOutput.cpp deleted file mode 100644 index fc8dd79fb..000000000 --- a/AVOutput/AVOutput.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2024 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 -#include "AVOutput.h" -#include "UtilsIarm.h" -#include "UtilsSearchRDKProfile.h" - -namespace WPEFramework { -namespace Plugin { - - SERVICE_REGISTRATION(AVOutput,1, 0); - - AVOutput::AVOutput() - { - LOGINFO("CTOR\n"); - } - - AVOutput::~AVOutput() - { - } - - const std::string AVOutput::Initialize(PluginHost::IShell* service) - { - LOGINFO("Entry\n"); - - profileType = searchRdkProfile(); - - if (profileType == STB || profileType == NOT_FOUND) - { - LOGINFO("Invalid profile type for TV \n"); - return (std::string("Not supported")); - } - - ASSERT(service != nullptr); - _skipURL = static_cast(service->WebPrefix().length()); - - DEVICE_TYPE::Initialize(); - - LOGINFO("Exit\n"); - return (service != nullptr ? _T("") : _T("No service.")); - } - - void AVOutput::Deinitialize(PluginHost::IShell* service) - { - - profileType = searchRdkProfile(); - - if (profileType == STB || profileType == NOT_FOUND) - { - LOGINFO("Invalid profile type for TV\n"); - return ; - } - - LOGINFO(); - - DEVICE_TYPE::Deinitialize(); - } - -} //namespace WPEFramework - -} //namespace Plugin diff --git a/AVOutput/AVOutput.h b/AVOutput/AVOutput.h deleted file mode 100644 index fb260adaf..000000000 --- a/AVOutput/AVOutput.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2024 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. -*/ - -#ifndef AVOUTPUT_H -#define AVOUTPUT_H - -#include -#include "libIARM.h" -#include "libIBusDaemon.h" -#include "libIBus.h" -#include "iarmUtil.h" - -#include - -#include -#include "Module.h" - -#include -#include - -//Default AVOutputSTB -#ifndef DEVICE_TYPE -#define DEVICE_TYPE AVOutputSTB -#include "AVOutputSTB.h" -#else -#include "AVOutputTV.h" -#endif - -namespace WPEFramework { -namespace Plugin { - - class AVOutput : public DEVICE_TYPE { - - private: - AVOutput(const AVOutput&) = delete; - AVOutput& operator=(const AVOutput&) = delete; - - public: - AVOutput(); - ~AVOutput(); - public: - // IPlugin methods - // ------------------------------------------------------------------------------------------------------- - const std::string Initialize(PluginHost::IShell* service); - void Deinitialize(PluginHost::IShell* service); - virtual string Information() const override { return {}; } - virtual void AddRef() const { } - virtual uint32_t Release() const {return 0; } - BEGIN_INTERFACE_MAP(AVOutput) - INTERFACE_ENTRY(PluginHost::IPlugin) - INTERFACE_ENTRY(PluginHost::IDispatcher) - END_INTERFACE_MAP - }; -} -} -#endif diff --git a/AVOutput/AVOutputBase.cpp b/AVOutput/AVOutputBase.cpp deleted file mode 100644 index 890194d2f..000000000 --- a/AVOutput/AVOutputBase.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2024 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 -#include "AVOutputBase.h" -#include "UtilsIarm.h" - -const char* PLUGIN_IARM_BUS_NAME = "Thunder_Plugins"; - -namespace WPEFramework { -namespace Plugin { - - AVOutputBase::AVOutputBase() - : _skipURL(0) - { - LOGINFO("CTOR\n"); - } - - AVOutputBase::~AVOutputBase() - { - } - - void AVOutputBase::Initialize() - { - LOGINFO("AVOutputBase Initialize\n"); - - } - - void AVOutputBase::Deinitialize() - { - LOGINFO("AVOutputBase Deinitialize\n"); - } - void AVOutputBase::InitializeIARM() - { - LOGINFO("AVOutputBase InitializeIARM \n"); - } - - void AVOutputBase::DeinitializeIARM() - { - LOGINFO("AVOutputBase De-InitializeIARM \n"); - } - -} //namespace WPEFramework - -} //namespace Plugin diff --git a/AVOutput/AVOutputBase.h b/AVOutput/AVOutputBase.h deleted file mode 100644 index bd7460129..000000000 --- a/AVOutput/AVOutputBase.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2024 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. -*/ - -#ifndef AVOUTPUTBASE_H -#define AVOUTPUTBASE_H - -#include -#include "libIARM.h" -#include "libIBusDaemon.h" -#include "libIBus.h" -#include "iarmUtil.h" -#include "dsMgr.h" -#include - -#include -#include "Module.h" - -#include -#include - -#define DECLARE_JSON_RPC_METHOD(method) \ - uint32_t method(const JsonObject& parameters, JsonObject& response); - -namespace WPEFramework { -namespace Plugin { - - class AVOutputBase : public PluginHost::IPlugin, public PluginHost::JSONRPC { - - private: - AVOutputBase(const AVOutputBase&) = delete; - AVOutputBase& operator=(const AVOutputBase&) = delete; - - public: - AVOutputBase(); - ~AVOutputBase(); - public: - uint8_t _skipURL; - // IPlugin methods - // ------------------------------------------------------------------------------------------------------- - virtual void Initialize(); - virtual void Deinitialize(); - virtual void InitializeIARM(); - virtual void DeinitializeIARM(); - }; -} -} -#endif diff --git a/AVOutput/AVOutputSTB.cpp b/AVOutput/AVOutputSTB.cpp deleted file mode 100644 index 53d40aae7..000000000 --- a/AVOutput/AVOutputSTB.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2024 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 -#include "AVOutputSTB.h" - -#define registerMethod(...) for (uint8_t i = 1; GetHandler(i); i++) GetHandler(i)->Register(__VA_ARGS__) - -namespace WPEFramework { -namespace Plugin { - - AVOutputSTB* AVOutputSTB::instance = nullptr; - - AVOutputSTB::AVOutputSTB() - { - LOGINFO("CTOR\n"); - instance = this; - - } - - AVOutputSTB :: ~AVOutputSTB() - { - } - -}//namespace Plugin -}//namespace WPEFramework diff --git a/AVOutput/AVOutputSTB.h b/AVOutput/AVOutputSTB.h deleted file mode 100644 index cb85f2f6f..000000000 --- a/AVOutput/AVOutputSTB.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2024 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. -*/ - -#ifndef AVOutputSTB_H -#define AVOutputSTB_H - -#include "string.h" - -#include -#include "Module.h" - -#include "AVOutputBase.h" -#include "libIARM.h" -#include "libIBusDaemon.h" -#include "libIBus.h" -#include "iarmUtil.h" -#include "UtilsLogging.h" -#include "UtilsJsonRpc.h" -#include "dsError.h" -#include "dsMgr.h" -#include "hdmiIn.hpp" - - -namespace WPEFramework { -namespace Plugin { - -//class AVOutputSTB : public PluginHost::IPlugin, public PluginHost::JSONRPC { -class AVOutputSTB : public AVOutputBase { - private: - AVOutputSTB(const AVOutputSTB&) = delete; - AVOutputSTB& operator=(const AVOutputSTB&) = delete; - - public: - AVOutputSTB(); - ~AVOutputSTB(); - static AVOutputSTB *instance; - static AVOutputSTB* getInstance() { return instance; } -}; - -}//namespace Plugin -}//namespace WPEFramework -#endif diff --git a/AVOutput/AVOutputTV.cpp b/AVOutput/AVOutputTV.cpp deleted file mode 100644 index e95b81e72..000000000 --- a/AVOutput/AVOutputTV.cpp +++ /dev/null @@ -1,3979 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2024 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 -#include "AVOutputTV.h" -#include "UtilsIarm.h" -#include "rfcapi.h" - -#define BUFFER_SIZE (128) - -#define registerMethod(...) for (uint8_t i = 1; GetHandler(i); i++) GetHandler(i)->Register(__VA_ARGS__) - -static bool filmMakerMode= false; -static bool m_isDalsEnabled = false; - -namespace WPEFramework { -namespace Plugin { - - AVOutputTV* AVOutputTV::instance = nullptr; - - static void tvVideoFormatChangeHandler(tvVideoFormatType_t format, void *userData) - { - LOGINFO("tvVideoFormatChangeHandler format:%d \n",format); - AVOutputTV *obj = (AVOutputTV *)userData; - if(obj) { - obj->NotifyVideoFormatChange(format); - } - } - - static void tvFilmMakerModeChangeHandler(tvContentType_t mode, void *userData) - { - LOGINFO("tvFilmMakerModeChangeHandler content:%d \n",mode); - AVOutputTV *obj = (AVOutputTV *)userData; - if(obj) { - obj->NotifyFilmMakerModeChange(mode); - } - } - - static void tvVideoResolutionChangeHandler(tvResolutionParam_t resolution, void *userData) - { - LOGINFO("tvVideoResolutionChangeHandler resolution:%d\n",resolution.resolutionValue); - AVOutputTV *obj = (AVOutputTV *)userData; - if(obj) { - obj->NotifyVideoResolutionChange(resolution); - } - } - - static void tvVideoFrameRateChangeHandler(tvVideoFrameRate_t frameRate, void *userData) - { - LOGINFO("tvVideoFrameRateChangeHandler format:%d \n",frameRate); - AVOutputTV *obj = (AVOutputTV *)userData; - if(obj) { - obj->NotifyVideoFrameRateChange(frameRate); - } - } - - static bool getVideoContentTypeToString(tvContentType_t content) - { - bool fmmMode = false; - switch(content) { - case tvContentType_FMM: - LOGINFO("Content Type: FMM\n"); - fmmMode = true; - break; - default: - LOGINFO("Content Type: NONE\n"); - fmmMode = false; - break; - } - return fmmMode; - } - - static const char *getVideoFormatTypeToString(tvVideoFormatType_t format) - { - const char *strValue = "NONE"; - switch(format) { - case VIDEO_FORMAT_SDR: - strValue = "SDR"; - break; - case VIDEO_FORMAT_HDR10: - strValue = "HDR10"; - break; - case VIDEO_FORMAT_HDR10PLUS: - strValue = "HDR10PLUS"; - break; - case VIDEO_FORMAT_HLG: - strValue = "HLG"; - break; - case VIDEO_FORMAT_DV: - strValue = "DV"; - break; - default: - strValue = "NONE"; - break; - } - LOGINFO("Video Format:%s\n", strValue); - return strValue; - } - - static std::string getVideoResolutionTypeToString(tvResolutionParam_t resolution) - { - std::string strValue = "NONE"; - std::string interlaceValue = (resolution.isInterlaced) ? "i" : "p"; - if ( resolution.resolutionValue != tvVideoResolution_NONE ) { - strValue = std::to_string(resolution.frameWidth) + "*" + std::to_string(resolution.frameHeight) + interlaceValue; - } - LOGINFO("Video Resolution:[%s]\n", strValue.c_str()); - return strValue; - } - - static const char *getVideoFrameRateTypeToString(tvVideoFrameRate_t frameRate) - { - const char *strValue = "NONE"; - switch(frameRate) { - case tvVideoFrameRate_24: - strValue = "24"; - break; - case tvVideoFrameRate_25: - strValue = "25"; - break; - case tvVideoFrameRate_30: - strValue = "30"; - break; - case tvVideoFrameRate_50: - strValue = "50"; - break; - case tvVideoFrameRate_60: - strValue = "60"; - break; - case tvVideoFrameRate_23dot98: - strValue = "23.98"; - break; - case tvVideoFrameRate_29dot97: - strValue = "29.97"; - break; - case tvVideoFrameRate_59dot94: - strValue = "59.94"; - break; - default: - strValue = "NONE"; - break; - - } - LOGINFO("Video FrameRate: %s\n",strValue); - return strValue; - } - - void AVOutputTV::NotifyVideoFormatChange(tvVideoFormatType_t format) - { - JsonObject response; - response["currentVideoFormat"] = getVideoFormatTypeToString(format); - sendNotify("onVideoFormatChanged", response); - } - - void AVOutputTV::NotifyFilmMakerModeChange(tvContentType_t mode) - { - JsonObject response; - JsonArray rangeArray; - bool fmmMode; - fmmMode = getVideoContentTypeToString(mode); - response["filmMakerMode"] = fmmMode; - - if (getCapabilitySource(rangeArray) == 0) { - response["filmMakerModeSources"] = rangeArray; - } - // cache for latest fmm mode - filmMakerMode = fmmMode; - sendNotify("onVideoContentChanged", response); - } - - void AVOutputTV::NotifyVideoResolutionChange(tvResolutionParam_t resolution) - { - JsonObject response; - response["currentVideoResolution"] = getVideoResolutionTypeToString(resolution); - sendNotify("onVideoResolutionChanged", response); - } - - void AVOutputTV::NotifyVideoFrameRateChange(tvVideoFrameRate_t frameRate) - { - JsonObject response; - response["currentVideoFrameRate"] = getVideoFrameRateTypeToString(frameRate); - sendNotify("onVideoFrameRateChanged", response); - } - - //Event - void AVOutputTV::dsHdmiStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!AVOutputTV::instance) { - return; - } - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS == eventId) { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_status.port; - bool hdmi_in_status = eventData->data.hdmi_in_status.isPresented; - LOGWARN("AVOutputPlugins: Received IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS event port: %d, started: %d", hdmi_in_port,hdmi_in_status); - if (!hdmi_in_status) { - tvError_t ret = tvERROR_NONE; - AVOutputTV::instance->m_isDisabledHdmiIn4KZoom = false; - LOGWARN("AVOutputPlugins: Hdmi streaming stopped here reapply the global zoom settings:%d here. m_isDisabledHdmiIn4KZoom: %d", AVOutputTV::instance->m_videoZoomMode, AVOutputTV::instance->m_isDisabledHdmiIn4KZoom); - ret = SetAspectRatio((tvDisplayMode_t)AVOutputTV::instance->m_videoZoomMode); - if (ret != tvERROR_NONE) { - LOGWARN("SetAspectRatio set Failed"); - } - } - else { - AVOutputTV::instance->m_isDisabledHdmiIn4KZoom = true; - LOGWARN("AVOutputPlugins: m_isDisabledHdmiIn4KZoom: %d", AVOutputTV::instance->m_isDisabledHdmiIn4KZoom); - } - } - } - - void AVOutputTV::dsHdmiVideoModeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!AVOutputTV::instance) { - return; - } - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE == eventId) { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_video_mode.port; - dsVideoPortResolution_t resolution; - AVOutputTV::instance->m_currentHdmiInResoluton = eventData->data.hdmi_in_video_mode.resolution.pixelResolution; - resolution.pixelResolution = eventData->data.hdmi_in_video_mode.resolution.pixelResolution; - resolution.interlaced = eventData->data.hdmi_in_video_mode.resolution.interlaced; - resolution.frameRate = eventData->data.hdmi_in_video_mode.resolution.frameRate; - LOGWARN("AVOutputPlugins: Received IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE event port: %d, pixelResolution: %d, interlaced : %d, frameRate: %d \n", hdmi_in_port,resolution.pixelResolution, resolution.interlaced, resolution.frameRate); - if (AVOutputTV::instance->m_isDisabledHdmiIn4KZoom) { - tvError_t ret = tvERROR_NONE; - if (AVOutputTV::instance->m_currentHdmiInResolutonm_currentHdmiInResoluton)) { - LOGWARN("AVOutputPlugins: Setting %d zoom mode for below 4K", AVOutputTV::instance->m_videoZoomMode); - ret = SetAspectRatio((tvDisplayMode_t)AVOutputTV::instance->m_videoZoomMode); - } - else { - LOGWARN("AVOutputPlugins: Setting auto zoom mode for 4K and above"); - ret = SetAspectRatio(tvDisplayMode_AUTO); - } - if (ret != tvERROR_NONE) { - LOGWARN("SetAspectRatio set Failed"); - } - } - else { - LOGWARN("AVOutputPlugins: %s: HdmiInput is not started yet. m_isDisabledHdmiIn4KZoom: %d", __FUNCTION__, AVOutputTV::instance->m_isDisabledHdmiIn4KZoom); - } - } - } - - AVOutputTV::AVOutputTV(): m_currentHdmiInResoluton (dsVIDEO_PIXELRES_1920x1080) - , m_videoZoomMode (tvDisplayMode_NORMAL) - , m_isDisabledHdmiIn4KZoom (false) - , rfc_caller_id() - { - LOGINFO("CTOR\n"); - AVOutputTV::instance = this; - - InitializeIARM(); - - registerMethod("getBacklight", &AVOutputTV::getBacklight, this); - registerMethod("setBacklight", &AVOutputTV::setBacklight, this); - registerMethod("resetBacklight", &AVOutputTV::resetBacklight, this); - registerMethod("getBacklightCaps", &AVOutputTV::getBacklightCaps, this); - registerMethod("getBrightnessCaps", &AVOutputTV::getBrightnessCaps, this); - registerMethod("getBrightness", &AVOutputTV::getBrightness, this); - registerMethod("setBrightness", &AVOutputTV::setBrightness, this); - registerMethod("resetBrightness", &AVOutputTV::resetBrightness, this); - registerMethod("getContrast", &AVOutputTV::getContrast, this); - registerMethod("setContrast", &AVOutputTV::setContrast, this); - registerMethod("resetContrast", &AVOutputTV::resetContrast, this); - registerMethod("getContrastCaps", &AVOutputTV::getContrastCaps, this); - registerMethod("getSharpness", &AVOutputTV::getSharpness, this); - registerMethod("setSharpness", &AVOutputTV::setSharpness, this); - registerMethod("resetSharpness", &AVOutputTV::resetSharpness, this); - registerMethod("getSharpnessCaps", &AVOutputTV::getSharpnessCaps, this); - registerMethod("getSaturation", &AVOutputTV::getSaturation, this); - registerMethod("setSaturation", &AVOutputTV::setSaturation, this); - registerMethod("resetSaturation", &AVOutputTV::resetSaturation, this); - registerMethod("getSaturationCaps", &AVOutputTV::getSaturationCaps, this); - registerMethod("getHue", &AVOutputTV::getHue, this); - registerMethod("setHue", &AVOutputTV::setHue, this); - registerMethod("resetHue", &AVOutputTV::resetHue, this); - registerMethod("getHueCaps", &AVOutputTV::getHueCaps, this); - registerMethod("getColorTemperature", &AVOutputTV::getColorTemperature, this); - registerMethod("setColorTemperature", &AVOutputTV::setColorTemperature, this); - registerMethod("resetColorTemperature", &AVOutputTV::resetColorTemperature, this); - registerMethod("getColorTemperatureCaps", &AVOutputTV::getColorTemperatureCaps, this); - - registerMethod("getBacklightDimmingMode", &AVOutputTV::getBacklightDimmingMode, this); - registerMethod("setBacklightDimmingMode", &AVOutputTV::setBacklightDimmingMode, this); - registerMethod("resetBacklightDimmingMode", &AVOutputTV::resetBacklightDimmingMode, this); - registerMethod("getBacklightDimmingModeCaps", &AVOutputTV::getBacklightDimmingModeCaps, this); - - registerMethod("getSupportedDolbyVisionModes", &AVOutputTV::getSupportedDolbyVisionModes, this); - registerMethod("getDolbyVisionMode", &AVOutputTV::getDolbyVisionMode, this); - registerMethod("setDolbyVisionMode", &AVOutputTV::setDolbyVisionMode, this); - registerMethod("resetDolbyVisionMode", &AVOutputTV::resetDolbyVisionMode, this); - registerMethod("getDolbyVisionModeCaps", &AVOutputTV::getDolbyVisionModeCaps, this); - registerMethod("getVideoFormat", &AVOutputTV::getVideoFormat, this); - registerMethod("getVideoSource", &AVOutputTV::getVideoSource, this); - registerMethod("getVideoFrameRate", &AVOutputTV::getVideoFrameRate, this); - registerMethod("getVideoResolution", &AVOutputTV::getVideoResolution, this); - registerMethod("getVideoContentType", &AVOutputTV::getVideoContentType, this); - - registerMethod("getZoomMode", &AVOutputTV::getZoomMode, this); - registerMethod("setZoomMode", &AVOutputTV::setZoomMode, this); - registerMethod("resetZoomMode", &AVOutputTV::resetZoomMode, this); - registerMethod("getZoomModeCaps", &AVOutputTV::getZoomModeCaps, this); - - registerMethod("getPictureMode", &AVOutputTV::getPictureMode, this); - registerMethod("setPictureMode", &AVOutputTV::setPictureMode, this); - registerMethod("signalFilmMakerMode", &AVOutputTV::signalFilmMakerMode, this); - registerMethod("resetPictureMode", &AVOutputTV::resetPictureMode, this); - registerMethod("getPictureModeCaps", &AVOutputTV::getPictureModeCaps, this); - registerMethod("getSupportedPictureModes", &AVOutputTV::getSupportedPictureModes, this); - registerMethod("getVideoSourceCaps", &AVOutputTV::getVideoSourceCaps, this); - registerMethod("getVideoFormatCaps", &AVOutputTV::getVideoFormatCaps, this); - registerMethod("getVideoFrameRateCaps", &AVOutputTV::getVideoFrameRateCaps, this); - registerMethod("getVideoResolutionCaps", &AVOutputTV::getVideoResolutionCaps, this); - - registerMethod("getLowLatencyState", &AVOutputTV::getLowLatencyState, this); - registerMethod("setLowLatencyState", &AVOutputTV::setLowLatencyState, this); - registerMethod("resetLowLatencyState", &AVOutputTV::resetLowLatencyState, this); - registerMethod("getLowLatencyStateCaps", &AVOutputTV::getLowLatencyStateCaps, this); - - registerMethod("getCMS", &AVOutputTV::getCMS, this); - registerMethod("setCMS", &AVOutputTV::setCMS, this); - registerMethod("resetCMS", &AVOutputTV::resetCMS, this); - registerMethod("getCMSCaps", &AVOutputTV::getCMSCaps, this); - - registerMethod("get2PointWB", &AVOutputTV::get2PointWB, this); - registerMethod("set2PointWB", &AVOutputTV::set2PointWB, this); - registerMethod("reset2PointWB", &AVOutputTV::reset2PointWB, this); - registerMethod("get2PointWBCaps", &AVOutputTV::get2PointWBCaps, this); - - registerMethod("getHDRMode", &AVOutputTV::getHDRMode, this); - registerMethod("setHDRMode", &AVOutputTV::setHDRMode, this); - registerMethod("resetHDRMode", &AVOutputTV::resetHDRMode, this); - registerMethod("getHDRModeCaps", &AVOutputTV::getHDRModeCaps, this); - - registerMethod("getAutoBacklightMode", &AVOutputTV::getAutoBacklightMode, this); - registerMethod("setAutoBacklightMode", &AVOutputTV::setAutoBacklightMode, this); - registerMethod("resetAutoBacklightMode", &AVOutputTV::resetAutoBacklightMode, this); - registerMethod("getAutoBacklightModeCaps", &AVOutputTV::getAutoBacklightModeCaps, this); - - LOGINFO("Exit\n"); - } - - AVOutputTV :: ~AVOutputTV() - { - DeinitializeIARM(); - } - - void AVOutputTV::Initialize() - { - LOGINFO("Entry\n"); - - tvError_t ret = tvERROR_NONE; - - TR181_ParamData_t param; - memset(¶m, 0, sizeof(param)); - - getDynamicAutoLatencyConfig(); - - try { - dsVideoPortResolution_t vidResolution; - device::HdmiInput::getInstance().getCurrentVideoModeObj(vidResolution); - m_currentHdmiInResoluton = vidResolution.pixelResolution; - } - catch (...) - { - LOGWARN("AVOutputPlugins: getCurrentVideoModeObj failed"); - } - LOGWARN("AVOutputPlugins: AVOutput Initialize m_currentHdmiInResoluton:%d m_mod:%d", m_currentHdmiInResoluton, m_videoZoomMode); - - ret = TvInit(); - - if(ret != tvERROR_NONE) { - LOGERR("Platform Init failed, ret: %s \n", getErrorString(ret).c_str()); - } - else { - LOGINFO("Platform Init successful...\n"); - } - - tvVideoFormatCallbackData callbackData = {this,tvVideoFormatChangeHandler}; - ret = RegisterVideoFormatChangeCB(&callbackData); - if(ret != tvERROR_NONE) { - LOGWARN("RegisterVideoFormatChangeCB failed"); - } - - tvVideoContentCallbackData ConcallbackData = {this,tvFilmMakerModeChangeHandler}; - ret = RegisterVideoContentChangeCB(&ConcallbackData); - if(ret != tvERROR_NONE) { - LOGWARN("RegisterVideoContentChangeCB failed"); - } - - tvVideoResolutionCallbackData RescallbackData = {this,tvVideoResolutionChangeHandler}; - ret = RegisterVideoResolutionChangeCB(&RescallbackData); - if(ret != tvERROR_NONE) { - LOGWARN("RegisterVideoResolutionChangeCB failed"); - } - - tvVideoFrameRateCallbackData FpscallbackData = {this,tvVideoFrameRateChangeHandler}; - ret = RegisterVideoFrameRateChangeCB(&FpscallbackData); - if(ret != tvERROR_NONE) { - LOGWARN("RegisterVideoFrameRateChangeCB failed"); - } - - locatePQSettingsFile(); - - // Get Index from PQ capabailites - if (getPqParamIndex() != 0) { - LOGWARN("Failed to get the supported index from capability \n"); - } - - syncAvoutputTVParamsToHAL("none","none","none"); - - setDefaultAspectRatio(); - - // source format specific sync to ssm data - syncAvoutputTVPQModeParamsToHAL("Current", "none", "none"); - - // As we have source to picture mode mapping, get current source and - // setting those picture mode - initializePictureMode(); - - LOGINFO("Exit\n" ); - } - - void AVOutputTV::Deinitialize() - { - LOGINFO("Entry\n"); - - tvError_t ret = tvERROR_NONE; - ret = TvTerm(); - - if(ret != tvERROR_NONE) { - LOGERR("Platform De-Init failed"); - } - else { - LOGINFO("Platform De-Init successful... \n"); - } - - LOGINFO("Exit\n"); - } - - uint32_t AVOutputTV::getZoomModeCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t info; - - JsonArray rangeArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - - unsigned int index = 0; - - tvError_t ret = getParamsCaps("AspectRatio",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - for (index = 0; index < info.rangeVector.size(); index++) { - rangeArray.Add(info.rangeVector[index]); - } - - response["options"]=rangeArray; - - if (info.pqmodeVector.front().compare("none") != 0) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::setZoomMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - std::string value; - tvDisplayMode_t mode = tvDisplayMode_16x9; - capDetails_t inputInfo; - - - value = parameters.HasLabel("zoomMode") ? parameters["zoomMode"].String() : ""; - returnIfParamNotFound(parameters,"zoomMode"); - - if (validateInputParameter("AspectRatio",value) != 0) { - LOGERR("%s: Range validation failed for AspectRatio\n", __FUNCTION__); - returnResponse(false); - } - - if (parsingSetInputArgument(parameters,"AspectRatio",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "AspectRatio",inputInfo )) { - LOGERR("%s: CapablityCheck failed for AspectRatio\n", __FUNCTION__); - returnResponse(false); - } - - if(!value.compare("TV 16X9 STRETCH")) { - mode = tvDisplayMode_16x9; - } - else if (!value.compare("TV 4X3 PILLARBOX")) { - mode = tvDisplayMode_4x3; - } - else if (!value.compare("TV NORMAL")) { - mode = tvDisplayMode_NORMAL; - } - else if (!value.compare("TV DIRECT")) { - mode = tvDisplayMode_DIRECT; - } - else if (!value.compare("TV AUTO")) { - mode = tvDisplayMode_AUTO; - } - else if (!value.compare("TV ZOOM")) { - mode = tvDisplayMode_ZOOM; - } - else { - returnResponse(false); - } - m_videoZoomMode = mode; - tvError_t ret = setAspectRatioZoomSettings (mode); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - //Save DisplayMode to localstore and ssm_data - int retval=updateAVoutputTVParam("set","AspectRatio",inputInfo,PQ_PARAM_ASPECT_RATIO,mode); - - if(retval != 0) { - LOGERR("Failed to Save DisplayMode to ssm_data\n"); - returnResponse(false); - } - - tr181ErrorCode_t err = setLocalParam(rfc_caller_id, AVOUTPUT_ASPECTRATIO_RFC_PARAM, value.c_str()); - if ( err != tr181Success ) { - LOGERR("setLocalParam for %s Failed : %s\n", AVOUTPUT_ASPECTRATIO_RFC_PARAM, getTR181ErrorString(err)); - returnResponse(false); - } - else { - LOGINFO("setLocalParam for %s Successful, Value: %s\n", AVOUTPUT_ASPECTRATIO_RFC_PARAM, value.c_str()); - } - LOGINFO("Exit : SetAspectRatio() value : %s\n",value.c_str()); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getZoomMode(const JsonObject& parameters, JsonObject& response) - { - - LOGINFO("Entry\n"); - tvDisplayMode_t mode; - - tvError_t ret = getUserSelectedAspectRatio (&mode); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - switch(mode) { - case tvDisplayMode_16x9: - LOGINFO("Aspect Ratio: TV 16X9 STRETCH\n"); - response["zoomMode"] = "TV 16X9 STRETCH"; - break; - - case tvDisplayMode_4x3: - LOGINFO("Aspect Ratio: TV 4X3 PILLARBOX\n"); - response["zoomMode"] = "TV 4X3 PILLARBOX"; - break; - - case tvDisplayMode_NORMAL: - LOGINFO("Aspect Ratio: TV Normal\n"); - response["zoomMode"] = "TV NORMAL"; - break; - - case tvDisplayMode_AUTO: - LOGINFO("Aspect Ratio: TV AUTO\n"); - response["zoomMode"] = "TV AUTO"; - break; - - case tvDisplayMode_DIRECT: - LOGINFO("Aspect Ratio: TV DIRECT\n"); - response["zoomMode"] = "TV DIRECT"; - break; - - case tvDisplayMode_ZOOM: - LOGINFO("Aspect Ratio: TV ZOOM\n"); - response["zoomMode"] = "TV ZOOM"; - break; - - default: - LOGINFO("Aspect Ratio: TV AUTO\n"); - response["zoomMode"] = "TV AUTO"; - break; - } - returnResponse(true); - } - } - - uint32_t AVOutputTV::resetZoomMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - capDetails_t inputInfo; - tvError_t ret = tvERROR_NONE; - - if (parsingSetInputArgument(parameters, "AspectRatio",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "AspectRatio",inputInfo )) { - LOGERR("%s: CapablityCheck failed for AspectRatio\n", __FUNCTION__); - returnResponse(false); - } - - tr181ErrorCode_t err = clearLocalParam(rfc_caller_id,AVOUTPUT_ASPECTRATIO_RFC_PARAM); - if ( err != tr181Success ) { - LOGERR("clearLocalParam for %s Failed : %s\n", AVOUTPUT_ASPECTRATIO_RFC_PARAM, getTR181ErrorString(err)); - ret = tvERROR_GENERAL; - } - else { - ret = setDefaultAspectRatio(inputInfo.pqmode,inputInfo.source,inputInfo.format); - } - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - LOGINFO("Exit : resetDefaultAspectRatio()\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getVideoFormat(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - tvVideoFormatType_t videoFormat; - tvError_t ret = GetCurrentVideoFormat(&videoFormat); - if(ret != tvERROR_NONE) { - response["currentVideoFormat"] = "NONE"; - returnResponse(false); - } - else { - response["currentVideoFormat"] = getVideoFormatTypeToString(videoFormat); - LOGINFO("Exit: getVideoFormat :%d success \n",videoFormat); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getVideoResolution(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - tvResolutionParam_t videoResolution; - tvError_t ret = GetCurrentVideoResolution(&videoResolution); - if(ret != tvERROR_NONE) { - response["currentVideoResolution"] = "NONE"; - returnResponse(false); - } - else { - response["currentVideoResolution"] = getVideoResolutionTypeToString(videoResolution); - LOGINFO("Exit: getVideoResolution :%d success \n",videoResolution.resolutionValue); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getVideoFrameRate(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - tvVideoFrameRate_t videoFramerate; - tvError_t ret = GetCurrentVideoFrameRate(&videoFramerate); - if(ret != tvERROR_NONE) { - response["currentVideoFrameRate"] = "NONE"; - returnResponse(false); - } - else { - response["currentVideoFrameRate"] = getVideoFrameRateTypeToString(videoFramerate); - LOGINFO("Exit: videoFramerate :%d success \n",videoFramerate); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getBacklight(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - - capDetails_t inputInfo; - std::string key; - paramIndex_t indexInfo; - int backlight = 0,err = 0; - - if (parsingGetInputArgument(parameters, "Backlight",inputInfo) != 0) { - LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - - if (isPlatformSupport("Backlight") != 0) { - returnResponse(false); - } - - if (getParamIndex("Backlight", inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - err = getLocalparam("Backlight",indexInfo,backlight, PQ_PARAM_BACKLIGHT); - if( err == 0 ) { - response["backlight"] = backlight; - LOGINFO("Exit : Backlight Value: %d \n", backlight); - returnResponse(true); - } - else { - returnResponse(false); - } - } - - uint32_t AVOutputTV::setBacklight(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - std::string value; - capDetails_t inputInfo; - int backlight = 0; - tvError_t ret = tvERROR_NONE; - - value = parameters.HasLabel("backlight") ? parameters["backlight"].String() : ""; - returnIfParamNotFound(parameters,"backlight"); - backlight = std::stoi(value); - - if (validateIntegerInputParameter("Backlight",backlight) != 0) { - LOGERR("Failed in Backlight range validation:%s", __FUNCTION__); - returnResponse(false); - } - - if (parsingSetInputArgument(parameters,"Backlight",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if (isPlatformSupport("Backlight") != 0 ) { - returnResponse(false); - } - - if( !isCapablityCheckPassed( "Backlight" , inputInfo )) { - LOGERR("%s: CapablityCheck failed for Backlight\n", __FUNCTION__); - returnResponse(false); - } - - if( isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with setBacklight\n"); - ret = SetBacklight(backlight); - } - - if(ret != tvERROR_NONE) { - LOGERR("Failed to set Backlight\n"); - returnResponse(false); - } - else { - int retval= updateAVoutputTVParam("set","Backlight",inputInfo,PQ_PARAM_BACKLIGHT,backlight); - if(retval != 0 ) { - LOGERR("Failed to Save Backlight to ssm_data\n"); - returnResponse(false); - } - LOGINFO("Exit : setBacklight successful to value: %d\n", backlight); - returnResponse(true); - } - - } - - uint32_t AVOutputTV::resetBacklight(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - capDetails_t inputInfo; - int backlight=0; - paramIndex_t indexInfo; - tvError_t ret = tvERROR_NONE; - - if (parsingSetInputArgument(parameters, "Backlight",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if (isPlatformSupport("Backlight") != 0) { - returnResponse(false); - } - - if( !isCapablityCheckPassed( "Backlight",inputInfo )) { - LOGERR("%s: CapablityCheck failed for Backlight\n", __FUNCTION__); - returnResponse(false); - } - - int retval= updateAVoutputTVParam("reset","Backlight",inputInfo,PQ_PARAM_BACKLIGHT,backlight); - if(retval != 0 ) { - LOGERR("Failed to reset Backlight\n"); - returnResponse(false); - } - else { - if (isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format)) { - inputInfo.pqmode = "Current"; - inputInfo.source = "Current"; - inputInfo.format = "Current"; - getParamIndex("Backlight", inputInfo,indexInfo); - int err = getLocalparam("Backlight",indexInfo,backlight, PQ_PARAM_BACKLIGHT); - if( err == 0 ) { - LOGINFO("%s : getLocalparam success format :%d source : %d format : %d value : %d\n",__FUNCTION__,indexInfo.formatIndex, indexInfo.sourceIndex, indexInfo.pqmodeIndex,backlight); - ret = SetBacklight(backlight); - } - else { - LOGERR("%s : GetLocalParam Failed \n",__FUNCTION__); - ret = tvERROR_GENERAL; - } - } - } - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - LOGINFO("Exit : resetBacklight Successful to value : %d \n",backlight); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getBacklightCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t vectorInfo; - JsonObject rangeObj; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - - unsigned int index = 0; - - tvError_t ret = getParamsCaps("Backlight", vectorInfo ); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - response["platformSupport"] = (vectorInfo.isPlatformSupportVector[0].compare("true") == 0) ? true : false; - - rangeObj["from"] = std::stoi(vectorInfo.rangeVector[0]); - rangeObj["to"] = std::stoi(vectorInfo.rangeVector[1]); - response["rangeInfo"]=rangeObj; - - if ((vectorInfo.pqmodeVector.front()).compare("none") != 0) { - for (index = 0; index < vectorInfo.pqmodeVector.size(); index++) { - pqmodeArray.Add(vectorInfo.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((vectorInfo.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < vectorInfo.sourceVector.size(); index++) { - sourceArray.Add(vectorInfo.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((vectorInfo.formatVector.front()).compare("none") != 0) { - for (index = 0; index < vectorInfo.formatVector.size(); index++) { - formatArray.Add(vectorInfo.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getBrightness(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int brightness = 0; - - if (parsingGetInputArgument(parameters, "Brightness",inputInfo) != 0) { - LOGERR("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - - if (getParamIndex("Brightness", inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - int err = getLocalparam("Brightness",indexInfo,brightness, PQ_PARAM_BRIGHTNESS); - if( err == 0 ) { - response["brightness"] = brightness; - LOGINFO("Exit : Brightness Value: %d \n", brightness); - returnResponse(true); - } - else { - returnResponse(false); - } - } - - uint32_t AVOutputTV::setBrightness(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - std::string value; - capDetails_t inputInfo; - int brightness = 0; - tvError_t ret = tvERROR_NONE; - - value = parameters.HasLabel("brightness") ? parameters["brightness"].String() : ""; - returnIfParamNotFound(parameters,"brightness"); - brightness = stoi(value); - - if (validateIntegerInputParameter("Brightness",brightness) != 0) { - LOGERR("Failed in Brightness range validation:%s", __FUNCTION__); - returnResponse(false); - } - - if (parsingSetInputArgument(parameters, "Brightness",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "Brightness",inputInfo )) { - LOGERR("%s: CapablityCheck failed for Brightness\n", __FUNCTION__); - returnResponse(false); - } - - if( isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with %s \n",__FUNCTION__); - ret = SetBrightness(brightness); - } - - if(ret != tvERROR_NONE) { - LOGERR("Failed to set Brightness\n"); - returnResponse(false); - } - else { - int retval= updateAVoutputTVParam("set","Brightness",inputInfo,PQ_PARAM_BRIGHTNESS,brightness); - if(retval != 0 ) { - LOGERR("Failed to Save Brightness to ssm_data\n"); - returnResponse(false); - } - LOGINFO("Exit : setBrightness successful to value: %d\n", brightness); - returnResponse(true); - } - - } - - - uint32_t AVOutputTV::resetBrightness(const JsonObject& parameters, JsonObject& response) - { - - LOGINFO("Entry\n"); - - std::string value; - capDetails_t inputInfo; - paramIndex_t indexInfo; - int brightness=0; - tvError_t ret = tvERROR_NONE; - - if (parsingSetInputArgument(parameters, "Brightness",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "Brightness",inputInfo )) { - LOGERR("%s: CapablityCheck failed for Brightness\n", __FUNCTION__); - returnResponse(false); - } - - int retval= updateAVoutputTVParam("reset","Brightness",inputInfo,PQ_PARAM_BRIGHTNESS,brightness); - if(retval != 0 ) { - LOGWARN("Failed to reset Brightness\n"); - returnResponse(false); - } - else { - if (isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format)) { - inputInfo.pqmode = "Current"; - inputInfo.source = "Current"; - inputInfo.format = "Current"; - getParamIndex("Brightness", inputInfo,indexInfo); - int err = getLocalparam("Brightness",indexInfo,brightness, PQ_PARAM_BRIGHTNESS); - if( err == 0 ) { - LOGINFO("%s : getLocalparam success format :%d source : %d format : %d value : %d\n",__FUNCTION__,indexInfo.formatIndex, indexInfo.sourceIndex, indexInfo.pqmodeIndex,brightness); - ret = SetBrightness(brightness); - } - else { - LOGERR("%s : GetLocalParam Failed \n",__FUNCTION__); - ret = tvERROR_GENERAL; - } - } - } - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - LOGINFO("Exit : resetBrightness Successful to value : %d \n",brightness); - returnResponse(true); - } - - } - - uint32_t AVOutputTV::getBrightnessCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t info; - - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - JsonObject rangeObj; - - unsigned int index = 0; - - tvError_t ret = getParamsCaps("Brightness",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - rangeObj["from"] = stoi(info.rangeVector[0]); - rangeObj["to"] = stoi(info.rangeVector[1]); - response["rangeInfo"]=rangeObj; - - if ((info.pqmodeVector.front()).compare("none") != 0) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getContrast(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int contrast = 0; - - if (parsingGetInputArgument(parameters, "Contrast",inputInfo) != 0) { - LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - - if (getParamIndex("Contrast",inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - int err = getLocalparam("Contrast",indexInfo,contrast, PQ_PARAM_CONTRAST); - if( err == 0 ) { - response["contrast"] = contrast; - LOGINFO("Exit : Contrast Value: %d \n", contrast); - returnResponse(true); - } - else { - returnResponse(false); - } - } - - uint32_t AVOutputTV::setContrast(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - int contrast = 0; - tvError_t ret = tvERROR_NONE; - std::string value; - - value = parameters.HasLabel("contrast") ? parameters["contrast"].String() : ""; - returnIfParamNotFound(parameters,"contrast"); - contrast = std::stoi(value); - - if (validateIntegerInputParameter("Contrast", contrast) != 0) { - LOGERR("Failed in contrast range validation:%s", __FUNCTION__); - returnResponse(false); - } - - if (parsingSetInputArgument(parameters, "Contrast",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "Contrast" , inputInfo )) { - LOGERR("%s: CapablityCheck failed for Contrast\n", __FUNCTION__); - returnResponse(false); - } - - if( isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with %s \n",__FUNCTION__); - ret = SetContrast(contrast); - } - - if(ret != tvERROR_NONE) { - LOGERR("Failed to set Contrast\n"); - returnResponse(false); - } - else { - int retval= updateAVoutputTVParam("set","Contrast",inputInfo,PQ_PARAM_CONTRAST,contrast); - if(retval != 0 ) { - LOGERR("Failed to Save Contrast to ssm_data\n"); - returnResponse(false); - } - LOGINFO("Exit : setContrast successful to value: %d\n", contrast); - returnResponse(true); - } - - } - - uint32_t AVOutputTV::resetContrast(const JsonObject& parameters, JsonObject& response) - { - - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int contrast=0; - tvError_t ret = tvERROR_NONE; - - if (parsingSetInputArgument(parameters, "Contrast",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "Contrast" , inputInfo )) { - LOGERR("%s: CapablityCheck failed for Contrast\n", __FUNCTION__); - returnResponse(false); - } - - int retval= updateAVoutputTVParam("reset","Contrast",inputInfo,PQ_PARAM_CONTRAST,contrast); - - if(retval != 0 ) { - LOGWARN("Failed to reset Contrast\n"); - returnResponse(false); - } - else { - if (isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format)) { - inputInfo.pqmode = "Current"; - inputInfo.source = "Current"; - inputInfo.format = "Current"; - getParamIndex("Contrast", inputInfo,indexInfo); - int err = getLocalparam("Contrast",indexInfo,contrast, PQ_PARAM_CONTRAST); - if( err == 0 ) { - LOGINFO("%s : getLocalparam success format :%d source : %d format : %d value : %d\n",__FUNCTION__,indexInfo.formatIndex, indexInfo.sourceIndex, indexInfo.pqmodeIndex,contrast); - ret = SetContrast(contrast); - } - else { - LOGERR("%s : GetLocalParam Failed \n",__FUNCTION__); - ret = tvERROR_GENERAL; - } - } - } - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - LOGINFO("Exit : resetContrast Successful to value : %d \n",contrast); - returnResponse(true); - } - - } - - uint32_t AVOutputTV::getContrastCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t info; - - JsonArray rangeArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - - JsonObject rangeObj; - unsigned int index = 0; - - tvError_t ret = getParamsCaps("Contrast",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - rangeObj["from"] = stoi(info.rangeVector[0]); - rangeObj["to"] = stoi(info.rangeVector[1]); - response["rangeInfo"]=rangeObj; - - if ((info.pqmodeVector.front()).compare("none") != 0) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getSaturation(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int saturation = 0; - - if (parsingGetInputArgument(parameters, "Saturation",inputInfo) != 0) { - LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - - if (getParamIndex("Saturation", inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - int err = getLocalparam("Saturation",indexInfo,saturation, PQ_PARAM_SATURATION); - if( err == 0 ) { - response["saturation"] = saturation; - LOGINFO("Exit : Saturation Value: %d \n", saturation); - returnResponse(true); - } - else { - returnResponse(false); - } - } - - uint32_t AVOutputTV::setSaturation(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - std::string value; - int saturation = 0; - tvError_t ret = tvERROR_NONE; - - value = parameters.HasLabel("saturation") ? parameters["saturation"].String() : ""; - returnIfParamNotFound(parameters,"saturation"); - saturation = std::stoi(value); - - if (validateIntegerInputParameter("Saturation",saturation) != 0) { - LOGERR("Failed in saturation range validation:%s", __FUNCTION__); - returnResponse(false); - } - - if (parsingSetInputArgument(parameters, "Saturation",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "Saturation" , inputInfo )) { - LOGERR("%s: CapablityCheck failed for Saturation\n", __FUNCTION__); - returnResponse(false); - } - - if( isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with %s\n",__FUNCTION__); - ret = SetSaturation(saturation); - } - - if(ret != tvERROR_NONE) { - LOGERR("Failed to set Saturation\n"); - returnResponse(false); - } - else { - int retval= updateAVoutputTVParam("set","Saturation",inputInfo,PQ_PARAM_SATURATION,saturation); - if(retval != 0 ) { - LOGERR("Failed to Save Saturation to ssm_data\n"); - returnResponse(false); - } - LOGINFO("Exit : setSaturation successful to value: %d\n", saturation); - returnResponse(true); - } - - } - - uint32_t AVOutputTV::resetSaturation(const JsonObject& parameters, JsonObject& response) - { - - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int saturation=0; - tvError_t ret = tvERROR_NONE; - - if (parsingSetInputArgument(parameters, "Saturation", inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "Saturation", inputInfo )) { - LOGERR("%s: CapablityCheck failed for Saturation\n", __FUNCTION__); - returnResponse(false); - } - - int retval= updateAVoutputTVParam("reset","Saturation",inputInfo,PQ_PARAM_SATURATION,saturation); - - if(retval != 0 ) { - LOGERR("Failed to reset Saturation\n"); - returnResponse(false); - } - else { - if (isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format)) { - inputInfo.pqmode = "Current"; - inputInfo.source = "Current"; - inputInfo.format = "Current"; - getParamIndex("Saturation",inputInfo,indexInfo); - int err = getLocalparam("Saturation",indexInfo, saturation, PQ_PARAM_SATURATION); - if( err == 0 ) { - LOGINFO("%s : getLocalparam success format :%d source : %d format : %d value : %d\n",__FUNCTION__,indexInfo.formatIndex, indexInfo.sourceIndex, indexInfo.pqmodeIndex,saturation); - ret = SetSaturation(saturation); - } - else { - LOGERR("%s : GetLocalParam Failed \n",__FUNCTION__); - ret = tvERROR_GENERAL; - } - } - } - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - LOGINFO("Exit : resetSaturation Successful to value : %d \n",saturation); - returnResponse(true); - } - - } - - uint32_t AVOutputTV::getSaturationCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t info; - - JsonArray rangeArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - - unsigned int index = 0; - JsonObject rangeObj; - - tvError_t ret = getParamsCaps("Saturation",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - rangeObj["from"] = stoi(info.rangeVector[0]); - rangeObj["to"] = stoi(info.rangeVector[1]); - response["rangeInfo"]=rangeObj; - - - if ((info.pqmodeVector.front()).compare("none") != 0) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getSharpness(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int sharpness = 0; - - if (parsingGetInputArgument(parameters, "Sharpness",inputInfo) != 0) { - LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - - if (getParamIndex("Sharpness",inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - int err = getLocalparam("Sharpness",indexInfo,sharpness, PQ_PARAM_SHARPNESS); - if( err == 0 ) { - response["sharpness"] = sharpness; - LOGINFO("Exit : Sharpness Value: %d \n", sharpness); - returnResponse(true); - } - else { - returnResponse(false); - } - } - - uint32_t AVOutputTV::setSharpness(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - int sharpness = 0; - tvError_t ret = tvERROR_NONE; - std::string value; - - value = parameters.HasLabel("sharpness") ? parameters["sharpness"].String() : ""; - returnIfParamNotFound(parameters,"sharpness"); - sharpness = std::stoi(value); - - if (validateIntegerInputParameter("Sharpness",sharpness) != 0) { - LOGERR("Failed in sharpness range validation:%s", __FUNCTION__); - returnResponse(false); - } - - if (parsingSetInputArgument(parameters, "Sharpness", inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "Sharpness", inputInfo )) { - LOGERR("%s: CapablityCheck failed for Sharpness\n", __FUNCTION__); - returnResponse(false); - } - - if( isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with %s\n",__FUNCTION__); - ret = SetSharpness(sharpness); - } - - if(ret != tvERROR_NONE) { - LOGERR("Failed to set Sharpness\n"); - returnResponse(false); - } - else { - int retval= updateAVoutputTVParam("set","Sharpness",inputInfo,PQ_PARAM_SHARPNESS,sharpness); - if(retval != 0 ) { - LOGERR("Failed to Save Sharpness to ssm_data\n"); - returnResponse(false); - } - LOGINFO("Exit : setSharpness successful to value: %d\n", sharpness); - returnResponse(true); - } - - } - - uint32_t AVOutputTV::resetSharpness(const JsonObject& parameters, JsonObject& response) - { - - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int sharpness=0; - tvError_t ret = tvERROR_NONE; - - if (parsingSetInputArgument(parameters, "Sharpness",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "Sharpness" , inputInfo)) { - LOGERR("%s: CapablityCheck failed for Sharpness\n", __FUNCTION__); - returnResponse(false); - } - - int retval= updateAVoutputTVParam("reset","Sharpness", inputInfo,PQ_PARAM_SHARPNESS,sharpness); - - if(retval != 0 ) { - LOGERR("Failed to reset Sharpness\n"); - returnResponse(false); - } - else { - if (isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format)) { - inputInfo.pqmode = "Current"; - inputInfo.source = "Current"; - inputInfo.format = "Current"; - getParamIndex("Sharpness",inputInfo,indexInfo); - int err = getLocalparam("Sharpness",indexInfo, sharpness, PQ_PARAM_SHARPNESS); - if( err == 0 ) { - LOGINFO("%s : getLocalparam success format :%d source : %d format : %d value : %d\n",__FUNCTION__,indexInfo.formatIndex, indexInfo.sourceIndex, indexInfo.pqmodeIndex,sharpness); - ret = SetSharpness(sharpness); - } - else { - LOGERR("%s : GetLocalParam Failed \n",__FUNCTION__); - ret = tvERROR_GENERAL; - } - } - } - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - LOGINFO("Exit : resetSharpness Successful to value : %d \n",sharpness); - returnResponse(true); - } - - } - - uint32_t AVOutputTV::getSharpnessCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t info; - - JsonArray rangeArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - - JsonObject rangeObj; - unsigned int index = 0; - - tvError_t ret = getParamsCaps("Sharpness",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - rangeObj["from"] = stoi(info.rangeVector[0]); - rangeObj["to"] = stoi(info.rangeVector[1]); - response["rangeInfo"]=rangeObj; - - if ((info.pqmodeVector.front()).compare("none") != 0) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getHue(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int hue = 0; - - if (parsingGetInputArgument(parameters, "Hue", inputInfo) != 0) { - LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - - if (getParamIndex("Hue",inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - int err = getLocalparam("Hue",indexInfo,hue, PQ_PARAM_HUE); - if( err == 0 ) { - response["hue"] = hue; - LOGINFO("Exit : Hue Value: %d \n", hue); - returnResponse(true); - } - else { - returnResponse(false); - } - } - - uint32_t AVOutputTV::setHue(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - int hue = 0; - tvError_t ret = tvERROR_NONE; - std::string value; - - value = parameters.HasLabel("hue") ? parameters["hue"].String() : ""; - returnIfParamNotFound(parameters,"hue"); - hue = std::stoi(value); - - if (validateIntegerInputParameter("Hue",hue) != 0) { - LOGERR("Failed in hue range validation:%s", __FUNCTION__); - returnResponse(false); - } - - if (parsingSetInputArgument(parameters, "Hue",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "Hue", inputInfo )) { - LOGERR("%s: CapablityCheck failed for Hue\n", __FUNCTION__); - returnResponse(false); - } - - if( isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with %s\n",__FUNCTION__); - ret = SetHue(hue); - } - - if(ret != tvERROR_NONE) { - LOGERR("Failed to set Hue\n"); - returnResponse(false); - } - else { - int retval= updateAVoutputTVParam("set","Hue",inputInfo,PQ_PARAM_HUE,hue); - if(retval != 0 ) { - LOGERR("Failed to Save Hue to ssm_data\n"); - returnResponse(false); - } - LOGINFO("Exit : setHue successful to value: %d\n", hue); - returnResponse(true); - } - - } - - uint32_t AVOutputTV::resetHue(const JsonObject& parameters, JsonObject& response) - { - - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int hue=0; - tvError_t ret = tvERROR_NONE; - - if (parsingSetInputArgument(parameters, "Hue",inputInfo)!= 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "Hue" , inputInfo )) { - LOGERR("%s: CapablityCheck failed for Hue\n", __FUNCTION__); - returnResponse(false); - } - - int retval= updateAVoutputTVParam("reset","Hue", inputInfo,PQ_PARAM_HUE,hue); - - if(retval != 0 ) { - LOGERR("Failed to reset Hue\n"); - returnResponse(false); - } - else { - if (isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format)) { - inputInfo.pqmode = "Current"; - inputInfo.source = "Current"; - inputInfo.format = "Current"; - getParamIndex("Hue",inputInfo,indexInfo); - int err = getLocalparam("Hue",indexInfo, hue, PQ_PARAM_HUE); - if( err == 0 ) { - LOGINFO("%s : getLocalparam success format :%d source : %d format : %d value : %d\n",__FUNCTION__,indexInfo.formatIndex, indexInfo.sourceIndex, indexInfo.pqmodeIndex,hue); - ret = SetHue(hue); - } - else { - LOGERR("%s : GetLocalParam Failed \n",__FUNCTION__); - ret = tvERROR_GENERAL; - } - } - } - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - LOGINFO("Exit : resetHue Successful to value : %d \n",hue); - returnResponse(true); - } - - } - - uint32_t AVOutputTV::getHueCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t info; - - JsonArray rangeArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - - JsonObject rangeObj; - unsigned int index = 0; - - tvError_t ret = getParamsCaps("Hue",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - rangeObj["from"] = stoi(info.rangeVector[0]); - rangeObj["to"] = stoi(info.rangeVector[1]); - response["rangeInfo"]=rangeObj; - - if ((info.pqmodeVector.front()).compare("none") != 0) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getColorTemperature(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int colortemp = 0; - - if (parsingGetInputArgument(parameters, "ColorTemperature", inputInfo) != 0) { - LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - - if (getParamIndex("ColorTemperature",inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - int err = getLocalparam("ColorTemp",indexInfo,colortemp,PQ_PARAM_COLOR_TEMPERATURE); - if( err == 0 ) { - switch(colortemp) { - case tvColorTemp_STANDARD: - LOGINFO("Color Temp Value: Standard\n"); - response["colorTemperature"] = "Standard"; - break; - - case tvColorTemp_WARM: - LOGINFO("Color Temp Value: Warm\n"); - response["colorTemperature"] = "Warm"; - break; - - case tvColorTemp_COLD: - LOGINFO("Color Temp Value: Cold\n"); - response["colorTemperature"] = "Cold"; - break; - - case tvColorTemp_USER: - LOGINFO("Color Temp Value: User Defined\n"); - response["colorTemperature"] = "UserDefined"; - break; - - default: - LOGINFO("Color Temp Value: Standard\n"); - response["colorTemperature"] = "Standard"; - break; - } - LOGINFO("Exit : ColorTemperature Value: %d \n", colortemp); - returnResponse(true); - } - else { - returnResponse(false); - } - } - - uint32_t AVOutputTV::setColorTemperature(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - std::string value; - tvColorTemp_t colortemp = tvColorTemp_MAX; - tvError_t ret = tvERROR_NONE; - - value = parameters.HasLabel("colorTemperature") ? parameters["colorTemperature"].String() : ""; - returnIfParamNotFound(parameters,"colorTemperature"); - if(!value.compare("Standard")) { - colortemp = tvColorTemp_STANDARD; - } - else if (!value.compare("Warm")) { - colortemp = tvColorTemp_WARM; - } - else if (!value.compare("Cold")) { - colortemp = tvColorTemp_COLD; - } - else if (!value.compare("UserDefined")) { - colortemp = tvColorTemp_USER; - } - else { - returnResponse(false); - } - - if (parsingSetInputArgument(parameters, "ColorTemperature",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "ColorTemperature", inputInfo )) { - LOGERR("%s: CapablityCheck failed for colorTemperature\n", __FUNCTION__); - returnResponse(false); - } - - if( isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with %s\n",__FUNCTION__); - ret = SetColorTemperature((tvColorTemp_t)colortemp); - } - - if(ret != tvERROR_NONE) { - LOGERR("Failed to set ColorTemperature\n"); - returnResponse(false); - } - else { - int retval= updateAVoutputTVParam("set","ColorTemp", inputInfo,PQ_PARAM_COLOR_TEMPERATURE,(int)colortemp); - if(retval != 0 ) { - LOGERR("Failed to Save ColorTemperature to ssm_data\n"); - returnResponse(false); - } - LOGINFO("Exit : setColorTemperature successful to value: %d\n", colortemp); - returnResponse(true); - } - } - - uint32_t AVOutputTV::resetColorTemperature(const JsonObject& parameters, JsonObject& response) - { - - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int colortemp=0; - tvError_t ret = tvERROR_NONE; - - if (parsingSetInputArgument(parameters, "ColorTemperature", inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "ColorTemperature", inputInfo )) { - LOGERR("%s: CapablityCheck failed for colorTemperature\n", __FUNCTION__); - returnResponse(false); - } - - int retval= updateAVoutputTVParam("reset","ColorTemp", inputInfo,PQ_PARAM_COLOR_TEMPERATURE,colortemp); - - if(retval != 0 ) { - LOGERR("Failed to reset ColorTemperature\n"); - returnResponse(false); - } - else { - if (isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format)) { - inputInfo.pqmode = "Current"; - inputInfo.source = "Current"; - inputInfo.format = "Current"; - getParamIndex("ColorTemperature",inputInfo,indexInfo); - int err = getLocalparam("ColorTemp",indexInfo, colortemp, PQ_PARAM_COLOR_TEMPERATURE); - if( err == 0 ) { - LOGINFO("%s : getLocalparam success format :%d source : %d format : %d value : %d\n",__FUNCTION__,indexInfo.formatIndex, indexInfo.sourceIndex, indexInfo.pqmodeIndex, colortemp); - ret = SetColorTemperature((tvColorTemp_t)colortemp); - } - else { - LOGERR("%s : GetLocalParam Failed \n",__FUNCTION__); - ret = tvERROR_GENERAL; - } - } - } - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - LOGINFO("Exit : resetColorTemperature Successful to value : %d \n",colortemp); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getColorTemperatureCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t info; - - JsonArray rangeArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - - unsigned int index = 0; - - tvError_t ret = getParamsCaps("ColorTemperature",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - for (index = 0; index < info.rangeVector.size(); index++) { - rangeArray.Add(info.rangeVector[index]); - } - - response["options"]=rangeArray; - - if (((info.pqmodeVector.front()).compare("none") != 0)) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getBacklightDimmingMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int dimmingMode = 0; - - if (parsingGetInputArgument(parameters, "DimmingMode", inputInfo) != 0) { - LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - - if (getParamIndex("DimmingMode",inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - - int err = getLocalparam("DimmingMode",indexInfo,dimmingMode, PQ_PARAM_DIMMINGMODE); - if( err == 0 ) { - switch(dimmingMode) { - case tvDimmingMode_Fixed: - LOGINFO("DimmingMode Value: Fixed\n"); - response["DimmingMode"] = "fixed"; - break; - - case tvDimmingMode_Local: - LOGINFO("DimmingMode Value: Local\n"); - response["DimmingMode"] = "local"; - break; - - case tvDimmingMode_Global: - LOGINFO("DimmingMode Value: Global\n"); - response["DimmingMode"] = "global"; - break; - - } - LOGINFO("Exit : DimmingMode Value: %d \n", dimmingMode); - returnResponse(true); - } - else { - returnResponse(false); - } - } - - uint32_t AVOutputTV::setBacklightDimmingMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - int dimmingMode = 0; - tvError_t ret = tvERROR_NONE; - std::string value; - - value = parameters.HasLabel("DimmingMode") ? parameters["DimmingMode"].String() : ""; - returnIfParamNotFound(parameters,"DimmingMode"); - - if (validateInputParameter("DimmingMode",value) != 0) { - LOGERR("%s: Range validation failed for DimmingMode\n", __FUNCTION__); - returnResponse(false); - } - dimmingMode = getDimmingModeIndex(value); - - if (parsingSetInputArgument(parameters, "DimmingMode",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "DimmingMode" , inputInfo )) { - LOGERR("%s: CapablityCheck failed for DimmingMode\n", __FUNCTION__); - returnResponse(false); - } - - if( isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with %s\n",__FUNCTION__); - ret = SetTVDimmingMode(value.c_str()); - } - - if(ret != tvERROR_NONE) { - LOGERR("Failed to set DimmingMode\n"); - returnResponse(false); - } - else { - int retval= updateAVoutputTVParam("set","DimmingMode",inputInfo,PQ_PARAM_DIMMINGMODE,(int)dimmingMode); - if(retval != 0 ) { - LOGERR("Failed to Save DimmingMode to ssm_data\n"); - returnResponse(false); - } - - LOGINFO("Exit : setDimmingMode successful to value: %d\n", dimmingMode); - returnResponse(true); - } - } - - uint32_t AVOutputTV::resetBacklightDimmingMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - std::string dimmingMode; - int dMode=0; - tvError_t ret = tvERROR_NONE; - - if (parsingSetInputArgument(parameters, "DimmingMode", inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "DimmingMode" , inputInfo )) { - LOGERR("%s: CapablityCheck failed for DimmingMode\n", __FUNCTION__); - returnResponse(false); - } - - int retval= updateAVoutputTVParam("reset","DimmingMode", inputInfo,PQ_PARAM_DIMMINGMODE,dMode); - - if(retval != 0 ) { - LOGERR("Failed to reset ldim\n"); - returnResponse(false); - } - - else { - if (isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format)) { - inputInfo.pqmode = "Current"; - inputInfo.source = "Current"; - inputInfo.format = "Current"; - getParamIndex("DimmingMode",inputInfo,indexInfo); - int err = getLocalparam("DimmingMode",indexInfo, dMode, PQ_PARAM_DIMMINGMODE); - if( err == 0 ) { - LOGINFO("%s : getLocalparam success format :%d source : %d format : %d value : %d\n",__FUNCTION__,indexInfo.formatIndex, indexInfo.sourceIndex, indexInfo.pqmodeIndex, dMode); - getDimmingModeStringFromEnum(dMode,dimmingMode); - ret = SetTVDimmingMode(dimmingMode.c_str()); - } - else { - LOGERR("%s : GetLocalParam Failed \n",__FUNCTION__); - ret = tvERROR_GENERAL; - } - } - } - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - LOGINFO("Exit : resetBacklightDimmingMode Successful to value : %s \n",dimmingMode.c_str()); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getBacklightDimmingModeCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t info; - - JsonArray supportedDimmingModeArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - - unsigned int index = 0; - - tvError_t ret = getParamsCaps("DimmingMode",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - for (index = 0; index < info.rangeVector.size(); index++) { - supportedDimmingModeArray.Add(info.rangeVector[index]); - } - - response["options"]=supportedDimmingModeArray; - - if (((info.pqmodeVector.front()).compare("none") != 0)) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getSupportedDolbyVisionModes(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - tvDolbyMode_t dvModes[tvMode_Max]; - tvDolbyMode_t *dvModesPtr = dvModes; // Pointer to statically allocated tvDolbyMode_t array - unsigned short totalAvailable = 0; - - // Set an initial value to indicate the mode type - dvModes[0] = tvDolbyMode_Dark; - - tvError_t ret = GetTVSupportedDolbyVisionModes(&dvModesPtr, &totalAvailable); - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - JsonArray SupportedDVModes; - - for(int count = 0;count range; - std::vector pqmode; - std::vector source; - std::vector format; - - if (getCapabilitySource(rangeArray) != 0) { - returnResponse(false); - } - response["options"]=rangeArray; - LOGINFO("Exit\n"); - returnResponse(true); - } - - uint32_t AVOutputTV::getVideoFormatCaps(const JsonObject& parameters, JsonObject& response) - { - - JsonArray rangeArray; - - capVectors_t info; - - tvError_t ret = getParamsCaps("VideoFormat",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - if ((info.rangeVector.front()).compare("none") != 0) { - for (unsigned int index = 0; index < info.rangeVector.size(); index++) { - rangeArray.Add(info.rangeVector[index]); - } - response["options"]=rangeArray; - } - } - LOGINFO("Exit\n"); - returnResponse(true); - } - - uint32_t AVOutputTV::getVideoFrameRateCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - std::vector rangeInfo; - JsonArray rangeArray; - - if ( getRangeCapability("VideoFrameRate", rangeInfo) != 0 ) { - returnResponse(false); - } - - for (unsigned int index = 0; index < rangeInfo.size(); index++) { - rangeArray.Add(std::stof(rangeInfo[index])); - } - - response["videoFrameRates"] = rangeArray; - returnResponse(true); - } - - uint32_t AVOutputTV::getVideoResolutionCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - response["maxResolution"] = "4096*2160p"; - returnResponse(true); - } - - uint32_t AVOutputTV::getPictureModeCaps(const JsonObject& parameters, JsonObject& response) - { - - JsonArray sourceArray; - JsonArray formatArray; - JsonArray rangeArray; - - capVectors_t info; - - unsigned int index = 0; - tvError_t ret = getParamsCaps("PictureMode",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - - if ((info.rangeVector.front()).compare("none") != 0) { - for (index = 0; index < info.rangeVector.size(); index++) { - rangeArray.Add(info.rangeVector[index]); - } - response["options"]=rangeArray; - } - - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getPictureMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - capDetails_t inputInfo; - paramIndex_t indexInfo; - std::string tr181_param_name; - TR181_ParamData_t param = {0}; - tr181ErrorCode_t err = tr181Success; - - if (parsingGetInputArgument(parameters, "PictureMode",inputInfo) != 0) { - LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - - if (getParamIndex("PictureMode",inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - tr181_param_name += std::string(AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM); - tr181_param_name += "." + convertSourceIndexToString(indexInfo.sourceIndex) + "." + "Format."+convertVideoFormatToString(indexInfo.formatIndex)+"."+"PictureModeString"; - err = getLocalParam(rfc_caller_id, tr181_param_name.c_str(), ¶m); - - if ( tr181Success != err ) { - returnResponse(false); - } - else { - std::string s; - s+=param.value; - response["pictureMode"] = s; - LOGINFO("Exit : getPictureMode() : %s\n",s.c_str()); - returnResponse(true); - } - } - - uint32_t AVOutputTV::setPictureMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - capDetails_t inputInfo; - char prevmode[PIC_MODE_NAME_MAX]={0}; - std::string value; - GetTVPictureMode(prevmode); - - tvError_t ret = tvERROR_NONE; - value = parameters.HasLabel("pictureMode") ? parameters["pictureMode"].String() : ""; - returnIfParamNotFound(parameters,"pictureMode"); - - // As only source need to validate, so pqmode and formate passing as currrent - if (parsingSetInputArgument(parameters, "PictureMode",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if (validateInputParameter("PictureMode",value) != 0) { - LOGERR("%s: Range validation failed for PictureMode\n", __FUNCTION__); - returnResponse(false); - } - if( !isCapablityCheckPassed( "PictureMode" , inputInfo )) { - LOGERR("%s: CapablityCheck failed for PictureMode\n", __FUNCTION__); - returnResponse(false); - } - - if( isSetRequired("Current",inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with SetTVPictureMode\n"); - ret = SetTVPictureMode(value.c_str()); - } - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - valueVectors_t values; - inputInfo.pqmode = "Current"; - - getSaveConfig("PictureMode" ,inputInfo, values); - - for (int sourceType : values.sourceValues) { - tvVideoSrcType_t source = (tvVideoSrcType_t)sourceType; - for (int formatType : values.formatValues) { - tvVideoFormatType_t format = (tvVideoFormatType_t)formatType; - std::string tr181_param_name = ""; - tr181_param_name += std::string(AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM); - // framing Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.AVOutput.Source.source_index[x].Format.format_index[x].PictureModeString.value - tr181_param_name += "."+convertSourceIndexToString(source)+"."+"Format."+ - convertVideoFormatToString(format)+"."+"PictureModeString"; - tr181ErrorCode_t err = setLocalParam(rfc_caller_id, tr181_param_name.c_str(), value.c_str()); - if ( err != tr181Success ) { - LOGERR("setLocalParam for %s Failed : %s\n", AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM, getTR181ErrorString(err)); - returnResponse(false); - } - else { - LOGINFO("setLocalParam for %s Successful, Value: %s\n", AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM, value.c_str()); - int pqmodeindex = (int)getPictureModeIndex(value); - SaveSourcePictureMode(source, format, pqmodeindex); - } - } - } - - //Filmmaker mode telemetry - if(!strncmp(value.c_str(),"filmmaker",strlen(value.c_str())) && strncmp(prevmode,"filmmaker",strlen(prevmode))) { - LOGINFO("%s mode has been enabled",value.c_str()); - } - else if(!strncmp(prevmode,"filmmaker",strlen(prevmode)) && strncmp(value.c_str(),"filmmaker",strlen(value.c_str()))) { - LOGINFO("%s mode has been disabled",prevmode); - } - - LOGINFO("Broadcasting the low latency change event \n"); - - if(m_isDalsEnabled) { - //GameModebroadcast - if(!strncmp(value.c_str(),"game",strlen(value.c_str())) && strncmp(prevmode,"game",strlen(prevmode))) { - broadcastLowLatencyModeChangeEvent(1); - } - else if(!strncmp(prevmode,"game",strlen(prevmode)) && strncmp(value.c_str(),"game",strlen(value.c_str()))) { - broadcastLowLatencyModeChangeEvent(0); - } - } - - LOGINFO("Exit : Value : %s \n",value.c_str()); - returnResponse(true); - } - } - - uint32_t AVOutputTV::resetPictureMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - tr181ErrorCode_t err = tr181Success; - TR181_ParamData_t param = {0}; - - valueVectors_t values; - capDetails_t inputInfo; - - // As only source need to validate, so pqmode and formate passing as currrent - if (parsingSetInputArgument(parameters, "PictureMode",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "PictureMode",inputInfo )) { - LOGERR("%s: CapablityCheck failed for PictureMode\n", __FUNCTION__); - returnResponse(false); - } - inputInfo.pqmode = "Current"; - getSaveConfig("PictureMode", inputInfo, values); - - for (int source : values.sourceValues) { - tvVideoSrcType_t sourceType = (tvVideoSrcType_t)source; - for (int format : values.formatValues) { - tvVideoFormatType_t formatType = (tvVideoFormatType_t)format; - std::string tr181_param_name = ""; - tr181_param_name += std::string(AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM); - tr181_param_name += "."+convertSourceIndexToString(sourceType)+"."+"Format."+ - convertVideoFormatToString(formatType)+"."+"PictureModeString"; - - err = clearLocalParam(rfc_caller_id, tr181_param_name.c_str()); - if ( err != tr181Success ) { - LOGWARN("clearLocalParam for %s Failed : %s\n", tr181_param_name.c_str(), getTR181ErrorString(err)); - returnResponse(false); - } - else { - err = getLocalParam(rfc_caller_id, tr181_param_name.c_str(), ¶m); - if ( tr181Success == err ) { - //get curren source and if matches save for that alone - tvVideoSrcType_t current_source = VIDEO_SOURCE_IP; - GetCurrentVideoSource(¤t_source); - - tvVideoFormatType_t current_format = VIDEO_FORMAT_NONE; - GetCurrentVideoFormat(¤t_format); - if( current_format == VIDEO_FORMAT_NONE) { - current_format = VIDEO_FORMAT_SDR; - } - - if (current_source == sourceType && current_format == formatType) { - - tvError_t ret = SetTVPictureMode(param.value); - if(ret != tvERROR_NONE) { - LOGWARN("Picture Mode set failed: %s\n",getErrorString(ret).c_str()); - returnResponse(false); - } - else { - LOGINFO("Exit : Picture Mode reset successfully, value: %s\n", param.value); - } - } - int pqmodeindex = (int)getPictureModeIndex(param.value); - SaveSourcePictureMode(sourceType, formatType, pqmodeindex); - } - else { - LOGWARN("getLocalParam for %s failed\n", AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM); - returnResponse(false); - } - } - } - } - returnResponse(true) - } - - uint32_t AVOutputTV::signalFilmMakerMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - std::string value; - char prevmode[PIC_MODE_NAME_MAX]={0}; - GetTVPictureMode(prevmode); - - value = parameters.HasLabel("signalFilmMakerMode") ? parameters["signalFilmMakerMode"].String() : ""; - returnIfParamNotFound(parameters, "signalFilmMakerMode"); - - if(strncmp(value.c_str(),"ON",strlen(value.c_str())) == 0) { - NotifyFilmMakerModeChange(tvContentType_FMM); - LOGINFO(" enabling Film makermode \n"); - } - else { - LOGINFO(" disabling Film makermode \n"); - NotifyFilmMakerModeChange(tvContentType_NONE); - } - returnResponse(true); - } - - uint32_t AVOutputTV::setLowLatencyState(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - std::string value; - capDetails_t inputInfo; - int lowLatencyIndex = 0,prevLowLatencyIndex = 0; - tvError_t ret = tvERROR_NONE; - - ret = GetLowLatencyState(&prevLowLatencyIndex); - if(ret != tvERROR_NONE) { - LOGERR("Get previous low latency state failed\n"); - returnResponse(false); - } - - value = parameters.HasLabel("LowLatencyState") ? parameters["LowLatencyState"].String() : ""; - returnIfParamNotFound(parameters,"LowLatencyState"); - lowLatencyIndex = std::stoi(value); - - if (validateIntegerInputParameter("LowLatencyState",lowLatencyIndex) != 0) { - LOGERR("Failed in Brightness range validation:%s", __FUNCTION__); - returnResponse(false); - } - - if (parsingSetInputArgument(parameters, "LowLatencyState",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "LowLatencyState" , inputInfo )) { - LOGERR("%s: CapablityCheck failed for LowLatencyState\n", __FUNCTION__); - returnResponse(false); - } - - int retval= updateAVoutputTVParam("set","LowLatencyState",inputInfo,PQ_PARAM_LOWLATENCY_STATE,lowLatencyIndex); - if(retval != 0 ) { - LOGERR("Failed to SaveLowLatency to ssm_data\n"); - returnResponse(false); - } else { - - if( isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with setLowLatencyState\n"); - ret = SetLowLatencyState( lowLatencyIndex ); - } - - if(ret != tvERROR_NONE) { - LOGERR("Failed to set low latency. Fallback to previous state %d\n", prevLowLatencyIndex); - retval=updateAVoutputTVParam("set","LowLatencyState",inputInfo,PQ_PARAM_LOWLATENCY_STATE,prevLowLatencyIndex); - if(retval != 0 ){ - LOGERR("Fallback to previous low latency state %d failed.\n", prevLowLatencyIndex); - } - returnResponse(false); - } - - LOGINFO("Exit : setLowLatency successful to value: %d\n", lowLatencyIndex); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getLowLatencyState(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int lowlatencystate = 0; - - if (parsingGetInputArgument(parameters, "LowLatencyState",inputInfo) != 0) { - LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - if (getParamIndex("LowLatencyState",inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - int err = getLocalparam("LowLatencyState", indexInfo ,lowlatencystate, PQ_PARAM_LOWLATENCY_STATE); - if( err == 0 ) { - response["lowLatencyState"] = std::to_string(lowlatencystate); - LOGINFO("Exit : LowLatencyState Value: %d \n", lowlatencystate); - returnResponse(true); - } - else { - returnResponse(false); - } - } - - uint32_t AVOutputTV::resetLowLatencyState(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int lowlatencystate=0; - tvError_t ret = tvERROR_NONE; - - if (parsingSetInputArgument(parameters, "LowLatencyState", inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "LowLatencyState" , inputInfo )) { - LOGERR("%s: CapablityCheck failed for LowLatencyState\n", __FUNCTION__); - returnResponse(false); - } - - int retval= updateAVoutputTVParam("reset","LowLatencyState", inputInfo,PQ_PARAM_LOWLATENCY_STATE,lowlatencystate); - if(retval != 0 ) { - LOGERR("Failed to clear Lowlatency from ssmdata and localstore\n"); - returnResponse(false); - } - else { - if (isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format)) { - inputInfo.pqmode = "Current"; - inputInfo.source = "Current"; - inputInfo.format = "Current"; - getParamIndex("LowLatencyState",inputInfo, indexInfo); - int err = getLocalparam("LowLatencyState",indexInfo, lowlatencystate, PQ_PARAM_LOWLATENCY_STATE); - if( err == 0 ) { - LOGINFO("%s : getLocalparam success format :%d source : %d format : %d value : %d\n",__FUNCTION__,indexInfo.formatIndex, indexInfo.sourceIndex, indexInfo.pqmodeIndex, lowlatencystate); - ret = SetLowLatencyState(lowlatencystate); - } - else { - LOGERR("%s : GetLocalParam Failed \n",__FUNCTION__); - ret = tvERROR_GENERAL; - } - } - } - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - LOGINFO("Exit : resetLowLatency Successful to value : %d \n",lowlatencystate); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getLowLatencyStateCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t info; - - JsonArray rangeArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - - unsigned int index = 0; - - tvError_t ret = getParamsCaps("LowLatencyState", info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - for (index = 0; index < info.rangeVector.size(); index++) { - rangeArray.Add(stoi(info.rangeVector[index])); - } - - response["LowLatencyInfo"]=rangeArray; - if ((info.pqmodeVector.front()).compare("none") != 0) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getCMS(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int level = 0; - tvPQParameterIndex_t tvPQEnum; - - inputInfo.color = parameters.HasLabel("color") ? parameters["color"].String() : ""; - inputInfo.component = parameters.HasLabel("component") ? parameters["component"].String() : ""; - - if( inputInfo.color.empty() || inputInfo.component.empty() ) { - LOGERR("%s : Color/Component param not found!!!\n",__FUNCTION__); - returnResponse(false); - } - - if (isPlatformSupport("CMS") != 0) { - returnResponse(false); - } - - - if (parsingGetInputArgument(parameters, "CMS", inputInfo) != 0) { - LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - - if (getParamIndex("CMS",inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - if ( convertCMSParamToPQEnum(inputInfo.component,inputInfo.color,tvPQEnum) != 0 ) { - LOGINFO("%s: Component/Color Param Not Found \n",__FUNCTION__); - returnResponse(false); - } - - int err = getLocalparam("CMS",indexInfo,level,tvPQEnum); - if( err == 0 ) { - response["level"] = level; - LOGINFO("Exit : params Value: %d \n", level); - returnResponse(true); - } - else { - returnResponse(false); - } - } - - uint32_t AVOutputTV::setCMS(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - int level = 0,retVal = 0; - tvPQParameterIndex_t tvPQEnum; - tvDataComponentColor_t colorEnum=tvDataColor_NONE; - std::string color,component; - tvError_t ret = tvERROR_NONE; - std::string value; - - inputInfo.color = parameters.HasLabel("color") ? parameters["color"].String() : ""; - inputInfo.component = parameters.HasLabel("component") ? parameters["component"].String() : ""; - - if( inputInfo.color.empty() || inputInfo.component.empty() ) { - LOGERR("%s : Color/Component param not found!!!\n",__FUNCTION__); - returnResponse(false); - } - - if (isPlatformSupport("CMS") != 0) { - returnResponse(false); - } - - value = parameters.HasLabel("level") ? parameters["level"].String() : ""; - returnIfParamNotFound(parameters,"level"); - level = std::stoi(value); - - if (validateCMSParameter(inputInfo.component,level) != 0) { - LOGERR("%s: CMS Failed in range validation", __FUNCTION__); - returnResponse(false); - } - - if (parsingSetInputArgument(parameters,"CMS",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "CMS",inputInfo )) { - LOGERR("%s: CapablityCheck failed for CMS\n", __FUNCTION__); - returnResponse(false); - } - - if ( convertCMSParamToPQEnum(inputInfo.component,inputInfo.color,tvPQEnum) != 0 ) { - LOGERR("%s: %s/%s Param Not Found \n",__FUNCTION__,inputInfo.component.c_str(),inputInfo.color.c_str()); - returnResponse(false); - } - - retVal = getCMSColorEnumFromString(inputInfo.color,colorEnum); - if( retVal == -1) { - LOGERR("%s: Invalid Color : %s\n",__FUNCTION__,inputInfo.color.c_str()); - returnResponse(false); - } - - if( isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with %s\n",__FUNCTION__); - tvError_t ret = SetCMSState(true); - if(ret != tvERROR_NONE) { - LOGWARN("CMS enable failed\n"); - returnResponse(false); - } - - if(inputInfo.component.compare("Saturation") == 0) - ret = SetCurrentComponentSaturation(colorEnum, level); - else if(inputInfo.component.compare("Hue") == 0 ) - ret = SetCurrentComponentHue(colorEnum,level); - else if( inputInfo.component.compare("Luma") == 0 ) - ret = SetCurrentComponentLuma(colorEnum,level); - - } - - if(ret != tvERROR_NONE) { - LOGERR("Failed to set CMS\n"); - returnResponse(false); - } - else { - std::string cmsParam; - cmsParam = inputInfo.color+"."+inputInfo.component; - - retVal= updateAVoutputTVParam("set","CMS",inputInfo,tvPQEnum,level); - if(retVal != 0 ) { - LOGERR("%s : Failed to Save CMS %s/%s(%s) to ssm_data\n",__FUNCTION__,inputInfo.component.c_str(),inputInfo.color.c_str(),cmsParam.c_str()); - returnResponse(false); - } - LOGINFO("Exit : setCMS %s/%s successful to value: %d\n", inputInfo.component.c_str(),inputInfo.color.c_str(),level); - returnResponse(true); - } - } - - uint32_t AVOutputTV::resetCMS(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - int retVal = 0; - std::string color,component; - tvError_t ret = tvERROR_NONE; - JsonArray sourceArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray colorArray; - JsonArray componentArray; - - if (isPlatformSupport("CMS") != 0) { - returnResponse(false); - } - - pqmodeArray = parameters.HasLabel("pictureMode") ? parameters["pictureMode"].Array() : JsonArray(); - for (int i = 0; i < pqmodeArray.Length(); ++i) { - inputInfo.pqmode += pqmodeArray[i].String(); - if (i != (pqmodeArray.Length() - 1) ) { - inputInfo.pqmode += ","; - } - } - - sourceArray = parameters.HasLabel("videoSource") ? parameters["videoSource"].Array() : JsonArray(); - for (int i = 0; i < sourceArray.Length(); ++i) { - inputInfo.source += sourceArray[i].String(); - if (i != (sourceArray.Length() - 1) ) { - inputInfo.source += ","; - } - } - - formatArray = parameters.HasLabel("videoFormat") ? parameters["videoFormat"].Array() : JsonArray(); - for (int i = 0; i < formatArray.Length(); ++i) { - inputInfo.format += formatArray[i].String(); - if (i != (formatArray.Length() - 1) ) { - inputInfo.format += ","; - } - } - colorArray = parameters.HasLabel("color") ? parameters["color"].Array() : JsonArray(); - for (int i = 0; i < colorArray.Length(); ++i) { - inputInfo.color += colorArray[i].String(); - if (i != (colorArray.Length() - 1) ) { - inputInfo.color += ","; - } - } - componentArray = parameters.HasLabel("component") ? parameters["component"].Array() : JsonArray(); - for (int i = 0; i < componentArray.Length(); ++i) { - inputInfo.component += componentArray[i].String(); - if (i != (componentArray.Length() - 1) ) { - inputInfo.component += ","; - } - } - if (inputInfo.source.empty()) { - inputInfo.source = "Global"; - } - if (inputInfo.pqmode.empty()) { - inputInfo.pqmode = "Global"; - } - if (inputInfo.format.empty()) { - inputInfo.format = "Global"; - } - if (inputInfo.color.empty()) { - inputInfo.color = "Global"; - } - if (inputInfo.component.empty()) { - inputInfo.component = "Global"; - } - - if (convertToValidInputParameter("CMS", inputInfo) != 0) { - LOGERR("%s: Failed to convert the input paramters. \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "CMS" , inputInfo )) { - LOGERR("%s: CapablityCheck failed for CMS\n", __FUNCTION__); - returnResponse(false); - } - - if( isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with %s\n",__FUNCTION__); - tvError_t ret = SetCMSState(false); - if(ret != tvERROR_NONE) { - LOGWARN("CMS disable failed\n"); - returnResponse(false); - } - } - - if(ret != tvERROR_NONE) { - LOGERR("%s : Failed to setCMSState\n",__FUNCTION__); - returnResponse(false); - } - else { - int cms = 0; - retVal= updateAVoutputTVParam("reset","CMS",inputInfo,PQ_PARAM_CMS_SATURATION_RED,cms); - if(retVal != 0 ) { - LOGERR("%s : Failed to Save CMS %s/%s to ssm_data\n",__FUNCTION__,inputInfo.component.c_str(),inputInfo.color.c_str() ); - returnResponse(false); - } - returnResponse(true); - } - } - - uint32_t AVOutputTV::getCMSCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t info; - - JsonArray rangeArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - JsonArray colorArray; - JsonArray componentArray; - - JsonObject componentSaturationRangeInfo; - JsonObject componentHueRangeInfo; - JsonObject componentLumaRangeInfo; - unsigned int index = 0; - - tvError_t ret = getParamsCaps("CMS",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - - response["platformSupport"] = (info.isPlatformSupportVector[0].compare("true") == 0) ? true : false; - - componentSaturationRangeInfo["from"] = stoi(info.rangeVector[0]); - componentSaturationRangeInfo["to"] = stoi(info.rangeVector[1]); - response["componentSaturationRangeInfo"]=componentSaturationRangeInfo; - - componentHueRangeInfo["from"] = stoi(info.rangeVector[2]); - componentHueRangeInfo["to"] = stoi(info.rangeVector[3]); - response["componentHueRangeInfo"]=componentHueRangeInfo; - - componentLumaRangeInfo["from"] = stoi(info.rangeVector[4]); - componentLumaRangeInfo["to"] = stoi(info.rangeVector[5]); - response["componentLumaRangeInfo"]=componentLumaRangeInfo; - - - if ((info.pqmodeVector.front()).compare("none") != 0) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - - if ((info.colorVector.front()).compare("none") != 0) { - for (index = 0; index < info.colorVector.size(); index++) { - colorArray.Add(info.colorVector[index]); - } - response["colorInfo"]=colorArray; - } - - if ((info.componentVector.front()).compare("none") != 0) { - for (index = 0; index < info.componentVector.size(); index++) { - componentArray.Add(info.componentVector[index]); - } - response["componentInfo"]=componentArray; - } - - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getHDRMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capDetails_t inputInfo; - int dolbyMode = 0; - int err = 0; - paramIndex_t indexInfo; - - if (parsingGetInputArgument(parameters, "HDRMode", inputInfo) != 0) { - LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - - if (isPlatformSupport("HDRMode") != 0) { - returnResponse(false); - } - - if (getParamIndex("HDRMode",inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - err = getLocalparam("HDRMode", indexInfo,dolbyMode, PQ_PARAM_DOLBY_MODE); - if( err == 0 ) { - response["hdrMode"] = getDolbyModeStringFromEnum((tvDolbyMode_t)dolbyMode); - LOGINFO("Exit : hdrMode Value: %d \n", dolbyMode); - returnResponse(true); - } - else { - returnResponse(false); - } - - } - - uint32_t AVOutputTV::setHDRMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - tvDolbyMode_t index; - capDetails_t inputInfo; - tvError_t ret = tvERROR_NONE; - std::string value; - int retval = 0; - - value = parameters.HasLabel("HDRMode") ? parameters["HDRMode"].String() : ""; - returnIfParamNotFound(parameters,"HDRMode"); - - if (parsingSetInputArgument(parameters, "HDRMode", inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if (isPlatformSupport("HDRMode") != 0) { - returnResponse(false); - } - - if (validateInputParameter("HDRMode",value) != 0) { - LOGERR("%s: Range validation failed for hdrMode\n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "HDRMode", inputInfo )) { - LOGERR("%s: CapablityCheck failed for hdrMode\n", __FUNCTION__); - returnResponse(false); - } - - if( isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format) ) { - LOGINFO("Proceed with HDRMode\n\n"); - retval = getHDRModeIndex(value,inputInfo.format,index); - if( retval != 0 ) - { - LOGERR("Failed to getHDRMode index\n"); - returnResponse(false); - } - ret = SetTVDolbyVisionMode(index); - } - - if(ret != tvERROR_NONE) { - LOGERR("Failed to set HDRMode\n\n"); - returnResponse(false); - } - else { - retval= updateAVoutputTVParam("set","HDRMode",inputInfo,PQ_PARAM_DOLBY_MODE,(int)index); - if(retval != 0 ) { - LOGERR("Failed to Save hdrMode mode\n"); - returnResponse(false); - } - LOGINFO("Exit : hdrMode successful to value: %s\n", value.c_str()); - returnResponse(true); - } - - } - - uint32_t AVOutputTV::resetHDRMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int dolbyMode=0; - tvError_t ret = tvERROR_NONE; - - if (parsingSetInputArgument(parameters, "HDRMode", inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if (isPlatformSupport("HDRMode") != 0) { - returnResponse(false); - } - - if( !isCapablityCheckPassed( "HDRMode" , inputInfo )) { - LOGERR("%s: CapablityCheck failed for HDRMode\n", __FUNCTION__); - returnResponse(false); - } - - int retval= updateAVoutputTVParam("reset","HDRMode",inputInfo,PQ_PARAM_DOLBY_MODE,dolbyMode); - if(retval != 0 ) { - LOGERR("Failed to reset HDRMode\n"); - returnResponse(false); - } - else { - if (isSetRequired( inputInfo.pqmode,inputInfo.source,inputInfo.format)) { - getParamIndex( "HDRMode", inputInfo,indexInfo); - int err = getLocalparam("HDRMode", indexInfo, dolbyMode, PQ_PARAM_DOLBY_MODE); - if( err == 0 ) { - LOGINFO("%s : getLocalparam success format :%d source : %d format : %d dolbyvalue : %d\n",__FUNCTION__,indexInfo.formatIndex, indexInfo.sourceIndex, indexInfo.pqmodeIndex, dolbyMode); - ret = SetTVDolbyVisionMode((tvDolbyMode_t)dolbyMode); - } - else { - LOGERR("%s : GetLocalParam Failed \n",__FUNCTION__); - ret = tvERROR_GENERAL; - } - } - } - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - LOGINFO("Exit : resetHDRMode Successful to value : %d \n",dolbyMode); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getHDRModeCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t info; - - JsonArray rangeArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - - unsigned int index = 0; - - tvError_t ret = getParamsCaps("HDRMode", info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - - response["platformSupport"] = (info.isPlatformSupportVector[0].compare("true") == 0 ) ? true : false; - - for (index = 0; index < info.rangeVector.size(); index++) { - rangeArray.Add(info.rangeVector[index]); - } - - response["options"]=rangeArray; - if ((info.pqmodeVector.front()).compare("none") != 0) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::get2PointWB(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - - capDetails_t inputInfo; - paramIndex_t indexInfo; - int level = 0; - tvPQParameterIndex_t tvPQEnum; - - inputInfo.color = parameters.HasLabel("color") ? parameters["color"].String() : ""; - inputInfo.control = parameters.HasLabel("control") ? parameters["control"].String() : ""; - - if( inputInfo.color.empty() || inputInfo.control.empty() ) { - LOGERR("%s : Color/Control param not found!!!\n",__FUNCTION__); - returnResponse(false); - } - - if (isPlatformSupport("WhiteBalance") != 0) { - returnResponse(false); - } - - if (parsingGetInputArgument(parameters, "WhiteBalance", inputInfo) != 0) { - LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); - returnResponse(false); - } - - if (getParamIndex("WhiteBalance", inputInfo,indexInfo) == -1) { - LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); - returnResponse(false); - } - - if ( convertWBParamToPQEnum(inputInfo.control,inputInfo.color,tvPQEnum) != 0 ) { - LOGINFO("%s: Control/Color Param Not Found \n",__FUNCTION__); - returnResponse(false); - } - - int err = getLocalparam("WhiteBalance",indexInfo,level, tvPQEnum); - if( err == 0 ) { - response["level"] = level; - LOGINFO("Exit : params Value: %d \n", level); - returnResponse(true); - } - else { - returnResponse(false); - } - } - - uint32_t AVOutputTV::set2PointWB(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - int level = 0; - tvPQParameterIndex_t tvPQEnum; - int retVal = 0; - std::string color,control,value; - tvError_t ret = tvERROR_NONE; - - inputInfo.color = parameters.HasLabel("color") ? parameters["color"].String() : ""; - inputInfo.control = parameters.HasLabel("control") ? parameters["control"].String() : ""; - - if (isPlatformSupport("WhiteBalance") != 0) { - returnResponse(false); - } - - if( inputInfo.color.empty() || inputInfo.control.empty() ) { - LOGERR("%s : Color/Control param not found!!!\n",__FUNCTION__); - returnResponse(false); - } - - value = parameters.HasLabel("level") ? parameters["level"].String() : ""; - returnIfParamNotFound(parameters,"level"); - level = std::stoi(value); - - if (validateWBParameter("WhiteBalance",inputInfo.control,level) != 0) { - LOGERR("%s: CMS Failed in range validation", __FUNCTION__); - returnResponse(false); - } - - if (parsingSetInputArgument(parameters,"WhiteBalance",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "WhiteBalance",inputInfo )) { - LOGERR("%s: CapablityCheck failed for WhiteBalance\n", __FUNCTION__); - returnResponse(false); - } - - if ( convertWBParamToPQEnum(inputInfo.control,inputInfo.color,tvPQEnum) != 0 ) { - LOGERR("%s: %s/%s Param Not Found \n",__FUNCTION__,inputInfo.component.c_str(),inputInfo.color.c_str()); - returnResponse(false); - } - - if( (isSetRequired(inputInfo.pqmode,inputInfo.source,inputInfo.format))) { - LOGINFO("Proceed with %s\n",__FUNCTION__); - - tvVideoSrcType_t currentSource = VIDEO_SOURCE_IP; - tvError_t ret = GetCurrentVideoSource(¤tSource); - - if(ret != tvERROR_NONE) { - LOGWARN("%s: GetCurrentVideoSource( ) Failed \n",__FUNCTION__); - return -1; - } - - tvWBColor_t colorLevel; - if ( getWBColorEnumFromString(inputInfo.color,colorLevel ) == -1 ) { - LOGERR("%s : GetColorEnumFromString Failed!!! ",__FUNCTION__); - return -1; - } - - tvWBControl_t controlLevel; - if ( getWBControlEnumFromString(inputInfo.control,controlLevel ) == -1 ) { - LOGERR("%s : GetComponentEnumFromString Failed!!! ",__FUNCTION__); - return -1; - } - - ret = SetCustom2PointWhiteBalance(colorLevel,controlLevel,level); - } - - if(ret != tvERROR_NONE) { - LOGERR("%s: Failed to set WhiteBalance\n",__FUNCTION__); - returnResponse(false); - } - else { - retVal= updateAVoutputTVParam("set","WhiteBalance",inputInfo,tvPQEnum,level); - if(retVal != 0 ) { - LOGERR("%s : Failed to Save WB %s/%s : %d to ssm_data\n",__FUNCTION__,inputInfo.control.c_str(),inputInfo.color.c_str(),level); - returnResponse(false); - } - LOGINFO("Exit : set2PointWB %s/%s successful to value: %d\n", inputInfo.control.c_str(),inputInfo.color.c_str(),level); - returnResponse(true); - } - } - - uint32_t AVOutputTV::reset2PointWB(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - capDetails_t inputInfo; - tvPQParameterIndex_t tvPQEnum; - int retVal = 0; - int level = 0; - std::string color,control; - inputInfo.color = parameters.HasLabel("color") ? parameters["color"].String() : ""; - inputInfo.control = parameters.HasLabel("control") ? parameters["control"].String() : ""; - - if (isPlatformSupport("WhiteBalance") != 0) { - returnResponse(false); - } - - if (parsingSetInputArgument(parameters,"WhiteBalance",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "WhiteBalance",inputInfo )) { - LOGERR("%s: CapablityCheck failed for WhiteBalance\n", __FUNCTION__); - returnResponse(false); - } - - for( int colorIndex= tvWB_COLOR_RED; colorIndex < tvWB_COLOR_MAX; colorIndex++) { - for(int controlIndex = tvWB_CONTROL_GAIN;controlIndex < tvWB_CONTROL_MAX;controlIndex++) { - inputInfo.control = getWBControlStringFromEnum((tvWBControl_t)controlIndex); - inputInfo.color = getWBColorStringFromEnum((tvWBColor_t)colorIndex); - if ( convertWBParamToPQEnum(inputInfo.control,inputInfo.color,tvPQEnum) != 0 ) { - LOGERR("%s: %s/%s Param Not Found \n",__FUNCTION__,inputInfo.control.c_str(),inputInfo.color.c_str()); - returnResponse(false); - } - - retVal |= updateAVoutputTVParam("reset","WhiteBalance",inputInfo,tvPQEnum,level); - } - } - - if( retVal != 0 ) { - LOGWARN("Failed to reset WhiteBalance\n"); - returnResponse(false); - } - else { - LOGINFO("Exit : reset2PointWB successful \n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::get2PointWBCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - capVectors_t info; - - JsonArray rangeArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - JsonArray colorArray; - JsonArray controlArray; - - JsonObject gainInfo; - JsonObject offsetInfo; - - unsigned int index = 0; - - tvError_t ret = getParamsCaps("WhiteBalance",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - response["platformSupport"] = (info.isPlatformSupportVector[0].compare("true") == 0) ? true : false; - - gainInfo["from"] = stoi(info.rangeVector[0]); - gainInfo["to"] = stoi(info.rangeVector[1]); - response["gainInfo"]=gainInfo; - - offsetInfo["from"] = stoi(info.rangeVector[0]); - offsetInfo["to"] = stoi(info.rangeVector[1]); - response["offsetInfo"]=offsetInfo; - - - - if ((info.pqmodeVector.front()).compare("none") != 0) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - - if ((info.colorVector.front()).compare("none") != 0) { - for (index = 0; index < info.colorVector.size(); index++) { - colorArray.Add(info.colorVector[index]); - } - response["colorInfo"]=colorArray; - } - - if ((info.controlVector.front()).compare("none") != 0) { - for (index = 0; index < info.controlVector.size(); index++) { - controlArray.Add(info.controlVector[index]); - } - response["controlInfo"]=controlArray; - } - - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getAutoBacklightModeCaps(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry"); - capVectors_t info; - - JsonArray rangeArray; - JsonArray pqmodeArray; - JsonArray formatArray; - JsonArray sourceArray; - - unsigned int index = 0; - - tvError_t ret = getParamsCaps("AutoBacklightMode",info); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - - response["platformSupport"] = (info.isPlatformSupportVector[0].compare("true") == 0 ) ? true : false; - - for (index = 0; index < info.rangeVector.size(); index++) { - rangeArray.Add(info.rangeVector[index]); - } - - response["options"]=rangeArray; - - if (info.pqmodeVector.front().compare("none") != 0) { - for (index = 0; index < info.pqmodeVector.size(); index++) { - pqmodeArray.Add(info.pqmodeVector[index]); - } - response["pictureModeInfo"]=pqmodeArray; - } - if ((info.sourceVector.front()).compare("none") != 0) { - for (index = 0; index < info.sourceVector.size(); index++) { - sourceArray.Add(info.sourceVector[index]); - } - response["videoSourceInfo"]=sourceArray; - } - if ((info.formatVector.front()).compare("none") != 0) { - for (index = 0; index < info.formatVector.size(); index++) { - formatArray.Add(info.formatVector[index]); - } - response["videoFormatInfo"]=formatArray; - } - LOGINFO("Exit\n"); - returnResponse(true); - } - } - - uint32_t AVOutputTV::setAutoBacklightMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - std::string value; - tvBacklightMode_t mode = tvBacklightMode_AMBIENT; - capDetails_t inputInfo; - - - value = parameters.HasLabel("mode") ? parameters["mode"].String() : ""; - returnIfParamNotFound(parameters,"mode"); - - if (validateInputParameter("AutoBacklightMode",value) != 0) { - LOGERR("%s: Range validation failed for AutoBacklightMode\n", __FUNCTION__); - returnResponse(false); - } - - if (isPlatformSupport("AutoBacklightMode") != 0) { - returnResponse(false); - } - - if (parsingSetInputArgument(parameters,"AutoBacklightMode",inputInfo) != 0) { - LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__); - returnResponse(false); - } - - if( !isCapablityCheckPassed( "AutoBacklightMode",inputInfo )) { - LOGERR("%s: CapablityCheck failed for AutoBacklightMode\n", __FUNCTION__); - returnResponse(false); - } - - if(!value.compare("Manual")) { - mode = tvBacklightMode_MANUAL; - } - else if (!value.compare("Ambient")) { - mode = tvBacklightMode_AMBIENT; - } - else { - returnResponse(false); - } - - tvError_t ret = SetCurrentBacklightMode (mode); - - if(ret != tvERROR_NONE) { - returnResponse(false); - } - else { - //Save AutoBacklightMode to localstore - - tr181ErrorCode_t err = setLocalParam(rfc_caller_id, AVOUTPUT_AUTO_BACKLIGHT_MODE_RFC_PARAM, value.c_str()); - if ( err != tr181Success ) { - LOGERR("setLocalParam for %s Failed : %s\n", AVOUTPUT_AUTO_BACKLIGHT_MODE_RFC_PARAM, getTR181ErrorString(err)); - returnResponse(false); - } - else { - LOGINFO("setLocalParam for %s Successful, Value: %s\n", AVOUTPUT_AUTO_BACKLIGHT_MODE_RFC_PARAM, value.c_str()); - } - LOGINFO("Exit : SetAutoBacklightMode() value : %s\n",value.c_str()); - returnResponse(true); - } - } - - uint32_t AVOutputTV::getAutoBacklightMode(const JsonObject& parameters, JsonObject& response) - { - - TR181_ParamData_t param; - - if (isPlatformSupport("AutoBacklightMode") != 0) { - returnResponse(false); - } - - tr181ErrorCode_t err = getLocalParam(rfc_caller_id, AVOUTPUT_AUTO_BACKLIGHT_MODE_RFC_PARAM, ¶m); - if (err!= tr181Success) { - returnResponse(false); - } - else { - std::string s; - s+=param.value; - response["mode"] = s; - LOGINFO("Exit getAutoBacklightMode(): %s\n",s.c_str()); - returnResponse(true); - } - - } - - uint32_t AVOutputTV::resetAutoBacklightMode(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("Entry\n"); - - tvError_t ret = tvERROR_NONE; - - if (isPlatformSupport("AutoBacklightMode") != 0) { - returnResponse(false); - } - - tr181ErrorCode_t err = clearLocalParam(rfc_caller_id,AVOUTPUT_AUTO_BACKLIGHT_MODE_RFC_PARAM); - if ( err != tr181Success ) { - LOGWARN("clearLocalParam for %s Failed : %s\n", AVOUTPUT_AUTO_BACKLIGHT_MODE_RFC_PARAM, getTR181ErrorString(err)); - ret = tvERROR_GENERAL; - } - else { - LOGINFO("clearLocalParam for %s Successful\n", AVOUTPUT_AUTO_BACKLIGHT_MODE_RFC_PARAM); - - TR181_ParamData_t param; - memset(¶m, 0, sizeof(param)); - - tr181ErrorCode_t err = getLocalParam(rfc_caller_id, AVOUTPUT_AUTO_BACKLIGHT_MODE_RFC_PARAM,¶m); - if ( err != tr181Success ) { - LOGWARN("getLocalParam for %s Failed : %s\n", AVOUTPUT_AUTO_BACKLIGHT_MODE_RFC_PARAM, getTR181ErrorString(err)); - ret = tvERROR_GENERAL; - } - else { - tvBacklightMode_t blMode = tvBacklightMode_NONE; - - if(!std::string(param.value).compare("none")) { - blMode = tvBacklightMode_NONE; - } - else if (!std::string(param.value).compare("Manual")){ - blMode = tvBacklightMode_MANUAL; - } - else if (!std::string(param.value).compare("Ambient")){ - blMode = tvBacklightMode_AMBIENT; - } - else if (!std::string(param.value).compare("Eco")){ - blMode = tvBacklightMode_ECO; - } - else { - blMode = tvBacklightMode_NONE; - } - ret = SetCurrentBacklightMode(blMode); - if(ret != tvERROR_NONE) { - LOGWARN("Autobacklight Mode set failed: %s\n",getErrorString(ret).c_str()); - } - else { - LOGINFO("Exit : Autobacklight Mode set successfully, value: %s\n", param.value); - } - } - } - if(ret != tvERROR_NONE) - { - returnResponse(false); - } - else - { - returnResponse(true); - } - } - - uint32_t AVOutputTV::getVideoSource(const JsonObject& parameters,JsonObject& response) - { - LOGINFO("Entry\n"); - tvVideoSrcType_t currentSource = VIDEO_SOURCE_IP; - - tvError_t ret = GetCurrentVideoSource(¤tSource); - if(ret != tvERROR_NONE) { - response["currentVideoSource"] = "NONE"; - returnResponse(false); - } - else { - response["currentVideoSource"] = convertSourceIndexToString(currentSource); - LOGINFO("Exit: getVideoSource :%d success \n", currentSource); - returnResponse(true); - } - } - - - uint32_t AVOutputTV::getVideoContentType(const JsonObject & parameters, JsonObject & response) - { - JsonArray rangeArray; - - response["currentFilmMakerMode"] = filmMakerMode; - - if (getCapabilitySource(rangeArray) == 0) { - response["currentFilmMakerModeSources"] = rangeArray; - } - - returnResponse(true); - } - - void AVOutputTV::InitializeIARM() - { - AVOutputBase::InitializeIARM(); -#if !defined (HDMIIN_4K_ZOOM) - if (Utils::IARM::init()) { - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, dsHdmiStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, dsHdmiVideoModeEventHandler) ); - } -#endif - } - - void AVOutputTV::DeinitializeIARM() - { - AVOutputBase::DeinitializeIARM(); -#if !defined (HDMIIN_4K_ZOOM) - if (Utils::IARM::isConnected()) - { - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, dsHdmiStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, dsHdmiVideoModeEventHandler) ); - } -#endif - } - -}//namespace Plugin -}//namespace WPEFramework -//} diff --git a/AVOutput/AVOutputTV.h b/AVOutput/AVOutputTV.h deleted file mode 100644 index 5e493068d..000000000 --- a/AVOutput/AVOutputTV.h +++ /dev/null @@ -1,414 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2024 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. -*/ - -#ifndef AVOutputTV_H -#define AVOutputTV_H - -#include "string.h" -#include -#include -#include - -#include "tvTypes.h" -#include "tvSettings.h" -#include "tvSettingsExtODM.h" -#include -#include "Module.h" -#include "tvError.h" -#include "tr181api.h" -#include "AVOutputBase.h" -#include "libIARM.h" -#include "libIBusDaemon.h" -#include "libIBus.h" -#include "iarmUtil.h" -#include "UtilsLogging.h" -#include "UtilsJsonRpc.h" -#include "dsError.h" -#include "dsMgr.h" -#include "hdmiIn.hpp" -#include - -//Macro -#define RFC_BUFF_MAX 100 -#define BACKLIGHT_RAW_VALUE_MAX (255) -#define AVOUTPUT_RFC_CALLERID "AVOutput" -#define AVOUTPUT_RFC_CALLERID_OVERRIDE "../../opt/panel/AVOutput" -#define AVOUTPUT_OVERRIDE_PATH "/opt/panel/AVOutput.ini" -#define AVOUTPUT_CONVERTERBOARD_PANELID "0_0_00" -#define AVOUTPUT_GENERIC_STRING_RFC_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.AVOutput." -#define AVOUTPUT_AUTO_BACKLIGHT_MODE_RFC_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.AVOutput.AutoBacklightMode" -#define AVOUTPUT_DOLBYVISIONMODE_RFC_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.AVOutput.DolbyVisionMode" -#define AVOUTPUT_HLGMODE_RFC_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.AVOutput.HLGMode" -#define AVOUTPUT_HDR10MODE_RFC_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.AVOutput.HDR10Mode" -#define AVOUTPUT_DIMMING_MODE_RFC_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.AVOutput.DimmingMode" -#define AVOUTPUT_PICTUREMODE_RFC_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.AVOutput.PictureMode" -#define AVOUTPUT_PICTUREMODE_STRING_RFC_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.AVOutput.PictureModeString" -#define AVOUTPUT_ASPECTRATIO_RFC_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.AVOutput.ZoomMode" -#define AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.AVOutput.Source" -#define AVOUTPUT_DALS_RFC_PARAM "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AVOutput.DynamicAutoLatency" - -#define STRING_DIRTY ".Dirty." -#define STRING_PICMODE "PicMode." -#define STRING_FORMAT "Format." -#define STRING_DEFAULT "Default" -#define STRING_SOURCE "Source." -#define STRING_COMPONENT "Component." -#define STRING_COLOR "Color." -#define STRING_CONTROL "Control." -#define STRING_COLORTEMPERATURE "ColorTemperature." -#define CREATE_DIRTY(__X__) (__X__+=STRING_DIRTY) -#define CAPABLITY_FILE_NAME "pq_capabilities.ini" - - -class CIniFile -{ - std::string m_path; - std::string opt_path; - boost::property_tree::ptree m_data; - -public: - CIniFile(const std::string & filename, const std::string & filepath = "/etc/" ) - { - opt_path = "/opt/panel/"; - m_path = filepath; - m_path.append(filename); - opt_path.append(filename); - - if(!boost::filesystem::exists( opt_path)) { - std::cout << "AVOutput : Using " << m_path < - T Get(const std::string & key) - { - return m_data.get(key); - } - - template - void Set(const std::string & key, const T & value){ - //TODO DD: Not required currently - //m_data.put(key, value); - } -}; - -namespace WPEFramework { -namespace Plugin { - -typedef struct -{ - std::string range; - std::string pqmode; - std::string format; - std::string source; - std::string isPlatformSupport; - std::string index; - std::string color; - std::string component; - std::string colorTemperature; - std::string control; -}capDetails_t; - -typedef struct -{ - std::vector rangeVector; - std::vector pqmodeVector; - std::vector formatVector; - std::vector sourceVector; - std::vector isPlatformSupportVector; - std::vector indexVector; - std::vector colorVector; - std::vector componentVector; - std::vector colorTempVector; - std::vector controlVector; -}capVectors_t; - - -typedef struct -{ - std::vector rangeValues; - std::vector pqmodeValues; - std::vector formatValues; - std::vector sourceValues; - std::vector isPlatformSupportValues; - std::vector indexValues; - std::vector colorValues; - std::vector componentValues; - std::vector colorTempValues; - std::vector controlValues; -}valueVectors_t; - -typedef struct -{ - uint8_t sourceIndex; - uint8_t pqmodeIndex; - uint8_t formatIndex; - uint8_t colorIndex; - uint8_t componentIndex; - uint8_t colorTempIndex; - uint8_t controlIndex; -}paramIndex_t; - - -//class AVOutputTV : public PluginHost::IPlugin, public PluginHost::JSONRPC { -class AVOutputTV : public AVOutputBase { - private: - AVOutputTV(const AVOutputTV&) = delete; - AVOutputTV& operator=(const AVOutputTV&) = delete; - public: - /*Get API's*/ - DECLARE_JSON_RPC_METHOD(getBacklight) - DECLARE_JSON_RPC_METHOD(getBrightness ) - DECLARE_JSON_RPC_METHOD(getContrast ) - DECLARE_JSON_RPC_METHOD(getSharpness ) - DECLARE_JSON_RPC_METHOD(getSaturation ) - DECLARE_JSON_RPC_METHOD(getHue ) - DECLARE_JSON_RPC_METHOD(getColorTemperature ) - DECLARE_JSON_RPC_METHOD(getBacklightDimmingMode ) - DECLARE_JSON_RPC_METHOD(getSupportedDolbyVisionModes ) - DECLARE_JSON_RPC_METHOD(getDolbyVisionMode) - DECLARE_JSON_RPC_METHOD(getSupportedPictureModes ) - DECLARE_JSON_RPC_METHOD(getPictureMode ) - DECLARE_JSON_RPC_METHOD(getVideoFormat) - DECLARE_JSON_RPC_METHOD(getVideoSource) - DECLARE_JSON_RPC_METHOD(getVideoFrameRate) - DECLARE_JSON_RPC_METHOD(getVideoResolution) - DECLARE_JSON_RPC_METHOD(getLowLatencyState) - DECLARE_JSON_RPC_METHOD(getZoomMode) - DECLARE_JSON_RPC_METHOD(getVideoContentType) - DECLARE_JSON_RPC_METHOD(getCMS) - DECLARE_JSON_RPC_METHOD(getHDRMode) - DECLARE_JSON_RPC_METHOD(get2PointWB) - DECLARE_JSON_RPC_METHOD(getAutoBacklightMode) - - - /*Get Capability API's*/ - DECLARE_JSON_RPC_METHOD(getBacklightCaps) - DECLARE_JSON_RPC_METHOD(getBrightnessCaps) - DECLARE_JSON_RPC_METHOD(getContrastCaps) - DECLARE_JSON_RPC_METHOD(getSharpnessCaps) - DECLARE_JSON_RPC_METHOD(getSaturationCaps) - DECLARE_JSON_RPC_METHOD(getHueCaps) - DECLARE_JSON_RPC_METHOD(getColorTemperatureCaps) - DECLARE_JSON_RPC_METHOD(getBacklightDimmingModeCaps ) - DECLARE_JSON_RPC_METHOD(getDolbyVisionModeCaps ) - DECLARE_JSON_RPC_METHOD(getPictureModeCaps) - DECLARE_JSON_RPC_METHOD(getVideoFormatCaps) - DECLARE_JSON_RPC_METHOD(getVideoSourceCaps) - DECLARE_JSON_RPC_METHOD(getVideoFrameRateCaps) - DECLARE_JSON_RPC_METHOD(getVideoResolutionCaps) - DECLARE_JSON_RPC_METHOD(getLowLatencyStateCaps) - DECLARE_JSON_RPC_METHOD(getZoomModeCaps) - DECLARE_JSON_RPC_METHOD(getCMSCaps) - DECLARE_JSON_RPC_METHOD(get2PointWBCaps) - DECLARE_JSON_RPC_METHOD(getHDRModeCaps) - DECLARE_JSON_RPC_METHOD(getAutoBacklightModeCaps) - - /*Set API's*/ - DECLARE_JSON_RPC_METHOD(setBacklight) - DECLARE_JSON_RPC_METHOD(setBrightness) - DECLARE_JSON_RPC_METHOD(setContrast ) - DECLARE_JSON_RPC_METHOD(setSharpness ) - DECLARE_JSON_RPC_METHOD(setSaturation ) - DECLARE_JSON_RPC_METHOD(setHue ) - DECLARE_JSON_RPC_METHOD(setColorTemperature ) - DECLARE_JSON_RPC_METHOD(setBacklightDimmingMode ) - DECLARE_JSON_RPC_METHOD(setDolbyVisionMode ) - DECLARE_JSON_RPC_METHOD(setPictureMode ) - DECLARE_JSON_RPC_METHOD(setLowLatencyState) - DECLARE_JSON_RPC_METHOD(setZoomMode) - DECLARE_JSON_RPC_METHOD(setWBCtrl ) - DECLARE_JSON_RPC_METHOD(setHDRMode ) - DECLARE_JSON_RPC_METHOD(setCMS ) - DECLARE_JSON_RPC_METHOD(set2PointWB ) - DECLARE_JSON_RPC_METHOD(signalFilmMakerMode) - DECLARE_JSON_RPC_METHOD(setAutoBacklightMode) - - /*Reset API's*/ - DECLARE_JSON_RPC_METHOD(resetBacklight) - DECLARE_JSON_RPC_METHOD(resetBrightness ) - DECLARE_JSON_RPC_METHOD(resetContrast ) - DECLARE_JSON_RPC_METHOD(resetSharpness ) - DECLARE_JSON_RPC_METHOD(resetSaturation ) - DECLARE_JSON_RPC_METHOD(resetHue ) - DECLARE_JSON_RPC_METHOD(resetColorTemperature ) - DECLARE_JSON_RPC_METHOD(resetBacklightDimmingMode ) - DECLARE_JSON_RPC_METHOD(resetDolbyVisionMode ) - DECLARE_JSON_RPC_METHOD(resetPictureMode ) - DECLARE_JSON_RPC_METHOD(resetLowLatencyState) - DECLARE_JSON_RPC_METHOD(resetZoomMode) - DECLARE_JSON_RPC_METHOD(resetHDRMode) - DECLARE_JSON_RPC_METHOD(resetCMS) - DECLARE_JSON_RPC_METHOD(reset2PointWB) - DECLARE_JSON_RPC_METHOD(resetAutoBacklightMode) - - private: - - - tvContentFormatType_t getContentFormatIndex(tvVideoHDRFormat_t formatToConvert); - int getPictureModeIndex(std::string pqmode); - int getSourceIndex(std::string source); - int getFormatIndex(std::string format); - int getPqParamIndex(); - int getParamIndex(std::string param, capDetails_t& paramInfo, paramIndex_t& indexInfo); - int getDolbyModeIndex(const char * dolbyMode); - int getHDRModeIndex(const std::string HDRMode, const std::string format,tvDolbyMode_t &value); - tvDimmingMode_t getDimmingModeIndex(string mode); - - bool isIncluded(const std::set set1,const std::set set2); - bool isSetRequired(std::string pqmode,std::string source,std::string format); - int isPlatformSupport(std::string pqparam); - - - bool isCapablityCheckPassed( std::string param, capDetails_t inputInfo ); - int parsingSetInputArgument(const JsonObject& parameters, std::string pqparam,capDetails_t& paramInfo); - int parsingGetInputArgument(const JsonObject& parameters, std::string pqparam, capDetails_t& info); - void spliltCapablities( capVectors_t& vectorInfo, capDetails_t stringInfo); - void spliltStringsAndConvertToSet( std::string pqmodeInfo,std::string formatInfo,std::string sourceInfo,std::set &pqmode, std::set &format, std::set &source); - int validateIntegerInputParameter(std::string param, int inputValue); - int fetchCapablities(string pqparam, capDetails_t& info); - int validateInputParameter(std::string param, std::string inputValue); - int validateWBParameter(std::string param,std::string control,int inputValue); - int validateCMSParameter(std::string component,int inputValue); - - /* AVoutput ini file default entries */ - void locatePQSettingsFile(void); - /* Intialise the last set picture mode at bootup */ - tvError_t initializePictureMode(); - - - std::string convertToString(std::vector vec_strings); - void convertParamToLowerCase(std::string &source, std::string &pqmode, std::string &format); - int convertToValidInputParameter(std::string pqparam, capDetails_t& info); - string convertSourceIndexToString(int source); - string convertVideoFormatToString(int format); - string convertPictureIndexToString(int pqmode); - tvContentFormatType_t convertFormatStringToTVContentFormat(const char *format); - //std::string convertSourceIndexToString(int sourceIndex); - //std::string convertVideoFormatToString( int formatIndex ); - void convertUserScaleBacklightToDriverScale(int format,int * params); - - /* Update TR181 with new values when app calls set/reset calls */ - tvError_t updateAVoutputTVParamToHAL(std::string forParam, paramIndex_t indexInfo, int value,bool setNotDelete); - /* updatePQParamsToCache will call updatePQParamToLocalCache for writing to TR181. - * it will call TVSettings HAL for setting/saving the value - * Will be called whenever the application invokes set/reset call - */ - int updateAVoutputTVParam( std::string action, std::string tr181ParamName, capDetails_t info, tvPQParameterIndex_t pqParamIndex, int level ); - - /* Every bootup this function is called to sync TR181 to TVSettings HAL for saving the value */ - tvError_t syncAvoutputTVParamsToHAL(std::string pqmode, std::string source, std::string format); - /* Every Bootup this function is called to sync TR181 to TVSettings HAL for saving the picture mode assiocation to source */ - int syncAvoutputTVPQModeParamsToHAL(std::string pqmode, std::string source, std::string format); - void syncCMSParams( ); - void syncWBParams( ); - - uint32_t generateStorageIdentifier(std::string &key, std::string forParam,paramIndex_t info); - uint32_t generateStorageIdentifierCMS(std::string &key, std::string forParam, paramIndex_t info); - uint32_t generateStorageIdentifierWB(std::string &key, std::string forParam, paramIndex_t info); - uint32_t generateStorageIdentifierDirty(std::string &key, std::string forParam,uint32_t contentFormat, int pqmode); - - std::string getErrorString (tvError_t eReturn); - - /* Get function to query TR181 entries or pq capability.ini file*/ - int getSaveConfig(std::string param, capDetails_t capInfo, valueVectors_t &values); - int getLocalparam( std::string forParam,paramIndex_t indexInfo,int & value,tvPQParameterIndex_t pqParamIndex,bool sync=false); - - tvDataComponentColor_t getComponentColorEnum(std::string colorName); - int getDolbyParams(tvContentFormatType_t format, std::string &s, std::string source = ""); - tvError_t getParamsCaps(std::string param, capVectors_t &vecInfo); - int GetPanelID(char *panelid); - int ConvertHDRFormatToContentFormat(tvhdr_type_t hdrFormat); - int ReadCapablitiesFromConf(std::string param, capDetails_t& info); - void getDimmingModeStringFromEnum(int value, std::string &toStore); - void getColorTempStringFromEnum(int value, std::string &toStore); - int getCurrentPictureMode(char *picMode); - int getDolbyParamToSync(int sourceIndex, int formatIndex, int& value); - tvDolbyMode_t GetDolbyVisionEnumFromModeString(const char* modeString); - std::string getDolbyModeStringFromEnum( tvDolbyMode_t mode); - JsonArray getSupportedVideoSource(void); - int getAvailableCapabilityModesWrapper(std::string param, std::string & outparam); - int getAvailableCapabilityModes( capDetails_t& info ); - int getCapabilitySource(JsonArray &rangeArray); - int getRangeCapability(std::string param, std::vector & rangeInfo); - void getDynamicAutoLatencyConfig(); - tvError_t getUserSelectedAspectRatio (tvDisplayMode_t* mode); - std::string getColorTemperatureStringFromEnum(tvColorTemp_t value); - std::string getCMSColorStringFromEnum(tvDataComponentColor_t value); - std::string getCMSComponentStringFromEnum(tvComponentType_t value); - std::string getWBControlStringFromEnum(tvWBControl_t value); - int getCMSColorEnumFromString(std::string color,tvDataComponentColor_t &value); - int getCMSComponentEnumFromString(std::string component, tvComponentType_t& value); - std::string getWBColorStringFromEnum(tvWBColor_t value); - int getWBColorEnumFromString(std::string color,tvWBColor_t& value); - int getWBControlEnumFromString(std::string color,tvWBControl_t& value); - int getColorTempEnumFromString(std::string color, tvColorTemp_t& value); - - bool checkCMSColorAndComponentCapability(const std::string capValue, const std::string inputValue); - int convertCMSParamToPQEnum(const std::string component, const std::string color,tvPQParameterIndex_t& value); - int convertWBParamToPQEnum(const std::string control, const std::string color,tvPQParameterIndex_t& value); - int convertWBParamToRGBEnum(const std::string color,const std::string control,tvRGBType_t &value); - - void broadcastLowLatencyModeChangeEvent(bool lowLatencyMode); - tvError_t setAspectRatioZoomSettings(tvDisplayMode_t mode); - tvError_t setDefaultAspectRatio(std::string pqmode="none",std::string format="none",std::string source="none"); - - public: - int m_currentHdmiInResoluton; - int m_videoZoomMode; - bool m_isDisabledHdmiIn4KZoom; - char rfc_caller_id[RFC_BUFF_MAX]; - bool appUsesGlobalBackLightFactor; - int pic_mode_index[PIC_MODES_SUPPORTED_MAX]; - - AVOutputTV(); - ~AVOutputTV(); - - static AVOutputTV *instance; - static AVOutputTV* getInstance() { return instance; } - - void NotifyVideoFormatChange(tvVideoFormatType_t format); - void NotifyFilmMakerModeChange(tvContentType_t mode); - void NotifyVideoResolutionChange(tvResolutionParam_t resolution); - void NotifyVideoFrameRateChange(tvVideoFrameRate_t frameRate); - - //override API - static void dsHdmiVideoModeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - static void dsHdmiStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - static void dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void Initialize(); - void Deinitialize(); - void InitializeIARM(); - void DeinitializeIARM(); -}; - - -}//namespace Plugin -}//namespace WPEFramework -#endif diff --git a/AVOutput/AVOutputTVHelper.cpp b/AVOutput/AVOutputTVHelper.cpp deleted file mode 100644 index 7e3b28c56..000000000 --- a/AVOutput/AVOutputTVHelper.cpp +++ /dev/null @@ -1,2468 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2024 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 -#include "AVOutputTV.h" -#include "UtilsIarm.h" -#include "rfcapi.h" - -#define CAPABLITY_FILE_NAME "pq_capabilities.ini" - -static std::map supportedSourcemap; -static std::map supportedPictureModemap; -static std::map supportedFormatmap; -static bool m_isDalsEnabled = false; - -namespace WPEFramework { -namespace Plugin { - - tvContentFormatType_t AVOutputTV::getContentFormatIndex(tvVideoHDRFormat_t formatToConvert) - { - /* default to SDR always*/ - tvContentFormatType_t ret = tvContentFormatType_NONE; - switch(formatToConvert) { - case tvVideoHDRFormat_HLG: - ret = tvContentFormatType_HLG; - break; - - case tvVideoHDRFormat_HDR10: - ret = tvContentFormatType_HDR10; - break; - - case tvVideoHDRFormat_HDR10PLUS: - ret = tvContentFormatType_HDR10PLUS; - break; - - case tvVideoHDRFormat_DV: - ret = tvContentFormatType_DOVI; - break; - - case tvVideoHDRFormat_SDR: - case tvVideoHDRFormat_NONE: - default: - ret = tvContentFormatType_SDR; - break; - } - return ret; - } - - int AVOutputTV::getPictureModeIndex(std::string pqparam) - { - int index = -1; - std::map :: iterator it; - - for(it = supportedPictureModemap.begin(); it != supportedPictureModemap.end(); it++) { - if (it->first == pqparam) { - index = it->second; - break; - } - } - return index; - } - - int AVOutputTV::getSourceIndex(std::string pqparam) - { - int index = -1; - std::map :: iterator it; - - for(it = supportedSourcemap.begin(); it != supportedSourcemap.end(); it++) { - if (it->first == pqparam) { - index = it->second; - break; - } - } - return index; - } - - int AVOutputTV::getFormatIndex(std::string pqparam) - { - int index = -1; - std::map :: iterator it; - - for(it = supportedFormatmap.begin(); it != supportedFormatmap.end(); it++) { - if (it->first == pqparam) { - index = it->second; - break; - } - } - return index; - } - - int AVOutputTV::getPqParamIndex() - { - - capVectors_t info; - - tvError_t ret = getParamsCaps("VideoSource", info); - if (ret == tvERROR_NONE) { - if (info.rangeVector.size() == info.indexVector.size()) { - for (unsigned int i = 0; i< info.rangeVector.size(); i++) { - supportedSourcemap[info.rangeVector[i]] = stoi(info.indexVector[i]); - } - } - } - else { - LOGERR("%s: Failed to fetch the source index \n", __FUNCTION__); - return -1; - } - - info.pqmodeVector.clear(); - info.sourceVector.clear(); - info.formatVector.clear(); - info.indexVector.clear(); - info.rangeVector.clear(); - - ret = getParamsCaps("PictureMode", info); - if (ret == tvERROR_NONE) { - if (info.rangeVector.size() == info.indexVector.size()) { - for (unsigned int i = 0; i< info.rangeVector.size(); i++) { - supportedPictureModemap[info.rangeVector[i]] = stoi(info.indexVector[i]); - } - } - } - else { - LOGERR("%s: Failed to fetch the picture index \n", __FUNCTION__); - return -1; - } - - info.pqmodeVector.clear(); - info.sourceVector.clear(); - info.formatVector.clear(); - info.indexVector.clear(); - info.rangeVector.clear(); - - ret = getParamsCaps( "VideoFormat", info); - if (ret == tvERROR_NONE) { - if ( info.rangeVector.size() == info.indexVector.size()) { - for (unsigned int i = 0; i< info.rangeVector.size(); i++) { - supportedFormatmap[info.rangeVector[i]] = stoi(info.indexVector[i]); - } - } - } - else { - LOGERR("%s: Failed to fetch the format index \n", __FUNCTION__); - return -1; - } - - return 0; - } - - int AVOutputTV::getParamIndex(std::string param, capDetails_t& paramInfo, paramIndex_t& indexInfo) - { - LOGINFO("Entry : %s param : %s pqmode : %s source :%s format :%s\n",__FUNCTION__,param.c_str(),paramInfo.pqmode.c_str(),paramInfo.source.c_str(),paramInfo.format.c_str()); - - if( paramInfo.source.compare("none") == 0 || paramInfo.source.compare("Current") == 0 ) { - tvVideoSrcType_t currentSource = VIDEO_SOURCE_IP; - GetCurrentVideoSource(¤tSource); - indexInfo.sourceIndex = (int)currentSource; - } - else { - indexInfo.sourceIndex = getSourceIndex(paramInfo.source); - } - if( paramInfo.pqmode.compare("none") == 0 || paramInfo.pqmode.compare("Current") == 0) { - char picMode[PIC_MODE_NAME_MAX]={0}; - if(!getCurrentPictureMode(picMode)) { - LOGERR("Failed to get the Current picture mode\n"); - } - else { - std::string local = picMode; - indexInfo.pqmodeIndex = getPictureModeIndex(local); - } - } - else { - indexInfo.pqmodeIndex = getPictureModeIndex(paramInfo.pqmode); - } - - if( paramInfo.format.compare("none") == 0 || paramInfo.format.compare("Current") == 0) { - tvVideoFormatType_t currentFormat = VIDEO_FORMAT_NONE; - GetCurrentVideoFormat(¤tFormat); - if( VIDEO_FORMAT_NONE == currentFormat ) { - indexInfo.formatIndex = VIDEO_FORMAT_SDR; - } - else { - indexInfo.formatIndex = (int)currentFormat; - } - } - else { - indexInfo.formatIndex = getFormatIndex(paramInfo.format); - } - - if(param == "CMS") - { - tvDataComponentColor_t level = tvDataColor_NONE; - if ( getCMSColorEnumFromString(paramInfo.color,level ) == -1 ) { - LOGERR("%s : GetColorEnumFromString Failed!!! ",__FUNCTION__); - return -1; - } - - indexInfo.colorIndex = level; - - tvComponentType_t componentLevel; - if ( getCMSComponentEnumFromString(paramInfo.component,componentLevel ) == -1 ) { - LOGERR("%s : GetComponentEnumFromString Failed!!! ",__FUNCTION__); - return -1; - } - - indexInfo.componentIndex = componentLevel; - - LOGINFO("%s colorIndex : %d , componentIndex : %d\n",__FUNCTION__,indexInfo.colorIndex, indexInfo.componentIndex); - } - - if(param == "WhiteBalance") - { - tvWBColor_t level; - if ( getWBColorEnumFromString(paramInfo.color,level ) == -1 ) { - LOGERR("%s : GetColorEnumFromString Failed!!! ",__FUNCTION__); - return -1; - } - - indexInfo.colorIndex = level; - - tvWBControl_t controlLevel; - if ( getWBControlEnumFromString(paramInfo.control,controlLevel ) == -1 ) { - LOGERR("%s : GetComponentEnumFromString Failed!!! ",__FUNCTION__); - return -1; - } - - indexInfo.controlIndex = controlLevel; - - /*tvColorTemp_t colorTemp; - if ( getColorTempEnumFromString(paramInfo.colorTemperature,colorTemp ) == -1 ) { - LOGERR("%s : GetComponentEnumFromString Failed!!! ",__FUNCTION__); - return -1; - } - - indexInfo.colorTempIndex = colorTemp; */ - - LOGINFO("%s colorIndex : %d , controlIndex : %d \n",__FUNCTION__,indexInfo.colorIndex, indexInfo.controlIndex); - - } - - if (indexInfo.sourceIndex == -1 || indexInfo.pqmodeIndex == -1 || indexInfo.formatIndex == -1) { - return -1; - } - LOGINFO("%s: Exit sourceIndex = %d pqmodeIndex = %d formatIndex = %d\n",__FUNCTION__,indexInfo.sourceIndex,indexInfo.pqmodeIndex,indexInfo.formatIndex); - - return 0; - } - - int AVOutputTV::getDolbyModeIndex(const char * dolbyMode) - { - int mode = 0; - tvDolbyMode_t dolbyModes[tvMode_Max]; - tvDolbyMode_t *dolbyModesPtr = dolbyModes; // Pointer to statically allocated tvDolbyMode_t array - unsigned short totalAvailable = 0; - - // Set an initial value to indicate the mode type - dolbyModes[0] = tvDolbyMode_Dark; - - tvError_t ret = GetTVSupportedDolbyVisionModes(&dolbyModesPtr, &totalAvailable); - if (ret == tvERROR_NONE) { - for (int count = 0; count < totalAvailable; count++) { - if(strncasecmp(dolbyMode, getDolbyModeStringFromEnum(dolbyModes[count]).c_str(), strlen(dolbyMode))==0) { - mode = dolbyModes[count]; - break; - } - } - } else { - mode = -1; - printf("(%s):get supported mode is failed\n", __func__); - } - return mode; - } - - int AVOutputTV::getHDRModeIndex(const std::string HDRMode, const std::string format,tvDolbyMode_t &value) { - // Create a map to associate format-mode pairs with enum values - int ret = 0; - static const std::unordered_map hdrModeIndexMap = { - {"DVDark", tvDolbyMode_Dark}, - {"DVBright", tvDolbyMode_Bright}, - {"DVGame", tvDolbyMode_Game}, - {"HDR10Dark", tvHDR10Mode_Dark}, - {"HDR10Bright", tvHDR10Mode_Bright}, - {"HDR10Game", tvHDR10Mode_Game}, - {"HLGDark", tvHLGMode_Dark}, - {"HLGBright", tvHLGMode_Bright}, - {"HLGGame", tvHLGMode_Game} - }; - - // Create the key by concatenating the format and HDRMode - std::string key = format+HDRMode; - - // Look up the key in the map - auto it = hdrModeIndexMap.find(key); - if (it != hdrModeIndexMap.end()) { - value = it->second; - ret = 0; - } else { - LOGERR("%s : Invalid format/mode\n",__FUNCTION__); - ret = -1; - } - return ret; - } - - tvDimmingMode_t AVOutputTV::getDimmingModeIndex(std::string mode) - { - tvDimmingMode_t index = tvDimmingMode_MAX; - - if(mode.compare("local") == 0 ) { - index=tvDimmingMode_Local; - } - else if(mode.compare("fixed") == 0 ) { - index=tvDimmingMode_Fixed; - } - else if(mode.compare("global") == 0 ) { - index=tvDimmingMode_Global; - } - else { - LOGINFO("Return Default Dimmingmode:%d!!!\n",index); - } - - return index; - } - - bool AVOutputTV::isIncluded(const std::set set1,const std::set set2) - { - for( const auto& element : set2) { - if(set1.find(element) == set1.end()) { - return false; - } - } - return true; - } - - bool AVOutputTV::isSetRequired(std::string pqmode,std::string source,std::string format) - { - bool ret=false; - char picMode[PIC_MODE_NAME_MAX]={0}; - tvError_t retVal = tvERROR_NONE; - tvVideoSrcType_t sourceIndex = VIDEO_SOURCE_IP; - std::string currentPicMode; - std::string currentSource; - std::string currentFormat; - - //GetCurrent pqmode - if(!getCurrentPictureMode(picMode)) { - LOGERR("Failed to get the current picture mode\n"); - } - - currentPicMode = picMode; //Convert to string - - //GetCurrentVideoSource - retVal = GetCurrentVideoSource(&sourceIndex); - if(retVal != tvERROR_NONE) { - LOGERR("%s : GetCurrentVideoSource( ) Failed\n",__FUNCTION__); - return false; - } - currentSource = convertSourceIndexToString(sourceIndex); - //GetCurrentFormat - tvVideoFormatType_t formatIndex = VIDEO_FORMAT_NONE; - GetCurrentVideoFormat(&formatIndex); - if ( formatIndex == VIDEO_FORMAT_NONE) { - formatIndex = VIDEO_FORMAT_SDR; - } - currentFormat = convertVideoFormatToString(formatIndex); - - if( ( (pqmode.find(currentPicMode) != std::string::npos) || (pqmode.compare("Global") == 0) || (pqmode.compare("Current") == 0) || - (pqmode.compare("none") == 0) ) && - ((source.find(currentSource) != std::string::npos) || (source.compare("Global") == 0) || (source.compare("Current") == 0) || - (source.compare("none") == 0) ) && - ( (format.find(currentFormat) != std::string::npos) || (format.compare("Global") == 0) || (format.compare("Current") == 0) || - (format.compare("none") == 0) ) ) { - ret=true; - } - - return ret; - } - - int AVOutputTV::isPlatformSupport(std::string pqparam) - { - capVectors_t vectorInfo; - - tvError_t ret = getParamsCaps(pqparam,vectorInfo); - - if (ret != tvERROR_NONE) { - LOGINFO("%s: failed to get the capability \n", __FUNCTION__); - return -1; - } - else { - if(vectorInfo.isPlatformSupportVector[0].compare("true") != 0) { - LOGERR("%s: platform support not available\n", __FUNCTION__); - return -1; - } - } - return 0; - } - - void AVOutputTV::spliltCapablities( capVectors_t& vectorInfo, capDetails_t stringInfo) - { - std::vector&>> streamVector; - - // Initializing the streamVector with stringstreams and corresponding vectors - streamVector.push_back({std::stringstream(stringInfo.range), vectorInfo.rangeVector}); - streamVector.push_back({std::stringstream(stringInfo.pqmode), vectorInfo.pqmodeVector}); - streamVector.push_back({std::stringstream(stringInfo.format), vectorInfo.formatVector}); - streamVector.push_back({std::stringstream(stringInfo.source), vectorInfo.sourceVector}); - streamVector.push_back({std::stringstream(stringInfo.isPlatformSupport), vectorInfo.isPlatformSupportVector}); - streamVector.push_back({std::stringstream(stringInfo.index), vectorInfo.indexVector}); - streamVector.push_back({std::stringstream(stringInfo.color), vectorInfo.colorVector}); - streamVector.push_back({std::stringstream(stringInfo.component), vectorInfo.componentVector}); - streamVector.push_back({std::stringstream(stringInfo.colorTemperature), vectorInfo.colorTempVector}); - streamVector.push_back({std::stringstream(stringInfo.control), vectorInfo.controlVector}); - - for (auto& pair : streamVector) { - std::stringstream& ss = pair.first; - std::vector& vec = pair.second; - - std::string token; - while (getline(ss, token, ',')) { - vec.push_back(token); - } - } - } - - bool AVOutputTV::isCapablityCheckPassed( std::string param, capDetails_t inputInfo ) - { - - capDetails_t paramInfo; - - std::set pqmodeCapSet; - std::set formatCapSet; - std::set sourceCapset; - std::set pqmodeInputSet; - std::set formatInputSet; - std::set sourceInputSet; - - - if( ReadCapablitiesFromConf( param, paramInfo ) != 0 ) { - LOGINFO( "%s: readCapablitiesFromConf Failed !!!\n",__FUNCTION__); - return false; - } - - if( param == "CMS") - { - // Check color - if (! checkCMSColorAndComponentCapability(paramInfo.color, inputInfo.color)) { - LOGINFO( "%s:CMS color Capablity Failed CapColor : %s inputColor : %s!!!\n",__FUNCTION__,paramInfo.color.c_str(), inputInfo.color.c_str()); - return false; - } - - // Check component - if (! checkCMSColorAndComponentCapability(paramInfo.component, inputInfo.component)) { - LOGINFO( "%s:CMS component Capablity capComponent : %s inputComponent : %s Failed!!!.\n",__FUNCTION__,paramInfo.component.c_str(), inputInfo.component.c_str()); - return false; - } - } - else if( param == "WhiteBalance") - { - if ( ( paramInfo.color.find(inputInfo.color) == std::string::npos ) || ( paramInfo.control.find(inputInfo.control) == std::string::npos) ) - return false; - } - //Compare capablityInfo with Input params - - //1.convertCapablity Info to set for comparison - spliltStringsAndConvertToSet( paramInfo.pqmode, paramInfo.format, paramInfo.source, pqmodeCapSet, formatCapSet, sourceCapset); - - //2.convert Application Input Info to set for comparison - spliltStringsAndConvertToSet( inputInfo.pqmode, inputInfo.format, inputInfo.source, pqmodeInputSet, formatInputSet, sourceInputSet ); - - //3.Compare Each pqmode/format/source InputInfo against CapablityInfo - if ( isIncluded(pqmodeCapSet,pqmodeInputSet) && isIncluded(formatCapSet,formatInputSet) && isIncluded(sourceCapset,sourceInputSet) ) { - LOGINFO("%s : Capablity Chesk passed \n", __FUNCTION__); - return true; - } - else { - LOGERR("%s : Capablity Check Failed \n", __FUNCTION__); - return false; - } - } - - int AVOutputTV::parsingSetInputArgument(const JsonObject& parameters, std::string pqparam,capDetails_t& paramInfo) { - - JsonArray sourceArray; - JsonArray pqmodeArray; - JsonArray formatArray; - - - pqmodeArray = parameters.HasLabel("pictureMode") ? parameters["pictureMode"].Array() : JsonArray(); - for (int i = 0; i < pqmodeArray.Length(); ++i) { - paramInfo.pqmode += pqmodeArray[i].String(); - if (i != (pqmodeArray.Length() - 1) ) { - paramInfo.pqmode += ","; - } - } - - sourceArray = parameters.HasLabel("videoSource") ? parameters["videoSource"].Array() : JsonArray(); - for (int i = 0; i < sourceArray.Length(); ++i) { - paramInfo.source += sourceArray[i].String(); - if (i != (sourceArray.Length() - 1) ) { - paramInfo.source += ","; - } - } - - formatArray = parameters.HasLabel("videoFormat") ? parameters["videoFormat"].Array() : JsonArray(); - for (int i = 0; i < formatArray.Length(); ++i) { - paramInfo.format += formatArray[i].String(); - if (i != (formatArray.Length() - 1) ) { - paramInfo.format += ","; - } - } - - if (paramInfo.source.empty()) { - paramInfo.source = "Global"; - } - if (paramInfo.pqmode.empty()) { - paramInfo.pqmode = "Global"; - } - if (paramInfo.format.empty()) { - paramInfo.format = "Global"; - } - - if( pqparam.compare("WhiteBalance") == 0 ) - { - if ( paramInfo.color.empty() ) - paramInfo.color = "Global"; - - if ( paramInfo.control.empty() ) - paramInfo.control = "Global"; - - if ( paramInfo.colorTemperature.empty() ) - paramInfo.colorTemperature = "Global"; - } - - if( pqparam.compare("CMS") == 0 ) - { - if ( paramInfo.color.empty() ) - paramInfo.color = "Global"; - - if ( paramInfo.component.empty() ) - paramInfo.component = "Global"; - } - - if (convertToValidInputParameter(pqparam, paramInfo) != 0) { - LOGERR("%s: Failed to convert the input paramters. \n", __FUNCTION__); - return -1; - } - - return 0; - } - - int AVOutputTV::parsingGetInputArgument(const JsonObject& parameters, std::string pqparam, capDetails_t& info) - { - info.pqmode = parameters.HasLabel("pictureMode") ? parameters["pictureMode"].String() : ""; - - info.source = parameters.HasLabel("videoSource") ? parameters["videoSource"].String() : ""; - - info.format = parameters.HasLabel("videoFormat") ? parameters["videoFormat"].String() : ""; - - if ( (info.source.compare("Global") == 0) || (info.pqmode.compare("Global") == 0) || (info.format.compare("Global") == 0) ) { - LOGERR("%s: get cannot fetch the Global inputs \n", __FUNCTION__); - return -1; - } - - if (info.source.empty()) { - info.source = "Current"; - } - if (info.pqmode.empty()) { - info.pqmode = "Current"; - } - if (info.format.empty()) { - info.format = "Current"; - } - - if (convertToValidInputParameter(pqparam,info) != 0) { - LOGERR("%s: Failed to convert the input paramters. \n", __FUNCTION__); - return -1; - } - - return 0; - } - - void AVOutputTV::spliltStringsAndConvertToSet( std::string pqmodeInfo,std::string formatInfo,std::string sourceInfo,std::set &pqmode, std::set &format, std::set &source) - { - std::string token; - std::stringstream pqmodeStream(pqmodeInfo); - std::stringstream formatStream(formatInfo); - std::stringstream sourceStream(sourceInfo); - - while( getline(pqmodeStream,token,',') ) { - pqmode.insert( token ); - token.clear(); - } - - while( getline(formatStream,token,',') ) { - format.insert( token ); - token.clear(); - } - - while( getline(sourceStream,token,',')) { - source.insert( token ); - token.clear(); - } - } - - int AVOutputTV::validateIntegerInputParameter(std::string param, int inputValue) - { - capVectors_t info; - tvError_t ret = getParamsCaps(param, info); - - if (ret != tvERROR_NONE) { - LOGERR("Failed to fetch the range capability[%s] \n", param.c_str()); - return -1; - } - - if ( (param == "Brightness") || (param == "Contrast") || - (param == "Sharpness") || (param == "Saturation") || - (param == "Hue") || (param == "WhiteBalance") || - (param == "CMS") || (param == "Backlight") || - (param == "WhiteBalance") || (param == "LowLatencyState") ) { - if (inputValue < stoi(info.rangeVector[0]) || inputValue > std::stoi(info.rangeVector[1])) { - LOGERR("wrong Input value[%d]", inputValue); - return -1; - } - } - return 0; - } - - int AVOutputTV::fetchCapablities(string pqparam, capDetails_t& info) { - - capVectors_t vectorInfo; - - tvError_t ret = tvERROR_NONE; - - ret = getParamsCaps(pqparam, vectorInfo); - - if (ret != tvERROR_NONE) { - LOGINFO("%s: failed to get the capability \n", __FUNCTION__); - return -1; - } - - if (vectorInfo.sourceVector.size() != 0) { - info.source = convertToString(vectorInfo.sourceVector); - } - - if (vectorInfo.pqmodeVector.size() != 0) { - info.pqmode = convertToString(vectorInfo.pqmodeVector); - } - - if (vectorInfo.formatVector.size() != 0) { - info.format = convertToString(vectorInfo.formatVector); - } - - if (vectorInfo.colorVector.size() != 0) { - info.color = convertToString(vectorInfo.colorVector); - } - - if (vectorInfo.componentVector.size() != 0) { - info.component = convertToString(vectorInfo.componentVector); - } - - if (vectorInfo.controlVector.size() != 0) { - info.control = convertToString(vectorInfo.controlVector); - } - - if (vectorInfo.colorTempVector.size() != 0) { - info.colorTemperature = convertToString(vectorInfo.colorTempVector); - } - - return 0; - } - - int AVOutputTV::validateInputParameter(std::string param, std::string inputValue) - { - - capVectors_t info; - - tvError_t ret = getParamsCaps( param, info); - - if (ret != tvERROR_NONE) { - LOGERR("Failed to fetch the range capability[%s] \n", param.c_str()); - return -1; - } - - if ( (param == "ColorTemperature") || - (param == "DimmingMode") || (param == "AutoBacklightMode") || - (param == "DolbyVisionMode") || (param == "HDR10Mode") || - (param == "HLGMode") || (param == "AspectRatio") || (param == "PictureMode") ) { - auto iter = find(info.rangeVector.begin(), info.rangeVector.end(), inputValue); - - if (iter == info.rangeVector.end()) { - LOGERR("Not a valid input value[%s].\n", inputValue.c_str()); - return -1; - } - } - return 0; - } - - void AVOutputTV::locatePQSettingsFile() - { - LOGINFO("Entry\n"); - char panelId[20] = {0}; - std::string PQFileName = AVOUTPUT_RFC_CALLERID; - std::string FilePath = "/etc/rfcdefaults/"; - - /* The if condition is to override the tvsettings ini file so it helps the PQ tuning process for new panels */ - if(access(AVOUTPUT_OVERRIDE_PATH, F_OK) == 0) { - PQFileName = std::string(AVOUTPUT_RFC_CALLERID_OVERRIDE); - } - else { - int val=GetPanelID(panelId); - if(val==0) { - LOGINFO("%s : panel id read is : %s\n",__FUNCTION__,panelId); - if(strncmp(panelId,AVOUTPUT_CONVERTERBOARD_PANELID,strlen(AVOUTPUT_CONVERTERBOARD_PANELID))!=0) { - PQFileName+=std::string("_")+panelId; - struct stat tmp_st; - - LOGINFO("%s: Looking for %s.ini \n",__FUNCTION__,PQFileName.c_str()); - if(stat((FilePath+PQFileName+std::string(".ini")).c_str(), &tmp_st)!=0) { - //fall back - LOGINFO("%s not available in %s Fall back to default\n",PQFileName.c_str(),FilePath.c_str()); - PQFileName =std::string(AVOUTPUT_RFC_CALLERID); - } - } - } - else { - LOGINFO("%s : GetPanelID failed : %d\n",__FUNCTION__,val); - } - } - strncpy(rfc_caller_id,PQFileName.c_str(),PQFileName.size()); - rfc_caller_id[sizeof(rfc_caller_id) - 1] = '\0'; - LOGINFO("%s : Default tvsettings file : %s\n",__FUNCTION__,rfc_caller_id); - } - - tvError_t AVOutputTV::initializePictureMode() - { - tvError_t ret = tvERROR_NONE; - TR181_ParamData_t param; - tvVideoSrcType_t current_source = VIDEO_SOURCE_IP; - std::string tr181_param_name = ""; - tvVideoFormatType_t current_format = VIDEO_FORMAT_NONE; - - GetCurrentVideoFormat(¤t_format); - if ( current_format == VIDEO_FORMAT_NONE) { - current_format = VIDEO_FORMAT_SDR; - } - // get current source - GetCurrentVideoSource(¤t_source); - - tr181_param_name += std::string(AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM); - tr181_param_name += "."+convertSourceIndexToString(current_source)+"."+"Format."+convertVideoFormatToString(current_format)+"."+"PictureModeString"; - tr181ErrorCode_t err = getLocalParam(rfc_caller_id, tr181_param_name.c_str(), ¶m); - if ( tr181Success == err ) { - ret = SetTVPictureMode(param.value); - - if(ret != tvERROR_NONE) { - LOGWARN("Picture Mode set failed: %s\n",getErrorString(ret).c_str()); - } - else { - LOGINFO("Picture Mode initialized successfully, tr181 value [%s] value: %s\n", tr181_param_name.c_str(), - param.value); - } - } - else { - ret = tvERROR_GENERAL; - LOGWARN("getLocalParam for %s Failed : %s\n", tr181_param_name.c_str(), getTR181ErrorString(err)); - } - - return ret; - } - - std::string AVOutputTV::convertToString(std::vector vec_strings) - { - std::string result = std::accumulate(vec_strings.begin(), vec_strings.end(), std::string(), - [](const std::string& a, const std::string& b) -> std::string { - return a.empty() ? b : a + "," + b; - }); - return result; - } - - int AVOutputTV::convertToValidInputParameter(std::string pqparam, capDetails_t& info) - { - - LOGINFO("Entry %s source %s pqmode %s format %s \n", __FUNCTION__, info.source.c_str(), info.pqmode.c_str(), info.format.c_str()); - - capDetails_t localInfo; - if (fetchCapablities(pqparam, localInfo) != 0) { - LOGINFO("%s, Failed to get capability fo %s\n", __FUNCTION__,pqparam.c_str()); - return -1; - } - - // converting pq to valid paramter format - if (info.pqmode == "Global") { - info.pqmode = localInfo.pqmode; - } - else if (info.pqmode == "Current") { - char picMode[PIC_MODE_NAME_MAX]={0}; - if(!getCurrentPictureMode(picMode)) { - LOGINFO("Failed to get the Current picture mode\n"); - return -1; - } - else { - info.pqmode = picMode; - } - } - - if (info.source == "Global") { - info.source = localInfo.source; - } - else if (info.source == "Current") { - tvVideoSrcType_t currentSource = VIDEO_SOURCE_IP; - tvError_t ret = GetCurrentVideoSource(¤tSource); - - if(ret != tvERROR_NONE) { - LOGWARN("%s: GetCurrentVideoSource( ) Failed \n",__FUNCTION__); - return -1; - } - info.source = convertSourceIndexToString(currentSource); - } - - //convert format into valid parameter - if (info.format == "Global") { - info.format = localInfo.format; - } - else if (info.format == "Current") { - tvVideoFormatType_t formatIndex = VIDEO_FORMAT_NONE; - GetCurrentVideoFormat(&formatIndex); - if ( formatIndex == VIDEO_FORMAT_NONE) { - formatIndex = VIDEO_FORMAT_SDR; - } - info.format = convertVideoFormatToString(formatIndex); - } - - //convert WB and CMS params - if( pqparam.compare("WhiteBalance") == 0 ) - { - if( info.control.compare("Global") == 0 ) - { - info.control = localInfo.control; - } - - if( info.color.compare("Global") == 0 ) - { - info.color = localInfo.color; - } - - if( info.colorTemperature.compare("Global") == 0 ) - { - info.colorTemperature= localInfo.colorTemperature; - } - - LOGINFO("%s : control : %s color : %s colorTemp : %s \n",__FUNCTION__,info.control.c_str(),info.color.c_str(),info.colorTemperature.c_str()); - - } - - if( pqparam.compare("CMS") == 0 ) - { - if( info.component.compare("Global") == 0 ) - { - info.component = localInfo.component; - } - - if( info.color.compare("Global") == 0 ) - { - info.color = localInfo.color; - } - - LOGINFO("%s : component : %s color : %s \n",__FUNCTION__,info.component.c_str(),info.color.c_str()); - } - - LOGINFO("Exit %s source %s pqmode %s format %s \n", __FUNCTION__, info.source.c_str(), info.pqmode.c_str(), info.format.c_str()); - return 0; - } - - string AVOutputTV::convertSourceIndexToString(int source) - { - std::string ret; - std::map :: iterator it; - for (it = supportedSourcemap.begin(); it != supportedSourcemap.end(); it++) { - if (it->second == source) { - ret = it->first; - break; - } - } - return ret; - } - - string AVOutputTV::convertVideoFormatToString(int format) - { - std::string ret; - std::map :: iterator it; - for (it = supportedFormatmap.begin(); it != supportedFormatmap.end(); it++) { - if (it->second == format) { - ret = it->first; - break; - } - } - return ret; - } - - string AVOutputTV::convertPictureIndexToString(int pqmode) - { - std::string ret; - std::map :: iterator it; - for(it = supportedPictureModemap.begin(); it != supportedPictureModemap.end(); it++) { - if (it->second == pqmode) { - ret = it->first; - break; - } - } - return ret; - } - - tvContentFormatType_t AVOutputTV::convertFormatStringToTVContentFormat(const char *format) - { - tvContentFormatType_t ret = tvContentFormatType_SDR; - - if( strncmp(format,"sdr",strlen(format)) == 0 || strncmp(format,"SDR",strlen(format)) == 0 ) { - ret = tvContentFormatType_SDR; - } - else if( strncmp(format,"hdr10",strlen(format)) == 0 || strncmp(format,"HDR10",strlen(format))==0 ) { - ret = tvContentFormatType_HDR10; - } - else if( strncmp(format,"hlg",strlen(format)) == 0 || strncmp(format,"HLG",strlen(format)) == 0 ) { - ret = tvContentFormatType_HLG; - } - else if( strncmp(format,"dolby",strlen(format)) == 0 || strncmp(format,"DOLBY",strlen(format)) == 0 ) { - ret=tvContentFormatType_DOVI; - } - - return ret; - } - - tvError_t AVOutputTV::updateAVoutputTVParamToHAL(std::string forParam, paramIndex_t indexInfo, int value,bool setNotDelete) - { - tvError_t ret = tvERROR_NONE; - std::string key; - - if( forParam.compare("CMS") == 0 ) - generateStorageIdentifierCMS(key,forParam,indexInfo); - else if( forParam.compare("WhiteBalance") == 0 ) - generateStorageIdentifierWB(key,forParam,indexInfo); - else - generateStorageIdentifier(key,forParam,indexInfo); - - if(key.empty()) { - LOGERR("generateStorageIdentifierDirty failed\n"); - ret = tvERROR_GENERAL; - } - else { - tr181ErrorCode_t err = tr181Success; - if(setNotDelete) { - std::string toStore = std::to_string(value); - if (forParam.compare("ColorTemp") == 0) { - getColorTempStringFromEnum(value, toStore); - } - else if(forParam.compare("DimmingMode") == 0 ) { - getDimmingModeStringFromEnum(value, toStore); - } - else if (forParam.compare("DolbyVisionMode") == 0 || forParam.compare("HDRMode") == 0 ) { - toStore = getDolbyModeStringFromEnum((tvDolbyMode_t)value); - } - err = setLocalParam(rfc_caller_id, key.c_str(),toStore.c_str()); - - } - else { - err = clearLocalParam(rfc_caller_id, key.c_str()); - } - - if ( err != tr181Success ) { - LOGERR("%s for %s Failed : %s\n", setNotDelete?"Set":"Delete", key.c_str(), getTR181ErrorString(err)); - ret = tvERROR_GENERAL; - } - } - return ret; - } - - int AVOutputTV::updateAVoutputTVParam( std::string action, std::string tr181ParamName, capDetails_t info, tvPQParameterIndex_t pqParamIndex, int level ) - { - LOGINFO("Entry : %s\n",__FUNCTION__); - valueVectors_t values; - paramIndex_t paramIndex; - std::vector sources; - std::vector pictureModes; - std::vector formats; - int ret = 0; - bool sync = !(action.compare("sync")); - bool reset = !(action.compare("reset")); - bool set = !(action.compare("set")); - - LOGINFO("%s: Entry param : %s Action : %s pqmode : %s source :%s format :%s color:%s component:%s control:%s\n",__FUNCTION__,tr181ParamName.c_str(),action.c_str(),info.pqmode.c_str(),info.source.c_str(),info.format.c_str(),info.color.c_str(),info.component.c_str(),info.control.c_str() ); - ret = getSaveConfig(tr181ParamName,info, values); - if( 0 == ret ) { - for( int sourceType: values.sourceValues ) { - paramIndex.sourceIndex = sourceType; - for( int modeType : values.pqmodeValues ) { - paramIndex.pqmodeIndex = modeType; - for( int formatType : values.formatValues ) { - paramIndex.formatIndex = formatType; - switch(pqParamIndex) { - case PQ_PARAM_BRIGHTNESS: - case PQ_PARAM_CONTRAST: - case PQ_PARAM_BACKLIGHT: - case PQ_PARAM_SATURATION: - case PQ_PARAM_SHARPNESS: - case PQ_PARAM_HUE: - case PQ_PARAM_COLOR_TEMPERATURE: - case PQ_PARAM_DIMMINGMODE: - case PQ_PARAM_LOWLATENCY_STATE: - case PQ_PARAM_DOLBY_MODE: - if(reset) { - ret |= updateAVoutputTVParamToHAL(tr181ParamName,paramIndex,0,false); - } - if(sync || reset) { - int value=0; - if(getLocalparam(tr181ParamName,paramIndex,value,pqParamIndex,sync)) { - continue; - } - level=value; - } - if(set) { - ret |= updateAVoutputTVParamToHAL(tr181ParamName,paramIndex,level,true); - } - break; - default: - break; - } - switch(pqParamIndex) { - case PQ_PARAM_BRIGHTNESS: - ret |= SaveBrightness((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,level); - break; - case PQ_PARAM_CONTRAST: - ret |= SaveContrast((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,level); - break; - case PQ_PARAM_SHARPNESS: - ret |= SaveSharpness((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,level); - break; - case PQ_PARAM_HUE: - ret |= SaveHue((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,level); - break; - case PQ_PARAM_SATURATION: - ret |= SaveSaturation((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,level); - break; - case PQ_PARAM_COLOR_TEMPERATURE: - ret |= SaveColorTemperature((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,(tvColorTemp_t)level); - break; - case PQ_PARAM_BACKLIGHT: - ret |= SaveBacklight((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,level); - break; - case PQ_PARAM_DIMMINGMODE: - ret |= SaveTVDimmingMode((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,(tvDimmingMode_t)level); - break; - case PQ_PARAM_LOWLATENCY_STATE: - ret |= SaveLowLatencyState((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,level); - break; - case PQ_PARAM_DOLBY_MODE: - ret |= SaveTVDolbyVisionMode((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,(tvDolbyMode_t)level); - break; - - case PQ_PARAM_ASPECT_RATIO: - ret |= SaveAspectRatio((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,(tvDisplayMode_t)level); - break; - - case PQ_PARAM_CMS_SATURATION_RED: - case PQ_PARAM_CMS_SATURATION_BLUE: - case PQ_PARAM_CMS_SATURATION_GREEN: - case PQ_PARAM_CMS_SATURATION_YELLOW: - case PQ_PARAM_CMS_SATURATION_CYAN: - case PQ_PARAM_CMS_SATURATION_MAGENTA: - case PQ_PARAM_CMS_HUE_RED: - case PQ_PARAM_CMS_HUE_BLUE: - case PQ_PARAM_CMS_HUE_GREEN: - case PQ_PARAM_CMS_HUE_YELLOW: - case PQ_PARAM_CMS_HUE_CYAN: - case PQ_PARAM_CMS_HUE_MAGENTA: - case PQ_PARAM_CMS_LUMA_RED: - case PQ_PARAM_CMS_LUMA_BLUE: - case PQ_PARAM_CMS_LUMA_GREEN: - case PQ_PARAM_CMS_LUMA_YELLOW: - case PQ_PARAM_CMS_LUMA_CYAN: - case PQ_PARAM_CMS_LUMA_MAGENTA: - { - for( int componentType : values.componentValues ) { - paramIndex.componentIndex = componentType; - for( int colorType : values.colorValues ) { - paramIndex.colorIndex = colorType; - if(reset) { - ret |= updateAVoutputTVParamToHAL(tr181ParamName,paramIndex,0,false); - } - if(sync || reset) { - int value=0; - tvPQParameterIndex_t pqIndex; - if ( convertCMSParamToPQEnum(getCMSComponentStringFromEnum((tvComponentType_t)paramIndex.componentIndex),getCMSColorStringFromEnum((tvDataComponentColor_t)paramIndex.colorIndex),pqIndex) != 0 ) - { - LOGERR("%s:convertCMSParamToPQEnum failed color : %d component : %d \n",__FUNCTION__,paramIndex.colorIndex,paramIndex.componentIndex); - return -1; - } - if(getLocalparam(tr181ParamName,paramIndex,value,pqIndex,sync)) { - continue; - } - level=value; - } - ret |= SaveCMS((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,(tvComponentType_t)paramIndex.componentIndex,(tvDataComponentColor_t)paramIndex.colorIndex,level); - - if(set) { - ret |= updateAVoutputTVParamToHAL(tr181ParamName,paramIndex,level,true); - } - } - } - break; - } - case PQ_PARAM_WB_GAIN_RED: - case PQ_PARAM_WB_GAIN_GREEN: - case PQ_PARAM_WB_GAIN_BLUE: - case PQ_PARAM_WB_OFFSET_RED: - case PQ_PARAM_WB_OFFSET_GREEN: - case PQ_PARAM_WB_OFFSET_BLUE: - { - for( int colorType : values.colorValues ) { - paramIndex.colorIndex = colorType; - for( int controlType : values.controlValues ) { - paramIndex.controlIndex = controlType; - if(reset) { - ret |= updateAVoutputTVParamToHAL(tr181ParamName,paramIndex,0,false); - } - if(sync || reset) { - int value=0; - if(getLocalparam(tr181ParamName,paramIndex,value,pqParamIndex,sync)) { - continue; - } - level=value; - } - /* tvRGBType_t rgbIndex; - if ( convertWBParamToRGBEnum(getWBColorStringFromEnum((tvWBColor_t)(paramIndex.colorIndex)),getWBControlStringFromEnum((tvWBControl_t)(paramIndex.controlIndex)),rgbIndex) != 0 ) - { - LOGERR("%s:convertWBParamToRGBEnum failed Color : %d Control : %d \n",__FUNCTION__,paramIndex.colorIndex,paramIndex.controlIndex); - return -1; - }*/ - ret |= SaveCustom2PointWhiteBalance((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,(tvWBColor_t)paramIndex.colorIndex,(tvWBControl_t)paramIndex.controlIndex,level); - - if(set) { - ret |= updateAVoutputTVParamToHAL(tr181ParamName,paramIndex,level,true); - } - } - } - break; - } - case PQ_PARAM_LOCALDIMMING_LEVEL: - { - if(sync) { - int value=0; - getLocalparam(tr181ParamName,paramIndex,value,pqParamIndex,sync); - level=value; - } - ret |= SaveTVDimmingMode((tvVideoSrcType_t)paramIndex.sourceIndex, paramIndex.pqmodeIndex,(tvVideoFormatType_t)paramIndex.formatIndex,(tvDimmingMode_t)level); - break; - } - case PQ_PARAM_CMS: - case PQ_PARAM_LDIM: - default: - break; - } - } - } - } - - } - return ret; - } - - tvError_t AVOutputTV::syncAvoutputTVParamsToHAL(std::string pqmode,std::string source,std::string format) - { - int level={0}; - capDetails_t info; - info.pqmode = pqmode; - info.source = source; - info.format = format; - - LOGINFO("Entry %s : pqmode : %s source : %s format : %s\n",__FUNCTION__,pqmode.c_str(),source.c_str(),format.c_str()); - - if( !updateAVoutputTVParam("sync","Brightness",info,PQ_PARAM_BRIGHTNESS,level)) { - LOGINFO("Brightness Successfully sync to Drive Cache\n"); - } - else { - LOGERR("Brightness Sync to cache Failed !!!\n"); - } - - if( !updateAVoutputTVParam("sync","Contrast",info,PQ_PARAM_CONTRAST,level)) { - LOGINFO("Contrast Successfully Synced to Drive Cache\n"); - } - else { - LOGERR("Contrast Sync to cache Failed !!!\n"); - } - - if( !updateAVoutputTVParam("sync","Sharpness",info,PQ_PARAM_SHARPNESS,level)) { - LOGINFO("Sharpness Successfully Synced to Drive Cache\n"); - } - else { - LOGERR("Sharpness Sync to cache Failed !!!\n"); - } - - if( !updateAVoutputTVParam("sync","Saturation",info,PQ_PARAM_SATURATION,level)) { - LOGINFO("Saturation Successfully Synced to Drive Cache\n"); - } - else { - LOGERR("Saturation Sync to cache Failed !!!\n"); - } - - if( !updateAVoutputTVParam("sync","Hue",info,PQ_PARAM_HUE,level)) { - LOGINFO("Hue Successfully Synced to Drive Cache\n"); - } - else { - LOGERR("Hue Sync to cache Failed !!!\n"); - } - - if( !updateAVoutputTVParam("sync","ColorTemp",info,PQ_PARAM_COLOR_TEMPERATURE,level)) { - LOGINFO("ColorTemp Successfully Synced to Drive Cache\n"); - } - else { - LOGERR("ColorTemp Sync to cache Failed !!!\n"); - } - if( !updateAVoutputTVParam("sync","HDRMode",info,PQ_PARAM_DOLBY_MODE,level)) { - LOGINFO("HDRmode Successfully Synced to Drive Cache\n"); - } - else { - LOGERR("HDRmode Sync to cache Failed !!!\n"); - } - - if( !updateAVoutputTVParam("sync","DimmingMode",info,PQ_PARAM_DIMMINGMODE,level)) { - LOGINFO("dimmingmode Successfully Synced to Drive Cache\n"); - } - else { - LOGERR("dimmingmode Sync to cache Failed !!!\n"); - } - - if( !updateAVoutputTVParam("sync","Backlight",info,PQ_PARAM_BACKLIGHT,level) ) { - LOGINFO("Backlight Successfully Synced to Drive Cache\n"); - } - else { - LOGERR("Backlight Sync to cache Failed !!!\n"); - } - - syncCMSParams(); //sync CMS - - syncWBParams(); - - info.format = "DV";//Sync only for Dolby - - if( !updateAVoutputTVParam("sync","DolbyVisionMode",info,PQ_PARAM_DOLBY_MODE,level)) { - LOGINFO("dvmode Successfully Synced to Drive Cache\n"); - } - else { - LOGERR("dvmode Sync to cache Failed !!!\n"); - } - - LOGINFO("Exit %s : pqmode : %s source : %s format : %s\n",__FUNCTION__,pqmode.c_str(),source.c_str(),format.c_str()); - return tvERROR_NONE; - } - - int AVOutputTV::syncAvoutputTVPQModeParamsToHAL(std::string pqmode, std::string source, std::string format) - { - capDetails_t inputInfo; - valueVectors_t valueVectors; - tr181ErrorCode_t err = tr181Success; - TR181_ParamData_t param = {0}; - int ret = 0; - - inputInfo.pqmode = pqmode; - inputInfo.source = source; - inputInfo.format = format; - - ret = getSaveConfig("PictureMode", inputInfo, valueVectors); - - if (ret == 0 ) { - for (int source : valueVectors.sourceValues ) { - tvVideoSrcType_t sourceType = (tvVideoSrcType_t)source; - for (int format : valueVectors.formatValues ) { - tvVideoFormatType_t formatType = (tvVideoFormatType_t)format; - std::string tr181_param_name = ""; - tr181_param_name += std::string(AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM); - tr181_param_name += "."+convertSourceIndexToString(sourceType)+"."+"Format."+ - convertVideoFormatToString(formatType)+"."+"PictureModeString"; - - err = getLocalParam(rfc_caller_id, tr181_param_name.c_str(), ¶m); - if ( tr181Success == err ) { - std::string local = param.value; - int pqmodeindex = (int)getPictureModeIndex(local); - - tvError_t tv_err = SaveSourcePictureMode(sourceType, formatType, pqmodeindex); - if (tv_err != tvERROR_NONE) { - LOGWARN("failed to SaveSourcePictureMode \n"); - return -1; - } - } - else { - LOGWARN("Failed to get the getLocalParam \n"); - return -1; - } - } - } - } - return ret; - } - - uint32_t AVOutputTV::generateStorageIdentifier(std::string &key, std::string forParam, paramIndex_t info) - { - key+=std::string(AVOUTPUT_GENERIC_STRING_RFC_PARAM); - key+=STRING_SOURCE+convertSourceIndexToString(info.sourceIndex)+std::string(".")+STRING_PICMODE+convertPictureIndexToString(info.pqmodeIndex)+std::string(".")+std::string(STRING_FORMAT)+convertVideoFormatToString(info.formatIndex)+std::string(".")+forParam; - return tvERROR_NONE; - } - - uint32_t AVOutputTV::generateStorageIdentifierCMS(std::string &key, std::string forParam, paramIndex_t info) - { - key+=std::string(AVOUTPUT_GENERIC_STRING_RFC_PARAM); - key+=STRING_SOURCE+convertSourceIndexToString(info.sourceIndex)+std::string(".")+STRING_PICMODE+convertPictureIndexToString(info.pqmodeIndex)+std::string(".")+std::string(STRING_FORMAT)+convertVideoFormatToString(info.formatIndex)+std::string(".")+STRING_COLOR+getCMSColorStringFromEnum((tvDataComponentColor_t)info.colorIndex)+std::string(".")+STRING_COMPONENT+getCMSComponentStringFromEnum((tvComponentType_t)info.componentIndex)+std::string(".")+forParam; - return tvERROR_NONE; - } - - uint32_t AVOutputTV::generateStorageIdentifierWB(std::string &key, std::string forParam, paramIndex_t info) - { - key+=std::string(AVOUTPUT_GENERIC_STRING_RFC_PARAM); - key+=STRING_SOURCE+convertSourceIndexToString(info.sourceIndex)+std::string(".")+STRING_PICMODE+convertPictureIndexToString(info.pqmodeIndex)+std::string(".")+std::string(STRING_FORMAT)+convertVideoFormatToString(info.formatIndex)+std::string(".")+STRING_COLOR+getWBColorStringFromEnum((tvWBColor_t)info.colorIndex)+std::string(".")+STRING_CONTROL+getWBControlStringFromEnum((tvWBControl_t)info.controlIndex)+std::string(".")+forParam; - return tvERROR_NONE; - } - - - - uint32_t AVOutputTV::generateStorageIdentifierDirty(std::string &key, std::string forParam,uint32_t contentFormat, int pqmode) - { - key+=std::string(AVOUTPUT_GENERIC_STRING_RFC_PARAM); - key+=STRING_PICMODE+std::to_string(pqmode)+std::string(".")+std::string(STRING_FORMAT)+std::to_string(contentFormat); - CREATE_DIRTY(key)+=forParam; - - return tvERROR_NONE; - } - - std::string AVOutputTV::getErrorString (tvError_t eReturn) - { - switch (eReturn) { - case tvERROR_NONE: - return "API SUCCESS"; - case tvERROR_GENERAL: - return "API FAILED"; - case tvERROR_OPERATION_NOT_SUPPORTED: - return "OPERATION NOT SUPPORTED ERROR"; - case tvERROR_INVALID_PARAM: - return "INVALID PARAM ERROR"; - case tvERROR_INVALID_STATE: - return "INVALID STATE ERROR"; - } - return "UNKNOWN ERROR"; - } - - int AVOutputTV::getSaveConfig(std::string param, capDetails_t capInfo, valueVectors_t &values) - { - LOGINFO("Entry : %s pqmode : %s source :%s format :%s component : %s color : %s control:%s\n",__FUNCTION__,capInfo.pqmode.c_str(),capInfo.source.c_str(),capInfo.format.c_str(),capInfo.component.c_str(),capInfo.color.c_str(),capInfo.control.c_str()); - - int ret = 0; - - if (getAvailableCapabilityModes(capInfo) != 0) { - LOGERR("%s: failed to get picture/source/format mode capability \n", __FUNCTION__); - return -1; - } - //pqmode - char *modeString = strdup(capInfo.pqmode.c_str()); - char *token = NULL; - while ((token = strtok_r(modeString,",",&modeString))) { - std::string local = token; - values.pqmodeValues.push_back(getPictureModeIndex(local)); - } - //source - char *sourceString = strdup(capInfo.source.c_str()); - char *sourceToken = NULL; - while ((sourceToken = strtok_r(sourceString,",",&sourceString))) { - std::string local = sourceToken; - if( local == "All") continue; - values.sourceValues.push_back(getSourceIndex(local)); - } - //3)check format - char *formatString = strdup(capInfo.format.c_str()); - char *formatToken = NULL; - while ((formatToken = strtok_r(formatString,",",&formatString))) { - std::string local = formatToken; - values.formatValues.push_back(getFormatIndex(local)); - } - - if( param.compare("CMS") == 0 ) - { - //Check Color - char *colorString = strdup(capInfo.color.c_str()); - char *colorToken = NULL; - while ((colorToken = strtok_r(colorString,",",&colorString))) { - std::string local = colorToken; - tvDataComponentColor_t level = tvDataColor_NONE; - if ( getCMSColorEnumFromString(local,level ) == -1 ) { - LOGERR("%s : GetColorEnumFromString Failed!!! ",__FUNCTION__); - return -1; - } - values.colorValues.push_back(level); - } - - //Check Component - char *componentString = strdup(capInfo.component.c_str()); - char *componentToken = NULL; - while ((componentToken = strtok_r(componentString,",",&componentString))) { - std::string local = componentToken; - tvComponentType_t level; - if ( getCMSComponentEnumFromString(local,level ) == -1 ) { - LOGERR("%s : GetComponentEnumFromString Failed!!! ",__FUNCTION__); - return -1; - } - values.componentValues.push_back(level); - } - } - - if( param.compare("WhiteBalance") == 0 ) - { - //Check Color - char *colorString = strdup(capInfo.color.c_str()); - char *colorToken = NULL; - while ((colorToken = strtok_r(colorString,",",&colorString))) { - std::string local = colorToken; - tvWBColor_t level=tvWB_COLOR_RED; - if ( getWBColorEnumFromString(local,level ) == -1 ) { - LOGERR("%s : GetWBColorEnumFromString Failed!!! ",__FUNCTION__); - return -1; - } - values.colorValues.push_back(level); - } - - //Check Control - char *controlString = strdup(capInfo.control.c_str()); - char *controlToken = NULL; - while ((controlToken = strtok_r(controlString,",",&controlString))) { - std::string local = controlToken; - tvWBControl_t level=tvWB_CONTROL_GAIN;; - if ( getWBControlEnumFromString(local,level ) == -1 ) { - LOGERR("%s : GetWBControlEnumFromString Failed!!! ",__FUNCTION__); - return -1; - } - values.controlValues.push_back(level); - } - - /* - //Check Color Temp - char *colorTempString = strdup(capInfo.colorTemperature.c_str()); - char *colorTempToken = NULL; - while ((colorTempToken = strtok_r(colorTempString,",",&colorTempString))) { - std::string local = colorTempToken; - tvColorTemp_t level; - if ( getColorTempEnumFromString(local,level ) == -1 ) { - LOGERR("%s : GetColorTempEnumFromString Failed!!! ",__FUNCTION__); - return -1; - } - values.colorTempValues.push_back(level); - }*/ - } - - LOGINFO("Exit : %s pqmode : %s source :%s format :%s ret:%d\n",__FUNCTION__,capInfo.pqmode.c_str(),capInfo.source.c_str(),capInfo.format.c_str(), ret); - return ret; - } - - int AVOutputTV::getLocalparam( std::string forParam,paramIndex_t indexInfo,int & value,tvPQParameterIndex_t pqParamIndex,bool sync) - { - string key; - TR181_ParamData_t param={0}; - - if( forParam.compare("CMS") == 0 ) { - generateStorageIdentifierCMS(key,forParam,indexInfo); - } else if( forParam.compare("WhiteBalance") == 0 ) { - generateStorageIdentifierWB(key,forParam,indexInfo); - } else { - generateStorageIdentifier(key,forParam,indexInfo); - } - - if(key.empty()) { - LOGERR("generateStorageIdentifier failed\n"); - return -1; - } - - tr181ErrorCode_t err=getLocalParam(rfc_caller_id, key.c_str(), ¶m); - - if ( tr181Success == err ) {//Fetch new tr181format values - if( forParam.compare("ColorTemp") == 0 ) { - if (strncmp(param.value, "Standard", strlen(param.value))==0) { - value=tvColorTemp_STANDARD; - } - else if (strncmp(param.value, "Warm", strlen(param.value))==0) { - value=tvColorTemp_WARM; - } - else if (strncmp(param.value, "Cold", strlen(param.value))==0) { - value=tvColorTemp_COLD; - } - else if (strncmp(param.value, "UserDefined", strlen(param.value))==0) { - value=tvColorTemp_USER; - } - else { - value=tvColorTemp_STANDARD; - } - return 0; - } - else if( forParam.compare("DimmingMode") == 0 ) { - if (strncmp(param.value, "fixed", strlen(param.value))==0) { - value=tvDimmingMode_Fixed; - } - else if (strncmp(param.value, "local", strlen(param.value))==0) { - value=tvDimmingMode_Local; - } - else if (strncmp(param.value, "global", strlen(param.value))==0) { - value=tvDimmingMode_Global; - } - return 0; - } - else if ( forParam.compare("DolbyVisionMode") == 0) { - if (strncmp(param.value, "Dark", strlen(param.value)) == 0) { - value = tvDolbyMode_Dark; - } - else if(strncmp(param.value, "Game", strlen(param.value)) == 0) { - value = tvDolbyMode_Game; - } - else { - value = tvDolbyMode_Bright; - } - return 0; - } - else if ( forParam.compare("HDRMode") == 0) { - if (strncmp(param.value, "Dark", strlen(param.value)) == 0 && key.find("DV") != std::string::npos ) { - value = tvDolbyMode_Dark; - } - else if(strncmp(param.value, "Bright", strlen(param.value)) == 0 && key.find("DV") != std::string::npos ) { - value = tvDolbyMode_Game; - } - else if(strncmp(param.value, "Dark", strlen(param.value)) == 0 && key.find("HDR10") != std::string::npos ) { - value = tvHDR10Mode_Dark; - } - else if(strncmp(param.value, "Bright", strlen(param.value)) == 0 && key.find("HDR10") != std::string::npos ) { - value = tvHDR10Mode_Bright; - } - else if(strncmp(param.value, "Dark", strlen(param.value)) == 0 && key.find("HLG") != std::string::npos ) { - value = tvHLGMode_Dark; - } - else if(strncmp(param.value, "Bright", strlen(param.value)) == 0 && key.find("HLG") != std::string::npos ) { - value = tvHLGMode_Bright; - } - else { - value = tvDolbyMode_Game; - } - return 0; - } - else { - value=std::stoi(param.value); - return 0; - } - } - else {// default value from DB - if( sync ) { - return 1; - } - GetDefaultPQParams(indexInfo.pqmodeIndex,(tvVideoSrcType_t)indexInfo.sourceIndex,(tvVideoFormatType_t)indexInfo.formatIndex,pqParamIndex,&value); - LOGINFO("Default value from DB : %s : %d \n",key.c_str(),value); - return 0; - } - } - - tvDataComponentColor_t AVOutputTV::getComponentColorEnum(std::string colorName) - { - tvDataComponentColor_t CompColorEnum = tvDataColor_MAX; - - if(!colorName.compare("none")) { - CompColorEnum = tvDataColor_NONE; - } - else if (!colorName.compare("red")) { - CompColorEnum = tvDataColor_RED; - } - else if (!colorName.compare("green")) { - CompColorEnum = tvDataColor_GREEN; - } - else if (!colorName.compare("blue")) { - CompColorEnum = tvDataColor_BLUE; - } - else if (!colorName.compare("yellow")) { - CompColorEnum = tvDataColor_YELLOW; - } - else if (!colorName.compare("cyan")) { - CompColorEnum = tvDataColor_CYAN; - } - else if (!colorName.compare("magenta")) { - CompColorEnum = tvDataColor_MAGENTA; - } - return CompColorEnum; - } - - tvError_t AVOutputTV::getParamsCaps(std::string param, capVectors_t &vecInfo) - { - tvError_t ret = tvERROR_NONE; - capDetails_t stringInfo; - - if( ReadCapablitiesFromConf( param, stringInfo) != 0 ) - { - LOGERR( "%s: ReadCapablitiesFromConf Failed !!!\n",__FUNCTION__); - return tvERROR_GENERAL; - } - else - { - spliltCapablities( vecInfo, stringInfo); - } - return ret; - } - - int AVOutputTV::GetPanelID(char *panelId) - { - if (panelId == NULL) { - printf("Invalid buffer provided for panel ID\n"); - return -1; - } - - const char *command = "/usr/bin/panelIDConfig -i"; - FILE *fp; - - // Execute the binary - fp = popen(command, "r"); - if (fp == NULL) { - printf("Failed to execute command: %s\n", command); - return -1; - } - - // Read the panel ID from the binary's output - if (fgets(panelId, 20, fp) != NULL) { - size_t len = strlen(panelId); - if (len > 0 && panelId[len - 1] == '\n') { - panelId[len - 1] = '\0'; - } - } else { - printf("Failed to read panel ID from panelIDConfig binary\n"); - pclose(fp); - return -1; - } - - pclose(fp); - return 0; - } - - int AVOutputTV::ConvertHDRFormatToContentFormat(tvhdr_type_t hdrFormat) - { - int ret=tvContentFormatType_SDR; - switch(hdrFormat) - { - case HDR_TYPE_SDR: - ret=tvContentFormatType_SDR; - break; - case HDR_TYPE_HDR10: - ret=tvContentFormatType_HDR10; - break; - case HDR_TYPE_HDR10PLUS: - ret=tvContentFormatType_HDR10PLUS; - break; - case HDR_TYPE_DOVI: - ret=tvContentFormatType_DOVI; - break; - case HDR_TYPE_HLG: - ret=tvContentFormatType_HLG; - break; - default: - break; - } - return ret; - } - - void AVOutputTV::getDimmingModeStringFromEnum(int value, std::string &toStore) - { - const char *color_temp_string[] = { - [tvDimmingMode_Fixed] = "fixed", - [tvDimmingMode_Local] = "local", - [tvDimmingMode_Global] = "global", - }; - toStore.clear(); - toStore+=color_temp_string[value]; - } - - void AVOutputTV::getColorTempStringFromEnum(int value, std::string &toStore) - { - const char *color_temp_string[] = { - [tvColorTemp_STANDARD] = "Standard", - [tvColorTemp_WARM] = "Warm", - [tvColorTemp_COLD] = "Cold", - [tvColorTemp_USER] = "UserDefined" - }; - toStore.clear(); - toStore+=color_temp_string[value]; - } - - int AVOutputTV::getCurrentPictureMode(char *picMode) - { - tvError_t ret = tvERROR_NONE; - TR181_ParamData_t param; - std::string tr181_param_name; - tvVideoSrcType_t currentSource = VIDEO_SOURCE_IP; - - ret = GetCurrentVideoSource(¤tSource); - if(ret != tvERROR_NONE) { - LOGERR("GetCurrentVideoSource() Failed set source to default\n"); - return 0; - } - - tvVideoFormatType_t current_format = VIDEO_FORMAT_NONE; - GetCurrentVideoFormat(¤t_format); - if ( current_format == VIDEO_FORMAT_NONE) { - current_format = VIDEO_FORMAT_SDR; - } - - tr181_param_name += std::string(AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM); - tr181_param_name += "." + convertSourceIndexToString(currentSource) + "." + "Format."+convertVideoFormatToString(current_format)+"."+"PictureModeString"; - - memset(¶m, 0, sizeof(param)); - - tr181ErrorCode_t err = getLocalParam(rfc_caller_id, tr181_param_name.c_str(), ¶m); - if ( err == tr181Success ) { - strncpy(picMode, param.value, strlen(param.value)+1); - picMode[strlen(param.value)] = '\0'; - LOGINFO("getLocalParam success, mode = %s\n", picMode); - return 1; - } - else { - LOGERR("getLocalParam failed %s\n",tr181_param_name.c_str()); - return 0; - } - } - - tvDolbyMode_t AVOutputTV::GetDolbyVisionEnumFromModeString(const char* modeString) - { - if (strcmp(modeString, "Invalid") == 0) { - return tvDolbyMode_Invalid; - } else if (strcmp(modeString, "Dark") == 0) { - return tvDolbyMode_Dark; - } else if (strcmp(modeString, "Bright") == 0) { - return tvDolbyMode_Bright; - } else if (strcmp(modeString, "Game") == 0) { - return tvDolbyMode_Game; - } - return tvDolbyMode_Invalid; // Default case for invalid input - } - - std::string AVOutputTV::getDolbyModeStringFromEnum( tvDolbyMode_t mode) - { - std::string value; - switch(mode) { - case tvDolbyMode_Dark: - case tvHDR10Mode_Dark: - case tvHLGMode_Dark: - value = "Dark"; - break; - case tvDolbyMode_Bright: - case tvHDR10Mode_Bright: - case tvHLGMode_Bright: - value = "Bright"; - break; - case tvDolbyMode_Game: - case tvHDR10Mode_Game: - case tvHLGMode_Game: - value = "Game"; - break; - default: - break; - } - - return value; - } - - int AVOutputTV::getAvailableCapabilityModesWrapper(std::string param, std::string & outparam) - { - tvError_t err = tvERROR_NONE; - capVectors_t info; - - err = getParamsCaps(param,info); - if (err != tvERROR_NONE) { - LOGERR("%s: failed to get [%s] capability \n", __FUNCTION__, param.c_str()); - return -1; - } - outparam = convertToString(info.rangeVector); - - return 0; - } - - int AVOutputTV::getAvailableCapabilityModes( capDetails_t &info) - { - if ((info.pqmode.compare("none") == 0 )) { - if (getAvailableCapabilityModesWrapper("PictureMode", info.pqmode) != 0) { - LOGERR("%s: failed to get picture mode capability \n", __FUNCTION__); - return -1; - } - } - - if( (info.source.compare("none") == 0)) { - if (getAvailableCapabilityModesWrapper("VideoSource",info.source) != 0) { - LOGERR("%s: failed to get source capability \n", __FUNCTION__); - return -1; - } - } - - if( (info.format.compare("none") == 0) ) { - if (getAvailableCapabilityModesWrapper("VideoFormat",info.format) != 0) { - LOGERR("%s: failed to get format capability \n", __FUNCTION__); - return -1; - } - } - return 0; - } - - int AVOutputTV::getCapabilitySource(JsonArray & rangeArray) - { - capVectors_t info; - - tvError_t ret = getParamsCaps("VideoSource",info); - - if(ret != tvERROR_NONE) { - return -1; - } - else { - if ((info.rangeVector.front()).compare("none") != 0) { - for (unsigned int index = 0; index < info.rangeVector.size(); index++) { - rangeArray.Add(info.rangeVector[index]); - } - } - } - return 0; - } - - int AVOutputTV::getRangeCapability(std::string param, std::vector & rangeInfo) - { - capVectors_t info; - - tvError_t ret = getParamsCaps(param,info); - - if(ret != tvERROR_NONE) { - return -1; - } - else { - if ((info.rangeVector.front()).compare("none") != 0) { - rangeInfo = info.rangeVector; - } - } - return 0; - } - - void AVOutputTV::getDynamicAutoLatencyConfig() - { - RFC_ParamData_t param = {0}; - WDMP_STATUS status = getRFCParameter((char *)AVOUTPUT_RFC_CALLERID, AVOUTPUT_DALS_RFC_PARAM, ¶m); - LOGINFO("RFC value for DALS - %s", param.value); - if(WDMP_SUCCESS == status && param.type == WDMP_BOOLEAN && (strncasecmp(param.value,"true",4) == 0)) { - m_isDalsEnabled = true; - LOGINFO("Value of m_isDalsEnabled is %d", m_isDalsEnabled); - } - else { - LOGINFO("Failed to fetch RFC or DALS is disabled"); - } - } - - - tvError_t AVOutputTV::getUserSelectedAspectRatio (tvDisplayMode_t* mode) - { - tvError_t ret = tvERROR_GENERAL; -#if !defined (HDMIIN_4K_ZOOM) - LOGERR("%s:mode selected is: %d", __FUNCTION__, m_videoZoomMode); - if (AVOutputTV::instance->m_isDisabledHdmiIn4KZoom) { - if (!(AVOutputTV::instance->m_currentHdmiInResolutonm_currentHdmiInResoluton))) { - *mode = (tvDisplayMode_t)AVOutputTV::instance->m_videoZoomMode; - LOGWARN("%s: Getting zoom mode %d for display, for 4K and above", __FUNCTION__, *mode); - return tvERROR_NONE; - } - } -#endif - ret = GetAspectRatio(mode); - return ret; - } - - void AVOutputTV::broadcastLowLatencyModeChangeEvent(bool lowLatencyMode) - { - LOGINFO("Entry:%d\n",lowLatencyMode); - JsonObject response; - response["lowLatencyMode"] = lowLatencyMode; - sendNotify("gameModeEvent", response); - } - - tvError_t AVOutputTV::setAspectRatioZoomSettings(tvDisplayMode_t mode) - { - tvError_t ret = tvERROR_GENERAL; - LOGERR("%s: mode selected is: %d", __FUNCTION__, m_videoZoomMode); -#if !defined (HDMIIN_4K_ZOOM) - if (AVOutputTV::instance->m_isDisabledHdmiIn4KZoom) { - if (AVOutputTV::instance->m_currentHdmiInResolutonm_isDisabledHdmiIn4KZoom); - ret = SetAspectRatio((tvDisplayMode_t)m_videoZoomMode); - } -#endif - return ret; - } - - tvError_t AVOutputTV::setDefaultAspectRatio(std::string pqmode,std::string format,std::string source) - { - tvDisplayMode_t mode = tvDisplayMode_MAX; - TR181_ParamData_t param; - tvError_t ret = tvERROR_NONE; - capDetails_t inputInfo; - - inputInfo.pqmode = pqmode; - inputInfo.source = source; - inputInfo.format = format; - - memset(¶m, 0, sizeof(param)); - tr181ErrorCode_t err = getLocalParam(rfc_caller_id, AVOUTPUT_ASPECTRATIO_RFC_PARAM, ¶m); - if ( tr181Success == err ) { - if(!std::string(param.value).compare("16:9")) { - mode = tvDisplayMode_16x9; - } - else if (!std::string(param.value).compare("4:3")) { - mode = tvDisplayMode_4x3; - } - else if (!std::string(param.value).compare("Full")) { - mode = tvDisplayMode_FULL; - } - else if (!std::string(param.value).compare("Normal")) { - mode = tvDisplayMode_NORMAL; - } - else if (!std::string(param.value).compare("TV AUTO")) { - mode = tvDisplayMode_AUTO; - } - else if (!std::string(param.value).compare("TV DIRECT")) { - mode = tvDisplayMode_DIRECT; - } - else if (!std::string(param.value).compare("TV NORMAL")) { - mode = tvDisplayMode_NORMAL; - } - else if (!std::string(param.value).compare("TV ZOOM")) { - mode = tvDisplayMode_ZOOM; - } - else if (!std::string(param.value).compare("TV 16X9 STRETCH")) { - mode = tvDisplayMode_16x9; - } - else if (!std::string(param.value).compare("TV 4X3 PILLARBOX")) { - mode = tvDisplayMode_4x3; - } - else { - mode = tvDisplayMode_AUTO; - } - - m_videoZoomMode = mode; - tvError_t ret = setAspectRatioZoomSettings (mode); - - if(ret != tvERROR_NONE) { - LOGERR("AspectRatio set failed: %s\n",getErrorString(ret).c_str()); - } - else { - //Save DisplayMode to ssm_data - int retval=updateAVoutputTVParam("set","ZoomMode",inputInfo,PQ_PARAM_ASPECT_RATIO,mode); - - if(retval != 0) { - LOGERR("Failed to Save DisplayMode to ssm_data\n"); - ret = tvERROR_GENERAL; - } - LOGINFO("Aspect Ratio initialized successfully, value: %s\n", param.value); - } - - } - else { - LOGERR("getLocalParam for %s Failed : %s\n", AVOUTPUT_ASPECTRATIO_RFC_PARAM, getTR181ErrorString(err)); - ret = tvERROR_GENERAL; - } - return ret; - } - - int AVOutputTV::getCMSComponentEnumFromString(std::string component, tvComponentType_t& value) - { - int ret = 0; - - if( component.compare("Luma") == 0 ) - value = COMP_LUMA; - else if( component.compare("Saturation") == 0 ) - value = COMP_SATURATION; - else if( component.compare("Hue") == 0 ) - value = COMP_HUE; - else - ret = -1; - - return ret; - } - - int AVOutputTV::getCMSColorEnumFromString(std::string color,tvDataComponentColor_t& value) - { - int ret = 0; - - if( color.compare("Red") == 0 ) - value = tvDataColor_RED; - else if( color.compare("Green") == 0 ) - value = tvDataColor_GREEN; - else if( color.compare("Blue") == 0 ) - value = tvDataColor_BLUE; - else if( color.compare("Yellow") == 0) - value = tvDataColor_YELLOW; - else if( color.compare("Cyan") == 0) - value = tvDataColor_CYAN; - else if( color.compare("Magenta") == 0) - value = tvDataColor_MAGENTA; - else - ret = -1; - - return ret; - } - - int AVOutputTV::getColorTempEnumFromString(std::string color, tvColorTemp_t& value) - { - int ret = 0; - - if( color.compare("Standard") == 0 ) - value = tvColorTemp_STANDARD; - else if( color.compare("Warm") == 0 ) - value = tvColorTemp_WARM; - else if( color.compare("Cold") == 0 ) - value = tvColorTemp_COLD; - else if( color.compare("UserDefined") == 0 ) - value =tvColorTemp_USER; - else - ret = -1; - return ret; - } - - void AVOutputTV::syncCMSParams( ) - { - int level = 0; - std::string cmsParam; - tvPQParameterIndex_t tvPQEnum; - capDetails_t inputInfo; - tvDataComponentColor_t colors[] = {tvDataColor_RED,tvDataColor_GREEN,tvDataColor_BLUE,tvDataColor_YELLOW,tvDataColor_CYAN,tvDataColor_MAGENTA}; - - inputInfo.pqmode = "none"; - inputInfo.source = "none"; - inputInfo.format = "none"; - - for ( int component = COMP_HUE; component < COMP_MAX;component++) { - for(int count = 0;count < (int)(sizeof(colors)/sizeof(colors[0])); ++count) { - tvDataComponentColor_t color = colors[count]; - std::string componentString = getCMSComponentStringFromEnum((tvComponentType_t)component); - std::string colorString = getCMSColorStringFromEnum((tvDataComponentColor_t)color); - cmsParam = componentString+"."+colorString; - - if ( convertCMSParamToPQEnum(componentString,colorString,tvPQEnum) != 0 ) { - LOGINFO("%s: %s/%s Param Not Found \n",__FUNCTION__,componentString.c_str(),componentString.c_str()); - continue; - } - - inputInfo.color = colorString; - inputInfo.component = componentString; - if( !updateAVoutputTVParam("sync","CMS", inputInfo,tvPQEnum,level)) - LOGINFO("CMS Successfully Synced to Drive Cache\n"); - else - LOGERR("CMS Sync to cache Failed !!!\n"); - } - } - } - - void AVOutputTV::syncWBParams( ) - { - int level = 0; - tvPQParameterIndex_t tvPQEnum; - capDetails_t inputInfo; - - inputInfo.pqmode = "none"; - inputInfo.source = "none"; - inputInfo.format = "none"; - - for( int colorIndex= tvWB_COLOR_RED; colorIndex < tvWB_COLOR_MAX; colorIndex++) { - for(int controlIndex = tvWB_CONTROL_GAIN;controlIndex < tvWB_CONTROL_MAX;controlIndex++) { - inputInfo.control = getWBControlStringFromEnum((tvWBControl_t)controlIndex); - inputInfo.color = getWBColorStringFromEnum((tvWBColor_t)colorIndex); - - if ( convertWBParamToPQEnum(inputInfo.control,inputInfo.color,tvPQEnum) != 0 ) { - LOGERR("%s: %s/%s Param Not Found \n",__FUNCTION__,inputInfo.control.c_str(),inputInfo.color.c_str()); - } - updateAVoutputTVParam("sync","WhiteBalance",inputInfo,tvPQEnum,level); - } - } - } - - - int AVOutputTV:: convertCMSParamToPQEnum(const std::string component, const std::string color,tvPQParameterIndex_t& value) { - // Create a map to associate color-component pairs with enum values - int ret = 0; - static const std::unordered_map colorComponentMap = { - {"SaturationRed", PQ_PARAM_CMS_SATURATION_RED}, - {"SaturationGreen", PQ_PARAM_CMS_SATURATION_GREEN}, - {"SaturationBlue", PQ_PARAM_CMS_SATURATION_BLUE}, - {"SaturationCyan", PQ_PARAM_CMS_SATURATION_CYAN}, - {"SaturationMagenta", PQ_PARAM_CMS_SATURATION_MAGENTA}, - {"SaturationYellow", PQ_PARAM_CMS_SATURATION_YELLOW}, - {"HueRed", PQ_PARAM_CMS_HUE_RED}, - {"HueGreen", PQ_PARAM_CMS_HUE_GREEN}, - {"HueBlue", PQ_PARAM_CMS_HUE_BLUE}, - {"HueCyan", PQ_PARAM_CMS_HUE_CYAN}, - {"HueMagenta", PQ_PARAM_CMS_HUE_MAGENTA}, - {"HueYellow", PQ_PARAM_CMS_HUE_YELLOW}, - {"LumaRed", PQ_PARAM_CMS_LUMA_RED}, - {"LumaGreen", PQ_PARAM_CMS_LUMA_GREEN}, - {"LumaBlue", PQ_PARAM_CMS_LUMA_BLUE}, - {"LumaCyan", PQ_PARAM_CMS_LUMA_CYAN}, - {"LumaMagenta", PQ_PARAM_CMS_LUMA_MAGENTA}, - {"LumaYellow", PQ_PARAM_CMS_LUMA_YELLOW} - }; - - // Create the key by concatenating the component and color - std::string key = component + color; - - // Look up the key in the map - auto it = colorComponentMap.find(key); - if (it != colorComponentMap.end()) { - value = it->second; - ret = 0; - } else { - LOGERR("%s : Invalid color/component\n",__FUNCTION__); - ret = -1; - } - return ret; - } - - int AVOutputTV:: convertWBParamToRGBEnum(const std::string color,std::string control,tvRGBType_t &value) - { - // Create a map to associate color-ntrol pairs with enum values - int ret = 0; - static const std::unordered_map colorControlMap = { - {"RedGain", R_GAIN}, - {"GreenGain", G_GAIN}, - {"BlueGain", B_GAIN}, - {"RedOffset", R_POST_OFFSET}, - {"GreenOffset", G_POST_OFFSET}, - {"BlueOffset", B_POST_OFFSET} - }; - - // Create the key by concatenating the color and control - std::string key = color + control; - - // Look up the key in the map - auto it = colorControlMap.find(key); - if (it != colorControlMap.end()) { - value = it->second; - ret = 0; - } else { - LOGERR("%s : Invalid color/control\n",__FUNCTION__); - ret = -1; - } - return ret; - } - - int AVOutputTV:: convertWBParamToPQEnum(const std::string control, const std::string color,tvPQParameterIndex_t& value) { - // Create a map to associate color-component pairs with enum values - int ret = 0; - static const std::unordered_map colorControlMap = { - {"RedGain", PQ_PARAM_WB_GAIN_RED}, - {"RedOffset", PQ_PARAM_WB_OFFSET_RED}, - {"GreenGain", PQ_PARAM_WB_GAIN_GREEN}, - {"GreenOffset", PQ_PARAM_WB_OFFSET_GREEN}, - {"BlueGain", PQ_PARAM_WB_GAIN_BLUE}, - {"BlueOffset", PQ_PARAM_WB_OFFSET_BLUE}, - }; - - // Create the key by concatenating the component and color - std::string key = color+control; - - // Look up the key in the map - auto it = colorControlMap.find(key); - if (it != colorControlMap.end()) { - value = it->second; - ret = 0; - } else { - LOGERR("%s : Invalid color/control\n",__FUNCTION__); - ret = -1; - } - return ret; - } - - std::string AVOutputTV::getCMSColorStringFromEnum(tvDataComponentColor_t value) - { - switch(value) - { - case tvDataColor_RED: return "Red"; - case tvDataColor_GREEN: return "Green"; - case tvDataColor_BLUE: return "Blue"; - case tvDataColor_YELLOW: return "Yellow"; - case tvDataColor_CYAN: return "Cyan"; - case tvDataColor_MAGENTA: return "Magenta"; - default : return "Max"; - } - } - - std::string AVOutputTV::getCMSComponentStringFromEnum(tvComponentType_t value) { - switch(value) { - case COMP_HUE: return "Hue"; - case COMP_SATURATION: return "Saturation"; - case COMP_LUMA: return "Luma"; - default : return "Max"; - } - } - - std::string AVOutputTV::getWBColorStringFromEnum(tvWBColor_t value) { - switch(value) { - case tvWB_COLOR_RED: return "Red"; - case tvWB_COLOR_GREEN: return "Green"; - case tvWB_COLOR_BLUE: return "Blue"; - default : return "Max"; - } - } - - std::string AVOutputTV::getWBControlStringFromEnum(tvWBControl_t value) { - switch(value) - { - case tvWB_CONTROL_GAIN: return "Gain"; - case tvWB_CONTROL_OFFSET: return "Offset"; - default: return "Max"; - } - } - - int AVOutputTV::getWBColorEnumFromString(std::string color,tvWBColor_t& value) { - int ret = 0; - - if( color.compare("Red") == 0 ) - value = tvWB_COLOR_RED; - else if( color.compare("Green") == 0 ) - value = tvWB_COLOR_GREEN; - else if( color.compare("Blue") == 0 ) - value = tvWB_COLOR_BLUE; - else - ret = -1; - - return ret; - } - - int AVOutputTV::getWBControlEnumFromString(std::string color,tvWBControl_t& value) { - int ret = 0; - - if( color.compare("Gain") == 0 ) - value = tvWB_CONTROL_GAIN; - else if( color.compare("Offset") == 0 ) - value = tvWB_CONTROL_OFFSET; - else - ret = -1; - - return ret; - } - - std::string AVOutputTV::getColorTemperatureStringFromEnum(tvColorTemp_t value) { - switch(value) { - case tvColorTemp_STANDARD: return "Standard"; - case tvColorTemp_WARM: return "Warm"; - case tvColorTemp_COLD: return "Cold"; - case tvColorTemp_USER : return "UserDefined"; - default : return "Max"; - } - } - - int AVOutputTV:: validateCMSParameter(std::string component,int inputValue) - { - capVectors_t info; - tvError_t ret = getParamsCaps("CMS", info); - - LOGINFO("%s : component : %s inputValue : %d\n",__FUNCTION__,component.c_str(),inputValue); - - if (ret != tvERROR_NONE) { - LOGERR("Failed to fetch the range capability \n"); - return -1; - } - - if( component == "Saturation" ) { - if (inputValue < stoi(info.rangeVector[0]) || inputValue > std::stoi(info.rangeVector[1])) { - LOGERR("wrong Input value[%d] for %s\n", inputValue,component.c_str()); - return -1; - } - } else if ( component == "Hue" ) { - if (inputValue < stoi(info.rangeVector[2]) || inputValue > std::stoi(info.rangeVector[3])) { - LOGERR("wrong Input value[%d] for %s\n", inputValue,component.c_str()); - return -1; - } - } else if ( component == "Luma" ) { - if (inputValue < stoi(info.rangeVector[4]) || inputValue > std::stoi(info.rangeVector[5])) { - LOGERR("wrong Input value[%d] for %s\n", inputValue,component.c_str()); - return -1; - } - } - return 0; - } - - int AVOutputTV:: validateWBParameter(std::string param,std::string control,int inputValue) - { - capVectors_t info; - tvError_t ret = getParamsCaps(param, info); - - if (ret != tvERROR_NONE) { - LOGERR("Failed to fetch the range capability[%s] \n", param.c_str()); - return -1; - } - - if( control == "Gain" ) { - if (inputValue < stoi(info.rangeVector[0]) || inputValue > std::stoi(info.rangeVector[1])) { - LOGERR("wrong Input value[%d] for %s\n", inputValue,control.c_str()); - return -1; - } - } else if ( control == "Offset" ) { - if (inputValue < stoi(info.rangeVector[2]) || inputValue > std::stoi(info.rangeVector[3])) { - LOGERR("wrong Input value[%d] for %s\n", inputValue,control.c_str()); - return -1; - } - } - return 0; - } - - int AVOutputTV::ReadCapablitiesFromConf(std::string param, capDetails_t& info) - { - int ret = 0; - - /*Consider User WhiteBalance as CustomWhiteBalance - To avoid clash with Factory WhiteBalance Calibration capablities*/ - - if ( param == "WhiteBalance") { - param = "CustomWhiteBalance"; - } else if ( param == "AutoBacklightMode") { - param = "BacklightControl"; - } - - try { - CIniFile inFile(CAPABLITY_FILE_NAME); - std::string configString; - - if(param == "CMS") - { - configString = param + ".color"; - info.color = inFile.Get(configString); - - configString = param + ".component"; - info.component = inFile.Get(configString); - } - - if(param == "CustomWhiteBalance") - { - configString = param + ".color"; - info.color = inFile.Get(configString); - - configString = param + ".control"; - info.control = inFile.Get(configString); - - } - - if ((param == "DolbyVisionMode") || (param == "Backlight") || (param == "CMS") || (param == "CustomWhiteBalance") || (param == "HDRMode") || (param == "BacklightControl")) { - configString = param + ".platformsupport"; - info.isPlatformSupport = inFile.Get(configString); - printf(" platformsupport : %s\n",info.isPlatformSupport.c_str() ); - } - - if ( (param == "ColorTemperature") || (param == "DimmingMode") || - ( param == "BacklightControl") || (param == "DolbyVisionMode") || - (param == "HDR10Mode") || (param == "HLGMode") || (param == "AspectRatio") || - (param == "PictureMode") || (param == "VideoSource") || (param == "VideoFormat") || - (param == "VideoFrameRate") || (param == "HDRMode") ) { - configString = param + ".range"; - info.range = inFile.Get(configString); - printf(" String Range info : %s\n",info.range.c_str() ); - } else if ( (param == "CMS" )) { - configString.clear(); - configString = param + ".range_Saturation_from"; - info.range = inFile.Get(configString); - configString = param + ".range_Saturation_to"; - info.range += ","+inFile.Get(configString); - - configString = param + ".range_Hue_from"; - info.range += ","+inFile.Get(configString); - configString = param + ".range_Hue_to"; - info.range += ","+inFile.Get(configString); - - configString = param + ".range_Luma_from"; - info.range += ","+inFile.Get(configString); - configString = param + ".range_Luma_to"; - info.range += ","+inFile.Get(configString); - } else if ( (param == "CustomWhiteBalance")) { - configString = param + ".range_Gain_from"; - info.range = inFile.Get(configString); - configString = param + ".range_Gain_to"; - info.range += ","+inFile.Get(configString); - - configString = param + ".range_Offset_from"; - info.range += ","+inFile.Get(configString); - configString = param + ".range_Offset_to"; - info.range += ","+inFile.Get(configString); - } else { - configString = param + ".range_from"; - info.range = inFile.Get(configString); - configString = param + ".range_to"; - info.range += ","+inFile.Get(configString); - printf(" Integer Range Info : %s\n",info.range.c_str() ); - } - - if ((param == "VideoSource") || (param == "PictureMode") || (param == "VideoFormat") ) { - configString.clear(); - configString = param + ".index"; - info.index = inFile.Get(configString); - printf("Index value %s\n", info.index.c_str()); - } - - configString.clear(); - configString = param + ".pqmode"; - info.pqmode = inFile.Get(configString); - configString = param + ".format"; - info.format = inFile.Get(configString); - configString = param + ".source"; - info.source = inFile.Get(configString); - ret = 0; - } - catch(const boost::property_tree::ptree_error &e) { - printf("%s: error %s::config table entry not found in ini file\n",__FUNCTION__,e.what()); - ret = -1; - } - return ret; - } - - bool AVOutputTV::checkCMSColorAndComponentCapability(const std::string capValue, const std::string inputValue) { - // Parse capValue into a set - std::set capSet; - std::istringstream capStream(capValue); - std::string token; - - while (std::getline(capStream, token, ',')) { - capSet.insert(token); - } - - // Parse inputValue and check if each item exists in the set - std::istringstream inputStream(inputValue); - while (std::getline(inputStream, token, ',')) { - if (capSet.find(token) == capSet.end()) { - return false; - } - } - return true; - } - -} //namespace Plugin -} //namespace WPEFramework diff --git a/AVOutput/CHANGELOG.md b/AVOutput/CHANGELOG.md deleted file mode 100644 index a3afa1227..000000000 --- a/AVOutput/CHANGELOG.md +++ /dev/null @@ -1,31 +0,0 @@ -# Changelog - -All notable changes to this RDK Service will be documented in this file. - -* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. - -* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: - * **Added** for new features. - * **Changed** for changes in existing functionality. - * **Deprecated** for soon-to-be removed features. - * **Removed** for now removed features. - * **Fixed** for any bug fixes. - * **Security** in case of vulnerabilities. - -* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. - -## [1.1.0] - 2025-03-14 -### Added -- Add additional features on AVOutput - -## [1.0.10] - 2025-02-17 -### Fixed -ODM API removal changes phase 1 and Fixed PQ Mode Camel Case issue - -## [1.0.0] - 2025-02-17 -### Added -- Add CHANGELOG - -### Change -- Reset API version to 1.0.0 -- Change README to inform how to update changelog and API version diff --git a/AVOutput/CMakeLists.txt b/AVOutput/CMakeLists.txt deleted file mode 100644 index a35894280..000000000 --- a/AVOutput/CMakeLists.txt +++ /dev/null @@ -1,95 +0,0 @@ -# If not stated otherwise in this file or this component's LICENSE file the -# following copyright and licenses apply: -# -# Copyright 2024 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. - -cmake_minimum_required (VERSION 2.6) - -Project(AVOUTPUT-PLUGINS) - -set(CMAKE_BUILD_TYPE "Debug") - -set(PLUGIN_NAME AVOutput) - -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) - -set(PLUGIN_AVOUTPUT_AUTOSTART "true" CACHE STRING "Automatically start AVOutput plugin") - -find_package(WPEFramework) -find_package(${NAMESPACE}Plugins REQUIRED) - -set (CMAKE_CXX_STANDARD 11) - -find_path (STAGING_INCDIR glib-2.0) -include_directories(${STAGING_INCDIR}) -include_directories(${STAGING_INCDIR}/glib-2.0) -include_directories(${STAGING_INCDIR}/../lib/glib-2.0/include) -include_directories(${STAGING_INCDIR}/rdk/iarmbus) -include_directories(${STAGING_INCDIR}/rdk/iarmmgrs-hal) -include_directories(${STAGING_INCDIR}/rdk/tv-hal) -include_directories(${STAGING_INCDIR}/rdk/ds-hal) -include_directories(${STAGING_INCDIR}/rdk/ds-rpc) -include_directories(${STAGING_INCDIR}/rdk/ds) - -if (AVOUTPUT_TV) -add_library(${MODULE_NAME} SHARED - AVOutputBase.cpp - AVOutputTV.cpp - AVOutputTVHelper.cpp - AVOutput.cpp - Module.cpp) - if (NOT RDK_SERVICE_L2_TEST) - target_link_libraries(${MODULE_NAME} "-lglib-2.0 -lpthread -lIARMBus -ltvsettings-hal -ltr181api -lds") - endif() -else() -add_library(${MODULE_NAME} SHARED - AVOutputBase.cpp - AVOutputSTB.cpp - AVOutput.cpp - Module.cpp) -target_link_libraries(${MODULE_NAME} "-lglib-2.0 -lpthread -lIARMBus -lds") -endif() - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -if (RDK_SERVICE_L2_TEST) - find_library(TESTMOCKLIB_LIBRARIES NAMES TestMocklib) - if (TESTMOCKLIB_LIBRARIES) - message ("linking mock libraries ${TESTMOCKLIB_LIBRARIES} library") - target_link_libraries(${MODULE_NAME} PRIVATE ${TESTMOCKLIB_LIBRARIES}) - else (TESTMOCKLIB_LIBRARIES) - message ("Require ${TESTMOCKLIB_LIBRARIES} library") - endif (TESTMOCKLIB_LIBRARIES) -endif (RDK_SERVICES_L2_TEST) - -list(APPEND CMAKE_MODULE_PATH - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") - -find_package(DS) - -target_include_directories(${MODULE_NAME} PRIVATE ${DS_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PRIVATE ../helpers) - -target_link_libraries(${MODULE_NAME} - PRIVATE - ${NAMESPACE}Plugins::${NAMESPACE}Plugins) - - -install(TARGETS ${MODULE_NAME} - DESTINATION lib/wpeframework/plugins) - -write_config(${PLUGIN_NAME}) diff --git a/AVOutput/Module.cpp b/AVOutput/Module.cpp deleted file mode 100644 index 792693e24..000000000 --- a/AVOutput/Module.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2024 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 "Module.h" - -MODULE_NAME_DECLARATION(BUILD_REFERENCE) - diff --git a/AVOutput/Module.h b/AVOutput/Module.h deleted file mode 100644 index 63db43d27..000000000 --- a/AVOutput/Module.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2024 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. -*/ - -#ifndef __MODULE_PLUGIN_FRONTPANEL_H -#define __MODULE_PLUGIN_FRONTPANEL_H - - -#ifndef MODULE_NAME -#define MODULE_NAME Plugin_AVOutput -#endif - -#include -#include -#include - - - -#endif // __MODULE_PLUGIN_FRONTPANEL_H - diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 73149475f..000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,139 +0,0 @@ -### Changelog - -All notable changes to this project will be documented in this file. Dates are displayed in UTC. - -Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - -#### [1.1.0](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.12...1.1.0) - -- RDK-52028 : Add CMS,WB,ALS to AVOutput (#6139) [`#23`](https://github.com/rdkcentral/entservices-inputoutput/pull/23) -- [RDKEMW-2711] RDKEMW-4232: Moving the L2 Test files to entservices-inputoutput [`#107`](https://github.com/rdkcentral/entservices-inputoutput/pull/107) -- [RDKEMW-2711] RDKEMW-3851: L1 - Move plugins Unit test to inputoutput repo [`#92`](https://github.com/rdkcentral/entservices-inputoutput/pull/92) -- RDKEMW-4155: Fix L1-test for HdcpProfile [`#111`](https://github.com/rdkcentral/entservices-inputoutput/pull/111) -- RDKEMW-4155 : Fix L1/L2 tests for HdcpProfile plugin [`#102`](https://github.com/rdkcentral/entservices-inputoutput/pull/102) -- RDK-55554 : Gtest for HdmiCecSource and sink [`#78`](https://github.com/rdkcentral/entservices-inputoutput/pull/78) -- RDK-55373:[RDKServices] Coverity integration with middleware componen… [`#96`](https://github.com/rdkcentral/entservices-inputoutput/pull/96) -- RDK-55373:[RDKServices] Coverity integration with middleware component workflow [`#94`](https://github.com/rdkcentral/entservices-inputoutput/pull/94) -- Merge tag '1.0.12' into develop [`2019c9f`](https://github.com/rdkcentral/entservices-inputoutput/commit/2019c9f8d72eba911fe9030cf4476ce99c2127de) - -#### [1.0.12](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.11...1.0.12) - -> 1 May 2025 - -- RDKEMW-1014 : Add COM-RPC support to HdcpProfile plugin [`#72`](https://github.com/rdkcentral/entservices-inputoutput/pull/72) -- RDK-55373:[RDKServices] Coverity integration with middleware component workflow [`#80`](https://github.com/rdkcentral/entservices-inputoutput/pull/80) -- [RDKEMW-2711] RDKEMW-2748 : Update the Test Coverage [`#75`](https://github.com/rdkcentral/entservices-inputoutput/pull/75) -- Update Utils.py [`#73`](https://github.com/rdkcentral/entservices-inputoutput/pull/73) -- RDKEMW-1014 - Changelog updates for 1.0.12 [`5f66dc2`](https://github.com/rdkcentral/entservices-inputoutput/commit/5f66dc28ba8ce5a57ba6dddd587db529110298e7) -- Merge tag '1.0.11' into develop [`c86b827`](https://github.com/rdkcentral/entservices-inputoutput/commit/c86b82721e32a4bbc828003d0fd5cf76c77d8cca) - -#### [1.0.11](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.10...1.0.11) - -> 25 April 2025 - -- PowerManager Interface file modified [`#62`](https://github.com/rdkcentral/entservices-inputoutput/pull/62) -- Update TestManager.py for removing frontpanel and hdcpprofile dependencies to execute testcases standalone [`#68`](https://github.com/rdkcentral/entservices-inputoutput/pull/68) -- 1.0.11 release changelog updates [`85c0153`](https://github.com/rdkcentral/entservices-inputoutput/commit/85c0153a722c521a8707a49758f9df1cd4e4dc59) -- Merge tag '1.0.10' into develop [`7a54d8c`](https://github.com/rdkcentral/entservices-inputoutput/commit/7a54d8cdb9da6de8071c19c8efdf48e7ec5bba96) - -#### [1.0.10](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.9...1.0.10) - -> 23 April 2025 - -- RDK-55554 Update return type [`#60`](https://github.com/rdkcentral/entservices-inputoutput/pull/60) -- RDKEMW-3207 [OSCR SCAN] RDKE - entservices-testframework [`#61`](https://github.com/rdkcentral/entservices-inputoutput/pull/61) -- RDK-55554 - Changelog updates for 1.0.10 [`36cea31`](https://github.com/rdkcentral/entservices-inputoutput/commit/36cea315c7be83b561012ea219fb78cbdd60f5d5) -- Modifying L1-tests.yml L2-tests.yml [`fd0a678`](https://github.com/rdkcentral/entservices-inputoutput/commit/fd0a6783526fa0dd6d6541b31aeef4c2d8272fb5) -- Merge tag '1.0.9' into develop [`668cc7c`](https://github.com/rdkcentral/entservices-inputoutput/commit/668cc7ce09864ac16e6c609cabbfcf94ae16faba) - -#### [1.0.9](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.8...1.0.9) - -> 15 April 2025 - -- RDK-57093: Resolved the compilation error [`#55`](https://github.com/rdkcentral/entservices-inputoutput/pull/55) -- 1.0.9 release change log updates [`fb8eb3c`](https://github.com/rdkcentral/entservices-inputoutput/commit/fb8eb3c4fe58d2165dbab6d57d8eab46673ed1f3) -- Merge tag '1.0.8' into develop [`fe37f21`](https://github.com/rdkcentral/entservices-inputoutput/commit/fe37f210ddbf3e698fccc454fd7593e7fb6e4a9d) - -#### [1.0.8](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.7...1.0.8) - -> 14 April 2025 - -- RDK-57093: Update Plugin Clients to use update Power manager interface [`#39`](https://github.com/rdkcentral/entservices-inputoutput/pull/39) -- 1.0.8 release change log updates [`2a859d3`](https://github.com/rdkcentral/entservices-inputoutput/commit/2a859d3da652a2ce6718d8bf678ecf73a6d2643f) -- Merge tag '1.0.7' into develop [`ac5ef43`](https://github.com/rdkcentral/entservices-inputoutput/commit/ac5ef4349be7cb05477dfbe9785aa1a60d1293a1) - -#### [1.0.7](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.6...1.0.7) - -> 11 April 2025 - -- RDKEMW-3359:HdmiCecSink RDK-V to RDK-E sync changes [`#48`](https://github.com/rdkcentral/entservices-inputoutput/pull/48) -- Update run_peru.sh by removing secrets [`#47`](https://github.com/rdkcentral/entservices-inputoutput/pull/47) -- RDK-55408: RDKE Services L2 Test Suite Development [`#30`](https://github.com/rdkcentral/entservices-inputoutput/pull/30) -- RDKEMW-2208 and RDKEMW-2209 Enabling L1 and L2 tests for entservices-inputoutput repo [`#25`](https://github.com/rdkcentral/entservices-inputoutput/pull/25) -- 1.0.7 release change log updates [`65465ee`](https://github.com/rdkcentral/entservices-inputoutput/commit/65465ee6c7cc800f3639a616209560ba800a3173) -- Enabling workflow for L1 and L2 [`4049a2e`](https://github.com/rdkcentral/entservices-inputoutput/commit/4049a2eb188efede1c1547be50847d29ddcb9e03) -- Merge tag '1.0.6' into develop [`f46b084`](https://github.com/rdkcentral/entservices-inputoutput/commit/f46b084ed21e61d89e20868eacdea4ba8198266d) - -#### [1.0.6](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.5...1.0.6) - -> 27 March 2025 - -- Removed Cec host header [`#35`](https://github.com/rdkcentral/entservices-inputoutput/pull/35) -- 1.0.9 release change log updates [`8abd094`](https://github.com/rdkcentral/entservices-inputoutput/commit/8abd09439355af4041436e562c4590769b55bc0c) -- Merge tag '1.0.5' into develop [`3b26eeb`](https://github.com/rdkcentral/entservices-inputoutput/commit/3b26eebfdf0e992e369e5cd3cdc981748c9cdb69) - -#### [1.0.5](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.4...1.0.5) - -> 27 March 2025 - -- RDK-56621: Update all the power manager plugin clients to new register events [`#17`](https://github.com/rdkcentral/entservices-inputoutput/pull/17) -- RDKEMW-2882: Replace the references of tj-actions/changed_files [`#26`](https://github.com/rdkcentral/entservices-inputoutput/pull/26) -- Replace the references of tj-actions/changed_files [`75a649d`](https://github.com/rdkcentral/entservices-inputoutput/commit/75a649d0c19c9f017701ddf408d3bbaf14680529) -- 1.0.5 release change log updates [`8a276be`](https://github.com/rdkcentral/entservices-inputoutput/commit/8a276be4f917dc4e00110ff4cf1456d3d067a0fe) -- Update update-changelog-and-api-version.yml [`6189d2c`](https://github.com/rdkcentral/entservices-inputoutput/commit/6189d2cf132847a726a2f7ca9e950b112e150ec4) - -#### [1.0.4](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.3...1.0.4) - -> 26 March 2025 - -- RDKEMW-1061: RDK-E Add COMRPC [`#29`](https://github.com/rdkcentral/entservices-inputoutput/pull/29) -- Merge pull request #27 from rdkcentral/feature/RDKEMW-1061-RDK-E-Add-… [`#28`](https://github.com/rdkcentral/entservices-inputoutput/pull/28) -- RDKEMW-1061: RDK-E Add COMRPC [`#27`](https://github.com/rdkcentral/entservices-inputoutput/pull/27) -- 1.0.4 release change log updates [`77d6ace`](https://github.com/rdkcentral/entservices-inputoutput/commit/77d6ace1230f6d08fe2604f4de0673bb16fbebe2) -- Merge tag '1.0.3' into develop [`9d73332`](https://github.com/rdkcentral/entservices-inputoutput/commit/9d7333267973f791c7183192c7fce499cbc26efc) - -#### [1.0.3](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.2...1.0.3) - -> 3 March 2025 - -- RDKEMW-1691 : Revert Unsupported plugin changes [`#13`](https://github.com/rdkcentral/entservices-inputoutput/pull/13) -- RDKEMW-1691 - Changelog updates for 1.0.3 [`bdbe8c0`](https://github.com/rdkcentral/entservices-inputoutput/commit/bdbe8c0e9572f79e390106242ca7b84880a208ad) -- Merge tag '1.0.2' into develop [`00db359`](https://github.com/rdkcentral/entservices-inputoutput/commit/00db359737a5db24230be599bbe5f3b0345b9673) - -#### [1.0.2](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.1...1.0.2) - -> 25 February 2025 - -- RDKEMW-1691 : Remove unsupported plugins in rdk-e [`#4`](https://github.com/rdkcentral/entservices-inputoutput/pull/4) -- RDK-55887: Update the Plugin Client with QueryInterface with CallSign [`#8`](https://github.com/rdkcentral/entservices-inputoutput/pull/8) -- test [`43988dc`](https://github.com/rdkcentral/entservices-inputoutput/commit/43988dcac9cd750a0afab83f2e85c44f3cb79b7b) -- Delete HdmiInput directory [`73fdb8c`](https://github.com/rdkcentral/entservices-inputoutput/commit/73fdb8c516741a054e8e9026816a6fd92cecbbf8) -- Delete CompositeInput directory [`1b86833`](https://github.com/rdkcentral/entservices-inputoutput/commit/1b8683384658fe40c9bb6fcb0f5f8976b0f37db4) - -#### [1.0.1](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.0...1.0.1) - -> 19 February 2025 - -- Update AVInput AVOutput plugins with latest HPK 1.4.4 interface options [`#3`](https://github.com/rdkcentral/entservices-inputoutput/pull/3) -- RDKE-672 - Changelog updates for 1.0.0 [`#2`](https://github.com/rdkcentral/entservices-inputoutput/pull/2) -- RDKE-672 - Changelog updates for 1.0.0 [`#1`](https://github.com/rdkcentral/entservices-inputoutput/pull/1) -- Remove ODM APIs - Phase 1 [`0dd73c6`](https://github.com/rdkcentral/entservices-inputoutput/commit/0dd73c6e92a8b197fa2bb8a1d0e7614c0acb3d0b) -- Composite VideoMode update [`b89381b`](https://github.com/rdkcentral/entservices-inputoutput/commit/b89381be1c5931a918fbf0c677e9539503185245) -- RDKServices changes - getHdmiVersion [`7e0ef17`](https://github.com/rdkcentral/entservices-inputoutput/commit/7e0ef17e4baed5ff3449b645cf3c56211c39c76c) - -#### 1.0.0 - -> 11 February 2025 - -- Import of source (develop) [`372d6b2`](https://github.com/rdkcentral/entservices-inputoutput/commit/372d6b20ee46251ab21e35d600c381a570428ab4) -- RDKE-672 - Changelog updates for 1.0.0 [`349d9b7`](https://github.com/rdkcentral/entservices-inputoutput/commit/349d9b762cb935487511b69c9f05ae52871d2b03) diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index df70686ac..000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,85 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2023 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. -### - -cmake_minimum_required(VERSION 3.3) - -find_package(WPEFramework) - -# All packages that did not deliver a CMake Find script (and some deprecated scripts that need to be removed) -# are located in the cmake directory. Include it in the search. -list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") - -option(COMCAST_CONFIG "Comcast services configuration" ON) -if(COMCAST_CONFIG) - include(services.cmake) -endif() - -# Library installation section -string(TOLOWER ${NAMESPACE} STORAGE_DIRECTORY) - -# for writing pc and config files -include(CmakeHelperFunctions) - -if(RDK_SERVICE_L2_TEST) -# add_subdirectory(Tests/L2Tests) -endif() - -if(RDK_SERVICES_L1_TEST) - add_subdirectory(Tests/L1Tests) -endif() - -if(PLUGIN_AVINPUT) - add_subdirectory(AVInput) -endif() - -if(PLUGIN_AVOUTPUT) - add_subdirectory(AVOutput) -endif() - -if(PLUGIN_HDMICECSOURCE) - add_subdirectory(HdmiCecSource) -endif() - -if(PLUGIN_HDMICECSINK) - add_subdirectory(HdmiCecSink) -endif() - -if(PLUGIN_HDCPPROFILE) - add_subdirectory(HdcpProfile) -endif() - -if(PLUGIN_HDMIINPUT) - add_subdirectory(HdmiInput) -endif() - - -if(WPEFRAMEWORK_CREATE_IPKG_TARGETS) - set(CPACK_GENERATOR "DEB") - set(CPACK_DEB_COMPONENT_INSTALL ON) - set(CPACK_COMPONENTS_GROUPING IGNORE) - - set(CPACK_DEBIAN_PACKAGE_NAME "${WPEFRAMEWORK_PLUGINS_OPKG_NAME}") - set(CPACK_DEBIAN_PACKAGE_VERSION "${WPEFRAMEWORK_PLUGINS_OPKG_VERSION}") - set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${WPEFRAMEWORK_PLUGINS_OPKG_ARCHITECTURE}") - set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${WPEFRAMEWORK_PLUGINS_OPKG_MAINTAINER}") - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${WPEFRAMEWORK_PLUGINS_OPKG_DESCRIPTION}") - set(CPACK_PACKAGE_FILE_NAME "${WPEFRAMEWORK_PLUGINS_OPKG_FILE_NAME}") - - include(CPack) -endif() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 161c09284..000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,4 +0,0 @@ -Contributing -============ - -If you would like to contribute code to this project you can do so through GitHub by forking the repository and sending a pull request. Before RDK accepts your code into the project you must sign the RDK Contributor License Agreement (CLA). \ No newline at end of file diff --git a/HdcpProfile/CHANGELOG.md b/HdcpProfile/CHANGELOG.md deleted file mode 100644 index 2e200c40d..000000000 --- a/HdcpProfile/CHANGELOG.md +++ /dev/null @@ -1,16 +0,0 @@ -# Changelog - -All notable changes to this RDK Service will be documented in this file. - -* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. - -* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: - * **Added** for new features. - * **Changed** for changes in existing functionality. - * **Deprecated** for soon-to-be removed features. - * **Removed** for now removed features. - * **Fixed** for any bug fixes. - * **Security** in case of vulnerabilities. - -* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. - diff --git a/HdcpProfile/CMakeLists.txt b/HdcpProfile/CMakeLists.txt deleted file mode 100644 index 9341cc08b..000000000 --- a/HdcpProfile/CMakeLists.txt +++ /dev/null @@ -1,97 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -set(PLUGIN_NAME HdcpProfile) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) -set(PLUGIN_IMPLEMENTATION ${MODULE_NAME}Implementation) - -set(PLUGIN_HDCPPROFILE_AUTOSTART "false" CACHE STRING "Automatically start HdcpProfile plugin") -set(PLUGIN_HDCPPROFILE_STARTUPORDER "" CACHE STRING "To configure startup order of HdcpProfile plugin") - -find_package(${NAMESPACE}Plugins REQUIRED) -if (USE_THUNDER_R4) - find_package(${NAMESPACE}COM REQUIRED) -else () - find_package(${NAMESPACE}Protocols REQUIRED) -endif (USE_THUNDER_R4) - -add_library(${MODULE_NAME} SHARED - HdcpProfile.cpp - Module.cpp) - - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -target_compile_definitions(${MODULE_NAME} PRIVATE MODULE_NAME=Plugin_${PLUGIN_NAME}) - - -include_directories( - ../helpers) - -target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins) - -install(TARGETS ${MODULE_NAME} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -add_library(${PLUGIN_IMPLEMENTATION} SHARED - HdcpProfileImplementation.cpp - Module.cpp) -target_link_libraries(${PLUGIN_IMPLEMENTATION} - PRIVATE - ${NAMESPACE}Plugins::${NAMESPACE}Plugins) -set_target_properties(${PLUGIN_IMPLEMENTATION} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - - -if (USE_THUNDER_R4) -target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE ${NAMESPACE}COM::${NAMESPACE}COM) -else () -target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE ${NAMESPACE}Protocols::${NAMESPACE}Protocols) -endif (USE_THUNDER_R4) - -find_package(DS) -find_package(IARMBus) -find_package(CEC) - -if (RDK_SERVICE_L2_TEST) - message ("L2 test Enabled") - find_library(TESTMOCKLIB_LIBRARIES NAMES TestMocklib) - if (TESTMOCKLIB_LIBRARIES) - message ("linking mock libraries ${TESTMOCKLIB_LIBRARIES} library") - target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE ${TESTMOCKLIB_LIBRARIES}) - else (TESTMOCKLIB_LIBRARIES) - message ("Require ${TESTMOCKLIB_LIBRARIES} library") - endif (TESTMOCKLIB_LIBRARIES) -endif() - - -target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ${IARMBUS_INCLUDE_DIRS}) -target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ${DS_INCLUDE_DIRS}) -target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ../helpers) - - -set_source_files_properties(HdcpProfile.cpp PROPERTIES COMPILE_FLAGS "-fexceptions") - -target_link_libraries(${PLUGIN_IMPLEMENTATION} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${DS_LIBRARIES}) - -install(TARGETS ${PLUGIN_IMPLEMENTATION} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -write_config(${PLUGIN_NAME}) diff --git a/HdcpProfile/HdcpProfile.conf.in b/HdcpProfile/HdcpProfile.conf.in deleted file mode 100644 index cddff2db5..000000000 --- a/HdcpProfile/HdcpProfile.conf.in +++ /dev/null @@ -1,12 +0,0 @@ -precondition = ["Platform"] -callsign = "org.rdk.HdcpProfile" -autostart = "@PLUGIN_HDCPPROFILE_AUTOSTART@" -startuporder = "@PLUGIN_HDCPPROFILE_STARTUPORDER@" - -configuration = JSON() -rootobject = JSON() - -rootobject.add("mode", "@PLUGIN_HDCPPROFILE_MODE@") -rootobject.add("locator", "lib@PLUGIN_IMPLEMENTATION@.so") - -configuration.add("root", rootobject) diff --git a/HdcpProfile/HdcpProfile.config b/HdcpProfile/HdcpProfile.config deleted file mode 100644 index 16c374cb7..000000000 --- a/HdcpProfile/HdcpProfile.config +++ /dev/null @@ -1,16 +0,0 @@ -set (autostart ${PLUGIN_HDCPPROFILE_AUTOSTART}) -set (preconditions Platform) -set (callsign "org.rdk.HdcpProfile") - -if(PLUGIN_HDCPPROFILE_STARTUPORDER) -set (startuporder ${PLUGIN_HDCPPROFILE_STARTUPORDER}) -endif() - -map() - key(root) - map() - kv(mode ${PLUGIN_HDCPPROFILE_MODE}) - kv(locator lib${PLUGIN_IMPLEMENTATION}.so) - end() -end() -ans(configuration) diff --git a/HdcpProfile/HdcpProfile.cpp b/HdcpProfile/HdcpProfile.cpp deleted file mode 100644 index bcfa8f631..000000000 --- a/HdcpProfile/HdcpProfile.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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 "HdcpProfile.h" - -#define API_VERSION_NUMBER_MAJOR 1 -#define API_VERSION_NUMBER_MINOR 0 -#define API_VERSION_NUMBER_PATCH 9 - -namespace WPEFramework -{ - - namespace { - - static Plugin::Metadata metadata( - // Version (Major, Minor, Patch) - API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH, - // Preconditions - {}, - // Terminations - {}, - // Controls - {} - ); - } - - namespace Plugin - { - SERVICE_REGISTRATION(HdcpProfile, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); - - HdcpProfile::HdcpProfile() - : _service(nullptr) - , _connectionId(0) - , _hdcpProfile(nullptr) - , _hdcpProfileNotification(this) - { - SYSLOG(Logging::Startup, (_T("HdcpProfile Constructor"))); - } - - HdcpProfile::~HdcpProfile() - { - SYSLOG(Logging::Shutdown, (string(_T("HdcpProfile Destructor")))); - } - - const string HdcpProfile::Initialize(PluginHost::IShell *service) - { - string message = ""; - - ASSERT(nullptr != service); - ASSERT(nullptr == _service); - ASSERT(nullptr == _hdcpProfile); - ASSERT(0 == _connectionId); - - SYSLOG(Logging::Startup, (_T("HdcpProfile::Initialize: PID=%u"), getpid())); - - _service = service; - _service->AddRef(); - _service->Register(&_hdcpProfileNotification); - _hdcpProfile = _service->Root(_connectionId, 5000, _T("HdcpProfileImplementation")); - - if (nullptr != _hdcpProfile) - { - configure = _hdcpProfile->QueryInterface(); - if (configure != nullptr) - { - uint32_t result = configure->Configure(_service); - if(result != Core::ERROR_NONE) - { - message = _T("HdcpProfile could not be configured"); - } - configure->Release(); - } - else - { - message = _T("HdcpProfile implementation did not provide a configuration interface"); - } - // Register for notifications - _hdcpProfile->Register(&_hdcpProfileNotification); - - // Invoking Plugin API register to wpeframework - Exchange::JHdcpProfile::Register(*this, _hdcpProfile); - } - else - { - SYSLOG(Logging::Startup, (_T("HdcpProfile::Initialize: Failed to initialise HdcpProfile plugin"))); - message = _T("HdcpProfile plugin could not be initialised"); - } - - if (0 != message.length()) - { - printf("HdcpProfile::Initialize: Failed to initialise HdcpProfile plugin"); - Deinitialize(service); - } - - return message; - } - - void HdcpProfile::Deinitialize(PluginHost::IShell *service) - { - ASSERT(_service == service); - printf("HdcpProfile::Deinitialize: service = %p", service); - SYSLOG(Logging::Shutdown, (string(_T("HdcpProfile::Deinitialize")))); - - // Make sure the Activated and Deactivated are no longer called before we start cleaning up.. - if (_service != nullptr) - { - _service->Unregister(&_hdcpProfileNotification); - } - if (nullptr != _hdcpProfile) - { - - _hdcpProfile->Unregister(&_hdcpProfileNotification); - Exchange::JHdcpProfile::Unregister(*this); - // Stop processing: - RPC::IRemoteConnection *connection = service->RemoteConnection(_connectionId); - VARIABLE_IS_NOT_USED uint32_t result = _hdcpProfile->Release(); - - _hdcpProfile = nullptr; - - // It should have been the last reference we are releasing, - // so it should endup in a DESTRUCTION_SUCCEEDED, if not we - // are leaking... - ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED); - - // If this was running in a (container) process... - if (nullptr != connection) - { - // Lets trigger the cleanup sequence for - // out-of-process code. Which will guard - // that unwilling processes, get shot if - // not stopped friendly :-) - connection->Terminate(); - connection->Release(); - } - } - _connectionId = 0; - - if (_service != nullptr) - { - _service->Release(); - _service = nullptr; - } - SYSLOG(Logging::Shutdown, (string(_T("HdcpProfile de-initialised")))); - } - string HdcpProfile::Information() const - { - return ("This HdcpProfile Plugin facilitates to persist event data for monitoring applications"); - } - - void HdcpProfile::Deactivated(RPC::IRemoteConnection *connection) - { - if (connection->Id() == _connectionId) - { - ASSERT(nullptr != _service); - Core::IWorkerPool::Instance().Submit(PluginHost::IShell::Job::Create(_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::FAILURE)); - } - } - } // namespace Plugin -} // namespace WPEFramework diff --git a/HdcpProfile/HdcpProfile.h b/HdcpProfile/HdcpProfile.h deleted file mode 100644 index ddf5fd910..000000000 --- a/HdcpProfile/HdcpProfile.h +++ /dev/null @@ -1,113 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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. -**/ - -#pragma once - -#include "Module.h" -#include -#include -#include -#include -#include "UtilsLogging.h" -#include "tracing/Logging.h" - - -namespace WPEFramework { - - namespace Plugin { - - class HdcpProfile : public PluginHost::IPlugin, public PluginHost::JSONRPC - { - private: - class Notification : public RPC::IRemoteConnection::INotification, public Exchange::IHdcpProfile::INotification - { - private: - Notification() = delete; - Notification(const Notification&) = delete; - Notification& operator=(const Notification&) = delete; - - public: - explicit Notification(HdcpProfile *parent) - : _parent(*parent) - { - ASSERT(parent != nullptr); - } - - virtual ~Notification() - { - } - - BEGIN_INTERFACE_MAP(Notification) - INTERFACE_ENTRY(Exchange::IHdcpProfile::INotification) - INTERFACE_ENTRY(RPC::IRemoteConnection::INotification) - END_INTERFACE_MAP - - void Activated(RPC::IRemoteConnection *) override - { - LOGINFO("HdcpProfile Notification Activated"); - } - - void Deactivated(RPC::IRemoteConnection *connection) override - { - LOGINFO("HdcpProfile Notification Deactivated"); - _parent.Deactivated(connection); - } - - void OnDisplayConnectionChanged(const Exchange::IHdcpProfile::HDCPStatus hdcpstatus) override - { - LOGINFO("OnDisplayConnectionChanged: isConnected: %d isHDCPCompliant: %d isHDCPEnabled: %d hdcpReason: %d supportedHDCPVersion: %s receiverHDCPVersion: %s currentHDCPVersion: %s", hdcpstatus.isConnected, hdcpstatus.isHDCPCompliant, hdcpstatus.isHDCPEnabled, hdcpstatus.hdcpReason, hdcpstatus.supportedHDCPVersion.c_str(), hdcpstatus.receiverHDCPVersion.c_str(), hdcpstatus.currentHDCPVersion.c_str()); - Exchange::JHdcpProfile::Event::OnDisplayConnectionChanged(_parent, hdcpstatus); - } - - private: - HdcpProfile &_parent; - }; - - public: - HdcpProfile(const HdcpProfile &) = delete; - HdcpProfile &operator=(const HdcpProfile &) = delete; - - HdcpProfile(); - virtual ~HdcpProfile(); - - BEGIN_INTERFACE_MAP(HdcpProfile) - INTERFACE_ENTRY(PluginHost::IPlugin) - INTERFACE_ENTRY(PluginHost::IDispatcher) - INTERFACE_AGGREGATE(Exchange::IHdcpProfile, _hdcpProfile) - END_INTERFACE_MAP - - // IPlugin methods - // ------------------------------------------------------------------------------------------------------- - const string Initialize(PluginHost::IShell* service) override; - void Deinitialize(PluginHost::IShell* service) override; - string Information() const override; - - private: - void Deactivated(RPC::IRemoteConnection* connection); - - private: - PluginHost::IShell *_service{}; - uint32_t _connectionId{}; - Exchange::IHdcpProfile *_hdcpProfile{}; - Core::Sink _hdcpProfileNotification; - Exchange::IConfiguration* configure; - }; - - } // namespace Plugin -} // namespace WPEFramework diff --git a/HdcpProfile/HdcpProfileImplementation.cpp b/HdcpProfile/HdcpProfileImplementation.cpp deleted file mode 100644 index 69b55a21a..000000000 --- a/HdcpProfile/HdcpProfileImplementation.cpp +++ /dev/null @@ -1,390 +0,0 @@ -/** - * If not stated otherwise in this file or this component's LICENSE - * file the following copyright and licenses apply: - * - * Copyright 2025 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 - - #include "HdcpProfileImplementation.h" - - #include "videoOutputPort.hpp" - #include "videoOutputPortConfig.hpp" - #include "dsMgr.h" - #include "manager.hpp" - #include "host.hpp" - - #include "UtilsJsonRpc.h" - #include "UtilsIarm.h" - - #include "UtilsSynchroIarm.hpp" - - #define HDMI_HOT_PLUG_EVENT_CONNECTED 0 - #define HDMI_HOT_PLUG_EVENT_DISCONNECTED 1 - - #define API_VERSION_NUMBER_MAJOR 1 - #define API_VERSION_NUMBER_MINOR 0 - #define API_VERSION_NUMBER_PATCH 9 - - using PowerState = WPEFramework::Exchange::IPowerManager::PowerState; - - namespace WPEFramework - { - namespace Plugin - { - SERVICE_REGISTRATION(HdcpProfileImplementation, 1, 0); - HdcpProfileImplementation *HdcpProfileImplementation::_instance = nullptr; - - PowerManagerInterfaceRef HdcpProfileImplementation::_powerManagerPlugin; - - - HdcpProfileImplementation::HdcpProfileImplementation() - : _adminLock(), mShell(nullptr) - { - LOGINFO("Create HdcpProfileImplementation Instance"); - HdcpProfileImplementation::_instance = this; - } - - HdcpProfileImplementation::~HdcpProfileImplementation() - { - LOGINFO("Call HdcpProfileImplementation destructor\n"); - if (_powerManagerPlugin) { - _powerManagerPlugin.Reset(); - } - if(_service != nullptr) - { - _service->Release(); - } - DeinitializeIARM(); - HdcpProfileImplementation::_instance = nullptr; - mShell = nullptr; - } - - void HdcpProfileImplementation::InitializePowerManager(PluginHost::IShell *service) - { - _powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager")) - .withIShell(service) - .withRetryIntervalMS(200) - .withRetryCount(25) - .createInterface(); - } - - void HdcpProfileImplementation::InitializeIARM() - { - Utils::IARM::init(); - - IARM_Result_t res; - IARM_CHECK( Utils::Synchro::RegisterLockedIarmEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG, dsHdmiEventHandler) ); - IARM_CHECK( Utils::Synchro::RegisterLockedIarmEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDCP_STATUS, dsHdmiEventHandler) ); - } - - void HdcpProfileImplementation::DeinitializeIARM() - { - if (Utils::IARM::isConnected()) - { - IARM_Result_t res; - IARM_CHECK( Utils::Synchro::RemoveLockedEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG, dsHdmiEventHandler) ); - IARM_CHECK( Utils::Synchro::RemoveLockedEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDCP_STATUS, dsHdmiEventHandler) ); - } - } - - void HdcpProfileImplementation::onHdmiOutputHotPlug(int connectStatus) - { - if (HDMI_HOT_PLUG_EVENT_CONNECTED == connectStatus) - { - LOGINFO("HDMI_HOT_PLUG Status[%d]",connectStatus); - } - onHdcpProfileDisplayConnectionChanged(); - } - - void HdcpProfileImplementation::onHdcpProfileDisplayConnectionChanged() - { - HDCPStatus hdcpstatus; - GetHDCPStatusInternal(hdcpstatus); - dispatchEvent(HDCPPROFILE_EVENT_DISPLAYCONNECTIONCHANGED, hdcpstatus); - logHdcpStatus("onHdcpProfileDisplayConnectionChanged", hdcpstatus); - } - - void HdcpProfileImplementation::logHdcpStatus (const char *trigger, HDCPStatus& status) - { - LOGWARN("[%s]-HDCPStatus::isConnected: %s", trigger, status.isConnected ? "true" : "false"); - LOGWARN("[%s]-HDCPStatus::isHDCPEnabled: %s", trigger, status.isHDCPEnabled ? "true" : "false"); - LOGWARN("[%s]-HDCPStatus::isHDCPCompliant: %s", trigger, status.isHDCPCompliant ? "true" : "false"); - LOGWARN("[%s]-HDCPStatus::supportedHDCPVersion: %s", trigger, status.supportedHDCPVersion.c_str()); - LOGWARN("[%s]-HDCPStatus::receiverHDCPVersion: %s", trigger, status.receiverHDCPVersion.c_str()); - LOGWARN("[%s]-HDCPStatus::currentHDCPVersion: %s", trigger, status.currentHDCPVersion.c_str()); - LOGWARN("[%s]-HDCPStatus::hdcpReason: %d", trigger, status.hdcpReason); - LOGWARN("[%s]-HDCPStatus Response: %s, %s, %s, %s, %s, %s, %d", trigger, - status.isConnected ? "true" : "false", - status.isHDCPEnabled ? "true" : "false", - status.isHDCPCompliant ? "true" : "false", - status.supportedHDCPVersion.c_str(), - status.receiverHDCPVersion.c_str(), - status.currentHDCPVersion.c_str(), - status.hdcpReason); - } - - void HdcpProfileImplementation::onHdmiOutputHDCPStatusEvent(int hdcpStatus) - { - LOGINFO("hdcpStatus[%d]",hdcpStatus); - onHdcpProfileDisplayConnectionChanged(); - } - - void HdcpProfileImplementation::dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - uint32_t res = Core::ERROR_GENERAL; - PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; - PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; - - if(!HdcpProfileImplementation::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_hotplug_event = eventData->data.hdmi_hpd.event; - LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG event data:%d \r\n", hdmi_hotplug_event); - - HdcpProfileImplementation::_instance->onHdmiOutputHotPlug(hdmi_hotplug_event); - } - else if (IARM_BUS_DSMGR_EVENT_HDCP_STATUS == eventId) - { - ASSERT (_powerManagerPlugin); - if (_powerManagerPlugin){ - res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev); - if (Core::ERROR_NONE != res) - { - LOGWARN("Failed to Invoke RPC method: GetPowerState"); - } - else - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdcpStatus = eventData->data.hdmi_hdcp.hdcpStatus; - LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDCP_STATUS event data:%d param.curState: %d \r\n", hdcpStatus,pwrStateCur); - HdcpProfileImplementation::_instance->onHdmiOutputHDCPStatusEvent(hdcpStatus); - } - } - } - } - - /** - * Register a notification callback - */ - Core::hresult HdcpProfileImplementation::Register(Exchange::IHdcpProfile::INotification *notification) - { - ASSERT(nullptr != notification); - - _adminLock.Lock(); - printf("HdcpProfileImplementation::Register: notification = %p", notification); - LOGINFO("Register notification"); - - // Make sure we can't register the same notification callback multiple times - if (std::find(_hdcpProfileNotification.begin(), _hdcpProfileNotification.end(), notification) == _hdcpProfileNotification.end()) - { - _hdcpProfileNotification.push_back(notification); - notification->AddRef(); - } - else - { - LOGERR("same notification is registered already"); - } - - _adminLock.Unlock(); - - return Core::ERROR_NONE; - } - - /** - * Unregister a notification callback - */ - Core::hresult HdcpProfileImplementation::Unregister(Exchange::IHdcpProfile::INotification *notification) - { - Core::hresult status = Core::ERROR_GENERAL; - - ASSERT(nullptr != notification); - - _adminLock.Lock(); - - // we just unregister one notification once - auto itr = std::find(_hdcpProfileNotification.begin(), _hdcpProfileNotification.end(), notification); - if (itr != _hdcpProfileNotification.end()) - { - (*itr)->Release(); - LOGINFO("Unregister notification"); - _hdcpProfileNotification.erase(itr); - status = Core::ERROR_NONE; - } - else - { - LOGERR("notification not found"); - } - - _adminLock.Unlock(); - - return status; - } - - uint32_t HdcpProfileImplementation::Configure(PluginHost::IShell* service) - { - uint32_t result = Core::ERROR_NONE; - _service = service; - _service->AddRef(); - ASSERT(service != nullptr); - InitializeIARM(); - InitializePowerManager(service); - return result; - } - - void HdcpProfileImplementation::dispatchEvent(Event event, const HDCPStatus &hdcpstatus) - { - Core::IWorkerPool::Instance().Submit(Job::Create(this, event, hdcpstatus)); - } - - void HdcpProfileImplementation::Dispatch(Event event,const HDCPStatus& hdcpstatus) - { - _adminLock.Lock(); - - std::list::const_iterator index(_hdcpProfileNotification.begin()); - - switch (event) - { - case HDCPPROFILE_EVENT_DISPLAYCONNECTIONCHANGED: - { - while (index != _hdcpProfileNotification.end()) - { - (*index)->OnDisplayConnectionChanged(hdcpstatus); - ++index; - } - } - break; - - default: - LOGWARN("Event[%u] not handled", event); - break; - } - _adminLock.Unlock(); - } - - bool HdcpProfileImplementation::GetHDCPStatusInternal(HDCPStatus& hdcpstatus) - { - bool isConnected = false; - bool isHDCPCompliant = false; - bool isHDCPEnabled = true; - int eHDCPEnabledStatus = dsHDCP_STATUS_UNPOWERED; - dsHdcpProtocolVersion_t hdcpProtocol = dsHDCP_VERSION_MAX; - dsHdcpProtocolVersion_t hdcpReceiverProtocol = dsHDCP_VERSION_MAX; - dsHdcpProtocolVersion_t hdcpCurrentProtocol = dsHDCP_VERSION_MAX; - - try - { - std::string strVideoPort = device::Host::getInstance().getDefaultVideoPortName(); - device::VideoOutputPort vPort = device::VideoOutputPortConfig::getInstance().getPort(strVideoPort.c_str()); - isConnected = vPort.isDisplayConnected(); - hdcpProtocol = (dsHdcpProtocolVersion_t)vPort.getHDCPProtocol(); - eHDCPEnabledStatus = vPort.getHDCPStatus(); - if(isConnected) - { - isHDCPCompliant = (eHDCPEnabledStatus == dsHDCP_STATUS_AUTHENTICATED); - isHDCPEnabled = vPort.isContentProtected(); - hdcpReceiverProtocol = (dsHdcpProtocolVersion_t)vPort.getHDCPReceiverProtocol(); - hdcpCurrentProtocol = (dsHdcpProtocolVersion_t)vPort.getHDCPCurrentProtocol(); - } - else - { - isHDCPCompliant = false; - isHDCPEnabled = false; - } - } - catch (const std::exception& e) - { - LOGWARN("DS exception caught from %s\r\n", __FUNCTION__); - } - - hdcpstatus.isConnected = isConnected; - hdcpstatus.isHDCPCompliant = isHDCPCompliant; - hdcpstatus.isHDCPEnabled = isHDCPEnabled; - hdcpstatus.hdcpReason = eHDCPEnabledStatus; - - if(hdcpProtocol == dsHDCP_VERSION_2X) - { - hdcpstatus.supportedHDCPVersion = "2.2"; - } - else - { - hdcpstatus.supportedHDCPVersion = "1.4"; - } - - if(hdcpReceiverProtocol == dsHDCP_VERSION_2X) - { - hdcpstatus.receiverHDCPVersion = "2.2"; - } - else - { - hdcpstatus.receiverHDCPVersion = "1.4"; - } - - if(hdcpCurrentProtocol == dsHDCP_VERSION_2X) - { - hdcpstatus.currentHDCPVersion = "2.2"; - } - else - { - hdcpstatus.currentHDCPVersion = "1.4"; - } - return true; - } - - Core::hresult HdcpProfileImplementation::GetHDCPStatus(HDCPStatus& hdcpstatus,bool& success) - { - success = GetHDCPStatusInternal(hdcpstatus); - return Core::ERROR_NONE; - } - - Core::hresult HdcpProfileImplementation::GetSettopHDCPSupport(string& supportedHDCPVersion,bool& isHDCPSupported,bool& success) - { - dsHdcpProtocolVersion_t hdcpProtocol = dsHDCP_VERSION_MAX; - - try - { - std::string strVideoPort = device::Host::getInstance().getDefaultVideoPortName(); - device::VideoOutputPort vPort = device::VideoOutputPortConfig::getInstance().getPort(strVideoPort.c_str()); - hdcpProtocol = (dsHdcpProtocolVersion_t)vPort.getHDCPProtocol(); - } - catch (const std::exception& e) - { - LOGWARN("DS exception caught from %s\r\n", __FUNCTION__); - } - - if(hdcpProtocol == dsHDCP_VERSION_2X) - { - supportedHDCPVersion = "2.2"; - LOGWARN("supportedHDCPVersion :2.2"); - } - else - { - supportedHDCPVersion = "1.4"; - LOGWARN("supportedHDCPVersion :1.4"); - } - - isHDCPSupported = true; - - success = true; - return Core::ERROR_NONE; - } - - - } // namespace Plugin - } // namespace WPEFramework diff --git a/HdcpProfile/HdcpProfileImplementation.h b/HdcpProfile/HdcpProfileImplementation.h deleted file mode 100644 index 8e0530d49..000000000 --- a/HdcpProfile/HdcpProfileImplementation.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * If not stated otherwise in this file or this component's LICENSE file the - * following copyright and licenses apply: - * - * Copyright 2025 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. - */ - - #pragma once - - #include "Module.h" - #include - #include - #include - #include - - #include - #include - #include - #include - - #include "libIBus.h" - - #include "PowerManagerInterface.h" - - namespace WPEFramework - { - namespace Plugin - { - - class HdcpProfileImplementation : public Exchange::IHdcpProfile, public Exchange::IConfiguration - // , public Exchange::IConfiguration - { - public: - // We do not allow this plugin to be copied !! - HdcpProfileImplementation(); - ~HdcpProfileImplementation() override; - - static HdcpProfileImplementation *instance(HdcpProfileImplementation *HdcpProfileImpl = nullptr); - - // We do not allow this plugin to be copied !! - HdcpProfileImplementation(const HdcpProfileImplementation &) = delete; - HdcpProfileImplementation &operator=(const HdcpProfileImplementation &) = delete; - - - BEGIN_INTERFACE_MAP(HdcpProfileImplementation) - INTERFACE_ENTRY(Exchange::IHdcpProfile) - INTERFACE_ENTRY(Exchange::IConfiguration) - END_INTERFACE_MAP - - public: - enum Event - { - HDCPPROFILE_EVENT_DISPLAYCONNECTIONCHANGED - }; - class EXTERNAL Job : public Core::IDispatch - { - protected: - Job(HdcpProfileImplementation *HdcpProfileImplementation, Event event, HDCPStatus ¶ms) - : _hdcpProfileImplementation(HdcpProfileImplementation), _event(event), _params(params) - { - if (_hdcpProfileImplementation != nullptr) - { - _hdcpProfileImplementation->AddRef(); - } - } - - public: - Job() = delete; - Job(const Job &) = delete; - Job &operator=(const Job &) = delete; - ~Job() - { - if (_hdcpProfileImplementation != nullptr) - { - _hdcpProfileImplementation->Release(); - } - } - - public: - static Core::ProxyType Create(HdcpProfileImplementation *hdcpProfileImplementation, Event event, HDCPStatus params) - { - #ifndef USE_THUNDER_R4 - return (Core::proxy_cast(Core::ProxyType::Create(hdcpProfileImplementation, event, params))); - #else - return (Core::ProxyType(Core::ProxyType::Create(hdcpProfileImplementation, event, params))); - #endif - } - virtual void Dispatch() - { - _hdcpProfileImplementation->Dispatch(_event, _params); - } - - private: - HdcpProfileImplementation *_hdcpProfileImplementation; - const Event _event; - HDCPStatus _params; - }; - - - public: - Core::hresult Register(Exchange::IHdcpProfile::INotification *notification) override; - Core::hresult Unregister(Exchange::IHdcpProfile::INotification *notification) override; - - Core::hresult GetHDCPStatus(HDCPStatus& hdcpstatus,bool& success) override; - Core::hresult GetSettopHDCPSupport(string& supportedHDCPVersion,bool& isHDCPSupported,bool& success) override; - bool GetHDCPStatusInternal(HDCPStatus& hdcpstatus); - void InitializePowerManager(PluginHost::IShell *service); - void InitializeIARM(); - void DeinitializeIARM(); - static void dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - void onHdmiOutputHotPlug(int connectStatus); - void onHdmiOutputHDCPStatusEvent(int); - void logHdcpStatus (const char *trigger, HDCPStatus& status); - void onHdcpProfileDisplayConnectionChanged(); - static PowerManagerInterfaceRef _powerManagerPlugin; - uint32_t Configure(PluginHost::IShell* service) override; - - private: - mutable Core::CriticalSection _adminLock; - PluginHost::IShell *mShell; - std::list _hdcpProfileNotification; // List of registered notifications - PluginHost::IShell* _service; - void dispatchEvent(Event, const HDCPStatus ¶ms); - void Dispatch(Event event, const HDCPStatus ¶ms); - - - public: - static HdcpProfileImplementation *_instance; - - // friend class Job; - }; - - } // namespace Plugin - } // namespace WPEFramework \ No newline at end of file diff --git a/HdcpProfile/Module.cpp b/HdcpProfile/Module.cpp deleted file mode 100644 index ce759b615..000000000 --- a/HdcpProfile/Module.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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 "Module.h" - -MODULE_NAME_DECLARATION(BUILD_REFERENCE) diff --git a/HdcpProfile/Module.h b/HdcpProfile/Module.h deleted file mode 100644 index 2aa252e86..000000000 --- a/HdcpProfile/Module.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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. -**/ - -#pragma once -#ifndef MODULE_NAME -#define MODULE_NAME Plugin_HdcpProfile -#endif - -#include -#include - -#undef EXTERNAL -#define EXTERNAL diff --git a/HdcpProfile/README.md b/HdcpProfile/README.md deleted file mode 100644 index 3ef1f1cf8..000000000 --- a/HdcpProfile/README.md +++ /dev/null @@ -1,9 +0,0 @@ ------------------ -Build: - -bitbake wpeframework-service-plugins - ------------------ -Test: - -curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "HdcpProfile.1."}' http://127.0.0.1:9998/jsonrpc diff --git a/HdmiCecSink/CHANGELOG.md b/HdmiCecSink/CHANGELOG.md deleted file mode 100644 index 140a1d0bb..000000000 --- a/HdmiCecSink/CHANGELOG.md +++ /dev/null @@ -1,15 +0,0 @@ -# Changelog - -All notable changes to this RDK Service will be documented in this file. - -* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. - -* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: - * **Added** for new features. - * **Changed** for changes in existing functionality. - * **Deprecated** for soon-to-be removed features. - * **Removed** for now removed features. - * **Fixed** for any bug fixes. - * **Security** in case of vulnerabilities. - -* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. diff --git a/HdmiCecSink/CMakeLists.txt b/HdmiCecSink/CMakeLists.txt deleted file mode 100644 index b244641ed..000000000 --- a/HdmiCecSink/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. -set(PLUGIN_NAME HdmiCecSink) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) - - -set(PLUGIN_HDMICECSINK_STARTUPORDER "" CACHE STRING "To configure startup order of HdmiCecSink plugin") - -find_package(${NAMESPACE}Plugins REQUIRED) - -add_library(${MODULE_NAME} SHARED - HdmiCecSink.cpp - Module.cpp) - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -target_compile_definitions(${MODULE_NAME} PRIVATE MODULE_NAME=Plugin_${PLUGIN_NAME}) - -find_package(DS) -find_package(IARMBus) -find_package(CEC) - -target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS} ../helpers) -target_include_directories(${MODULE_NAME} PRIVATE ${CEC_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PRIVATE ${DS_INCLUDE_DIRS}) -set_source_files_properties(HdmiCecSink.cpp PROPERTIES COMPILE_FLAGS "-fexceptions") - -target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${CEC_LIBRARIES} ${DS_LIBRARIES} ) - -if (NOT RDK_SERVICES_L1_TEST) - target_compile_options(${MODULE_NAME} PRIVATE -Wno-error=deprecated) -endif () - -install(TARGETS ${MODULE_NAME} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -write_config(${PLUGIN_NAME}) diff --git a/HdmiCecSink/HdmiCecSink.conf.in b/HdmiCecSink/HdmiCecSink.conf.in deleted file mode 100644 index de8e1cdf8..000000000 --- a/HdmiCecSink/HdmiCecSink.conf.in +++ /dev/null @@ -1,4 +0,0 @@ -precondition = ["Platform"] -callsign = "org.rdk.HdmiCecSink" -autostart = "false" -startuporder = "@PLUGIN_HDMICECSINK_STARTUPORDER@" diff --git a/HdmiCecSink/HdmiCecSink.config b/HdmiCecSink/HdmiCecSink.config deleted file mode 100644 index 13ed07889..000000000 --- a/HdmiCecSink/HdmiCecSink.config +++ /dev/null @@ -1,7 +0,0 @@ -set (autostart false) -set (preconditions Platform) -set (callsign "org.rdk.HdmiCecSink") - -if(PLUGIN_HDMICECSINK_STARTUPORDER) -set (startuporder ${PLUGIN_HDMICECSINK_STARTUPORDER}) -endif() diff --git a/HdmiCecSink/HdmiCecSink.cpp b/HdmiCecSink/HdmiCecSink.cpp deleted file mode 100644 index 26aef24c3..000000000 --- a/HdmiCecSink/HdmiCecSink.cpp +++ /dev/null @@ -1,3559 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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 "HdmiCecSink.h" - -#include "ccec/Connection.hpp" -#include "ccec/CECFrame.hpp" -#include "ccec/MessageEncoder.hpp" -#include "host.hpp" -#include "UtilsgetRFCConfig.h" - -#include "dsMgr.h" -#include "dsRpc.h" -#include "dsDisplay.h" -#include "videoOutputPort.hpp" -#include "manager.hpp" -#include "websocket/URL.h" - -#include "UtilsIarm.h" -#include "UtilsJsonRpc.h" -#include "UtilssyncPersistFile.h" -#include "UtilsSearchRDKProfile.h" - -#define HDMICECSINK_METHOD_SET_ENABLED "setEnabled" -#define HDMICECSINK_METHOD_GET_ENABLED "getEnabled" -#define HDMICECSINK_METHOD_OTP_SET_ENABLED "setOTPEnabled" -#define HDMICECSINK_METHOD_OTP_GET_ENABLED "getOTPEnabled" -#define HDMICECSINK_METHOD_SET_OSD_NAME "setOSDName" -#define HDMICECSINK_METHOD_GET_OSD_NAME "getOSDName" -#define HDMICECSINK_METHOD_SET_VENDOR_ID "setVendorId" -#define HDMICECSINK_METHOD_GET_VENDOR_ID "getVendorId" -#define HDMICECSINK_METHOD_PRINT_DEVICE_LIST "printDeviceList" -#define HDMICECSINK_METHOD_SET_ACTIVE_PATH "setActivePath" -#define HDMICECSINK_METHOD_SET_ROUTING_CHANGE "setRoutingChange" -#define HDMICECSINK_METHOD_GET_DEVICE_LIST "getDeviceList" -#define HDMICECSINK_METHOD_GET_ACTIVE_SOURCE "getActiveSource" -#define HDMICECSINK_METHOD_SET_ACTIVE_SOURCE "setActiveSource" -#define HDMICECSINK_METHOD_GET_ACTIVE_ROUTE "getActiveRoute" -#define HDMICECSINK_METHOD_SET_MENU_LANGUAGE "setMenuLanguage" -#define HDMICECSINK_METHOD_REQUEST_ACTIVE_SOURCE "requestActiveSource" -#define HDMICECSINK_METHOD_SETUP_ARC "setupARCRouting" -#define HDMICECSINK_METHOD_REQUEST_SHORT_AUDIO_DESCRIPTOR "requestShortAudioDescriptor" -#define HDMICECSINK_METHOD_SEND_STANDBY_MESSAGE "sendStandbyMessage" -#define HDMICECSINK_METHOD_SEND_AUDIO_DEVICE_POWER_ON "sendAudioDevicePowerOnMessage" -#define HDMICECSINK_METHOD_SEND_KEY_PRESS "sendKeyPressEvent" -#define HDMICECSINK_METHOD_SEND_USER_CONTROL_PRESSED "sendUserControlPressed" -#define HDMICECSINK_METHOD_SEND_USER_CONTROL_RELEASED "sendUserControlReleased" -#define HDMICECSINK_METHOD_SEND_GIVE_AUDIO_STATUS "sendGetAudioStatusMessage" -#define HDMICECSINK_METHOD_GET_AUDIO_DEVICE_CONNECTED_STATUS "getAudioDeviceConnectedStatus" -#define HDMICECSINK_METHOD_REQUEST_AUDIO_DEVICE_POWER_STATUS "requestAudioDevicePowerStatus" -#define HDMICECSINK_METHOD_SET_LATENCY_INFO "setLatencyInfo" - -#define TEST_ADD 0 -#define HDMICECSINK_REQUEST_MAX_RETRY 3 -#define HDMICECSINK_REQUEST_MAX_WAIT_TIME_MS 2000 -#define HDMICECSINK_PING_INTERVAL_MS 10000 -#define HDMICECSINK_WAIT_FOR_HDMI_IN_MS 1000 -#define HDMICECSINK_REQUEST_INTERVAL_TIME_MS 500 -#define HDMICECSINK_NUMBER_TV_ADDR 2 -#define HDMICECSINK_UPDATE_POWER_STATUS_INTERVA_MS (60 * 1000) -#define HDMISINK_ARC_START_STOP_MAX_WAIT_MS 4000 -#define HDMICECSINK_UPDATE_AUDIO_STATUS_INTERVAL_MS 500 - - -#define SAD_FMT_CODE_AC3 2 -#define SAD_FMT_CODE_ENHANCED_AC3 10 - -#define SYSTEM_AUDIO_MODE_ON 0x01 -#define SYSTEM_AUDIO_MODE_OFF 0x00 -#define AUDIO_DEVICE_POWERSTATE_OFF 1 - -#define DEFAULT_VIDEO_LATENCY 100 -#define DEFAULT_LATENCY_FLAGS 3 -#define DEFAULT_AUDIO_OUTPUT_DELAY 100 - -//Device Type is TV - Bit 7 is set to 1 -#define ALL_DEVICE_TYPES 128 - -//RC Profile of TV is 3 - Typical TV Remote -#define RC_PROFILE_TV 10 - -//Device Features supported by TV - ARC Tx -#define DEVICE_FEATURES_TV 4 - -#define TR181_HDMICECSINK_CEC_VERSION "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.HdmiCecSink.CECVersion" - -enum { - DEVICE_POWER_STATE_ON = 0, - DEVICE_POWER_STATE_OFF = 1 -}; - - -enum { - HDMICECSINK_EVENT_ACTIVE_SOURCE_CHANGE = 1, - HDMICECSINK_EVENT_WAKEUP_FROM_STANDBY, - HDMICECSINK_EVENT_TEXT_VIEW_ON_MSG, - HDMICECSINK_EVENT_IMAGE_VIEW_ON_MSG, - HDMICECSINK_EVENT_DEVICE_ADDED, - HDMICECSINK_EVENT_DEVICE_REMOVED, - HDMICECSINK_EVENT_DEVICE_INFO_UPDATED, - HDMICECSINK_EVENT_INACTIVE_SOURCE, - HDMICECSINK_EVENT_ARC_INITIATION_EVENT, - HDMICECSINK_EVENT_ARC_TERMINATION_EVENT, - HDMICECSINK_EVENT_SHORT_AUDIODESCRIPTOR_EVENT, - HDMICECSINK_EVENT_STANDBY_MSG_EVENT, - HDMICECSINK_EVENT_SYSTEM_AUDIO_MODE, - HDMICECSINK_EVENT_REPORT_AUDIO_STATUS, - HDMICECSINK_EVENT_AUDIO_DEVICE_CONNECTED_STATUS, - HDMICECSINK_EVENT_CEC_ENABLED, - HDMICECSINK_EVENT_AUDIO_DEVICE_POWER_STATUS, - HDMICECSINK_EVENT_FEATURE_ABORT_EVENT, -}; - -static const char *eventString[] = { - "None", - "onActiveSourceChange", - "onWakeupFromStandby", - "onTextViewOnMsg", - "onImageViewOnMsg", - "onDeviceAdded", - "onDeviceRemoved", - "onDeviceInfoUpdated", - "onInActiveSource", - "arcInitiationEvent", - "arcTerminationEvent", - "shortAudiodesciptorEvent", - "standbyMessageReceived", - "setSystemAudioModeEvent", - "reportAudioStatusEvent", - "reportAudioDeviceConnectedStatus", - "reportCecEnabledEvent", - "reportAudioDevicePowerStatus", - "reportFeatureAbortEvent" -}; - - -#define CEC_SETTING_ENABLED_FILE "/opt/persistent/ds/cecData_2.json" -#define CEC_SETTING_OTP_ENABLED "cecOTPEnabled" -#define CEC_SETTING_ENABLED "cecEnabled" -#define CEC_SETTING_OSD_NAME "cecOSDName" -#define CEC_SETTING_VENDOR_ID "cecVendorId" - -static std::vector defaultVendorId = {0x00,0x19,0xFB}; -static VendorID appVendorId = {defaultVendorId.at(0),defaultVendorId.at(1),defaultVendorId.at(2)}; -static VendorID lgVendorId = {0x00,0xE0,0x91}; -static PhysicalAddress physical_addr = {0x0F,0x0F,0x0F,0x0F}; -static LogicalAddress logicalAddress = 0xF; -static Language defaultLanguage = "eng"; -static OSDName osdName = "TV Box"; -static int32_t powerState = DEVICE_POWER_STATE_OFF; -static std::vector formatid = {0,0}; -static std::vector audioFormatCode = { SAD_FMT_CODE_ENHANCED_AC3,SAD_FMT_CODE_AC3 }; -static uint8_t numberofdescriptor = 2; -static int32_t HdmiArcPortID = -1; -static float cecVersion = 1.4; -static AllDeviceTypes allDevicetype = ALL_DEVICE_TYPES; -static std::vector rcProfile = {RC_PROFILE_TV}; -static std::vector deviceFeatures = {DEVICE_FEATURES_TV}; - -#define API_VERSION_NUMBER_MAJOR 1 -#define API_VERSION_NUMBER_MINOR 3 -#define API_VERSION_NUMBER_PATCH 10 - -namespace WPEFramework -{ - namespace { - - static Plugin::Metadata metadata( - // Version (Major, Minor, Patch) - API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH, - // Preconditions - {}, - // Terminations - {}, - // Controls - {} - ); - } - - namespace Plugin - { - SERVICE_REGISTRATION(HdmiCecSink, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); - - HdmiCecSink* HdmiCecSink::_instance = nullptr; - static int libcecInitStatus = 0; - -//=========================================== HdmiCecSinkFrameListener ========================================= - void HdmiCecSinkFrameListener::notify(const CECFrame &in) const { - const uint8_t *buf = NULL; - char strBuffer[512] = {0}; - size_t len = 0; - - in.getBuffer(&buf, &len); - for (unsigned int i = 0; i < len; i++) { - snprintf(strBuffer + (i*3) , sizeof(strBuffer) - (i*3), "%02X ",(uint8_t) *(buf + i)); - } - LOGINFO(" >>>>> Received CEC Frame: :%s \n",strBuffer); - - MessageDecoder(processor).decode(in); - } - -//=========================================== HdmiCecSinkProcessor ========================================= - void HdmiCecSinkProcessor::process (const ActiveSource &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: ActiveSource %s : %s : %s \n",GetOpName(msg.opCode()),msg.physicalAddress.name().c_str(),msg.physicalAddress.toString().c_str()); - if(!(header.to == LogicalAddress(LogicalAddress::BROADCAST))){ - LOGINFO("Ignore Direct messages, accepts only broadcast messages"); - return; - } - HdmiCecSink::_instance->addDevice(header.from.toInt()); - HdmiCecSink::_instance->updateActiveSource(header.from.toInt(), msg); - } - void HdmiCecSinkProcessor::process (const InActiveSource &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: InActiveSource %s : %s : %s \n",GetOpName(msg.opCode()),msg.physicalAddress.name().c_str(),msg.physicalAddress.toString().c_str()); - if(header.to.toInt() == LogicalAddress::BROADCAST){ - LOGINFO("Ignore Broadcast messages, accepts only direct messages"); - return; - } - - HdmiCecSink::_instance->updateInActiveSource(header.from.toInt(), msg); - } - - void HdmiCecSinkProcessor::process (const ImageViewOn &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: ImageViewOn from %s\n", header.from.toString().c_str()); - if(header.to.toInt() == LogicalAddress::BROADCAST){ - LOGINFO("Ignore Broadcast messages, accepts only direct messages"); - return; - } - HdmiCecSink::_instance->addDevice(header.from.toInt()); - HdmiCecSink::_instance->updateImageViewOn(header.from.toInt()); - } - void HdmiCecSinkProcessor::process (const TextViewOn &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: TextViewOn\n"); - if(header.to.toInt() == LogicalAddress::BROADCAST){ - LOGINFO("Ignore Broadcast messages, accepts only direct messages"); - return; - } - HdmiCecSink::_instance->addDevice(header.from.toInt()); - HdmiCecSink::_instance->updateTextViewOn(header.from.toInt()); - } - void HdmiCecSinkProcessor::process (const RequestActiveSource &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: RequestActiveSource\n"); - if(!(header.to == LogicalAddress(LogicalAddress::BROADCAST))){ - LOGINFO("Ignore Direct messages, accepts only broadcast messages"); - return; - } - - HdmiCecSink::_instance->setActiveSource(true); - } - void HdmiCecSinkProcessor::process (const Standby &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: Standby from %s\n", header.from.toString().c_str()); - HdmiCecSink::_instance->SendStandbyMsgEvent(header.from.toInt()); - } - void HdmiCecSinkProcessor::process (const GetCECVersion &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: GetCECVersion sending CECVersion response \n"); - if(header.to.toInt() == LogicalAddress::BROADCAST){ - LOGINFO("Ignore Broadcast messages, accepts only direct messages"); - return; - } - try - { - if(cecVersion == 2.0) { - conn.sendToAsync(header.from, MessageEncoder().encode(CECVersion(Version::V_2_0))); - } - else{ - conn.sendToAsync(header.from, MessageEncoder().encode(CECVersion(Version::V_1_4))); - } - } - catch(...) - { - LOGWARN("Exception while sending CECVersion "); - } - } - void HdmiCecSinkProcessor::process (const CECVersion &msg, const Header &header) - { - bool updateStatus; - printHeader(header); - LOGINFO("Command: CECVersion Version : %s \n",msg.version.toString().c_str()); - - HdmiCecSink::_instance->addDevice(header.from.toInt()); - updateStatus = HdmiCecSink::_instance->deviceList[header.from.toInt()].m_isVersionUpdated; - LOGINFO("updateStatus %d\n",updateStatus); - HdmiCecSink::_instance->deviceList[header.from.toInt()].update(msg.version); - if(!updateStatus) - HdmiCecSink::_instance->sendDeviceUpdateInfo(header.from.toInt()); - } - void HdmiCecSinkProcessor::process (const SetMenuLanguage &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: SetMenuLanguage Language : %s \n",msg.language.toString().c_str()); - } - void HdmiCecSinkProcessor::process (const GiveOSDName &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: GiveOSDName sending SetOSDName : %s\n",osdName.toString().c_str()); - if(header.to.toInt() == LogicalAddress::BROADCAST){ - LOGINFO("Ignore Broadcast messages, accepts only direct messages"); - return; - } - try - { - conn.sendToAsync(header.from, MessageEncoder().encode(SetOSDName(osdName))); - } - catch(...) - { - LOGWARN("Exception while sending SetOSDName"); - } - } - void HdmiCecSinkProcessor::process (const GivePhysicalAddress &msg, const Header &header) - { - LOGINFO("Command: GivePhysicalAddress\n"); - if (!(header.to == LogicalAddress(LogicalAddress::BROADCAST))) - { - try - { - LOGINFO(" sending ReportPhysicalAddress response physical_addr :%s logicalAddress :%x \n",physical_addr.toString().c_str(), logicalAddress.toInt()); - conn.sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(ReportPhysicalAddress(physical_addr,logicalAddress.toInt())), 500); - } - catch(...) - { - LOGWARN("Exception while sending ReportPhysicalAddress "); - } - } - } - void HdmiCecSinkProcessor::process (const GiveDeviceVendorID &msg, const Header &header) - { - printHeader(header); - if(header.to == LogicalAddress(LogicalAddress::BROADCAST)){ - LOGINFO("Ignore Broadcast messages, accepts only direct messages"); - return; - } - try - { - LOGINFO("Command: GiveDeviceVendorID sending VendorID response :%s\n",appVendorId.toString().c_str()); - conn.sendToAsync(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(DeviceVendorID(appVendorId))); - } - catch(...) - { - LOGWARN("Exception while sending DeviceVendorID"); - } - - } - void HdmiCecSinkProcessor::process (const SetOSDString &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: SetOSDString OSDString : %s\n",msg.osdString.toString().c_str()); - } - void HdmiCecSinkProcessor::process (const SetOSDName &msg, const Header &header) - { - printHeader(header); - bool updateStatus ; - LOGINFO("Command: SetOSDName OSDName : %s\n",msg.osdName.toString().c_str()); - if(header.to.toInt() == LogicalAddress::BROADCAST){ - LOGINFO("Ignore Broadcast messages, accepts only direct messages"); - return; - } - - HdmiCecSink::_instance->addDevice(header.from.toInt()); - updateStatus = HdmiCecSink::_instance->deviceList[header.from.toInt()].m_isOSDNameUpdated; - LOGINFO("updateStatus %d\n",updateStatus); - HdmiCecSink::_instance->deviceList[header.from.toInt()].update(msg.osdName); - if(HdmiCecSink::_instance->deviceList[header.from.toInt()].m_isRequestRetry > 0 && - HdmiCecSink::_instance->deviceList[header.from.toInt()].m_isRequested == CECDeviceParams::REQUEST_OSD_NAME) { - HdmiCecSink::_instance->deviceList[header.from.toInt()].m_isRequestRetry = 0; - } - if(!updateStatus) - HdmiCecSink::_instance->sendDeviceUpdateInfo(header.from.toInt()); - } - void HdmiCecSinkProcessor::process (const RoutingChange &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: RoutingChange From : %s To: %s \n",msg.from.toString().c_str(),msg.to.toString().c_str()); - } - void HdmiCecSinkProcessor::process (const RoutingInformation &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: RoutingInformation Routing Information to Sink : %s\n",msg.toSink.toString().c_str()); - } - void HdmiCecSinkProcessor::process (const SetStreamPath &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: SetStreamPath Set Stream Path to Sink : %s\n",msg.toSink.toString().c_str()); - } - void HdmiCecSinkProcessor::process (const GetMenuLanguage &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: GetMenuLanguage\n"); - if(header.to.toInt() == LogicalAddress::BROADCAST){ - LOGINFO("Ignore Broadcast messages, accepts only direct messages"); - return; - } - HdmiCecSink::_instance->sendMenuLanguage(); - } - void HdmiCecSinkProcessor::process (const ReportPhysicalAddress &msg, const Header &header) - { - printHeader(header); - bool updateDeviceTypeStatus; - bool updatePAStatus; - LOGINFO("Command: ReportPhysicalAddress\n"); - if(!(header.to == LogicalAddress(LogicalAddress::BROADCAST))){ - LOGINFO("Ignore Direct messages, accepts only broadcast messages"); - return; - } - - if(!HdmiCecSink::_instance) - return; - HdmiCecSink::_instance->addDevice(header.from.toInt()); - updateDeviceTypeStatus = HdmiCecSink::_instance->deviceList[header.from.toInt()].m_isDeviceTypeUpdated; - updatePAStatus = HdmiCecSink::_instance->deviceList[header.from.toInt()].m_isPAUpdated; - LOGINFO("updateDeviceTypeStatus %d updatePAStatus %d \n",updateDeviceTypeStatus,updatePAStatus); - if(HdmiCecSink::_instance->deviceList[header.from.toInt()].m_physicalAddr.toString() != msg.physicalAddress.toString() && updatePAStatus){ - updatePAStatus= false; - LOGINFO("There is a change in physical address from current PA %s to newly reported PA %s\n",HdmiCecSink::_instance->deviceList[header.from.toInt()].m_physicalAddr.toString().c_str(),msg.physicalAddress.toString().c_str()); - } - HdmiCecSink::_instance->deviceList[header.from.toInt()].update(msg.physicalAddress); - HdmiCecSink::_instance->deviceList[header.from.toInt()].update(msg.deviceType); - if(HdmiCecSink::_instance->deviceList[header.from.toInt()].m_isRequestRetry > 0 && - HdmiCecSink::_instance->deviceList[header.from.toInt()].m_isRequested == CECDeviceParams::REQUEST_PHISICAL_ADDRESS) { - HdmiCecSink::_instance->deviceList[header.from.toInt()].m_isRequestRetry = 0; - } - HdmiCecSink::_instance->updateDeviceChain(header.from, msg.physicalAddress); - if (!updateDeviceTypeStatus || !updatePAStatus) - HdmiCecSink::_instance->sendDeviceUpdateInfo(header.from.toInt()); - } - void HdmiCecSinkProcessor::process (const DeviceVendorID &msg, const Header &header) - { - bool updateStatus ; - printHeader(header); - LOGINFO("Command: DeviceVendorID VendorID : %s\n",msg.vendorId.toString().c_str()); - if(!(header.to == LogicalAddress(LogicalAddress::BROADCAST))){ - LOGINFO("Ignore Direct messages, accepts only broadcast messages"); - return; - } - - HdmiCecSink::_instance->addDevice(header.from.toInt()); - updateStatus = HdmiCecSink::_instance->deviceList[header.from.toInt()].m_isVendorIDUpdated; - LOGINFO("updateStatus %d\n",updateStatus); - HdmiCecSink::_instance->deviceList[header.from.toInt()].update(msg.vendorId); - if (!updateStatus) - HdmiCecSink::_instance->sendDeviceUpdateInfo(header.from.toInt()); - } - void HdmiCecSinkProcessor::process (const GiveDevicePowerStatus &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: GiveDevicePowerStatus sending powerState :%d \n",powerState); - if(header.to.toInt() == LogicalAddress::BROADCAST){ - LOGINFO("Ignore Broadcast messages, accepts only direct messages"); - return; - } - try - { - conn.sendTo(header.from, MessageEncoder().encode(ReportPowerStatus(PowerStatus(powerState)))); - } - catch(...) - { - LOGWARN("Exception while sending ReportPowerStatus"); - } - } - void HdmiCecSinkProcessor::process (const ReportPowerStatus &msg, const Header &header) - { - uint32_t oldPowerStatus,newPowerStatus; - printHeader(header); - LOGINFO("Command: ReportPowerStatus Power Status from:%s status : %s \n",header.from.toString().c_str(),msg.status.toString().c_str()); - if(header.to.toInt() == LogicalAddress::BROADCAST){ - LOGINFO("Ignore Broadcast messages, accepts only direct messages"); - return; - } - oldPowerStatus = HdmiCecSink::_instance->deviceList[header.from.toInt()].m_powerStatus.toInt(); - HdmiCecSink::_instance->addDevice(header.from.toInt()); - HdmiCecSink::_instance->deviceList[header.from.toInt()].update(msg.status); - newPowerStatus = HdmiCecSink::_instance->deviceList[header.from.toInt()].m_powerStatus.toInt(); - LOGINFO(" oldPowerStatus %d newpower status %d \n",oldPowerStatus,newPowerStatus); - if ((oldPowerStatus != newPowerStatus) ) - { - HdmiCecSink::_instance->sendDeviceUpdateInfo(header.from.toInt()); - } - - if((header.from.toInt() == LogicalAddress::AUDIO_SYSTEM) && (HdmiCecSink::_instance->m_audioDevicePowerStatusRequested)) { - HdmiCecSink::_instance->reportAudioDevicePowerStatusInfo(header.from.toInt(), newPowerStatus); - } - - } - void HdmiCecSinkProcessor::process (const FeatureAbort &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: FeatureAbort opcode=%s, Reason = %s\n", msg.feature.toString().c_str(), msg.reason.toString().c_str()); - if(header.to.toInt() == LogicalAddress::BROADCAST){ - LOGINFO("Ignore Broadcast messages, accepts only direct messages"); - return; - } - - if(header.from.toInt() < LogicalAddress::UNREGISTERED && - msg.reason.toInt() == AbortReason::UNRECOGNIZED_OPCODE) - { - switch(msg.feature.opCode()) - { - case GET_CEC_VERSION : - { - /* If we get a Feature abort for CEC Version then default to 1.4b */ - HdmiCecSink::_instance->deviceList[header.from.toInt()].update(Version(Version::V_1_4)); - } - break; - case GIVE_DEVICE_VENDOR_ID : - { - /* If we get a Feature abort for CEC Version then default to 1.4b */ - HdmiCecSink::_instance->deviceList[header.from.toInt()].update(VendorID((uint8_t *)"FA", 2)); - } - break; - - case GIVE_OSD_NAME : - { - HdmiCecSink::_instance->deviceList[header.from.toInt()].update(OSDName("")); - } - break; - - case GIVE_DEVICE_POWER_STATUS : - { - HdmiCecSink::_instance->deviceList[header.from.toInt()].update(PowerStatus(PowerStatus::POWER_STATUS_FEATURE_ABORT)); - } - break; - } - - HdmiCecSink::_instance->deviceList[header.from.toInt()].m_featureAborts.push_back(msg); - } - - LogicalAddress logicaladdress = header.from.toInt(); - OpCode featureOpcode = msg.feature; - AbortReason abortReason = msg.reason; - - HdmiCecSink::_instance->reportFeatureAbortEvent(logicaladdress,featureOpcode,abortReason); - - if(msg.feature.opCode() == REQUEST_SHORT_AUDIO_DESCRIPTOR) - { - JsonArray audiodescriptor; - audiodescriptor.Add(0); - HdmiCecSink::_instance->Send_ShortAudioDescriptor_Event(audiodescriptor); - } - - } - void HdmiCecSinkProcessor::process (const Abort &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: Abort\n"); - if (!(header.to == LogicalAddress(LogicalAddress::BROADCAST))) - { - AbortReason reason = AbortReason::UNRECOGNIZED_OPCODE; - LogicalAddress logicaladdress =header.from.toInt(); - OpCode feature = msg.opCode(); - HdmiCecSink::_instance->sendFeatureAbort(logicaladdress, feature,reason); - } - else - { - LOGINFO("Command: Abort broadcast msg so ignore\n"); - } - } - void HdmiCecSinkProcessor::process (const Polling &msg, const Header &header) { - printHeader(header); - LOGINFO("Command: Polling\n"); - } - - void HdmiCecSinkProcessor::process (const InitiateArc &msg, const Header &header) - { - printHeader(header); - if((!(header.from.toInt() == 0x5)) || (header.to.toInt() == LogicalAddress::BROADCAST)){ - LOGINFO("Ignoring the message coming from addresses other than 0X5 or a braodcast message"); - return; - } - PhysicalAddress physical_addr_invalid = {0x0F,0x0F,0x0F,0x0F}; - PhysicalAddress physical_addr_arc_port = {0x0F,0x0F,0x0F,0x0F}; - - LOGINFO("Command: INITIATE_ARC \n"); - if(!HdmiCecSink::_instance || HdmiArcPortID == -1) - return; - - if (HdmiArcPortID == 0 ) - physical_addr_arc_port = {0x01,0x00,0x00,0x00}; - if (HdmiArcPortID == 1 ) - physical_addr_arc_port = {0x02,0x00,0x00,0x00}; - if (HdmiArcPortID == 2 ) - physical_addr_arc_port = {0x03,0x00,0x00,0x00}; - - if( (HdmiCecSink::_instance->deviceList[0x5].m_physicalAddr.toString() == physical_addr_arc_port.toString()) || (HdmiCecSink::_instance->deviceList[0x5].m_physicalAddr.toString() == physical_addr_invalid.toString()) ) { - LOGINFO("Command: INITIATE_ARC InitiateArc success %s \n",HdmiCecSink::_instance->deviceList[0x5].m_physicalAddr.toString().c_str()); - HdmiCecSink::_instance->Process_InitiateArc(); - } else { - LOGINFO("Command: INITIATE_ARC InitiateArc ignore %s \n",HdmiCecSink::_instance->deviceList[0x5].m_physicalAddr.toString().c_str()); - } - } - void HdmiCecSinkProcessor::process (const TerminateArc &msg, const Header &header) - { - printHeader(header); - if((!(header.from.toInt() == 0x5)) || (header.to.toInt() == LogicalAddress::BROADCAST)){ - LOGINFO("Ignoring the message coming from addresses other than 0X5 or a braodcast message"); - return; - } - if(!HdmiCecSink::_instance) - return; - HdmiCecSink::_instance->Process_TerminateArc(); - } - void HdmiCecSinkProcessor::process (const ReportShortAudioDescriptor &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: ReportShortAudioDescriptor %s : %d \n",GetOpName(msg.opCode()),numberofdescriptor); - HdmiCecSink::_instance->Process_ShortAudioDescriptor_msg(msg); - } - - void HdmiCecSinkProcessor::process (const SetSystemAudioMode &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: SetSystemAudioMode %s audio status %d audio status is %s \n",GetOpName(msg.opCode()),msg.status.toInt(),msg.status.toString().c_str()); - HdmiCecSink::_instance->Process_SetSystemAudioMode_msg(msg); - } - void HdmiCecSinkProcessor::process (const ReportAudioStatus &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: ReportAudioStatus %s audio Mute status %d means %s and current Volume level is %d \n",GetOpName(msg.opCode()),msg.status.getAudioMuteStatus(),msg.status.toString().c_str(),msg.status.getAudioVolume()); - if(header.to.toInt() == LogicalAddress::BROADCAST){ - LOGINFO("Ignore Broadcast messages, accepts only direct messages"); - return; - } - HdmiCecSink::_instance->Process_ReportAudioStatus_msg(msg); - } - void HdmiCecSinkProcessor::process (const GiveFeatures &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: GiveFeatures \n"); - try - { - if(cecVersion == 2.0) { - conn.sendToAsync(LogicalAddress(LogicalAddress::BROADCAST),MessageEncoder().encode(ReportFeatures(Version::V_2_0,allDevicetype,rcProfile,deviceFeatures))); - } - } - catch(...) - { - LOGWARN("Exception while sending ReportFeatures"); - } - } - void HdmiCecSinkProcessor::process (const RequestCurrentLatency &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: Request Current Latency :%s, physical address: %s",GetOpName(msg.opCode()),msg.physicaladdress.toString().c_str()); - - if(msg.physicaladdress.toString() == physical_addr.toString()) { - HdmiCecSink::_instance->setLatencyInfo(); - } - else { - LOGINFO("Physical Address does not match with TV's physical address"); - return; - } - } -//=========================================== HdmiCecSink ========================================= - - HdmiCecSink::HdmiCecSink() - : PluginHost::JSONRPC() - , _pwrMgrNotification(*this) - , _registeredEventHandlers(false) - { - LOGWARN("Initlaizing HdmiCecSink"); - } - - HdmiCecSink::~HdmiCecSink() - { - } - const std::string HdmiCecSink::Initialize(PluginHost::IShell *service) - { - InitializePowerManager(service); - profileType = searchRdkProfile(); - - if (profileType == STB || profileType == NOT_FOUND) - { - LOGINFO("Invalid profile type for TV \n"); - return (std::string("Not supported")); - } - - HdmiCecSink::_instance = this; - smConnection=NULL; - cecEnableStatus = false; - HdmiCecSink::_instance->m_numberOfDevices = 0; - m_logicalAddressAllocated = LogicalAddress::UNREGISTERED; - m_currentActiveSource = -1; - m_isHdmiInConnected = false; - hdmiCecAudioDeviceConnected = false; - m_isAudioStatusInfoUpdated = false; - m_audioStatusReceived = false; - m_audioStatusTimerStarted = false; - m_audioDevicePowerStatusRequested = false; - m_pollNextState = POLL_THREAD_STATE_NONE; - m_pollThreadState = POLL_THREAD_STATE_NONE; - m_video_latency = DEFAULT_VIDEO_LATENCY; - m_latency_flags = DEFAULT_LATENCY_FLAGS ; - m_audio_output_delay = DEFAULT_AUDIO_OUTPUT_DELAY; - - Register(HDMICECSINK_METHOD_SET_ENABLED, &HdmiCecSink::setEnabledWrapper, this); - Register(HDMICECSINK_METHOD_GET_ENABLED, &HdmiCecSink::getEnabledWrapper, this); - Register(HDMICECSINK_METHOD_SET_OSD_NAME, &HdmiCecSink::setOSDNameWrapper, this); - Register(HDMICECSINK_METHOD_GET_OSD_NAME, &HdmiCecSink::getOSDNameWrapper, this); - Register(HDMICECSINK_METHOD_SET_VENDOR_ID, &HdmiCecSink::setVendorIdWrapper, this); - Register(HDMICECSINK_METHOD_GET_VENDOR_ID, &HdmiCecSink::getVendorIdWrapper, this); - Register(HDMICECSINK_METHOD_PRINT_DEVICE_LIST, &HdmiCecSink::printDeviceListWrapper, this); - Register(HDMICECSINK_METHOD_SET_ACTIVE_PATH, &HdmiCecSink::setActivePathWrapper, this); - Register(HDMICECSINK_METHOD_SET_ROUTING_CHANGE, &HdmiCecSink::setRoutingChangeWrapper, this); - Register(HDMICECSINK_METHOD_GET_DEVICE_LIST, &HdmiCecSink::getDeviceListWrapper, this); - Register(HDMICECSINK_METHOD_GET_ACTIVE_SOURCE, &HdmiCecSink::getActiveSourceWrapper, this); - Register(HDMICECSINK_METHOD_SET_ACTIVE_SOURCE, &HdmiCecSink::setActiveSourceWrapper, this); - Register(HDMICECSINK_METHOD_GET_ACTIVE_ROUTE, &HdmiCecSink::getActiveRouteWrapper, this); - Register(HDMICECSINK_METHOD_REQUEST_ACTIVE_SOURCE, &HdmiCecSink::requestActiveSourceWrapper, this); - Register(HDMICECSINK_METHOD_SETUP_ARC, &HdmiCecSink::setArcEnableDisableWrapper, this); - Register(HDMICECSINK_METHOD_SET_MENU_LANGUAGE, &HdmiCecSink::setMenuLanguageWrapper, this); - Register(HDMICECSINK_METHOD_REQUEST_SHORT_AUDIO_DESCRIPTOR, &HdmiCecSink::requestShortAudioDescriptorWrapper, this); - Register(HDMICECSINK_METHOD_SEND_STANDBY_MESSAGE, &HdmiCecSink::sendStandbyMessageWrapper, this); - Register(HDMICECSINK_METHOD_SEND_AUDIO_DEVICE_POWER_ON, &HdmiCecSink::sendAudioDevicePowerOnMsgWrapper, this); - Register(HDMICECSINK_METHOD_SEND_KEY_PRESS,&HdmiCecSink::sendRemoteKeyPressWrapper,this); - Register(HDMICECSINK_METHOD_SEND_USER_CONTROL_PRESSED,&HdmiCecSink::sendUserControlPressedWrapper,this); - Register(HDMICECSINK_METHOD_SEND_USER_CONTROL_RELEASED,&HdmiCecSink::sendUserControlReleasedWrapper,this); - Register(HDMICECSINK_METHOD_SEND_GIVE_AUDIO_STATUS,&HdmiCecSink::sendGiveAudioStatusWrapper,this); - Register(HDMICECSINK_METHOD_GET_AUDIO_DEVICE_CONNECTED_STATUS,&HdmiCecSink::getAudioDeviceConnectedStatusWrapper,this); - Register(HDMICECSINK_METHOD_REQUEST_AUDIO_DEVICE_POWER_STATUS,&HdmiCecSink::requestAudioDevicePowerStatusWrapper,this); - Register(HDMICECSINK_METHOD_SET_LATENCY_INFO, &HdmiCecSink::setLatencyInfoWrapper, this); - logicalAddressDeviceType = "None"; - logicalAddress = 0xFF; - // load persistence setting - loadSettings(); - - int err; - dsHdmiInGetNumberOfInputsParam_t hdmiInput; - InitializeIARM(); - m_sendKeyEventThreadExit = false; - m_sendKeyEventThread = std::thread(threadSendKeyEvent); - - m_currentArcRoutingState = ARC_STATE_ARC_TERMINATED; - m_semSignaltoArcRoutingThread.acquire(); - m_arcRoutingThread = std::thread(threadArcRouting); - - m_audioStatusDetectionTimer.connect( std::bind( &HdmiCecSink::audioStatusTimerFunction, this ) ); - m_audioStatusDetectionTimer.setSingleShot(true); - m_arcStartStopTimer.connect( std::bind( &HdmiCecSink::arcStartStopTimerFunction, this ) ); - m_arcStartStopTimer.setSingleShot(true); - // get power state: - Core::hresult res = Core::ERROR_GENERAL; - PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; - PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; - - ASSERT (_powerManagerPlugin); - if (_powerManagerPlugin) { - res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev); - if (Core::ERROR_NONE == res) { - powerState = (pwrStateCur == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON) ? DEVICE_POWER_STATE_ON : DEVICE_POWER_STATE_OFF; - LOGINFO("Current state is PowerManagerPlugin: (%d) powerState :%d \n", pwrStateCur, powerState); - } - } - - err = IARM_Bus_Call(IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_API_dsHdmiInGetNumberOfInputs, - (void *)&hdmiInput, - sizeof(hdmiInput)); - - if (err == IARM_RESULT_SUCCESS && hdmiInput.result == dsERR_NONE) - { - LOGINFO("Number of Inputs [%d] \n", hdmiInput.numHdmiInputs ); - m_numofHdmiInput = hdmiInput.numHdmiInputs; - }else{ - LOGINFO("Not able to get Numebr of inputs so defaulting to 3 \n"); - m_numofHdmiInput = 3; - } - - LOGINFO("initalize inputs \n"); - - for (int i = 0; i < m_numofHdmiInput; i++){ - HdmiPortMap hdmiPort((uint8_t)i); - LOGINFO(" Add to vector [%d] \n", i); - hdmiInputs.push_back(hdmiPort); - } - - LOGINFO("Check the HDMI State \n"); - - CheckHdmiInState(); - if (cecSettingEnabled) - { - try - { - CECEnable(); - } - catch(...) - { - LOGWARN("Exception while enabling CEC settings .\r\n"); - } - } - getCecVersion(); - LOGINFO(" HdmiCecSink plugin Initialize completed \n"); - return (std::string()); - - } - - void HdmiCecSink::Deinitialize(PluginHost::IShell* /* service */) - { - if(_powerManagerPlugin) - { - _powerManagerPlugin->Unregister(_pwrMgrNotification.baseInterface()); - _powerManagerPlugin.Reset(); - } - _registeredEventHandlers = false; - - profileType = searchRdkProfile(); - - if (profileType == STB || profileType == NOT_FOUND) - { - LOGINFO("Invalid profile type for TV \n"); - return ; - } - - CECDisable(); - m_currentArcRoutingState = ARC_STATE_ARC_EXIT; - - m_semSignaltoArcRoutingThread.release(); - - try - { - if (m_arcRoutingThread.joinable()) - m_arcRoutingThread.join(); - } - catch(const std::system_error& e) - { - LOGERR("system_error exception in thread join %s", e.what()); - } - catch(const std::exception& e) - { - LOGERR("exception in thread join %s", e.what()); - } - - { - m_sendKeyEventThreadExit = true; - std::unique_lock lk(m_sendKeyEventMutex); - m_sendKeyEventThreadRun = true; - m_sendKeyCV.notify_one(); - } - - try - { - if (m_sendKeyEventThread.joinable()) - m_sendKeyEventThread.join(); - } - catch(const std::system_error& e) - { - LOGERR("system_error exception in thread join %s", e.what()); - } - catch(const std::exception& e) - { - LOGERR("exception in thread join %s", e.what()); - } - - HdmiCecSink::_instance = nullptr; - DeinitializeIARM(); - LOGWARN(" HdmiCecSink Deinitialize() Done"); - } - - const void HdmiCecSink::InitializeIARM() - { - if (Utils::IARM::init()) - { - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, dsHdmiEventHandler) ); - } - } - - void HdmiCecSink::DeinitializeIARM() - { - if (Utils::IARM::isConnected()) - { - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, dsHdmiEventHandler) ); - } - } - - void HdmiCecSink::InitializePowerManager(PluginHost::IShell *service) - { - _powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager")) - .withIShell(service) - .withRetryIntervalMS(200) - .withRetryCount(25) - .createInterface(); - registerEventHandlers(); - } - void HdmiCecSink::registerEventHandlers() - { - ASSERT (_powerManagerPlugin); - - if(!_registeredEventHandlers && _powerManagerPlugin) { - _registeredEventHandlers = true; - _powerManagerPlugin->Register(_pwrMgrNotification.baseInterface()); - } - } - - void HdmiCecSink::dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiCecSink::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - bool isHdmiConnected = eventData->data.hdmi_in_connect.isPortConnected; - dsHdmiInPort_t portId = eventData->data.hdmi_in_connect.port; - LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG event port: %d data:%d \r\n",portId, isHdmiConnected); - HdmiCecSink::_instance->onHdmiHotPlug(portId,isHdmiConnected); - } - } - - void HdmiCecSink::onPowerModeChanged(const PowerState currentState, const PowerState newState) - { - if(!HdmiCecSink::_instance) - return; - - LOGINFO("Event IARM_BUS_PWRMGR_EVENT_MODECHANGED: State Changed %d -- > %d\r", - currentState, newState); - LOGWARN(" m_logicalAddressAllocated 0x%x CEC enable status %d \n",_instance->m_logicalAddressAllocated,_instance->cecEnableStatus); - if(newState == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON) - { - powerState = DEVICE_POWER_STATE_ON; - } - else - { - powerState = DEVICE_POWER_STATE_OFF; - if((_instance->m_currentArcRoutingState == ARC_STATE_REQUEST_ARC_INITIATION) || (_instance->m_currentArcRoutingState == ARC_STATE_ARC_INITIATED)) - { - LOGINFO("%s: Stop ARC \n",__FUNCTION__); - _instance->stopArc(); - } - - } - if (_instance->cecEnableStatus) - { - if ( _instance->m_logicalAddressAllocated != LogicalAddress::UNREGISTERED ) - { - _instance->deviceList[_instance->m_logicalAddressAllocated].m_powerStatus = PowerStatus(powerState); - - if ( powerState != DEVICE_POWER_STATE_ON ) - { - /* reset the current active source when TV on going to standby */ - HdmiCecSink::_instance->m_currentActiveSource = -1; - } - /* Initiate a ping straight away */ - HdmiCecSink::_instance->m_pollNextState = POLL_THREAD_STATE_PING; - HdmiCecSink::_instance->m_ThreadExitCV.notify_one(); - } - } - else - { - LOGWARN("CEC not Enabled\n"); - } - } - - - void HdmiCecSink::sendStandbyMessage() - { - if(!HdmiCecSink::_instance) - return; - if(!(HdmiCecSink::_instance->smConnection)) - return; - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED){ - LOGERR("Logical Address NOT Allocated Or its not valid"); - return; - } - - _instance->smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(Standby()), 1000); - } - - void HdmiCecSink::onHdmiHotPlug(int portId , int connectStatus) - { - LOGINFO("onHdmiHotPlug Status : %d ", connectStatus); - if(!connectStatus) - { - LOGINFO(" removeDevice port: %d Logical address :%d \r\n",portId,hdmiInputs[portId].m_logicalAddr.toInt() ); - _instance->removeDevice(hdmiInputs[portId].m_logicalAddr.toInt()); - } - CheckHdmiInState(); - - if(cecEnableStatus) { - LOGINFO("cecEnableStatus : %d Trigger CEC Ping !!! \n", cecEnableStatus); - m_pollNextState = POLL_THREAD_STATE_PING; - m_ThreadExitCV.notify_one(); - } - if( HdmiArcPortID >= 0 ) { - updateArcState(); - } - return; - } - void HdmiCecSink::updateArcState() - { - if ( m_currentArcRoutingState != ARC_STATE_ARC_TERMINATED ) - { - if (!(hdmiInputs[HdmiArcPortID].m_isConnected)) - { - std::lock_guard lock(_instance->m_arcRoutingStateMutex); - m_currentArcRoutingState = ARC_STATE_ARC_TERMINATED; - } - else - { - LOGINFO("updateArcState :not updating ARC state current arc state %d ",m_currentArcRoutingState); - } - } - } - void HdmiCecSink::arcStartStopTimerFunction() - { - JsonObject params; - - if (m_arcstarting) - { - LOGINFO("arcStartStopTimerFunction ARC start timer expired"); - LOGINFO("notify_device setting that Initiate ARC failed to get the ARC_STATE_ARC_INITIATED state\n"); - params["status"] = string("failure"); - sendNotify(eventString[HDMICECSINK_EVENT_ARC_INITIATION_EVENT], params); - } - else - { - LOGINFO("arcStartStopTimerFunction ARC stop timer expired"); - LOGINFO("notify_device setting that Terminate ARC failed to get the ARC_STATE_ARC_TERMINATED state\n"); - params["status"] = string("failure"); - sendNotify(eventString[HDMICECSINK_EVENT_ARC_TERMINATION_EVENT], params); - - - } - /* bring the state machine to the clean state for a new start */ - std::lock_guard lock(_instance->m_arcRoutingStateMutex); - m_currentArcRoutingState = ARC_STATE_ARC_TERMINATED; - } - void HdmiCecSink::Send_ShortAudioDescriptor_Event(JsonArray audiodescriptor) - { - JsonObject params; - - LOGINFO("Notify the DS "); - params["ShortAudioDescriptor"]= JsonValue(audiodescriptor); - sendNotify(eventString[HDMICECSINK_EVENT_SHORT_AUDIODESCRIPTOR_EVENT], params); - } - - void HdmiCecSink::Process_ShortAudioDescriptor_msg(const ReportShortAudioDescriptor &msg) - { - uint8_t numberofdescriptor = msg.numberofdescriptor; - uint32_t descriptor =0; - JsonArray audiodescriptor; - - if (numberofdescriptor) - { - for( uint8_t i=0; i < numberofdescriptor; i++) - { - descriptor = msg.shortAudioDescriptor[i].getAudiodescriptor(); - - LOGINFO("descriptor%d 0x%x\n",i,descriptor); - audiodescriptor.Add(descriptor); - - } - } - else - { - audiodescriptor.Add(descriptor); - } - HdmiCecSink::_instance->Send_ShortAudioDescriptor_Event(audiodescriptor); - } - - void HdmiCecSink::updateCurrentLatency(int videoLatency, bool lowLatencyMode,int audioOutputCompensated, int audioOutputDelay = 0) - { - uint8_t latencyFlags = 0; - latencyFlags = ((lowLatencyMode & 0x1) << 2) | (audioOutputCompensated & 0x3); - LOGINFO("Video Latency : %d , Low Latency Mode : %d ,Audio Output Compensated value : %d , Audio Output Delay : %d , Latency Flags: %d ", videoLatency, lowLatencyMode, audioOutputCompensated, audioOutputDelay, latencyFlags); - m_video_latency = (videoLatency/2) + 1; - m_latency_flags = latencyFlags; - m_audio_output_delay = (audioOutputDelay/2) + 1; - setLatencyInfo(); - } - - void HdmiCecSink::setLatencyInfo() - { - if(!HdmiCecSink::_instance) - return; - - if(!(_instance->smConnection)) - return; - - LOGINFO("Send Report Current Latency message \n"); - _instance->smConnection->sendTo(LogicalAddress::BROADCAST,MessageEncoder().encode(ReportCurrentLatency(physical_addr,m_video_latency,m_latency_flags,m_audio_output_delay))); - - } - - void HdmiCecSink::Process_SetSystemAudioMode_msg(const SetSystemAudioMode &msg) - { - JsonObject params; - if(!HdmiCecSink::_instance) - return; - - //DD: Check cecSettingEnabled to prevent race conditions which gives immediate UI setting status - //SetSystemAudioMode message may come from AVR/Soundbar while CEC disable is in-progress - if ( cecSettingEnabled != true ) - { - LOGINFO("Process SetSystemAudioMode from Audio device: Cec is disabled-> EnableCEC first"); - return; - } - - if ( (msg.status.toInt() == SYSTEM_AUDIO_MODE_OFF) && (m_currentArcRoutingState == ARC_STATE_ARC_INITIATED)) - { - /* ie system audio mode off -> amplifier goign to standby but still ARC is in initiated state,stop ARC and - bring the ARC state machine to terminated state*/ - LOGINFO("system audio mode off message but arc is not in terminated state so stopping ARC"); - stopArc(); - - } - - params["audioMode"] = msg.status.toString().c_str(); - if (msg.status.toInt() == SYSTEM_AUDIO_MODE_ON) { - LOGINFO("panel power state is %s", powerState ? "Off" : "On"); - if (powerState == DEVICE_POWER_STATE_ON ) { - LOGINFO("Notifying system audio mode ON event"); - sendNotify(eventString[HDMICECSINK_EVENT_SYSTEM_AUDIO_MODE], params); - } else { - LOGINFO("Not notifying system audio mode ON event"); - } - } else { - LOGINFO("Notifying system audio Mode OFF event"); - sendNotify(eventString[HDMICECSINK_EVENT_SYSTEM_AUDIO_MODE], params); - } - } - void HdmiCecSink::Process_ReportAudioStatus_msg(const ReportAudioStatus msg) - { - JsonObject params; - if(!HdmiCecSink::_instance) - return; - if (m_audioStatusTimerStarted) - { - m_audioStatusReceived = true; - m_isAudioStatusInfoUpdated = true; - m_audioStatusTimerStarted = false; - if (m_audioStatusDetectionTimer.isActive()) - { - LOGINFO("AudioStatus received from the Audio Device and the timer is still active. So stopping the timer!\n"); - m_audioStatusDetectionTimer.stop(); - } - LOGINFO("AudioStatus received from the Audio Device. Updating the AudioStatus info! m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d ", m_isAudioStatusInfoUpdated,m_audioStatusReceived,m_audioStatusTimerStarted); - } - LOGINFO("Command: ReportAudioStatus %s audio Mute status %d means %s and current Volume level is %d \n",GetOpName(msg.opCode()),msg.status.getAudioMuteStatus(),msg.status.toString().c_str(),msg.status.getAudioVolume()); - params["muteStatus"] = msg.status.getAudioMuteStatus(); - params["volumeLevel"] = msg.status.getAudioVolume(); - sendNotify(eventString[HDMICECSINK_EVENT_REPORT_AUDIO_STATUS], params); - - } - void HdmiCecSink::sendKeyPressEvent(const int logicalAddress, int keyCode) - { - if(!(_instance->smConnection)) - return; - LOGINFO(" sendKeyPressEvent logicalAddress 0x%x keycode 0x%x\n",logicalAddress,keyCode); - switch(keyCode) - { - case VOLUME_UP: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_VOLUME_UP)),100); - break; - case VOLUME_DOWN: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_VOLUME_DOWN)), 100); - break; - case MUTE: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_MUTE)), 100); - break; - case UP: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_UP)), 100); - break; - case DOWN: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_DOWN)), 100); - break; - case LEFT: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_LEFT)), 100); - break; - case RIGHT: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_RIGHT)), 100); - break; - case SELECT: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_SELECT)), 100); - break; - case HOME: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_HOME)), 100); - break; - case BACK: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_BACK)), 100); - break; - case NUMBER_0: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_0)), 100); - break; - case NUMBER_1: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_1)), 100); - break; - case NUMBER_2: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_2)), 100); - break; - case NUMBER_3: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_3)), 100); - break; - case NUMBER_4: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_4)), 100); - break; - case NUMBER_5: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_5)), 100); - break; - case NUMBER_6: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_6)), 100); - break; - case NUMBER_7: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_7)), 100); - break; - case NUMBER_8: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_8)), 100); - break; - case NUMBER_9: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_9)), 100); - break; - - } - } - - void HdmiCecSink::sendUserControlPressed(const int logicalAddress, int keyCode) - { - if(!(_instance->smConnection)) - return; - LOGINFO(" sendUserControlPressed logicalAddress 0x%x keycode 0x%x\n",logicalAddress,keyCode); - switch(keyCode) - { - case VOLUME_UP: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_VOLUME_UP)),100); - break; - case VOLUME_DOWN: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_VOLUME_DOWN)), 100); - break; - case MUTE: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_MUTE)), 100); - break; - case UP: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_UP)), 100); - break; - case DOWN: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_DOWN)), 100); - break; - case LEFT: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_LEFT)), 100); - break; - case RIGHT: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_RIGHT)), 100); - break; - case SELECT: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_SELECT)), 100); - break; - case HOME: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_HOME)), 100); - break; - case BACK: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_BACK)), 100); - break; - case NUMBER_0: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_0)), 100); - break; - case NUMBER_1: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_1)), 100); - break; - case NUMBER_2: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_2)), 100); - break; - case NUMBER_3: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_3)), 100); - break; - case NUMBER_4: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_4)), 100); - break; - case NUMBER_5: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_5)), 100); - break; - case NUMBER_6: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_6)), 100); - break; - case NUMBER_7: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_7)), 100); - break; - case NUMBER_8: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_8)), 100); - break; - case NUMBER_9: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_9)), 100); - break; - - } - } - - void HdmiCecSink::sendKeyReleaseEvent(const int logicalAddress) - { - if(!(_instance->smConnection)) - return; - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlReleased()), 100); - - } - - void HdmiCecSink::sendUserControlReleased(const int logicalAddress) - { - if(!(_instance->smConnection)) - return; - LOGINFO(" User Control Released \n"); - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlReleased()), 100); - } - - void HdmiCecSink::sendDeviceUpdateInfo(const int logicalAddress) - { - JsonObject params; - params["logicalAddress"] = JsonValue(logicalAddress); - sendNotify(eventString[HDMICECSINK_EVENT_DEVICE_INFO_UPDATED], params); - } - void HdmiCecSink::systemAudioModeRequest() - { - if ( cecEnableStatus != true ) - { - LOGINFO("systemAudioModeRequest: Cec is disabled-> EnableCEC first"); - return; - } - - if(!HdmiCecSink::_instance) - return; - if(!(_instance->smConnection)) - return; - LOGINFO(" Send systemAudioModeRequest "); - _instance->smConnection->sendTo(LogicalAddress::AUDIO_SYSTEM,MessageEncoder().encode(SystemAudioModeRequest(physical_addr)), 1000); - - } - void HdmiCecSink::sendGiveAudioStatusMsg() - { - if(!HdmiCecSink::_instance) - return; - if(!(_instance->smConnection)) - return; - LOGINFO(" Send GiveAudioStatus "); - _instance->smConnection->sendTo(LogicalAddress::AUDIO_SYSTEM,MessageEncoder().encode(GiveAudioStatus()), 100); - - } - void HdmiCecSink::reportAudioDevicePowerStatusInfo(const int logicalAddress, const int powerStatus) - { - JsonObject params; - params["powerStatus"] = JsonValue(powerStatus); - LOGINFO("Panle power state is %s", powerState ? "Off" : "On"); - if (powerStatus != AUDIO_DEVICE_POWERSTATE_OFF) { - if (powerState == DEVICE_POWER_STATE_ON ) { - LOGINFO("Notify DS!!! logicalAddress = %d , Audio device power status = %d \n", logicalAddress, powerStatus); - sendNotify(eventString[HDMICECSINK_EVENT_AUDIO_DEVICE_POWER_STATUS], params); - } else { - LOGINFO("Not notifying audio device power state to DS"); - } - } else { - LOGINFO("Notify DS!!! logicalAddress = %d , Audio device power status = %d \n", logicalAddress, powerStatus); - sendNotify(eventString[HDMICECSINK_EVENT_AUDIO_DEVICE_POWER_STATUS], params); - } - } - - void HdmiCecSink::SendStandbyMsgEvent(const int logicalAddress) - { - JsonObject params; - if(!HdmiCecSink::_instance) - return; - params["logicalAddress"] = JsonValue(logicalAddress); - sendNotify(eventString[HDMICECSINK_EVENT_STANDBY_MSG_EVENT], params); - } - uint32_t HdmiCecSink::setEnabledWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - bool enabled = false; - - if (parameters.HasLabel("enabled")) - { - getBoolParameter("enabled", enabled); - } - else - { - returnResponse(false); - } - - setEnabled(enabled); - returnResponse(true); - } - - uint32_t HdmiCecSink::getEnabledWrapper(const JsonObject& parameters, JsonObject& response) - { - response["enabled"] = getEnabled(); - returnResponse(true); - } - - uint32_t HdmiCecSink::getAudioDeviceConnectedStatusWrapper(const JsonObject& parameters, JsonObject& response) - { - response["connected"] = getAudioDeviceConnectedStatus(); - returnResponse(true); - } - - uint32_t HdmiCecSink::requestAudioDevicePowerStatusWrapper(const JsonObject& parameters, JsonObject& response) - { - requestAudioDevicePowerStatus(); - returnResponse(true); - } - - uint32_t HdmiCecSink::getActiveSourceWrapper(const JsonObject& parameters, JsonObject& response) - { - char routeString[1024] = {'\0'}; - int length = 0; - std::stringstream temp; - - if ( HdmiCecSink::_instance->m_currentActiveSource != -1 ) - { - int n = HdmiCecSink::_instance->m_currentActiveSource; - response["available"] = true; - response["logicalAddress"] = HdmiCecSink::_instance->deviceList[n].m_logicalAddress.toInt(); - response["physicalAddress"] = HdmiCecSink::_instance->deviceList[n].m_physicalAddr.toString().c_str(); - response["deviceType"] = HdmiCecSink::_instance->deviceList[n].m_deviceType.toString().c_str(); - response["cecVersion"] = HdmiCecSink::_instance->deviceList[n].m_cecVersion.toString().c_str(); - response["osdName"] = HdmiCecSink::_instance->deviceList[n].m_osdName.toString().c_str(); - response["vendorID"] = HdmiCecSink::_instance->deviceList[n].m_vendorID.toString().c_str(); - response["powerStatus"] = HdmiCecSink::_instance->deviceList[n].m_powerStatus.toString().c_str(); - - if ( HdmiCecSink::_instance->deviceList[n].m_physicalAddr.getByteValue(0) != 0 ) - { - snprintf(&routeString[length], sizeof(routeString) - length, "%s%d", "HDMI",(HdmiCecSink::_instance->deviceList[n].m_physicalAddr.getByteValue(0) - 1)); - } - else if ( HdmiCecSink::_instance->deviceList[n].m_physicalAddr.getByteValue(0) == 0 ) - { - snprintf(&routeString[length], sizeof(routeString) - length, "%s", "TV"); - } - - temp << (char *)routeString; - response["port"] = temp.str(); - - } - else - { - response["available"] = false; - } - - returnResponse(true); - } - - uint32_t HdmiCecSink::getDeviceListWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - response["numberofdevices"] = HdmiCecSink::_instance->m_numberOfDevices; - LOGINFO("getDeviceListWrapper m_numberOfDevices :%d \n", HdmiCecSink::_instance->m_numberOfDevices); - JsonArray deviceList; - - for (int n = 0; n <= LogicalAddress::UNREGISTERED; n++) - { - - if ( n != HdmiCecSink::_instance->m_logicalAddressAllocated && - HdmiCecSink::_instance->deviceList[n].m_isDevicePresent ) - { - JsonObject device; - - device["logicalAddress"] = HdmiCecSink::_instance->deviceList[n].m_logicalAddress.toInt(); - device["physicalAddress"] = HdmiCecSink::_instance->deviceList[n].m_physicalAddr.toString().c_str(); - device["deviceType"] = HdmiCecSink::_instance->deviceList[n].m_deviceType.toString().c_str(); - device["cecVersion"] = HdmiCecSink::_instance->deviceList[n].m_cecVersion.toString().c_str(); - device["osdName"] = HdmiCecSink::_instance->deviceList[n].m_osdName.toString().c_str(); - device["vendorID"] = HdmiCecSink::_instance->deviceList[n].m_vendorID.toString().c_str(); - device["powerStatus"] = HdmiCecSink::_instance->deviceList[n].m_powerStatus.toString().c_str(); - int hdmiPortNumber = -1; - LOGINFO("getDeviceListWrapper m_numofHdmiInput:%d looking for Logical Address :%d \n", m_numofHdmiInput, HdmiCecSink::_instance->deviceList[n].m_logicalAddress.toInt()); - for (int i=0; i < m_numofHdmiInput; i++) - { - LOGINFO("getDeviceListWrapper connected : %d, portid:%d LA: %d \n", hdmiInputs[i].m_isConnected, hdmiInputs[i].m_portID, hdmiInputs[i].m_logicalAddr.toInt()); - if(hdmiInputs[i].m_isConnected && hdmiInputs[i].m_logicalAddr.toInt() == HdmiCecSink::_instance->deviceList[n].m_logicalAddress.toInt()) - { - hdmiPortNumber = hdmiInputs[i].m_portID; - LOGINFO("got portid :%d break \n", hdmiPortNumber); - break; - } - } - device["portNumber"] = hdmiPortNumber; - deviceList.Add(device); - } - } - - response["deviceList"] = deviceList; - - returnResponse(true); - } - - - uint32_t HdmiCecSink::setOSDNameWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - if (parameters.HasLabel("name")) - { - std::string osd = parameters["name"].String(); - LOGINFO("setOSDNameWrapper osdName: %s",osd.c_str()); - osdName = osd.c_str(); - Utils::persistJsonSettings (CEC_SETTING_ENABLED_FILE, CEC_SETTING_OSD_NAME, JsonValue(osd.c_str())); - } - else - { - returnResponse(false); - } - returnResponse(true); - } - - uint32_t HdmiCecSink::getOSDNameWrapper(const JsonObject& parameters, JsonObject& response) - { - response["name"] = osdName.toString(); - LOGINFO("getOSDNameWrapper osdName : %s \n",osdName.toString().c_str()); - returnResponse(true); - } - - uint32_t HdmiCecSink::printDeviceListWrapper(const JsonObject& parameters, JsonObject& response) - { - printDeviceList(); - response["printed"] = true; - returnResponse(true); - } - - uint32_t HdmiCecSink::setActiveSourceWrapper(const JsonObject& parameters, JsonObject& response) - { - setActiveSource(false); - returnResponse(true); - } - - uint32_t HdmiCecSink::setActivePathWrapper(const JsonObject& parameters, JsonObject& response) - { - if (parameters.HasLabel("activePath")) - { - std::string id = parameters["activePath"].String(); - PhysicalAddress phy_addr = PhysicalAddress(id); - - LOGINFO("Addr = %s, length = %zu", id.c_str(), id.length()); - - setStreamPath(phy_addr); - returnResponse(true); - } - else - { - returnResponse(false); - } - } - - uint32_t HdmiCecSink::getActiveRouteWrapper(const JsonObject& parameters, JsonObject& response) - { - std::vector route; - char routeString[1024] = {'\0'}; - int length = 0; - JsonArray pathList; - std::stringstream temp; - - if (HdmiCecSink::_instance->m_currentActiveSource != -1 && - HdmiCecSink::_instance->m_currentActiveSource != HdmiCecSink::_instance->m_logicalAddressAllocated ) - { - HdmiCecSink::_instance->getActiveRoute(LogicalAddress(HdmiCecSink::_instance->m_currentActiveSource), route); - - if (route.size()) - { - response["available"] = true; - response["length"] = route.size(); - - for (unsigned int i=0; i < route.size(); i++) - { - if ( route[i] != LogicalAddress::UNREGISTERED ) - { - JsonObject device; - - device["logicalAddress"] = HdmiCecSink::_instance->deviceList[route[i]].m_logicalAddress.toInt(); - device["physicalAddress"] = HdmiCecSink::_instance->deviceList[route[i]].m_physicalAddr.toString().c_str(); - device["deviceType"] = HdmiCecSink::_instance->deviceList[route[i]].m_deviceType.toString().c_str(); - device["osdName"] = HdmiCecSink::_instance->deviceList[route[i]].m_osdName.toString().c_str(); - device["vendorID"] = HdmiCecSink::_instance->deviceList[route[i]].m_vendorID.toString().c_str(); - - pathList.Add(device); - - snprintf(&routeString[length], sizeof(routeString) - length, "%s", _instance->deviceList[route[i]].m_logicalAddress.toString().c_str()); - length += _instance->deviceList[route[i]].m_logicalAddress.toString().length(); - snprintf(&routeString[length], sizeof(routeString) - length, "(%s", _instance->deviceList[route[i]].m_osdName.toString().c_str()); - length += _instance->deviceList[route[i]].m_osdName.toString().length(); - snprintf(&routeString[length], sizeof(routeString) - length, "%s", ")-->"); - length += strlen(")-->"); - if( i + 1 == route.size() ) - { - snprintf(&routeString[length], sizeof(routeString) - length, "%s%d", "HDMI",(HdmiCecSink::_instance->deviceList[route[i]].m_physicalAddr.getByteValue(0) - 1)); - } - } - } - - response["pathList"] = pathList; - temp << (char *)routeString; - response["ActiveRoute"] = temp.str(); - LOGINFO("ActiveRoute = [%s]", routeString); - } - - } - else if ( HdmiCecSink::_instance->m_currentActiveSource == HdmiCecSink::_instance->m_logicalAddressAllocated ) - { - response["available"] = true; - response["ActiveRoute"] = "TV"; - } - else - { - response["available"] = false; - } - - returnResponse(true); - } - - uint32_t HdmiCecSink::requestActiveSourceWrapper(const JsonObject& parameters, JsonObject& response) - { - requestActiveSource(); - returnResponse(true); - } - - uint32_t HdmiCecSink::setRoutingChangeWrapper(const JsonObject& parameters, JsonObject& response) - { - std::string oldPortID; - std::string newPortID; - - returnIfParamNotFound(parameters, "oldPort"); - returnIfParamNotFound(parameters, "newPort"); - - oldPortID = parameters["oldPort"].String(); - newPortID = parameters["newPort"].String(); - - - if ((oldPortID.find("HDMI",0) != std::string::npos || - oldPortID.find("TV",0) != std::string::npos ) && - ( newPortID.find("HDMI", 0) != std::string::npos || - newPortID.find("TV", 0) != std::string::npos )) - { - setRoutingChange(oldPortID, newPortID); - returnResponse(true); - } - else - { - returnResponse(false); - } - } - - - uint32_t HdmiCecSink::setMenuLanguageWrapper(const JsonObject& parameters, JsonObject& response) - { - std::string lang; - - returnIfParamNotFound(parameters, "language"); - - lang = parameters["language"].String(); - - setCurrentLanguage(Language(lang.data())); - sendMenuLanguage(); - returnResponse(true); - } - - - uint32_t HdmiCecSink::setVendorIdWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - if (parameters.HasLabel("vendorid")) - { - std::string id = parameters["vendorid"].String(); - unsigned int vendorID = 0x00; - try - { - vendorID = stoi(id,NULL,16); - } - catch (...) - { - LOGWARN("Exception in setVendorIdWrapper set default value\n"); - vendorID = 0x0019FB; - } - appVendorId = {(uint8_t)(vendorID >> 16 & 0xff),(uint8_t)(vendorID>> 8 & 0xff),(uint8_t) (vendorID & 0xff)}; - LOGINFO("appVendorId : %s vendorID :%x \n",appVendorId.toString().c_str(), vendorID ); - - Utils::persistJsonSettings (CEC_SETTING_ENABLED_FILE, CEC_SETTING_VENDOR_ID, JsonValue(vendorID)); - } - else - { - returnResponse(false); - } - returnResponse(true); - } - uint32_t HdmiCecSink::setArcEnableDisableWrapper(const JsonObject& parameters, JsonObject& response) - { - - bool enabled = false; - - if (parameters.HasLabel("enabled")) - { - getBoolParameter("enabled", enabled); - } - else - { - returnResponse(false); - } - if(enabled) - { - startArc(); - } - else - { - stopArc(); - - } - - returnResponse(true); - } - uint32_t HdmiCecSink::getVendorIdWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("getVendorIdWrapper appVendorId : %s \n",appVendorId.toString().c_str()); - response["vendorid"] = appVendorId.toString() ; - returnResponse(true); - } - - uint32_t HdmiCecSink::requestShortAudioDescriptorWrapper(const JsonObject& parameters, JsonObject& response) - { - requestShortaudioDescriptor(); - returnResponse(true); - } - uint32_t HdmiCecSink::sendStandbyMessageWrapper(const JsonObject& parameters, JsonObject& response) - { - sendStandbyMessage(); - returnResponse(true); - } - - uint32_t HdmiCecSink::sendAudioDevicePowerOnMsgWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFO("%s invoked. \n",__FUNCTION__); - systemAudioModeRequest(); - returnResponse(true); - } - uint32_t HdmiCecSink::sendRemoteKeyPressWrapper(const JsonObject& parameters, JsonObject& response) - { - returnIfParamNotFound(parameters, "logicalAddress"); - returnIfParamNotFound(parameters, "keyCode"); - string logicalAddress = parameters["logicalAddress"].String(); - string keyCode = parameters["keyCode"].String(); - SendKeyInfo keyInfo; - keyInfo.logicalAddr = stoi(logicalAddress); - keyInfo.keyCode = stoi(keyCode); - keyInfo.UserControl = "sendKeyPressEvent"; - std::unique_lock lk(m_sendKeyEventMutex); - m_SendKeyQueue.push(keyInfo); - m_sendKeyEventThreadRun = true; - m_sendKeyCV.notify_one(); - LOGINFO("Post send key press event to queue size:%zu \n",m_SendKeyQueue.size()); - returnResponse(true); - } - - uint32_t HdmiCecSink::sendUserControlPressedWrapper(const JsonObject& parameters, JsonObject& response) - { - returnIfParamNotFound(parameters, "logicalAddress"); - returnIfParamNotFound(parameters, "keyCode"); - string logicalAddress = parameters["logicalAddress"].String(); - string keyCode = parameters["keyCode"].String(); - SendKeyInfo keyInfo; - keyInfo.logicalAddr = stoi(logicalAddress); - keyInfo.keyCode = stoi(keyCode); - keyInfo.UserControl = "sendUserControlPressed"; - std::unique_lock lk(m_sendKeyEventMutex); - m_SendKeyQueue.push(keyInfo); - m_sendKeyEventThreadRun = true; - m_sendKeyCV.notify_one(); - LOGINFO("User control pressed, queue size:%zu \n",m_SendKeyQueue.size()); - returnResponse(true); - } - - uint32_t HdmiCecSink::sendUserControlReleasedWrapper(const JsonObject& parameters, JsonObject& response) - { - returnIfParamNotFound(parameters, "logicalAddress"); - string logicalAddress = parameters["logicalAddress"].String(); - SendKeyInfo keyInfo; - keyInfo.logicalAddr = stoi(logicalAddress); - keyInfo.keyCode = 0; - keyInfo.UserControl = "sendUserControlReleased"; - std::unique_lock lk(m_sendKeyEventMutex); - m_SendKeyQueue.push(keyInfo); - m_sendKeyEventThreadRun = true; - m_sendKeyCV.notify_one(); - LOGINFO("User Control Released, queue size:%zu \n",m_SendKeyQueue.size()); - returnResponse(true); - } - - uint32_t HdmiCecSink::sendGiveAudioStatusWrapper(const JsonObject& parameters, JsonObject& response) - { - sendGiveAudioStatusMsg(); - returnResponse(true); - } - uint32_t HdmiCecSink::setLatencyInfoWrapper(const JsonObject& parameters, JsonObject& response) - { - int video_latency,audio_output_compensated,audio_output_delay; - bool low_latency_mode; - - returnIfParamNotFound(parameters, "videoLatency"); - returnIfParamNotFound(parameters, "lowLatencyMode"); - returnIfParamNotFound(parameters, "audioOutputCompensated"); - returnIfParamNotFound(parameters, "audioOutputDelay"); - video_latency = stoi(parameters["videoLatency"].String()); - low_latency_mode = stoi(parameters["lowLatencyMode"].String()); - audio_output_compensated = stoi(parameters["audioOutputCompensated"].String()); - audio_output_delay = stoi(parameters["audioOutputDelay"].String()); - - updateCurrentLatency(video_latency, low_latency_mode,audio_output_compensated, audio_output_delay); - returnResponse(true); - } - bool HdmiCecSink::loadSettings() - { - Core::File file; - file = CEC_SETTING_ENABLED_FILE; - - if( file.Open()) - { - JsonObject parameters; - parameters.IElement::FromFile(file); - bool isConfigAdded = false; - - if( parameters.HasLabel(CEC_SETTING_ENABLED)) - { - getBoolParameter(CEC_SETTING_ENABLED, cecSettingEnabled); - LOGINFO("CEC_SETTING_ENABLED present value:%d",cecSettingEnabled); - } - else - { - parameters[CEC_SETTING_ENABLED] = true; - cecSettingEnabled = true; - isConfigAdded = true; - LOGINFO("CEC_SETTING_ENABLED not present set dafult true:\n "); - } - - if( parameters.HasLabel(CEC_SETTING_OTP_ENABLED)) - { - getBoolParameter(CEC_SETTING_OTP_ENABLED, cecOTPSettingEnabled); - LOGINFO("CEC_SETTING_OTP_ENABLED present value :%d",cecOTPSettingEnabled); - } - else - { - parameters[CEC_SETTING_OTP_ENABLED] = true; - cecOTPSettingEnabled = true; - isConfigAdded = true; - LOGINFO("CEC_SETTING_OTP_ENABLED not present set dafult true:\n "); - } - if( parameters.HasLabel(CEC_SETTING_OSD_NAME)) - { - std::string osd_name; - getStringParameter(CEC_SETTING_OSD_NAME, osd_name); - osdName = osd_name.c_str(); - LOGINFO("CEC_SETTING_OSD_NAME present osd_name :%s",osdName.toString().c_str()); - } - else - { - parameters[CEC_SETTING_OSD_NAME] = osdName.toString(); - LOGINFO("CEC_SETTING_OSD_NMAE not present set dafult value :%s\n ",osdName.toString().c_str()); - isConfigAdded = true; - } - unsigned int vendorId = (defaultVendorId.at(0) <<16) | ( defaultVendorId.at(1) << 8 ) | defaultVendorId.at(2); - if( parameters.HasLabel(CEC_SETTING_VENDOR_ID)) - { - getNumberParameter(CEC_SETTING_VENDOR_ID, vendorId); - LOGINFO("CEC_SETTING_VENDOR_ID present :%x ",vendorId); - } - else - { - LOGINFO("CEC_SETTING_VENDOR_ID not present set dafult value :%x \n ",vendorId); - parameters[CEC_SETTING_VENDOR_ID] = vendorId; - isConfigAdded = true; - } - - appVendorId = {(uint8_t)(vendorId >> 16 & 0xff),(uint8_t)(vendorId >> 8 & 0xff),(uint8_t) (vendorId & 0xff)}; - LOGINFO("appVendorId : %s vendorId :%x \n",appVendorId.toString().c_str(), vendorId ); - - if(isConfigAdded) - { - LOGINFO("isConfigAdded true so update file:\n "); - file.Destroy(); - file.Create(); - parameters.IElement::ToFile(file); - - } - - file.Close(); - } - else - { - LOGINFO("CEC_SETTING_ENABLED_FILE file not present create with default settings "); - file.Open(false); - if (!file.IsOpen()) - file.Create(); - - JsonObject parameters; - unsigned int vendorId = (defaultVendorId.at(0) <<16) | ( defaultVendorId.at(1) << 8 ) | defaultVendorId.at(2); - parameters[CEC_SETTING_ENABLED] = true; - parameters[CEC_SETTING_OSD_NAME] = osdName.toString(); - parameters[CEC_SETTING_VENDOR_ID] = vendorId; - - cecSettingEnabled = true; - cecOTPSettingEnabled = true; - parameters.IElement::ToFile(file); - - file.Close(); - - } - - return cecSettingEnabled; - } - - void HdmiCecSink::setEnabled(bool enabled) - { - LOGINFO("Entered setEnabled: %d cecSettingEnabled :%d ",enabled, cecSettingEnabled); - - if (cecSettingEnabled != enabled) - { - Utils::persistJsonSettings (CEC_SETTING_ENABLED_FILE, CEC_SETTING_ENABLED, JsonValue(enabled)); - cecSettingEnabled = enabled; - } - if(true == enabled) - { - CECEnable(); - } - else - { - CECDisable(); - } - return; - } - - void HdmiCecSink::updateImageViewOn(const int logicalAddress) - { - JsonObject params; - if(!HdmiCecSink::_instance) - return; - - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED || - logicalAddress == LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - if (_instance->deviceList[logicalAddress].m_isDevicePresent && - _instance->deviceList[_instance->m_logicalAddressAllocated].m_powerStatus.toInt() == PowerStatus::STANDBY) - - { - /* Bringing TV out of standby is handled by application.notify UI to bring the TV out of standby */ - sendNotify(eventString[HDMICECSINK_EVENT_WAKEUP_FROM_STANDBY], params); - } - - sendNotify(eventString[HDMICECSINK_EVENT_IMAGE_VIEW_ON_MSG], params); - } - - void HdmiCecSink::updateTextViewOn(const int logicalAddress) - { - JsonObject params; - if(!HdmiCecSink::_instance) - return; - - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED || - logicalAddress == LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - if (_instance->deviceList[logicalAddress].m_isDevicePresent && - _instance->deviceList[_instance->m_logicalAddressAllocated].m_powerStatus.toInt() == PowerStatus::STANDBY) - { - /* Bringing TV out of standby is handled by application.notify UI to bring the TV out of standby */ - sendNotify(eventString[HDMICECSINK_EVENT_WAKEUP_FROM_STANDBY], params); - } - - sendNotify(eventString[HDMICECSINK_EVENT_TEXT_VIEW_ON_MSG], params); - } - - - void HdmiCecSink::updateDeviceChain(const LogicalAddress &logicalAddress, const PhysicalAddress &phy_addr) - { - if(!HdmiCecSink::_instance) - return; - - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - if (_instance->deviceList[logicalAddress.toInt()].m_isDevicePresent && - logicalAddress.toInt() != _instance->m_logicalAddressAllocated) - { - for (int i=0; i < m_numofHdmiInput; i++) - { - LOGINFO(" addr = %d, portID = %d", phy_addr.getByteValue(0), hdmiInputs[i].m_portID); - if (phy_addr.getByteValue(0) == (hdmiInputs[i].m_portID + 1)) { - hdmiInputs[i].addChild(logicalAddress, phy_addr); - } - } - } - } - - void HdmiCecSink::getActiveRoute(const LogicalAddress &logicalAddress, std::vector &route) - { - if(!HdmiCecSink::_instance) - return; - - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED || - logicalAddress.toInt() == LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - if (_instance->deviceList[logicalAddress.toInt()].m_isDevicePresent && - logicalAddress.toInt() != _instance->m_logicalAddressAllocated && - _instance->deviceList[logicalAddress.toInt()].m_isActiveSource ) - { - route.clear(); - for (int i=0; i < m_numofHdmiInput; i++) - { - LOGINFO("physicalAddress = [%d], portID = %d", _instance->deviceList[logicalAddress.toInt()].m_physicalAddr.getByteValue(0), hdmiInputs[i].m_portID); - if (_instance->deviceList[logicalAddress.toInt()].m_physicalAddr.getByteValue(0) == (hdmiInputs[i].m_portID + 1)) { - hdmiInputs[i].getRoute(_instance->deviceList[logicalAddress.toInt()].m_physicalAddr, route); - } - } - } - else { - LOGERR("Not in correct state to Find Route"); - } - } - - - void HdmiCecSink::CheckHdmiInState() - { - int err; - bool isAnyPortConnected = false; - - dsHdmiInGetStatusParam_t params; - err = IARM_Bus_Call(IARM_BUS_DSMGR_NAME, - IARM_BUS_DSMGR_API_dsHdmiInGetStatus, - (void *)¶ms, - sizeof(params)); - - if(err == IARM_RESULT_SUCCESS && params.result == dsERR_NONE ) - { - for( int i = 0; i < m_numofHdmiInput; i++ ) - { - LOGINFO("Is HDMI In Port [%d] connected [%d] \n",i, params.status.isPortConnected[i]); - if ( params.status.isPortConnected[i] ) - { - isAnyPortConnected = true; - } - - LOGINFO("update Port Status [%d] \n", i); - hdmiInputs[i].update(params.status.isPortConnected[i]); - } - } - - if ( isAnyPortConnected ) { - m_isHdmiInConnected = true; - } else { - m_isHdmiInConnected = false; - } - } - - void HdmiCecSink::requestActiveSource() - { - if(!HdmiCecSink::_instance) - return; - - if(!(_instance->smConnection)) - return; - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - _instance->smConnection->sendTo(LogicalAddress::BROADCAST, - MessageEncoder().encode(RequestActiveSource()), 500); - } - - void HdmiCecSink::setActiveSource(bool isResponse) - { - if(!HdmiCecSink::_instance) - return; - - if(!(_instance->smConnection)) - return; - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - if (isResponse && (_instance->m_currentActiveSource != _instance->m_logicalAddressAllocated) ) - { - LOGWARN("TV is not current Active Source"); - return; - } - - _instance->smConnection->sendTo(LogicalAddress::BROADCAST, - MessageEncoder().encode(ActiveSource(_instance->deviceList[_instance->m_logicalAddressAllocated].m_physicalAddr)), 500); - _instance->m_currentActiveSource = _instance->m_logicalAddressAllocated; - } - - void HdmiCecSink::setCurrentLanguage(const Language &lang) - { - if(!HdmiCecSink::_instance) - return; - - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - _instance->deviceList[_instance->m_logicalAddressAllocated].m_currentLanguage = lang; - } - - void HdmiCecSink::sendMenuLanguage() - { - Language lang = ""; - if(!HdmiCecSink::_instance) - return; - - if(!(_instance->smConnection)) - return; - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - lang = _instance->deviceList[_instance->m_logicalAddressAllocated].m_currentLanguage; - - _instance->smConnection->sendTo(LogicalAddress::BROADCAST, MessageEncoder().encode(SetMenuLanguage(lang)), 100); - } - - void HdmiCecSink::updateInActiveSource(const int logical_address, const InActiveSource &source ) - { - JsonObject params; - if(!HdmiCecSink::_instance) - return; - - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - if( logical_address != _instance->m_logicalAddressAllocated ) - { - _instance->deviceList[logical_address].m_isActiveSource = false; - - if ( _instance->m_currentActiveSource == logical_address ) - { - _instance->m_currentActiveSource = -1; - } - - params["logicalAddress"] = JsonValue(logical_address); - params["phsicalAddress"] = source.physicalAddress.toString().c_str(); - sendNotify(eventString[HDMICECSINK_EVENT_INACTIVE_SOURCE], params); - } - } - - void HdmiCecSink::updateActiveSource(const int logical_address, const ActiveSource &source ) - { - JsonObject params; - if(!HdmiCecSink::_instance) - return; - - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - if( logical_address != _instance->m_logicalAddressAllocated ) - { - if ( _instance->m_currentActiveSource != -1 ) - { - _instance->deviceList[_instance->m_currentActiveSource].m_isActiveSource = false; - } - - _instance->deviceList[logical_address].m_isActiveSource = true; - _instance->deviceList[logical_address].update(source.physicalAddress); - _instance->m_currentActiveSource = logical_address; - - if (_instance->deviceList[logical_address].m_isDevicePresent && - _instance->deviceList[_instance->m_logicalAddressAllocated].m_powerStatus.toInt() == PowerStatus::STANDBY) - { - /* Bringing TV out of standby is handled by application.notify UI to bring the TV out of standby */ - sendNotify(eventString[HDMICECSINK_EVENT_WAKEUP_FROM_STANDBY], params); - } - - params["logicalAddress"] = JsonValue(logical_address); - params["physicalAddress"] = _instance->deviceList[logical_address].m_physicalAddr.toString().c_str(); - sendNotify(eventString[HDMICECSINK_EVENT_ACTIVE_SOURCE_CHANGE], params); - } - } - - void HdmiCecSink::requestShortaudioDescriptor() - { - if ( cecEnableStatus != true ) - { - LOGINFO("requestShortaudioDescriptor: cec is disabled-> EnableCEC first"); - return; - } - - if(!HdmiCecSink::_instance) - return; - - if(!(_instance->smConnection)) - return; - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - LOGINFO(" Send requestShortAudioDescriptor Message "); - _instance->smConnection->sendTo(LogicalAddress::AUDIO_SYSTEM,MessageEncoder().encode(RequestShortAudioDescriptor(formatid,audioFormatCode,numberofdescriptor)), 1000); - - } - - void HdmiCecSink::requestAudioDevicePowerStatus() - { - if ( cecEnableStatus != true ) - { - LOGWARN("cec is disabled-> EnableCEC first"); - return; - } - - if(!HdmiCecSink::_instance) - return; - - if(!(_instance->smConnection)) - return; - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - LOGINFO(" Send GiveDevicePowerStatus Message to Audio system in the network \n"); - _instance->smConnection->sendTo(LogicalAddress::AUDIO_SYSTEM, MessageEncoder().encode(GiveDevicePowerStatus()), 500); - - m_audioDevicePowerStatusRequested = true; - } - - void HdmiCecSink::sendFeatureAbort(const LogicalAddress logicalAddress, const OpCode feature, const AbortReason reason) - { - - if(!HdmiCecSink::_instance) - return; - if(!(_instance->smConnection)) - return; - LOGINFO(" Sending FeatureAbort to %s for opcode %s with reason %s ",logicalAddress.toString().c_str(),feature.toString().c_str(),reason.toString().c_str()); - _instance->smConnection->sendTo(logicalAddress, MessageEncoder().encode(FeatureAbort(feature,reason)), 500); - } - - void HdmiCecSink::reportFeatureAbortEvent(const LogicalAddress logicalAddress, const OpCode featureOpcode, const AbortReason abortReason) - { - LOGINFO(" Notifying the UI FeatureAbort from the %s for the opcode %s with the reason %s ",logicalAddress.toString().c_str(),featureOpcode.toString().c_str(),abortReason.toString().c_str()); - JsonObject params; - params["LogicalAddress"] = logicalAddress.toInt(); - params["opcode"] = featureOpcode.opCode(); - params["FeatureAbortReason"] = abortReason.toInt(); - sendNotify(eventString[HDMICECSINK_EVENT_FEATURE_ABORT_EVENT], params); - } - - void HdmiCecSink::pingDevices(std::vector &connected , std::vector &disconnected) - { - int i; - - if(!HdmiCecSink::_instance) - return; - if(!(_instance->smConnection)) - return; - - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - for(i=0; i< LogicalAddress::UNREGISTERED; i++ ) { - if ( i != _instance->m_logicalAddressAllocated ) - { - //LOGWARN("PING for 0x%x \r\n",i); - try { - _instance->smConnection->ping(LogicalAddress(_instance->m_logicalAddressAllocated), LogicalAddress(i), Throw_e()); - } - catch(CECNoAckException &e) - { - if ( _instance->deviceList[i].m_isDevicePresent ) { - disconnected.push_back(i); - } - //LOGWARN("Ping device: 0x%x caught %s \r\n", i, e.what()); - usleep(50000); - continue; - } - catch(Exception &e) - { - LOGWARN("Ping device: 0x%x caught %s \r\n", i, e.what()); - usleep(50000); - continue; - } - - /* If we get ACK, then the device is present in the network*/ - if ( !_instance->deviceList[i].m_isDevicePresent ) - { - connected.push_back(i); - //LOGWARN("Ping success, added device: 0x%x \r\n", i); - } - usleep(50000); - } - } - } - - int HdmiCecSink::requestType( const int logicalAddress ) { - int requestType = CECDeviceParams::REQUEST_NONE; - - if ( !_instance->deviceList[logicalAddress].m_isPAUpdated || !_instance->deviceList[logicalAddress].m_isDeviceTypeUpdated ) { - requestType = CECDeviceParams::REQUEST_PHISICAL_ADDRESS; - }else if ( !_instance->deviceList[logicalAddress].m_isOSDNameUpdated ) { - requestType = CECDeviceParams::REQUEST_OSD_NAME; - }else if ( !_instance->deviceList[logicalAddress].m_isVersionUpdated ) { - requestType = CECDeviceParams::REQUEST_CEC_VERSION; - }else if ( !_instance->deviceList[logicalAddress].m_isVendorIDUpdated ) { - requestType = CECDeviceParams::REQUEST_DEVICE_VENDOR_ID; - }else if ( !_instance->deviceList[logicalAddress].m_isPowerStatusUpdated ) { - requestType = CECDeviceParams::REQUEST_POWER_STATUS; - } - - return requestType; - } - - void HdmiCecSink::printDeviceList() { - int i; - - if(!HdmiCecSink::_instance) - return; - - for(i=0; i< 16; i++) - { - if (HdmiCecSink::_instance->deviceList[i].m_isDevicePresent) { - LOGWARN("------ Device ID = %d--------", i); - HdmiCecSink::_instance->deviceList[i].printVariable(); - LOGWARN("-----------------------------"); - } - } - } - - void HdmiCecSink::setStreamPath( const PhysicalAddress &physical_addr) { - - if(!HdmiCecSink::_instance) - return; - - if(!(_instance->smConnection)) - return; - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED){ - LOGERR("Logical Address NOT Allocated Or its not valid"); - return; - } - - _instance->smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(SetStreamPath(physical_addr)), 500); - } - - void HdmiCecSink::setRoutingChange(const std::string &from, const std::string &to) { - PhysicalAddress oldPhyAddr = {0xF,0xF,0xF,0xF}; - PhysicalAddress newPhyAddr = {0xF,0xF,0xF,0xF}; - int oldPortID = -1; - int newPortID = -1; - - if(!HdmiCecSink::_instance) - return; - - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED){ - LOGERR("Logical Address NOT Allocated Or its not valid"); - return; - } - - if( from.find("TV",0) != std::string::npos ) - { - oldPhyAddr = _instance->deviceList[_instance->m_logicalAddressAllocated].m_physicalAddr; - _instance->m_currentActiveSource = -1; - } - else - { - oldPortID = stoi(from.substr(4,1),NULL,16); - if ( oldPortID < _instance->m_numofHdmiInput ) - { - oldPhyAddr = _instance->hdmiInputs[oldPortID].m_physicalAddr; - } - else - { - LOGERR("Invalid HDMI Old Port ID"); - return; - } - } - - if( to.find("TV",0) != std::string::npos ) - { - newPhyAddr = _instance->deviceList[_instance->m_logicalAddressAllocated].m_physicalAddr; - /*set active source as TV */ - _instance->m_currentActiveSource = _instance->m_logicalAddressAllocated; - } - else - { - newPortID = stoi(to.substr(4,1),NULL,16); - - if ( newPortID < _instance->m_numofHdmiInput ) - { - newPhyAddr = _instance->hdmiInputs[newPortID].m_physicalAddr; - } - else - { - LOGERR("Invalid HDMI New Port ID"); - return; - } - } - - if(!(_instance->smConnection)) - return; - _instance->smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(RoutingChange(oldPhyAddr, newPhyAddr)), 500); - } - - void HdmiCecSink::addDevice(const int logicalAddress) { - JsonObject params; - - if(!HdmiCecSink::_instance) - return; - - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - if ( !HdmiCecSink::_instance->deviceList[logicalAddress].m_isDevicePresent ) - { - HdmiCecSink::_instance->deviceList[logicalAddress].m_isDevicePresent = true; - HdmiCecSink::_instance->deviceList[logicalAddress].m_logicalAddress = LogicalAddress(logicalAddress); - HdmiCecSink::_instance->m_numberOfDevices++; - HdmiCecSink::_instance->m_pollNextState = POLL_THREAD_STATE_INFO; - - if(logicalAddress == 0x5) - { - LOGINFO(" logicalAddress =%d , Audio device detected, Notify Device Settings", logicalAddress ); - params["status"] = string("success"); - params["audioDeviceConnected"] = string("true"); - hdmiCecAudioDeviceConnected = true; - sendNotify(eventString[HDMICECSINK_EVENT_AUDIO_DEVICE_CONNECTED_STATUS], params); - } - - sendNotify(eventString[HDMICECSINK_EVENT_DEVICE_ADDED], JsonObject()); - } - } - - void HdmiCecSink::removeDevice(const int logicalAddress) { - JsonObject params; - - if(!HdmiCecSink::_instance) - return; - - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED){ - LOGERR("Logical Address NOT Allocated"); - return; - } - - if (_instance->deviceList[logicalAddress].m_isDevicePresent) - { - _instance->m_numberOfDevices--; - - for (int i=0; i < m_numofHdmiInput; i++) - { - if (_instance->deviceList[logicalAddress].m_physicalAddr.getByteValue(0) == (hdmiInputs[i].m_portID + 1)) { - hdmiInputs[i].removeChild(_instance->deviceList[logicalAddress].m_physicalAddr); - hdmiInputs[i].update(LogicalAddress(LogicalAddress::UNREGISTERED)); - } - } - - if(logicalAddress == 0x5) - { - LOGINFO(" logicalAddress =%d , Audio device removed, Notify Device Settings", logicalAddress ); - params["status"] = string("success"); - params["audioDeviceConnected"] = string("false"); - hdmiCecAudioDeviceConnected = false; - if (m_audioStatusDetectionTimer.isActive()){ - m_audioStatusDetectionTimer.stop(); - } - m_isAudioStatusInfoUpdated = false; - m_audioStatusReceived = false; - m_audioStatusTimerStarted = false; - LOGINFO("Audio device removed, reset the audio status info. m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d ", m_isAudioStatusInfoUpdated,m_audioStatusReceived,m_audioStatusTimerStarted); - sendNotify(eventString[HDMICECSINK_EVENT_AUDIO_DEVICE_CONNECTED_STATUS], params) - } - - _instance->deviceList[logicalAddress].m_isRequestRetry = 0; - _instance->deviceList[logicalAddress].clear(); - sendNotify(eventString[HDMICECSINK_EVENT_DEVICE_REMOVED], JsonObject()); - } - } - - void HdmiCecSink::request(const int logicalAddress) { - int requestType; - - if(!HdmiCecSink::_instance) - return; - if(!(_instance->smConnection)) - return; - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED || logicalAddress >= LogicalAddress::UNREGISTERED + TEST_ADD ){ - LOGERR("Logical Address NOT Allocated Or its not valid"); - return; - } - - requestType = _instance->requestType(logicalAddress); - _instance->deviceList[logicalAddress].m_isRequested = requestType; - - switch (requestType) - { - case CECDeviceParams::REQUEST_PHISICAL_ADDRESS : - { - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(GivePhysicalAddress()), 200); - } - break; - - case CECDeviceParams::REQUEST_CEC_VERSION : - { - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(GetCECVersion()), 100); - } - break; - - case CECDeviceParams::REQUEST_DEVICE_VENDOR_ID : - { - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(GiveDeviceVendorID()), 100); - } - break; - - case CECDeviceParams::REQUEST_OSD_NAME : - { - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(GiveOSDName()), 500); - } - break; - - case CECDeviceParams::REQUEST_POWER_STATUS : - { - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(GiveDevicePowerStatus()), 100); - } - break; - default: - { - _instance->deviceList[logicalAddress].m_isRequested = CECDeviceParams::REQUEST_NONE; - } - break; - } - - _instance->deviceList[logicalAddress].m_requestTime = std::chrono::system_clock::now(); - LOGINFO("request type %d", _instance->deviceList[logicalAddress].m_isRequested); - } - - int HdmiCecSink::requestStatus(const int logicalAddress) { - std::chrono::duration elapsed; - bool isElapsed = false; - - if(!HdmiCecSink::_instance) - return -1; - - - if ( _instance->m_logicalAddressAllocated == LogicalAddress::UNREGISTERED || logicalAddress >= LogicalAddress::UNREGISTERED + TEST_ADD ) { - LOGERR("Logical Address NOT Allocated Or its not valid"); - return -1; - } - - switch ( _instance->deviceList[logicalAddress].m_isRequested ) { - case CECDeviceParams::REQUEST_PHISICAL_ADDRESS : - { - if( _instance->deviceList[logicalAddress].m_isPAUpdated && - _instance->deviceList[logicalAddress].m_isDeviceTypeUpdated ) - { - _instance->deviceList[logicalAddress].m_isRequested = CECDeviceParams::REQUEST_NONE; - } - } - break; - - case CECDeviceParams::REQUEST_CEC_VERSION : - { - if( _instance->deviceList[logicalAddress].m_isVersionUpdated ) - { - _instance->deviceList[logicalAddress].m_isRequested = CECDeviceParams::REQUEST_NONE; - } - } - break; - - case CECDeviceParams::REQUEST_DEVICE_VENDOR_ID : - { - if( _instance->deviceList[logicalAddress].m_isVendorIDUpdated ) - { - _instance->deviceList[logicalAddress].m_isRequested = CECDeviceParams::REQUEST_NONE; - } - } - break; - - case CECDeviceParams::REQUEST_OSD_NAME : - { - if( _instance->deviceList[logicalAddress].m_isOSDNameUpdated ) - { - _instance->deviceList[logicalAddress].m_isRequested = CECDeviceParams::REQUEST_NONE; - } - } - break; - - case CECDeviceParams::REQUEST_POWER_STATUS : - { - if( _instance->deviceList[logicalAddress].m_isPowerStatusUpdated ) - { - _instance->deviceList[logicalAddress].m_isRequested = CECDeviceParams::REQUEST_NONE; - } - } - break; - default: - break; - } - - if ( _instance->deviceList[logicalAddress].m_isRequested != CECDeviceParams::REQUEST_NONE ) - { - elapsed = std::chrono::system_clock::now() - _instance->deviceList[logicalAddress].m_requestTime; - - if ( elapsed.count() > HDMICECSINK_REQUEST_MAX_WAIT_TIME_MS ) - { - LOGINFO("request elapsed "); - isElapsed = true; - } - } - - if (isElapsed) - { - /* For some request it should be retry, like report physical address etc for other we can have default values */ - switch( _instance->deviceList[logicalAddress].m_isRequested ) - { - case CECDeviceParams::REQUEST_PHISICAL_ADDRESS : - { - LOGINFO("Retry for REQUEST_PHISICAL_ADDRESS = %d", _instance->deviceList[logicalAddress].m_isRequestRetry); - /* Update with Invalid Physical Address */ - if ( _instance->deviceList[logicalAddress].m_isRequestRetry++ >= HDMICECSINK_REQUEST_MAX_RETRY ) - { - LOGINFO("Max retry for REQUEST_PHISICAL_ADDRESS = %d", _instance->deviceList[logicalAddress].m_isRequestRetry); - _instance->deviceList[logicalAddress].update(PhysicalAddress(0xF,0xF,0xF,0xF)); - _instance->deviceList[logicalAddress].update(DeviceType(DeviceType::RESERVED)); - _instance->deviceList[logicalAddress].m_isRequestRetry = 0; - } - } - break; - - case CECDeviceParams::REQUEST_CEC_VERSION : - { - /*Defaulting to 1.4*/ - _instance->deviceList[logicalAddress].update(Version(Version::V_1_4)); - } - break; - - case CECDeviceParams::REQUEST_DEVICE_VENDOR_ID : - { - _instance->deviceList[logicalAddress].update(VendorID(0,0,0)); - } - break; - - case CECDeviceParams::REQUEST_OSD_NAME : - { - if ( _instance->deviceList[logicalAddress].m_isRequestRetry++ >= HDMICECSINK_REQUEST_MAX_RETRY ) - { - LOGINFO("Max retry for REQUEST_OSD_NAME = %d", _instance->deviceList[logicalAddress].m_isRequestRetry); - _instance->deviceList[logicalAddress].update(OSDName("")); - _instance->deviceList[logicalAddress].m_isRequestRetry = 0; - } - } - break; - - case CECDeviceParams::REQUEST_POWER_STATUS : - { - _instance->deviceList[logicalAddress].update(PowerStatus(PowerStatus::POWER_STATUS_NOT_KNOWN)); - } - break; - default: - break; - } - - - _instance->deviceList[logicalAddress].m_isRequested = CECDeviceParams::REQUEST_NONE; - } - - if( _instance->deviceList[logicalAddress].m_isRequested == CECDeviceParams::REQUEST_NONE) - { - LOGINFO("Request Done"); - return CECDeviceParams::REQUEST_DONE; - } - - //LOGINFO("Request NOT Done"); - return CECDeviceParams::REQUEST_NOT_DONE; - } - - void HdmiCecSink::threadRun() - { - std::vector connected; - std::vector disconnected; - int logicalAddressRequested = LogicalAddress::UNREGISTERED + TEST_ADD; - bool isExit = false; - - if(!HdmiCecSink::_instance) - return; - - if(!(_instance->smConnection)) - return; - LOGINFO("Entering ThreadRun: _instance->m_pollThreadExit %d isExit %d _instance->m_pollThreadState %d _instance->m_pollNextState %d",_instance->m_pollThreadExit,isExit,_instance->m_pollThreadState,_instance->m_pollNextState ); - _instance->m_sleepTime = HDMICECSINK_PING_INTERVAL_MS; - - while(1) - { - - if (_instance->m_pollThreadExit || isExit ){ - LOGWARN("Thread Exits _instance->m_pollThreadExit %d isExit %d _instance->m_pollThreadState %d _instance->m_pollNextState %d",_instance->m_pollThreadExit,isExit,_instance->m_pollThreadState,_instance->m_pollNextState ); - break; - } - - if ( _instance->m_pollNextState != POLL_THREAD_STATE_NONE ) - { - _instance->m_pollThreadState = _instance->m_pollNextState; - _instance->m_pollNextState = POLL_THREAD_STATE_NONE; - } - - switch (_instance->m_pollThreadState) { - - case POLL_THREAD_STATE_POLL : - { - //LOGINFO("POLL_THREAD_STATE_POLL"); - _instance->allocateLogicalAddress(DeviceType::TV); - if ( _instance->m_logicalAddressAllocated != LogicalAddress::UNREGISTERED) - { - try{ - - logicalAddress = LogicalAddress(_instance->m_logicalAddressAllocated); - LibCCEC::getInstance().addLogicalAddress(logicalAddress); - _instance->smConnection->setSource(logicalAddress); - _instance->m_numberOfDevices = 0; - _instance->deviceList[_instance->m_logicalAddressAllocated].m_deviceType = DeviceType::TV; - _instance->deviceList[_instance->m_logicalAddressAllocated].m_isDevicePresent = true; - _instance->deviceList[_instance->m_logicalAddressAllocated].update(physical_addr); - _instance->deviceList[_instance->m_logicalAddressAllocated].m_cecVersion = Version::V_1_4; - _instance->deviceList[_instance->m_logicalAddressAllocated].m_vendorID = appVendorId; - _instance->deviceList[_instance->m_logicalAddressAllocated].m_powerStatus = PowerStatus(powerState); - _instance->deviceList[_instance->m_logicalAddressAllocated].m_currentLanguage = defaultLanguage; - _instance->deviceList[_instance->m_logicalAddressAllocated].m_osdName = osdName.toString().c_str(); - if(cecVersion == 2.0) { - _instance->deviceList[_instance->m_logicalAddressAllocated].m_cecVersion = Version::V_2_0; - _instance->smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST), - MessageEncoder().encode(ReportFeatures(Version::V_2_0,allDevicetype,rcProfile,deviceFeatures)), 500); - } - _instance->smConnection->addFrameListener(_instance->msgFrameListener); - _instance->smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST), - MessageEncoder().encode(ReportPhysicalAddress(physical_addr, _instance->deviceList[_instance->m_logicalAddressAllocated].m_deviceType)), 100); - - _instance->m_sleepTime = 0; - _instance->m_pollThreadState = POLL_THREAD_STATE_PING; - } - catch(InvalidStateException &e){ - LOGWARN("InvalidStateException caught while allocated logical address. %s", e.what()); - _instance->m_pollThreadState = POLL_THREAD_STATE_EXIT; - } - catch(IOException &e){ - LOGWARN("IOException caught while allocated logical address. %s", e.what()); - _instance->m_pollThreadState = POLL_THREAD_STATE_EXIT; - } - catch(...){ - LOGWARN("Exception caught while allocated logical address."); - _instance->m_pollThreadState = POLL_THREAD_STATE_EXIT; - } - } - else - { - LOGINFO("Not able allocate Logical Address for TV"); - _instance->m_pollThreadState = POLL_THREAD_STATE_EXIT; - } - } - break; - - case POLL_THREAD_STATE_PING : - { - //LOGINFO("POLL_THREAD_STATE_PING"); - _instance->m_pollThreadState = POLL_THREAD_STATE_INFO; - connected.clear(); - disconnected.clear(); - _instance->pingDevices(connected, disconnected); - - if ( disconnected.size() ){ - for( unsigned int i=0; i< disconnected.size(); i++ ) - { - LOGWARN("Disconnected Devices [%zu]", disconnected.size()); - _instance->removeDevice(disconnected[i]); - } - } - - if (connected.size()) { - LOGWARN("Connected Devices [%zu]", connected.size()); - for( unsigned int i=0; i< connected.size(); i++ ) - { - _instance->addDevice(connected[i]); - /* If new device is connected, then try to aquire the information */ - _instance->m_pollThreadState = POLL_THREAD_STATE_INFO; - _instance->m_sleepTime = 0; - } - } - else - { - for(int i=0;im_logicalAddressAllocated && - _instance->deviceList[i].m_isDevicePresent && - !_instance->deviceList[i].isAllUpdated() ) - { - _instance->m_pollNextState = POLL_THREAD_STATE_INFO; - _instance->m_sleepTime = 0; - } - } - /* Check for any update required */ - _instance->m_pollThreadState = POLL_THREAD_STATE_UPDATE; - _instance->m_sleepTime = 0; - } - } - break; - - case POLL_THREAD_STATE_INFO : - { - //LOGINFO("POLL_THREAD_STATE_INFO"); - - if ( logicalAddressRequested == LogicalAddress::UNREGISTERED + TEST_ADD ) - { - int i = 0; - for(;im_logicalAddressAllocated && - _instance->deviceList[i].m_isDevicePresent && - !_instance->deviceList[i].isAllUpdated() ) - { - //LOGINFO("POLL_THREAD_STATE_INFO -> request for %d", i); - logicalAddressRequested = i; - _instance->request(logicalAddressRequested); - _instance->m_sleepTime = HDMICECSINK_REQUEST_INTERVAL_TIME_MS; - break; - } - } - - if ( i == LogicalAddress::UNREGISTERED) - { - /*So there is no update required, try to ping after some seconds*/ - _instance->m_pollThreadState = POLL_THREAD_STATE_IDLE; - _instance->m_sleepTime = 0; - //LOGINFO("POLL_THREAD_STATE_INFO -> state change to Ping", i); - } - } - else - { - /*So there is request sent for logical address, so wait and check the status */ - if ( _instance->requestStatus(logicalAddressRequested) == CECDeviceParams::REQUEST_DONE ) - { - logicalAddressRequested = LogicalAddress::UNREGISTERED; - } - else - { - _instance->m_sleepTime = HDMICECSINK_REQUEST_INTERVAL_TIME_MS; - } - } - } - break; - - /* updating the power status and if required we can add other information later*/ - case POLL_THREAD_STATE_UPDATE : - { - //LOGINFO("POLL_THREAD_STATE_UPDATE"); - - for(int i=0;im_logicalAddressAllocated && - _instance->deviceList[i].m_isDevicePresent && - _instance->deviceList[i].m_isPowerStatusUpdated ) - { - std::chrono::duration elapsed = std::chrono::system_clock::now() - _instance->deviceList[i].m_lastPowerUpdateTime; - - if ( elapsed.count() > HDMICECSINK_UPDATE_POWER_STATUS_INTERVA_MS ) - { - _instance->deviceList[i].m_isPowerStatusUpdated = false; - _instance->m_pollNextState = POLL_THREAD_STATE_INFO; - _instance->m_sleepTime = 0; - } - } - } - - _instance->m_pollThreadState = POLL_THREAD_STATE_IDLE; - _instance->m_sleepTime = 0; - } - break; - - case POLL_THREAD_STATE_IDLE : - { - //LOGINFO("POLL_THREAD_STATE_IDLE"); - _instance->m_sleepTime = HDMICECSINK_PING_INTERVAL_MS; - _instance->m_pollThreadState = POLL_THREAD_STATE_PING; - } - break; - - case POLL_THREAD_STATE_WAIT : - { - /* Wait for Hdmi is connected, in case it disconnected */ - //LOGINFO("19Aug2020-[01] -> POLL_THREAD_STATE_WAIT"); - _instance->m_sleepTime = HDMICECSINK_WAIT_FOR_HDMI_IN_MS; - - if ( _instance->m_isHdmiInConnected == true ) - { - _instance->m_pollThreadState = POLL_THREAD_STATE_POLL; - } - } - break; - - case POLL_THREAD_STATE_EXIT : - { - isExit = true; - _instance->m_sleepTime = 0; - } - break; - } - - std::unique_lock lk(_instance->m_pollExitMutex); - if ( _instance->m_ThreadExitCV.wait_for(lk, std::chrono::milliseconds(_instance->m_sleepTime)) == std::cv_status::timeout ) - continue; - else - LOGINFO("Thread is going to Exit m_pollThreadExit %d\n", _instance->m_pollThreadExit ); - - } - } - - void HdmiCecSink::allocateLAforTV() - { - bool gotLogicalAddress = false; - int addr = LogicalAddress::TV; - int i, j; - if (!(_instance->smConnection)) - return; - - for (i = 0; i< HDMICECSINK_NUMBER_TV_ADDR; i++) - { - /* poll for TV logical address - retry 5 times*/ - for (j = 0; j < 5; j++) - { - try { - smConnection->poll(LogicalAddress(addr), Throw_e()); - } - catch(CECNoAckException &e ) - { - LOGWARN("Poll caught %s \r\n",e.what()); - gotLogicalAddress = true; - break; - } - catch(Exception &e) - { - LOGWARN("Poll caught %s \r\n",e.what()); - usleep(250000); - } - } - if (gotLogicalAddress) - { - break; - } - addr = LogicalAddress::SPECIFIC_USE; - } - - if ( gotLogicalAddress ) - { - m_logicalAddressAllocated = addr; - } - else - { - m_logicalAddressAllocated = LogicalAddress::UNREGISTERED; - } - - LOGWARN("Logical Address for TV 0x%x \r\n",m_logicalAddressAllocated); - } - - void HdmiCecSink::allocateLogicalAddress(int deviceType) - { - if( deviceType == DeviceType::TV ) - { - allocateLAforTV(); - } - } - - void HdmiCecSink::CECEnable(void) - { - std::lock_guard lock(m_enableMutex); - JsonObject params; - LOGINFO("Entered CECEnable"); - if (cecEnableStatus) - { - LOGWARN("CEC Already Enabled"); - return; - } - - if(0 == libcecInitStatus) - { - try - { - LibCCEC::getInstance().init("HdmiCecSink"); - } - catch(InvalidStateException &e){ - LOGWARN("InvalidStateException caught in LibCCEC::init %s", e.what()); - } - catch(IOException &e){ - LOGWARN("IOException caught in LibCCEC::init %s", e.what()); - } - catch(...){ - LOGWARN("Exception caught in LibCCEC::init"); - } - } - libcecInitStatus++; - - //Acquire CEC Addresses - getPhysicalAddress(); - - smConnection = new Connection(LogicalAddress::UNREGISTERED,false,"ServiceManager::Connection::"); - smConnection->open(); - allocateLogicalAddress(DeviceType::TV); - LOGINFO("logical address allocalted: %x \n",m_logicalAddressAllocated); - if ( m_logicalAddressAllocated != LogicalAddress::UNREGISTERED && smConnection) - { - logicalAddress = LogicalAddress(m_logicalAddressAllocated); - LOGINFO(" add logical address %x \n",m_logicalAddressAllocated); - LibCCEC::getInstance().addLogicalAddress(logicalAddress); - smConnection->setSource(logicalAddress); - } - msgProcessor = new HdmiCecSinkProcessor(*smConnection); - msgFrameListener = new HdmiCecSinkFrameListener(*msgProcessor); - if(smConnection) - { - LOGWARN("Start Thread %p", smConnection ); - m_pollThreadState = POLL_THREAD_STATE_POLL; - m_pollNextState = POLL_THREAD_STATE_NONE; - m_pollThreadExit = false; - m_pollThread = std::thread(threadRun); - } - cecEnableStatus = true; - - params["cecEnable"] = string("true"); - sendNotify(eventString[HDMICECSINK_EVENT_CEC_ENABLED], params); - - return; - } - - void HdmiCecSink::CECDisable(void) - { - std::lock_guard lock(m_enableMutex); - JsonObject params; - LOGINFO("Entered CECDisable "); - if(!cecEnableStatus) - { - LOGWARN("CEC Already Disabled "); - return; - } - - if(m_currentArcRoutingState != ARC_STATE_ARC_TERMINATED) - { - stopArc(); - while(m_currentArcRoutingState != ARC_STATE_ARC_TERMINATED) - { - usleep(500000); - } - } - - LOGINFO(" CECDisable ARC stopped "); - cecEnableStatus = false; - if (smConnection != NULL) - { - LOGWARN("Stop Thread %p", smConnection ); - m_pollThreadExit = true; - m_ThreadExitCV.notify_one(); - - try - { - if (m_pollThread.joinable()) - { - LOGWARN("Join Thread %p", smConnection ); - m_pollThread.join(); - } - } - catch(const std::system_error& e) - { - LOGERR("system_error exception in thread join %s", e.what()); - } - catch(const std::exception& e) - { - LOGERR("exception in thread join %s", e.what()); - } - - m_pollThreadState = POLL_THREAD_STATE_NONE; - m_pollNextState = POLL_THREAD_STATE_NONE; - - LOGWARN("Deleted Thread %p", smConnection ); - - smConnection->close(); - delete smConnection; - smConnection = NULL; - } - - m_logicalAddressAllocated = LogicalAddress::UNREGISTERED; - m_currentArcRoutingState = ARC_STATE_ARC_TERMINATED; - if (m_audioStatusDetectionTimer.isActive()){ - m_audioStatusDetectionTimer.stop(); - } - m_isAudioStatusInfoUpdated = false; - m_audioStatusReceived = false; - m_audioStatusTimerStarted = false; - LOGINFO("CEC Disabled, reset the audio status info. m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d ", m_isAudioStatusInfoUpdated,m_audioStatusReceived,m_audioStatusTimerStarted); - - - for(int i=0; i< 16; i++) - { - if (_instance->deviceList[i].m_isDevicePresent) - { - _instance->deviceList[i].clear(); - } - } - - if(1 == libcecInitStatus) - { - try - { - LibCCEC::getInstance().term(); - } - catch(InvalidStateException &e){ - LOGWARN("InvalidStateException caught in LibCCEC::term %s", e.what()); - } - catch(IOException &e){ - LOGWARN("IOException caught in LibCCEC::term %s", e.what()); - } - catch(...){ - LOGWARN("Exception caught in LibCCEC::term"); - } - } - - libcecInitStatus--; - LOGWARN("CEC Disabled %d",libcecInitStatus); - - params["cecEnable"] = string("false"); - sendNotify(eventString[HDMICECSINK_EVENT_CEC_ENABLED], params); - - return; - } - - - void HdmiCecSink::getPhysicalAddress() - { - LOGINFO("Entered getPhysicalAddress "); - - uint32_t physAddress = 0x0F0F0F0F; - - try { - LibCCEC::getInstance().getPhysicalAddress(&physAddress); - physical_addr = {(uint8_t)((physAddress >> 24) & 0xFF),(uint8_t)((physAddress >> 16) & 0xFF),(uint8_t) ((physAddress >> 8) & 0xFF),(uint8_t)((physAddress) & 0xFF)}; - LOGINFO("getPhysicalAddress: physicalAddress: %s ", physical_addr.toString().c_str()); - } - catch (const std::exception& e) - { - LOGWARN("exception caught from getPhysicalAddress"); - } - return; - } - - bool HdmiCecSink::getEnabled() - { - - - LOGINFO("getEnabled :%d ",cecEnableStatus); - if(true == cecEnableStatus) - return true; - else - return false; - } - - bool HdmiCecSink::getAudioDeviceConnectedStatus() - { - LOGINFO("getAudioDeviceConnectedStatus :%d ", hdmiCecAudioDeviceConnected); - if(true == hdmiCecAudioDeviceConnected) - return true; - else - return false; - } - //Arc Routing related functions - void HdmiCecSink::startArc() - { - if ( cecEnableStatus != true ) - { - LOGINFO("Initiate_Arc Cec is disabled-> EnableCEC first"); - return; - } - if(!HdmiCecSink::_instance) - return; - - LOGINFO("Current ARC State : %d\n", m_currentArcRoutingState); - - _instance->requestArcInitiation(); - - // start initiate ARC timer 3 sec - if (m_arcStartStopTimer.isActive()) - { - m_arcStartStopTimer.stop(); - } - m_arcstarting = true; - m_arcStartStopTimer.start((HDMISINK_ARC_START_STOP_MAX_WAIT_MS)); - - } - void HdmiCecSink::requestArcInitiation() - { - { - std::lock_guard lock(m_arcRoutingStateMutex); - m_currentArcRoutingState = ARC_STATE_REQUEST_ARC_INITIATION; - } - LOGINFO("requestArcInitiation release sem"); - _instance->m_semSignaltoArcRoutingThread.release(); - - } - void HdmiCecSink::stopArc() - { - if ( cecEnableStatus != true ) - { - LOGINFO("Initiate_Arc Cec is disabled-> EnableCEC first"); - return; - } - if(!HdmiCecSink::_instance) - return; - if(m_currentArcRoutingState == ARC_STATE_REQUEST_ARC_TERMINATION || m_currentArcRoutingState == ARC_STATE_ARC_TERMINATED) - { - LOGINFO("ARC is either Termination in progress or already Terminated"); - return; - } - - _instance->requestArcTermination(); - /* start a timer for 3 sec to get the desired ARC_STATE_ARC_TERMINATED */ - if (m_arcStartStopTimer.isActive()) - { - m_arcStartStopTimer.stop(); - } - /* m_arcstarting = true means starting the ARC start timer ,false means ARC stopping timer*/ - m_arcstarting = false; - m_arcStartStopTimer.start((HDMISINK_ARC_START_STOP_MAX_WAIT_MS)); - - - } - void HdmiCecSink::requestArcTermination() - { - { - std::lock_guard lock(m_arcRoutingStateMutex); - m_currentArcRoutingState = ARC_STATE_REQUEST_ARC_TERMINATION; - } - LOGINFO("requestArcTermination release sem"); - _instance->m_semSignaltoArcRoutingThread.release(); - - } - - void HdmiCecSink::Process_InitiateArc() - { - JsonObject params; - - LOGINFO("Command: INITIATE_ARC \n"); - - if(!HdmiCecSink::_instance) - return; - - //DD: Check cecSettingEnabled to prevent race conditions which gives immediate UI setting status - //Initiate ARC message may come from AVR/Soundbar while CEC disable is in-progress - if ( cecSettingEnabled != true ) - { - LOGINFO("Process InitiateArc from Audio device: Cec is disabled-> EnableCEC first"); - return; - } - - LOGINFO("Got : INITIATE_ARC and current Arcstate is %d\n",_instance->m_currentArcRoutingState); - - if (m_arcStartStopTimer.isActive()) - { - m_arcStartStopTimer.stop(); - } - if (powerState == DEVICE_POWER_STATE_ON ) { - LOGINFO("Notifying Arc Initiation event as power state is %s", powerState ? "Off" : "On"); - { - std::lock_guard lock(_instance->m_arcRoutingStateMutex); - _instance->m_currentArcRoutingState = ARC_STATE_ARC_INITIATED; - } - _instance->m_semSignaltoArcRoutingThread.release(); - LOGINFO("Got : ARC_INITIATED and notify Device setting"); - params["status"] = string("success"); - sendNotify(eventString[HDMICECSINK_EVENT_ARC_INITIATION_EVENT], params); - } else { - LOGINFO("Not notifying Arc Initiation event as power state is %s", powerState ? "Off" : "On"); - } - - } - void HdmiCecSink::Process_TerminateArc() - { - JsonObject params; - - LOGINFO("Command: TERMINATE_ARC current arc state %d \n",HdmiCecSink::_instance->m_currentArcRoutingState); - if (m_arcStartStopTimer.isActive()) - { - m_arcStartStopTimer.stop(); - } - { - std::lock_guard lock(m_arcRoutingStateMutex); - HdmiCecSink::_instance->m_currentArcRoutingState = ARC_STATE_ARC_TERMINATED; - } - _instance->m_semSignaltoArcRoutingThread.release(); - - // trigger callback to Device setting informing to TERMINATE_ARC - LOGINFO("Got : ARC_TERMINATED and notify Device setting"); - params["status"] = string("success"); - sendNotify(eventString[HDMICECSINK_EVENT_ARC_TERMINATION_EVENT], params); - } - - void HdmiCecSink::threadSendKeyEvent() - { - if(!HdmiCecSink::_instance) - return; - - SendKeyInfo keyInfo = {-1,-1}; - - while(!_instance->m_sendKeyEventThreadExit) - { - keyInfo.logicalAddr = -1; - keyInfo.keyCode = -1; - { - // Wait for a message to be added to the queue - std::unique_lock lk(_instance->m_sendKeyEventMutex); - _instance->m_sendKeyCV.wait(lk, []{return (_instance->m_sendKeyEventThreadRun == true);}); - } - - if (_instance->m_sendKeyEventThreadExit == true) - { - LOGINFO(" threadSendKeyEvent Exiting"); - _instance->m_sendKeyEventThreadRun = false; - break; - } - - if (_instance->m_SendKeyQueue.empty()) { - _instance->m_sendKeyEventThreadRun = false; - continue; - } - - keyInfo = _instance->m_SendKeyQueue.front(); - _instance->m_SendKeyQueue.pop(); - - if(keyInfo.UserControl == "sendUserControlPressed" ) - { - LOGINFO("sendUserControlPressed : logical addr:0x%x keyCode: 0x%x queue size :%zu \n",keyInfo.logicalAddr,keyInfo.keyCode,_instance->m_SendKeyQueue.size()); - _instance->sendUserControlPressed(keyInfo.logicalAddr,keyInfo.keyCode); - } - else if(keyInfo.UserControl == "sendUserControlReleased") - { - LOGINFO("sendUserControlReleased : logical addr:0x%x queue size :%zu \n",keyInfo.logicalAddr,_instance->m_SendKeyQueue.size()); - _instance->sendUserControlReleased(keyInfo.logicalAddr); - } - else - { - LOGINFO("sendKeyPressEvent : logical addr:0x%x keyCode: 0x%x queue size :%zu \n",keyInfo.logicalAddr,keyInfo.keyCode,_instance->m_SendKeyQueue.size()); - _instance->sendKeyPressEvent(keyInfo.logicalAddr,keyInfo.keyCode); - _instance->sendKeyReleaseEvent(keyInfo.logicalAddr); - } - - if((_instance->m_SendKeyQueue.size()<=1 || (_instance->m_SendKeyQueue.size() % 2 == 0)) && ((keyInfo.keyCode == VOLUME_UP) || (keyInfo.keyCode == VOLUME_DOWN) || (keyInfo.keyCode == MUTE)) ) - { - if(keyInfo.keyCode == MUTE) - { - _instance->sendGiveAudioStatusMsg(); - } - else - { - LOGINFO("m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d ",_instance->m_isAudioStatusInfoUpdated,_instance->m_audioStatusReceived,_instance->m_audioStatusTimerStarted); - if (!_instance->m_isAudioStatusInfoUpdated) - { - if ( !(_instance->m_audioStatusDetectionTimer.isActive())) - { - LOGINFO("Audio status info not updated. Starting the Timer!"); - _instance->m_audioStatusTimerStarted = true; - _instance->m_audioStatusDetectionTimer.start((HDMICECSINK_UPDATE_AUDIO_STATUS_INTERVAL_MS)); - } - LOGINFO("m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d ", _instance->m_isAudioStatusInfoUpdated,_instance->m_audioStatusReceived,_instance->m_audioStatusTimerStarted); - } - else - { - if (!_instance->m_audioStatusReceived){ - _instance->sendGiveAudioStatusMsg(); - } - } - } - } - - }//while(!_instance->m_sendKeyEventThreadExit) - }//threadSendKeyEvent - - void HdmiCecSink::audioStatusTimerFunction() - { - m_audioStatusTimerStarted = false; - m_isAudioStatusInfoUpdated = true; - LOGINFO("Timer Expired. Requesting the AudioStatus since not received.\n"); - sendGiveAudioStatusMsg(); - LOGINFO("m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d ", m_isAudioStatusInfoUpdated,m_audioStatusReceived,m_audioStatusTimerStarted); - } - - void HdmiCecSink::threadArcRouting() - { - bool isExit = false; - uint32_t currentArcRoutingState; - - if(!HdmiCecSink::_instance) - return; - - LOGINFO("Running threadArcRouting"); - _instance->getHdmiArcPortID(); - - while(1) - { - - _instance->m_semSignaltoArcRoutingThread.acquire(); - - - - { - LOGINFO(" threadArcRouting Got semaphore"); - std::lock_guard lock(_instance->m_arcRoutingStateMutex); - - currentArcRoutingState = _instance->m_currentArcRoutingState; - - LOGINFO(" threadArcRouting Got Sem arc state %d",currentArcRoutingState); - } - - switch (currentArcRoutingState) - { - - case ARC_STATE_REQUEST_ARC_INITIATION : - { - - _instance->systemAudioModeRequest(); - _instance->Send_Request_Arc_Initiation_Message(); - - } - break; - case ARC_STATE_ARC_INITIATED : - { - _instance->Send_Report_Arc_Initiated_Message(); - } - break; - case ARC_STATE_REQUEST_ARC_TERMINATION : - { - - _instance->Send_Request_Arc_Termination_Message(); - - } - break; - case ARC_STATE_ARC_TERMINATED : - { - _instance->Send_Report_Arc_Terminated_Message(); - } - break; - case ARC_STATE_ARC_EXIT : - { - isExit = true; - } - break; - } - - if (isExit == true) - { - LOGINFO(" threadArcRouting EXITing"); - break; - } - }//while(1) - }//threadArcRouting - - void HdmiCecSink::Send_Request_Arc_Initiation_Message() - { - if(!HdmiCecSink::_instance) - return; - if(!(_instance->smConnection)) - return; - LOGINFO(" Send_Request_Arc_Initiation_Message "); - _instance->smConnection->sendTo(LogicalAddress::AUDIO_SYSTEM,MessageEncoder().encode(RequestArcInitiation()), 1000); - - } - void HdmiCecSink::Send_Report_Arc_Initiated_Message() - { - if(!HdmiCecSink::_instance) - return; - if(!(_instance->smConnection)) - return; - _instance->smConnection->sendTo(LogicalAddress::AUDIO_SYSTEM,MessageEncoder().encode(ReportArcInitiation()), 1000); - - } - void HdmiCecSink::Send_Request_Arc_Termination_Message() - { - - if(!HdmiCecSink::_instance) - return; - if(!(_instance->smConnection)) - return; - _instance->smConnection->sendTo(LogicalAddress::AUDIO_SYSTEM,MessageEncoder().encode(RequestArcTermination()), 1000); - } - - void HdmiCecSink::Send_Report_Arc_Terminated_Message() - { - if(!HdmiCecSink::_instance) - return; - if(!(_instance->smConnection)) - return; - _instance->smConnection->sendTo(LogicalAddress::AUDIO_SYSTEM,MessageEncoder().encode(ReportArcTermination()), 1000); - - } - - void HdmiCecSink::getHdmiArcPortID() - { - int err; - dsGetHDMIARCPortIdParam_t param; - err = IARM_Bus_Call(IARM_BUS_DSMGR_NAME, - (char *)IARM_BUS_DSMGR_API_dsGetHDMIARCPortId, - (void *)¶m, - sizeof(param)); - if (IARM_RESULT_SUCCESS == err) - { - LOGINFO("HDMI ARC port ID HdmiArcPortID=[%d] \n", param.portId); - HdmiArcPortID = param.portId; - } - } - - void HdmiCecSink::getCecVersion() - { - RFC_ParamData_t param = {0}; - WDMP_STATUS status = getRFCParameter((char*)"thunderapi", TR181_HDMICECSINK_CEC_VERSION, ¶m); - if(WDMP_SUCCESS == status && param.type == WDMP_STRING) { - LOGINFO("CEC Version from RFC = [%s] \n", param.value); - cecVersion = atof(param.value); - } - else { - LOGINFO("Error while fetching CEC Version from RFC "); - } - } - - } // namespace Plugin -} // namespace WPEFrameworklk diff --git a/HdmiCecSink/HdmiCecSink.h b/HdmiCecSink/HdmiCecSink.h deleted file mode 100644 index 418fb1345..000000000 --- a/HdmiCecSink/HdmiCecSink.h +++ /dev/null @@ -1,749 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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. -**/ - -#pragma once - -#include -#include "ccec/FrameListener.hpp" -#include "ccec/Connection.hpp" - -#include "libIARM.h" -#include "ccec/Assert.hpp" -#include "ccec/Messages.hpp" -#include "ccec/MessageDecoder.hpp" -#include "ccec/MessageProcessor.hpp" - -#undef Assert // this define from Connection.hpp conflicts with WPEFramework - -#include "Module.h" -#include "tptimer.h" -#include -#include -#include -#include - -#include "UtilsLogging.h" -#include -#include "PowerManagerInterface.h" - -using namespace WPEFramework; -using PowerState = WPEFramework::Exchange::IPowerManager::PowerState; -using ThermalTemperature = WPEFramework::Exchange::IPowerManager::ThermalTemperature; - - -namespace WPEFramework { - - namespace Plugin { - class HdmiCecSinkFrameListener : public FrameListener - { - public: - HdmiCecSinkFrameListener(MessageProcessor &processor) : processor(processor) {} - void notify(const CECFrame &in) const; - ~HdmiCecSinkFrameListener() {} - private: - MessageProcessor &processor; - }; - - class HdmiCecSinkProcessor : public MessageProcessor - { - public: - HdmiCecSinkProcessor(Connection &conn) : conn(conn) {} - void process (const ActiveSource &msg, const Header &header); - void process (const InActiveSource &msg, const Header &header); - void process (const ImageViewOn &msg, const Header &header); - void process (const TextViewOn &msg, const Header &header); - void process (const RequestActiveSource &msg, const Header &header); - void process (const Standby &msg, const Header &header); - void process (const GetCECVersion &msg, const Header &header); - void process (const CECVersion &msg, const Header &header); - void process (const SetMenuLanguage &msg, const Header &header); - void process (const GiveOSDName &msg, const Header &header); - void process (const GivePhysicalAddress &msg, const Header &header); - void process (const GiveDeviceVendorID &msg, const Header &header); - void process (const SetOSDString &msg, const Header &header); - void process (const SetOSDName &msg, const Header &header); - void process (const RoutingChange &msg, const Header &header); - void process (const RoutingInformation &msg, const Header &header); - void process (const SetStreamPath &msg, const Header &header); - void process (const GetMenuLanguage &msg, const Header &header); - void process (const ReportPhysicalAddress &msg, const Header &header); - void process (const DeviceVendorID &msg, const Header &header); - void process (const GiveDevicePowerStatus &msg, const Header &header); - void process (const ReportPowerStatus &msg, const Header &header); - void process (const FeatureAbort &msg, const Header &header); - void process (const Abort &msg, const Header &header); - void process (const Polling &msg, const Header &header); - void process (const InitiateArc &msg, const Header &header); - void process (const TerminateArc &msg, const Header &header); - void process (const ReportShortAudioDescriptor &msg, const Header &header); - void process (const SetSystemAudioMode &msg, const Header &header); - void process (const ReportAudioStatus &msg, const Header &header); - void process (const GiveFeatures &msg, const Header &header); - void process (const RequestCurrentLatency &msg, const Header &header); - private: - Connection conn; - void printHeader(const Header &header) - { - printf("Header : From : %s \n", header.from.toString().c_str()); - printf("Header : to : %s \n", header.to.toString().c_str()); - } - - }; - - class CECDeviceParams { - public: - - enum { - REQUEST_NONE = 0, - REQUEST_PHISICAL_ADDRESS = 1, - REQUEST_CEC_VERSION, - REQUEST_DEVICE_VENDOR_ID, - REQUEST_POWER_STATUS, - REQUEST_OSD_NAME, - }; - - enum { - REQUEST_DONE = 0, - REQUEST_NOT_DONE, - REQUEST_TIME_ELAPSED, - }; - - DeviceType m_deviceType; - LogicalAddress m_logicalAddress; - PhysicalAddress m_physicalAddr; - Version m_cecVersion; - VendorID m_vendorID; - OSDName m_osdName; - PowerStatus m_powerStatus; - bool m_isDevicePresent; - bool m_isDeviceDisconnected; - Language m_currentLanguage; - bool m_isActiveSource; - bool m_isDeviceTypeUpdated; - bool m_isPAUpdated; - bool m_isVersionUpdated; - bool m_isOSDNameUpdated; - bool m_isVendorIDUpdated; - bool m_isPowerStatusUpdated; - int m_isRequested; - int m_isRequestRetry; - std::chrono::system_clock::time_point m_requestTime; - std::vector m_featureAborts; - std::chrono::system_clock::time_point m_lastPowerUpdateTime; - - CECDeviceParams() - : m_deviceType(0), m_logicalAddress(0),m_physicalAddr(0x0f,0x0f,0x0f,0x0f),m_cecVersion(0),m_vendorID(0,0,0),m_osdName(""),m_powerStatus(0),m_currentLanguage("") - { - m_isDevicePresent = false; - m_isActiveSource = false; - m_isPAUpdated = false; - m_isVersionUpdated = false; - m_isOSDNameUpdated = false; - m_isVendorIDUpdated = false; - m_isPowerStatusUpdated = false; - m_isDeviceDisconnected = false; - m_isDeviceTypeUpdated = false; - m_isRequestRetry = 0; - } - - void clear( ) - { - m_deviceType = 0; - m_logicalAddress = 0; - m_physicalAddr = PhysicalAddress(0x0f,0x0f,0x0f,0x0f); - m_cecVersion = 0; - m_vendorID = VendorID(0,0,0); - m_osdName = ""; - m_powerStatus = 0; - m_currentLanguage = ""; - m_isDevicePresent = false; - m_isActiveSource = false; - m_isPAUpdated = false; - m_isVersionUpdated = false; - m_isOSDNameUpdated = false; - m_isVendorIDUpdated = false; - m_isPowerStatusUpdated = false; - m_isDeviceDisconnected = false; - m_isDeviceTypeUpdated = false; - } - - void printVariable() - { - LOGWARN("Device LogicalAddress %s", m_logicalAddress.toString().c_str()); - LOGWARN("Device Type %s", m_deviceType.toString().c_str()); - LOGWARN("Device Present %d", m_isDevicePresent); - LOGWARN("Active Source %d", m_isActiveSource); - LOGWARN("PA Updated %d", m_isPAUpdated); - LOGWARN("Version Updated %d", m_isVersionUpdated); - LOGWARN("OSDName Updated %d", m_isOSDNameUpdated); - LOGWARN("PowerStatus Updated %d", m_isPowerStatusUpdated); - LOGWARN("VendorID Updated %d", m_isPowerStatusUpdated); - LOGWARN("CEC Version : %s", m_cecVersion.toString().c_str()); - LOGWARN("Vendor ID : %s", m_vendorID.toString().c_str()); - LOGWARN("PhisicalAddress : %s", m_physicalAddr.toString().c_str()); - LOGWARN("OSDName : %s", m_osdName.toString().c_str()); - LOGWARN("Power Status : %s", m_powerStatus.toString().c_str()); - LOGWARN("Language : %s", m_currentLanguage.toString().c_str()); - } - - bool isAllUpdated() { - if( !m_isPAUpdated - || !m_isVersionUpdated - || !m_isOSDNameUpdated - || !m_isVendorIDUpdated - || !m_isPowerStatusUpdated - || !m_isDeviceTypeUpdated ){ - return false; - } - return true; - } - - void update( const DeviceType &deviceType ) { - m_deviceType = deviceType; - m_isDeviceTypeUpdated = true; - } - - void update( const PhysicalAddress &physical_addr ) { - m_physicalAddr = physical_addr; - m_isPAUpdated = true; - } - - void update ( const VendorID &vendorId) { - m_vendorID = vendorId; - m_isVendorIDUpdated = true; - } - - void update ( const Version &version ) { - m_cecVersion = version; - m_isVersionUpdated = true; - } - - void update ( const OSDName &osdName ) { - m_osdName = osdName; - m_isOSDNameUpdated = true; - } - - void update ( const PowerStatus &status ) { - m_powerStatus = status; - m_isPowerStatusUpdated = true; - m_lastPowerUpdateTime = std::chrono::system_clock::now(); - } - }; - - class DeviceNode { - public: - uint8_t m_childsLogicalAddr[LogicalAddress::UNREGISTERED]; - - DeviceNode() { - int i; - for (i = 0; i < LogicalAddress::UNREGISTERED; i++ ) - { - m_childsLogicalAddr[i] = LogicalAddress::UNREGISTERED; - } - } - - } ; - typedef struct sendKeyInfo - { - int logicalAddr; - int keyCode; - string UserControl; - }SendKeyInfo; - - class HdmiPortMap { - public: - uint8_t m_portID; - bool m_isConnected; - LogicalAddress m_logicalAddr; - PhysicalAddress m_physicalAddr; - DeviceNode m_deviceChain[3]; - - HdmiPortMap(uint8_t portID) : m_portID(portID), - m_logicalAddr(LogicalAddress::UNREGISTERED), - m_physicalAddr(portID+1,0,0,0) - { - m_isConnected = false; - } - - void update(bool isConnected) - { - m_isConnected = isConnected; - } - - void update( const LogicalAddress &addr ) - { - m_logicalAddr = addr; - } - - void addChild( const LogicalAddress &logical_addr, const PhysicalAddress &physical_addr ) - { - LOGINFO(" logicalAddr = %d, phisicalAddr = %s", m_logicalAddr.toInt(), physical_addr.toString().c_str()); - - if ( m_logicalAddr.toInt() != LogicalAddress::UNREGISTERED && - m_logicalAddr.toInt() != logical_addr.toInt() ) - { - LOGINFO(" update own logicalAddr = %d, new devcie logicalAddress = %d", m_logicalAddr.toInt(), logical_addr.toInt() ); - /* check matching with this port's physical address */ - if( physical_addr.getByteValue(0) == m_physicalAddr.getByteValue(0) && - physical_addr.getByteValue(1) != 0 ) - { - if ( physical_addr.getByteValue(3) != 0 ) - { - m_deviceChain[2].m_childsLogicalAddr[physical_addr.getByteValue(3) - 1] = logical_addr.toInt(); - } - else if ( physical_addr.getByteValue(2) != 0 ) - { - m_deviceChain[1].m_childsLogicalAddr[physical_addr.getByteValue(2) - 1] = logical_addr.toInt(); - } - else if ( physical_addr.getByteValue(1) != 0 ) - { - m_deviceChain[0].m_childsLogicalAddr[physical_addr.getByteValue(1) - 1] = logical_addr.toInt(); - } - } - } - else if ( physical_addr == m_physicalAddr ) - { - update(logical_addr); - LOGINFO(" update own logicalAddr = %d", m_logicalAddr.toInt()); - } - } - - void removeChild( PhysicalAddress &physical_addr ) - { - if ( m_logicalAddr.toInt() != LogicalAddress::UNREGISTERED ) - { - /* check matching with this port's physical address */ - if( physical_addr.getByteValue(0) == m_physicalAddr.getByteValue(0) && - physical_addr.getByteValue(1) != 0 ) - { - if ( physical_addr.getByteValue(3) != 0 ) - { - m_deviceChain[2].m_childsLogicalAddr[physical_addr.getByteValue(3) - 1] = LogicalAddress::UNREGISTERED; - } - else if ( physical_addr.getByteValue(2) != 0 ) - { - m_deviceChain[1].m_childsLogicalAddr[physical_addr.getByteValue(2) - 1] = LogicalAddress::UNREGISTERED; - } - else if ( physical_addr.getByteValue(1) != 0 ) - { - m_deviceChain[0].m_childsLogicalAddr[physical_addr.getByteValue(1) - 1] = LogicalAddress::UNREGISTERED; - } - } - } - } - - void getRoute( PhysicalAddress &physical_addr, std::vector & route ) - { - LOGINFO(" logicalAddr = %d, phsical = %s", m_logicalAddr.toInt(), physical_addr.toString().c_str()); - - if ( m_logicalAddr.toInt() != LogicalAddress::UNREGISTERED ) - { - LOGINFO(" search for logicalAddr = %d", m_logicalAddr.toInt()); - /* check matching with this port's physical address */ - if( physical_addr.getByteValue(0) == m_physicalAddr.getByteValue(0) && - physical_addr.getByteValue(1) != 0 ) - { - if ( physical_addr.getByteValue(3) != 0 ) - { - route.push_back(m_deviceChain[2].m_childsLogicalAddr[physical_addr.getByteValue(3) - 1]); - } - - if ( physical_addr.getByteValue(2) != 0 ) - { - route.push_back(m_deviceChain[1].m_childsLogicalAddr[physical_addr.getByteValue(2) - 1]); - } - - if ( physical_addr.getByteValue(1) != 0 ) - { - route.push_back(m_deviceChain[0].m_childsLogicalAddr[physical_addr.getByteValue(1) - 1]); - } - - route.push_back(m_logicalAddr.toInt()); - } - else - { - route.push_back(m_logicalAddr.toInt()); - LOGINFO("logicalAddr = %d, physical = %s", m_logicalAddr.toInt(), m_physicalAddr.toString().c_str()); - } - } - } - }; - - class binary_semaphore { - - public: - - explicit binary_semaphore(int init_count = count_max) - - : count_(init_count) {} - - - - // P-operation / acquire - - void wait() - - { - - std::unique_lock lk(m_); - - cv_.wait(lk, [=]{ return 0 < count_; }); - - --count_; - - } - - bool try_wait() - - { - - std::lock_guard lk(m_); - - if (0 < count_) { - - --count_; - - return true; - - } else { - - return false; - - } - - } - - // V-operation / release - - void signal() - - { - - std::lock_guard lk(m_); - - if (count_ < count_max) { - - ++count_; - - cv_.notify_one(); - - } - - } - - - - // Lockable requirements - - void acquire() { wait(); } - - bool try_lock() { return try_wait(); } - - void release() { signal(); } - - - -private: - - static const int count_max = 1; - - int count_; - - std::mutex m_; - - std::condition_variable cv_; - -}; - // This is a server for a JSONRPC communication channel. - // For a plugin to be capable to handle JSONRPC, inherit from PluginHost::JSONRPC. - // By inheriting from this class, the plugin realizes the interface PluginHost::IDispatcher. - // This realization of this interface implements, by default, the following methods on this plugin - // - exists - // - register - // - unregister - // Any other methood to be handled by this plugin can be added can be added by using the - // templated methods Register on the PluginHost::JSONRPC class. - // As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC, - // this class exposes a public method called, Notify(), using this methods, all subscribed clients - // will receive a JSONRPC message as a notification, in case this method is called. - class HdmiCecSink : public PluginHost::IPlugin, public PluginHost::JSONRPC { - - enum { - POLL_THREAD_STATE_NONE, - POLL_THREAD_STATE_IDLE, - POLL_THREAD_STATE_POLL, - POLL_THREAD_STATE_PING, - POLL_THREAD_STATE_INFO, - POLL_THREAD_STATE_WAIT, - POLL_THREAD_STATE_CLEAN, - POLL_THREAD_STATE_UPDATE, - POLL_THREAD_STATE_EXIT, - }; - enum { - ARC_STATE_REQUEST_ARC_INITIATION, - ARC_STATE_ARC_INITIATED, - ARC_STATE_REQUEST_ARC_TERMINATION, - ARC_STATE_ARC_TERMINATED, - ARC_STATE_ARC_EXIT - }; - enum { - VOLUME_UP = 0x41, - VOLUME_DOWN = 0x42, - MUTE = 0x43, - UP = 0x01, - DOWN = 0x02, - LEFT = 0x03, - RIGHT = 0x04, - SELECT = 0x00, - HOME = 0x09, - BACK = 0x0D, - NUMBER_0 = 0x20, - NUMBER_1 = 0x21, - NUMBER_2 = 0x22, - NUMBER_3 = 0x23, - NUMBER_4 = 0x24, - NUMBER_5 = 0x25, - NUMBER_6 = 0x26, - NUMBER_7 = 0x27, - NUMBER_8 = 0x28, - NUMBER_9 = 0x29 - }; - public: - HdmiCecSink(); - virtual ~HdmiCecSink(); - virtual const string Initialize(PluginHost::IShell* shell) override; - virtual void Deinitialize(PluginHost::IShell* service) override; - virtual string Information() const override { return {}; } - static HdmiCecSink* _instance; - CECDeviceParams deviceList[16]; - std::vector hdmiInputs; - int m_currentActiveSource; - void updateInActiveSource(const int logical_address, const InActiveSource &source ); - void updateActiveSource(const int logical_address, const ActiveSource &source ); - void updateTextViewOn(const int logicalAddress); - void updateImageViewOn(const int logicalAddress); - void updateDeviceChain(const LogicalAddress &logicalAddress, const PhysicalAddress &phy_addr); - void getActiveRoute(const LogicalAddress &logicalAddress, std::vector &route); - void removeDevice(const int logicalAddress); - void addDevice(const int logicalAddress); - void printDeviceList(); - void setStreamPath( const PhysicalAddress &physical_addr); - void setRoutingChange(const std::string &from, const std::string &to); - void sendStandbyMessage(); - void setCurrentLanguage(const Language &lang); - void sendMenuLanguage(); - void setActiveSource(bool isResponse); - void requestActiveSource(); - void startArc(); - void stopArc(); - void Process_InitiateArc(); - void Process_TerminateArc(); - void updateArcState(); - void requestShortaudioDescriptor(); - void Send_ShortAudioDescriptor_Event(JsonArray audiodescriptor); - void Process_ShortAudioDescriptor_msg(const ReportShortAudioDescriptor &msg); - void Process_SetSystemAudioMode_msg(const SetSystemAudioMode &msg); - void sendDeviceUpdateInfo(const int logicalAddress); - void sendFeatureAbort(const LogicalAddress logicalAddress, const OpCode feature, const AbortReason reason); - void reportFeatureAbortEvent(const LogicalAddress logicalAddress, const OpCode feature, const AbortReason reason); - void systemAudioModeRequest(); - void SendStandbyMsgEvent(const int logicalAddress); - void requestAudioDevicePowerStatus(); - void reportAudioDevicePowerStatusInfo(const int logicalAddress, const int powerStatus); - void updateCurrentLatency(int videoLatency, bool lowLatencyMode, int audioOutputCompensated, int audioOutputDelay); - void setLatencyInfo(); - void Process_ReportAudioStatus_msg(const ReportAudioStatus msg); - void sendKeyPressEvent(const int logicalAddress, int keyCode); - void sendKeyReleaseEvent(const int logicalAddress); - void sendUserControlPressed(const int logicalAddress, int keyCode); - void sendUserControlReleased(const int logicalAddress); - void onPowerModeChanged(const PowerState currentState, const PowerState newState); - void registerEventHandlers(); - void sendGiveAudioStatusMsg(); - void getHdmiArcPortID(); - int m_numberOfDevices; /* Number of connected devices othethan own device */ - bool m_audioDevicePowerStatusRequested; - - BEGIN_INTERFACE_MAP(HdmiCecSink) - INTERFACE_ENTRY(PluginHost::IPlugin) - INTERFACE_ENTRY(PluginHost::IDispatcher) - END_INTERFACE_MAP - - private: - class PowerManagerNotification : public Exchange::IPowerManager::IModeChangedNotification { - private: - PowerManagerNotification(const PowerManagerNotification&) = delete; - PowerManagerNotification& operator=(const PowerManagerNotification&) = delete; - - public: - explicit PowerManagerNotification(HdmiCecSink& parent) - : _parent(parent) - { - } - ~PowerManagerNotification() override = default; - - public: - void OnPowerModeChanged(const PowerState currentState, const PowerState newState) override - { - _parent.onPowerModeChanged(currentState, newState); - } - - template - T* baseInterface() - { - static_assert(std::is_base_of(), "base type mismatch"); - return static_cast(this); - } - - BEGIN_INTERFACE_MAP(PowerManagerNotification) - INTERFACE_ENTRY(Exchange::IPowerManager::IModeChangedNotification) - END_INTERFACE_MAP - - private: - HdmiCecSink& _parent; - }; - // We do not allow this plugin to be copied !! - HdmiCecSink(const HdmiCecSink&) = delete; - HdmiCecSink& operator=(const HdmiCecSink&) = delete; - - //Begin methods - uint32_t setEnabledWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getEnabledWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setOSDNameWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getOSDNameWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setVendorIdWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getVendorIdWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t printDeviceListWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setActivePathWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setRoutingChangeWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getDeviceListWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getActiveSourceWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setActiveSourceWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getActiveRouteWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t requestActiveSourceWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setArcEnableDisableWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setMenuLanguageWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t requestShortAudioDescriptorWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t sendStandbyMessageWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t sendAudioDevicePowerOnMsgWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t sendRemoteKeyPressWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t sendUserControlPressedWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t sendUserControlReleasedWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t sendGiveAudioStatusWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getAudioDeviceConnectedStatusWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t requestAudioDevicePowerStatusWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setLatencyInfoWrapper(const JsonObject& parameters, JsonObject& response); - void InitializePowerManager(PluginHost::IShell *service); - //End methods - std::string logicalAddressDeviceType; - bool cecSettingEnabled; - bool cecOTPSettingEnabled; - bool cecEnableStatus; - bool hdmiCecAudioDeviceConnected; - bool m_isHdmiInConnected; - int m_numofHdmiInput; - uint8_t m_deviceType; - int m_logicalAddressAllocated; - std::thread m_pollThread; - uint32_t m_pollThreadState; - uint32_t m_pollNextState; - bool m_pollThreadExit; - uint32_t m_sleepTime; - std::mutex m_pollExitMutex; - std::mutex m_enableMutex; - /* Send Key event related */ - bool m_sendKeyEventThreadExit; - bool m_sendKeyEventThreadRun; - bool m_isAudioStatusInfoUpdated; - bool m_audioStatusReceived; - bool m_audioStatusTimerStarted; - std::thread m_sendKeyEventThread; - std::mutex m_sendKeyEventMutex; - std::queue m_SendKeyQueue; - std::condition_variable m_sendKeyCV; - std::condition_variable m_ThreadExitCV; - - /* DALS - Latency Values */ - uint8_t m_video_latency; - uint8_t m_latency_flags; - uint8_t m_audio_output_delay; - - /* ARC related */ - std::thread m_arcRoutingThread; - uint32_t m_currentArcRoutingState; - std::mutex m_arcRoutingStateMutex; - binary_semaphore m_semSignaltoArcRoutingThread; - bool m_arcstarting; - TpTimer m_arcStartStopTimer; - TpTimer m_audioStatusDetectionTimer; - - Connection *smConnection; - std::vector m_connectedDevices; - HdmiCecSinkProcessor *msgProcessor; - HdmiCecSinkFrameListener *msgFrameListener; - PowerManagerInterfaceRef _powerManagerPlugin; - Core::Sink _pwrMgrNotification; - bool _registeredEventHandlers; - const void InitializeIARM(); - void DeinitializeIARM(); - void allocateLogicalAddress(int deviceType); - void allocateLAforTV(); - void pingDevices(std::vector &connected , std::vector &disconnected); - void CheckHdmiInState(); - void request(const int logicalAddress); - int requestType(const int logicalAddress); - int requestStatus(const int logicalAddress); - static void threadRun(); - void cecMonitoringThread(); - static void dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - void onHdmiHotPlug(int portId, int connectStatus); - bool loadSettings(); - void persistSettings(bool enableStatus); - void persistOTPSettings(bool enableStatus); - void persistOSDName(const char *name); - void persistVendorId(unsigned int vendorID); - void setEnabled(bool enabled); - bool getEnabled(); - bool getAudioDeviceConnectedStatus(); - void CECEnable(void); - void CECDisable(void); - void getPhysicalAddress(); - void getLogicalAddress(); - void cecAddressesChanged(int changeStatus); - - // Arc functions - - static void threadSendKeyEvent(); - static void threadArcRouting(); - void requestArcInitiation(); - void requestArcTermination(); - void Send_Request_Arc_Initiation_Message(); - void Send_Report_Arc_Initiated_Message(); - void Send_Request_Arc_Termination_Message(); - void Send_Report_Arc_Terminated_Message(); - void arcStartStopTimerFunction(); - void audioStatusTimerFunction(); - void getCecVersion(); - }; - } // namespace Plugin -} // namespace WPEFramework - - - - diff --git a/HdmiCecSink/Module.cpp b/HdmiCecSink/Module.cpp deleted file mode 100644 index ce759b615..000000000 --- a/HdmiCecSink/Module.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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 "Module.h" - -MODULE_NAME_DECLARATION(BUILD_REFERENCE) diff --git a/HdmiCecSink/Module.h b/HdmiCecSink/Module.h deleted file mode 100644 index 6697f8880..000000000 --- a/HdmiCecSink/Module.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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. -**/ - -#pragma once -#ifndef MODULE_NAME -#define MODULE_NAME Plugin_HdmiCecSink -#endif - -#include -#include - -#undef EXTERNAL -#define EXTERNAL diff --git a/HdmiCecSink/README.md b/HdmiCecSink/README.md deleted file mode 100644 index 6ca797021..000000000 --- a/HdmiCecSink/README.md +++ /dev/null @@ -1,9 +0,0 @@ ------------------ -Build: - -bitbake wpeframework-service-plugins - ------------------ -Test: - -curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "rdk.org.HdmiCecSink.1."}' http://127.0.0.1:9998/jsonrpc diff --git a/HdmiCecSource/CHANGELOG.md b/HdmiCecSource/CHANGELOG.md deleted file mode 100644 index 2e200c40d..000000000 --- a/HdmiCecSource/CHANGELOG.md +++ /dev/null @@ -1,16 +0,0 @@ -# Changelog - -All notable changes to this RDK Service will be documented in this file. - -* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. - -* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: - * **Added** for new features. - * **Changed** for changes in existing functionality. - * **Deprecated** for soon-to-be removed features. - * **Removed** for now removed features. - * **Fixed** for any bug fixes. - * **Security** in case of vulnerabilities. - -* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. - diff --git a/HdmiCecSource/CMakeLists.txt b/HdmiCecSource/CMakeLists.txt deleted file mode 100644 index 6a60b721f..000000000 --- a/HdmiCecSource/CMakeLists.txt +++ /dev/null @@ -1,85 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -set(PLUGIN_NAME HdmiCecSource) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) -set(PLUGIN_IMPLEMENTATION ${MODULE_NAME}Implementation) - -set(PLUGIN_HDMICECSOURCE_STARTUPORDER "" CACHE STRING "To configure startup order of HdmiCecSource plugin") - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - -set_source_files_properties(HdmiCecSource.cpp PROPERTIES COMPILE_FLAGS "-fexceptions") -set_source_files_properties(HdmiCecSourceImplementation.cpp PROPERTIES COMPILE_FLAGS "-fexceptions") - -find_package(${NAMESPACE}Plugins REQUIRED) -find_package(${NAMESPACE}Definitions REQUIRED) -find_package(CompileSettingsDebug CONFIG REQUIRED) - -add_library(${MODULE_NAME} SHARED - HdmiCecSource.cpp - Module.cpp) -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS} ../helpers) - -target_link_libraries(${MODULE_NAME} - PRIVATE - CompileSettingsDebug::CompileSettingsDebug - ${NAMESPACE}Plugins::${NAMESPACE}Plugins - ${NAMESPACE}Definitions::${NAMESPACE}Definitions - ${IARMBUS_LIBRARIES}) - -install(TARGETS ${MODULE_NAME} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -add_library(${PLUGIN_IMPLEMENTATION} SHARED - HdmiCecSourceImplementation.cpp - Module.cpp) - -set_target_properties(${PLUGIN_IMPLEMENTATION} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -find_package(DS) -find_package(IARMBus) -find_package(CEC) - - -target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ${IARMBUS_INCLUDE_DIRS} ../helpers) -target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ${CEC_INCLUDE_DIRS}) -target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ${DS_INCLUDE_DIRS}) - - -target_link_libraries(${PLUGIN_IMPLEMENTATION} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${CEC_LIBRARIES} ${DS_LIBRARIES} ) - -target_link_libraries(${PLUGIN_IMPLEMENTATION} - PRIVATE - CompileSettingsDebug::CompileSettingsDebug - ${NAMESPACE}Plugins::${NAMESPACE}Plugins) - -if (NOT RDK_SERVICES_L1_TEST) - target_compile_options(${PLUGIN_IMPLEMENTATION} PRIVATE -Wno-error=deprecated) -endif () - - -install(TARGETS ${PLUGIN_IMPLEMENTATION} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -write_config(${PLUGIN_NAME}) diff --git a/HdmiCecSource/HdmiCecSource.conf.in b/HdmiCecSource/HdmiCecSource.conf.in deleted file mode 100644 index 1dae4b85c..000000000 --- a/HdmiCecSource/HdmiCecSource.conf.in +++ /dev/null @@ -1,11 +0,0 @@ -precondition = ["Platform"] -callsign = "org.rdk.HdmiCecSource" -autostart = "false" -startuporder = "@PLUGIN_HDMICECSOURCE_STARTUPORDER@" - -configuration = JSON() -rootobject = JSON() - -rootobject.add("mode", "@PLUGIN_HDMICECSOURCE_MODE@") -rootobject.add("locator", "lib@PLUGIN_IMPLEMENTATION@.so") -configuration.add("root", rootobject) \ No newline at end of file diff --git a/HdmiCecSource/HdmiCecSource.config b/HdmiCecSource/HdmiCecSource.config deleted file mode 100644 index 787e151a2..000000000 --- a/HdmiCecSource/HdmiCecSource.config +++ /dev/null @@ -1,17 +0,0 @@ -set (autostart false) -set (preconditions Platform) -set (callsign "org.rdk.HdmiCecSource") - -if(PLUGIN_HDMICECSOURCE_STARTUPORDER) -set (startuporder ${PLUGIN_HDMICECSOURCE_STARTUPORDER}) -endif() - - -map() - key(root) - map() - kv(mode ${PLUGIN_HDMICECSOURCE_MODE}) - kv(locator lib${PLUGIN_IMPLEMENTATION}.so) - end() -end() -ans(configuration) diff --git a/HdmiCecSource/HdmiCecSource.cpp b/HdmiCecSource/HdmiCecSource.cpp deleted file mode 100644 index e00fba1de..000000000 --- a/HdmiCecSource/HdmiCecSource.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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 "HdmiCecSource.h" - -#include "UtilsIarm.h" -#include "UtilsJsonRpc.h" -#include "UtilssyncPersistFile.h" -#include "UtilsSearchRDKProfile.h" - -#define API_VERSION_NUMBER_MAJOR 1 -#define API_VERSION_NUMBER_MINOR 0 -#define API_VERSION_NUMBER_PATCH 8 - -using namespace WPEFramework; - - -namespace WPEFramework -{ - namespace { - - static Plugin::Metadata metadata( - // Version (Major, Minor, Patch) - API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH, - // Preconditions - {}, - // Terminations - {}, - // Controls - {} - ); - } - - namespace Plugin - { - SERVICE_REGISTRATION(HdmiCecSource, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); - - const string HdmiCecSource::Initialize(PluginHost::IShell *service) - { - LOGWARN("Initlaizing HdmiCecSource plugin \n"); - - profileType = searchRdkProfile(); - - if (profileType == TV || profileType == NOT_FOUND) - { - LOGINFO("Invalid profile type for STB \n"); - return (std::string("Not supported")); - } - - string msg = ""; - - ASSERT(nullptr != service); - ASSERT(nullptr == _service); - ASSERT(nullptr == _hdmiCecSource); - ASSERT(0 == _connectionId); - - - _service = service; - _service->AddRef(); - _service->Register(&_notification); - _hdmiCecSource = _service->Root(_connectionId, 5000, _T("HdmiCecSourceImplementation")); - - if(nullptr != _hdmiCecSource) - { - _hdmiCecSource->Configure(service); - _hdmiCecSource->Register(&_notification); - Exchange::JHdmiCecSource::Register(*this, _hdmiCecSource); - LOGINFO("HdmiCecSource plugin is available. Successfully activated HdmiCecSource Plugin"); - } - else - { - msg = "HdmiCecSource plugin is not available"; - LOGINFO("HdmiCecSource plugin is not available. Failed to activate HdmiCecSource Plugin"); - } - - if (0 != msg.length()) - { - Deinitialize(service); - } - - // On success return empty, to indicate there is no error text. - return msg; - } - - - void HdmiCecSource::Deinitialize(PluginHost::IShell* service) - { - LOGWARN("Deinitialize HdmiCecSource plugin \n"); - - ASSERT(nullptr != service); - - - profileType = searchRdkProfile(); - - if (profileType == TV || profileType == NOT_FOUND) - { - LOGINFO("Invalid profile type for STB \n"); - return ; - } - - bool enabled = false; - bool ret = false; - HdmiCecSource::_hdmiCecSource->GetEnabled(enabled,ret); - - if(ret && enabled) - { - Exchange::IHdmiCecSource::HdmiCecSourceSuccess success; - HdmiCecSource::_hdmiCecSource->SetEnabled(false,success); - } - HdmiCecSource::_notification.OnActiveSourceStatusUpdated(false); - - if(nullptr != _hdmiCecSource) - { - _hdmiCecSource->Unregister(&_notification); - Exchange::JHdmiCecSource::Unregister(*this); - _hdmiCecSource->Release(); - _hdmiCecSource = nullptr; - - RPC::IRemoteConnection* connection = _service->RemoteConnection(_connectionId); - if (connection != nullptr) - { - try{ - connection->Terminate(); - } - catch(const std::exception& e) - { - std::string errorMessage = "Failed to terminate connection: "; - errorMessage += e.what(); - LOGWARN("%s",errorMessage.c_str()); - } - - connection->Release(); - } - } - - _connectionId = 0; - _service->Unregister(&_notification); - _service->Release(); - _service = nullptr; - LOGINFO("HdmiCecSource plugin is deactivated. Successfully deactivated HdmiCecSource Plugin"); - } - - string HdmiCecSource::Information() const - { - return("This HdmiCecSource PLugin Facilitates the HDMI CEC Source Control"); - } - - void HdmiCecSource::Deactivated(RPC::IRemoteConnection* connection) - { - if (connection->Id() == _connectionId) - { - ASSERT(_service != nullptr); - Core::IWorkerPool::Instance().Submit(PluginHost::IShell::Job::Create(_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::FAILURE)); - } - } - - } // namespace Plugin -} // namespace WPEFramework diff --git a/HdmiCecSource/HdmiCecSource.h b/HdmiCecSource/HdmiCecSource.h deleted file mode 100644 index b53266e0c..000000000 --- a/HdmiCecSource/HdmiCecSource.h +++ /dev/null @@ -1,187 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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. -**/ - -#pragma once - -#include -#include -#include - -#include - -#undef Assert // this define from Connection.hpp conflicts with WPEFramework - -#include "Module.h" - -#include "UtilsBIT.h" -#include "UtilsThreadRAII.h" - -#include -#include -#include - -using namespace WPEFramework; - -namespace WPEFramework { - - namespace Plugin { - // This is a server for a JSONRPC communication channel. - // For a plugin to be capable to handle JSONRPC, inherit from PluginHost::JSONRPC. - // By inheriting from this class, the plugin realizes the interface PluginHost::IDispatcher. - // This realization of this interface implements, by default, the following methods on this plugin - // - exists - // - register - // - unregister - // Any other methood to be handled by this plugin can be added can be added by using the - // templated methods Register on the PluginHost::JSONRPC class. - // As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC, - // this class exposes a public method called, Notify(), using this methods, all subscribed clients - // will receive a JSONRPC message as a notification, in case this method is called. - class HdmiCecSource : public PluginHost::IPlugin, public PluginHost::JSONRPC { - - private: - class Notification : public RPC::IRemoteConnection::INotification, - public Exchange::IHdmiCecSource::INotification - { - private: - Notification() = delete; - Notification(const Notification&) = delete; - Notification& operator=(const Notification&) = delete; - - public: - explicit Notification(HdmiCecSource* parent) - : _parent(*parent) - { - ASSERT(parent != nullptr); - } - - virtual ~Notification() - { - } - - BEGIN_INTERFACE_MAP(Notification) - INTERFACE_ENTRY(Exchange::IHdmiCecSource::INotification) - INTERFACE_ENTRY(RPC::IRemoteConnection::INotification) - END_INTERFACE_MAP - - void Activated(RPC::IRemoteConnection*) override - { - } - - void Deactivated(RPC::IRemoteConnection *connection) override - { - _parent.Deactivated(connection); - } - - void OnDeviceAdded(const int logicalAddress) override - { - LOGINFO("OnDeviceAdded"); - LOGINFO("logicalAddress: %d", logicalAddress); - Exchange::JHdmiCecSource::Event::OnDeviceAdded(_parent, logicalAddress); - } - void OnDeviceRemoved(const int logicalAddress) override - { - LOGINFO("OnDeviceRemoved"); - LOGINFO("logicalAddress: %d", logicalAddress); - Exchange::JHdmiCecSource::Event::OnDeviceRemoved(_parent, logicalAddress); - } - void OnDeviceInfoUpdated(const int logicalAddress) override - { - LOGINFO("OnDeviceInfoUpdated"); - LOGINFO("logicalAddress: %d", logicalAddress); - Exchange::JHdmiCecSource::Event::OnDeviceInfoUpdated(_parent, logicalAddress); - } - void OnActiveSourceStatusUpdated(const bool status) override - { - LOGINFO("OnActiveSourceStatusUpdated"); - LOGINFO("status: %d", status); - Exchange::JHdmiCecSource::Event::OnActiveSourceStatusUpdated(_parent, status); - } - void StandbyMessageReceived(const int logicalAddress) override - { - LOGINFO("StandbyMessageReceived"); - LOGINFO("logicalAddress: %d", logicalAddress); - Exchange::JHdmiCecSource::Event::StandbyMessageReceived(_parent, logicalAddress); - } - void OnKeyReleaseEvent(const int logicalAddress) override - { - LOGINFO("OnKeyReleaseEvent"); - LOGINFO("logicalAddress: %d", logicalAddress); - Exchange::JHdmiCecSource::Event::OnKeyReleaseEvent(_parent, logicalAddress); - } - void OnKeyPressEvent(const int logicalAddress, const int keyCode) override - { - LOGINFO("OnKeyPressEvent"); - LOGINFO("logicalAddress: %d, keyCode: %d", logicalAddress, keyCode); - Exchange::JHdmiCecSource::Event::OnKeyPressEvent(_parent, logicalAddress, keyCode); - } - - private: - HdmiCecSource &_parent; - - }; - - public: - // We do not allow this plugin to be copied !! - HdmiCecSource(const HdmiCecSource&) = delete; - HdmiCecSource& operator=(const HdmiCecSource&) = delete; - - HdmiCecSource() - : PluginHost::IPlugin() - , PluginHost::JSONRPC() - , _service(nullptr) - , _notification(this) - , _hdmiCecSource(nullptr) - , _connectionId(0) - { - - } - virtual ~HdmiCecSource() - { - - } - - BEGIN_INTERFACE_MAP(HdmiCecSource) - INTERFACE_ENTRY(PluginHost::IPlugin) - INTERFACE_ENTRY(PluginHost::IDispatcher) - INTERFACE_AGGREGATE(Exchange::IHdmiCecSource, _hdmiCecSource) - END_INTERFACE_MAP - - // IPlugin methods - // ------------------------------------------------------------------------------------------------------- - const string Initialize(PluginHost::IShell* service) override; - void Deinitialize(PluginHost::IShell* service) override; - string Information() const override; - //Begin methods - - private: - void Deactivated(RPC::IRemoteConnection* connection); - - private: - PluginHost::IShell* _service{}; - Core::Sink _notification; - Exchange::IHdmiCecSource* _hdmiCecSource; - uint32_t _connectionId; - }; - } // namespace Plugin -} // namespace WPEFramework - - - - diff --git a/HdmiCecSource/HdmiCecSourceImplementation.cpp b/HdmiCecSource/HdmiCecSourceImplementation.cpp deleted file mode 100644 index 4a4e3e64f..000000000 --- a/HdmiCecSource/HdmiCecSourceImplementation.cpp +++ /dev/null @@ -1,1641 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2025 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 "HdmiCecSourceImplementation.h" - - -#include "ccec/Connection.hpp" -#include "ccec/CECFrame.hpp" -#include "ccec/MessageEncoder.hpp" -#include "host.hpp" - -#include "dsMgr.h" -#include "dsDisplay.h" -#include "videoOutputPort.hpp" -#include "manager.hpp" -#include "websocket/URL.h" - -#include "UtilsIarm.h" -#include "UtilsJsonRpc.h" -#include "UtilssyncPersistFile.h" -#include "UtilsSearchRDKProfile.h" - -#define HDMICECSOURCE_METHOD_SET_ENABLED "SetEnabled" -#define HDMICECSOURCE_METHOD_GET_ENABLED "GetEnabled" -#define HDMICECSOURCE_METHOD_OTP_SET_ENABLED "SetOTPEnabled" -#define HDMICECSOURCE_METHOD_OTP_GET_ENABLED "GetOTPEnabled" -#define HDMICECSOURCE_METHOD_SET_OSD_NAME "SetOSDName" -#define HDMICECSOURCE_METHOD_GET_OSD_NAME "GetOSDName" -#define HDMICECSOURCE_METHOD_SET_VENDOR_ID "SetVendorId" -#define HDMICECSOURCE_METHOD_GET_VENDOR_ID "GetVendorId" -#define HDMICECSOURCE_METHOD_PERFORM_OTP_ACTION "PerformOTPAction" -#define HDMICECSOURCE_METHOD_SEND_STANDBY_MESSAGE "SendStandbyMessage" -#define HDMICECSOURCE_METHOD_GET_ACTIVE_SOURCE_STATUS "getActiveSourceStatus" -#define HDMICECSOURCE_METHOD_SEND_KEY_PRESS "SendKeyPressEvent" -#define HDMICEC_EVENT_ON_DEVICES_CHANGED "onDevicesChanged" -#define HDMICEC_EVENT_ON_HDMI_HOT_PLUG "onHdmiHotPlug" -#define HDMICEC_EVENT_ON_STANDBY_MSG_RECEIVED "standbyMessageReceived" -#define HDMICEC_EVENT_ON_KEYPRESS_MSG_RECEIVED "onKeyPressEvent" -#define HDMICEC_EVENT_ON_KEYRELEASE_MSG_RECEIVED "onKeyReleaseEvent" -#define DEV_TYPE_TUNER 1 -#define HDMI_HOT_PLUG_EVENT_CONNECTED 0 -#define ABORT_REASON_ID 4 - -#define API_VERSION_NUMBER_MAJOR 1 -#define API_VERSION_NUMBER_MINOR 0 -#define API_VERSION_NUMBER_PATCH 8 - -#define CEC_SETTING_ENABLED_FILE "/opt/persistent/ds/cecData_2.json" -#define CEC_SETTING_ENABLED "cecEnabled" -#define CEC_SETTING_OTP_ENABLED "cecOTPEnabled" -#define CEC_SETTING_OSD_NAME "cecOSDName" -#define CEC_SETTING_VENDOR_ID "cecVendorId" - -static std::vector defaultVendorId = {0x00,0x19,0xFB}; -static VendorID appVendorId = {defaultVendorId.at(0),defaultVendorId.at(1),defaultVendorId.at(2)}; -static VendorID lgVendorId = {0x00,0xE0,0x91}; -static PhysicalAddress physical_addr = {0x0F,0x0F,0x0F,0x0F}; -static LogicalAddress logicalAddress = 0xF; -static OSDName osdName = "TV Box"; -static int32_t powerState = 1; -static PowerStatus tvPowerState = 1; -static bool isDeviceActiveSource = false; -static bool isLGTvConnected = false; - -using namespace WPEFramework; - - -namespace WPEFramework -{ - namespace Plugin - { - SERVICE_REGISTRATION(HdmiCecSourceImplementation, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); - - HdmiCecSourceImplementation* HdmiCecSourceImplementation::_instance = nullptr; - static int libcecInitStatus = 0; - -//=========================================== HdmiCecSourceFrameListener ========================================= - void HdmiCecSourceFrameListener::notify(const CECFrame &in) const { - const uint8_t *buf = NULL; - char strBuffer[512] = {0}; - size_t len = 0; - - in.getBuffer(&buf, &len); - for (unsigned int i = 0; i < len; i++) { - snprintf(strBuffer + (i*3) , sizeof(strBuffer) - (i*3), "%02X ",(uint8_t) *(buf + i)); - } - LOGINFO(" >>>>> Received CEC Frame: :%s \n",strBuffer); - - MessageDecoder(processor).decode(in); - } - -//=========================================== HdmiCecSourceProcessor ========================================= - void HdmiCecSourceProcessor::process (const ActiveSource &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: ActiveSource %s : %s : %s \n",GetOpName(msg.opCode()),msg.physicalAddress.name().c_str(),msg.physicalAddress.toString().c_str()); - if(msg.physicalAddress.toString() == physical_addr.toString()) - isDeviceActiveSource = true; - else - isDeviceActiveSource = false; - LOGINFO("ActiveSource isDeviceActiveSource status :%d \n", isDeviceActiveSource); - HdmiCecSourceImplementation::_instance->sendActiveSourceEvent(); - HdmiCecSourceImplementation::_instance->addDevice(header.from.toInt()); - } - void HdmiCecSourceProcessor::process (const InActiveSource &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: InActiveSource %s : %s : %s \n",GetOpName(msg.opCode()),msg.physicalAddress.name().c_str(),msg.physicalAddress.toString().c_str()); - } - void HdmiCecSourceProcessor::process (const ImageViewOn &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: ImageViewOn \n"); - HdmiCecSourceImplementation::_instance->addDevice(header.from.toInt()); - } - void HdmiCecSourceProcessor::process (const TextViewOn &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: TextViewOn\n"); - HdmiCecSourceImplementation::_instance->addDevice(header.from.toInt()); - } - void HdmiCecSourceProcessor::process (const RequestActiveSource &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: RequestActiveSource\n"); - if(isDeviceActiveSource) - { - LOGINFO("sending ActiveSource\n"); - try - { - conn.sendTo(LogicalAddress::BROADCAST, MessageEncoder().encode(ActiveSource(physical_addr))); - } - catch(...) - { - LOGWARN("Exception while sending ActiveSource"); - } - } - } - void HdmiCecSourceProcessor::process (const Standby &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: Standby from %s\n", header.from.toString().c_str()); - HdmiCecSourceImplementation::_instance->SendStandbyMsgEvent(header.from.toInt()); - - } - void HdmiCecSourceProcessor::process (const GetCECVersion &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: GetCECVersion sending CECVersion response \n"); - try - { - conn.sendTo(header.from, MessageEncoder().encode(CECVersion(Version::V_1_4))); - } - catch(...) - { - LOGWARN("Exception while sending CECVersion "); - } - } - void HdmiCecSourceProcessor::process (const CECVersion &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: CECVersion Version : %s \n",msg.version.toString().c_str()); - HdmiCecSourceImplementation::_instance->addDevice(header.from.toInt()); - } - void HdmiCecSourceProcessor::process (const SetMenuLanguage &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: SetMenuLanguage Language : %s \n",msg.language.toString().c_str()); - } - void HdmiCecSourceProcessor::process (const GiveOSDName &msg, const Header &header) - { - printHeader(header); - if (!(header.from == LogicalAddress(LogicalAddress::UNREGISTERED))) - { - LOGINFO("Command: GiveOSDName sending SetOSDName : %s\n",osdName.toString().c_str()); - try - { - conn.sendTo(header.from, MessageEncoder().encode(SetOSDName(osdName))); - } - catch(...) - { - LOGWARN("Exception while sending SetOSDName"); - } - } - } - void HdmiCecSourceProcessor::process (const GivePhysicalAddress &msg, const Header &header) - { - LOGINFO("Command: GivePhysicalAddress\n"); - try - { - LOGINFO(" sending ReportPhysicalAddress response physical_addr :%s logicalAddress :%x \n",physical_addr.toString().c_str(), logicalAddress.toInt()); - conn.sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(ReportPhysicalAddress(physical_addr,logicalAddress.toInt()))); - } - catch(...) - { - LOGWARN("Exception while sending ReportPhysicalAddress "); - } - } - void HdmiCecSourceProcessor::process (const GiveDeviceVendorID &msg, const Header &header) - { - printHeader(header); - try - { - LOGINFO("Command: GiveDeviceVendorID sending VendorID response :%s\n",(isLGTvConnected)?lgVendorId.toString().c_str():appVendorId.toString().c_str()); - if(isLGTvConnected) - conn.sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(DeviceVendorID(lgVendorId))); - else - conn.sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(DeviceVendorID(appVendorId))); - } - catch(...) - { - LOGWARN("Exception while sending DeviceVendorID"); - } - - } - void HdmiCecSourceProcessor::process (const SetOSDString &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: SetOSDString OSDString : %s\n",msg.osdString.toString().c_str()); - } - void HdmiCecSourceProcessor::process (const SetOSDName &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: SetOSDName OSDName : %s\n",msg.osdName.toString().c_str()); - if (HdmiCecSourceImplementation::_instance) { - bool isOSDNameUpdated = HdmiCecSourceImplementation::_instance->deviceList[header.from.toInt()].update(msg.osdName); - if (isOSDNameUpdated) - HdmiCecSourceImplementation::_instance->sendDeviceUpdateInfo(header.from.toInt()); - } else { - LOGWARN("Exception HdmiCecSourceImplementation::_instance NULL"); - } - } - void HdmiCecSourceProcessor::process (const RoutingChange &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: RoutingChange From : %s To: %s \n",msg.from.toString().c_str(),msg.to.toString().c_str()); - if(msg.to.toString() == physical_addr.toString()) - isDeviceActiveSource = true; - else - isDeviceActiveSource = false; - LOGINFO("physical_addr : %s isDeviceActiveSource :%d \n",physical_addr.toString().c_str(),isDeviceActiveSource); - HdmiCecSourceImplementation::_instance->sendActiveSourceEvent(); - } - void HdmiCecSourceProcessor::process (const RoutingInformation &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: RoutingInformation Routing Information to Sink : %s\n",msg.toSink.toString().c_str()); - if(msg.toSink.toString() == physical_addr.toString()) - isDeviceActiveSource = true; - else - isDeviceActiveSource = false; - LOGINFO("physical_addr : %s isDeviceActiveSource :%d \n",physical_addr.toString().c_str(),isDeviceActiveSource); - HdmiCecSourceImplementation::_instance->sendActiveSourceEvent(); - } - void HdmiCecSourceProcessor::process (const SetStreamPath &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: SetStreamPath Set Stream Path to Sink : %s\n",msg.toSink.toString().c_str()); - if(msg.toSink.toString() == physical_addr.toString()) - isDeviceActiveSource = true; - else - isDeviceActiveSource = false; - LOGINFO("physical_addr : %s isDeviceActiveSource :%d \n",physical_addr.toString().c_str(),isDeviceActiveSource); - HdmiCecSourceImplementation::_instance->sendActiveSourceEvent(); - - } - void HdmiCecSourceProcessor::process (const GetMenuLanguage &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: GetMenuLanguage\n"); - } - void HdmiCecSourceProcessor::process (const ReportPhysicalAddress &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: ReportPhysicalAddress\n"); - HdmiCecSourceImplementation::_instance->addDevice(header.from.toInt()); - } - void HdmiCecSourceProcessor::process (const DeviceVendorID &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: DeviceVendorID VendorID : %s\n",msg.vendorId.toString().c_str()); - if (HdmiCecSourceImplementation::_instance){ - bool isVendorIdUpdated = HdmiCecSourceImplementation::_instance->deviceList[header.from.toInt()].update(msg.vendorId); - if (isVendorIdUpdated) - HdmiCecSourceImplementation::_instance->sendDeviceUpdateInfo(header.from.toInt()); - } - else { - LOGWARN("Exception HdmiCecSourceImplementation::_instance NULL"); - } - - } - void HdmiCecSourceProcessor::process (const GiveDevicePowerStatus &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: GiveDevicePowerStatus sending powerState :%d \n",powerState); - try - { - conn.sendTo(header.from, MessageEncoder().encode(ReportPowerStatus(PowerStatus(powerState)))); - } - catch(...) - { - LOGWARN("Exception while sending ReportPowerStatus"); - } - } - void HdmiCecSourceProcessor::process (const ReportPowerStatus &msg, const Header &header) - { - printHeader(header); - if ((header.from == LogicalAddress(LogicalAddress::TV))) - tvPowerState = msg.status; - LOGINFO("Command: ReportPowerStatus TV Power Status from:%s status : %s \n",header.from.toString().c_str(),msg.status.toString().c_str()); - HdmiCecSourceImplementation::_instance->addDevice(header.from.toInt()); - } - void HdmiCecSourceProcessor::process (const UserControlPressed &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: UserControlPressed message received from:%s command : %d \n",header.from.toString().c_str(),msg.uiCommand.toInt()); - HdmiCecSourceImplementation::_instance->SendKeyPressMsgEvent(header.from.toInt(),msg.uiCommand.toInt()); - } - void HdmiCecSourceProcessor::process (const UserControlReleased &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: UserControlReleased message received from:%s \n",header.from.toString().c_str()); - HdmiCecSourceImplementation::_instance->SendKeyReleaseMsgEvent(header.from.toInt()); - } - void HdmiCecSourceProcessor::process (const FeatureAbort &msg, const Header &header) - { - printHeader(header); - LOGINFO("Command: FeatureAbort\n"); - } - void HdmiCecSourceProcessor::process (const Abort &msg, const Header &header) - { - printHeader(header); - if (!(header.from == LogicalAddress(LogicalAddress::BROADCAST))) - { - LOGINFO("Command: Abort, sending FeatureAbort"); - try - { - conn.sendTo(header.from, MessageEncoder().encode(FeatureAbort(OpCode(msg.opCode()),AbortReason(ABORT_REASON_ID)))); - } - catch(...) - { - LOGWARN("Exception while sending FeatureAbort command"); - } - - } - LOGINFO("Command: Abort\n"); - } - void HdmiCecSourceProcessor::process (const Polling &msg, const Header &header) { - printHeader(header); - LOGINFO("Command: Polling\n"); - } - - -//=========================================== HdmiCecSourceImplementation ========================================= - - HdmiCecSourceImplementation::HdmiCecSourceImplementation() - : cecEnableStatus(false),smConnection(nullptr), m_sendKeyEventThreadRun(false) - , _pwrMgrNotification(*this) - , _registeredEventHandlers(false) - { - LOGWARN("ctor"); - HdmiCecSourceImplementation::_instance = this; - } - - HdmiCecSourceImplementation::~HdmiCecSourceImplementation() - { - LOGWARN("dtor"); - HdmiCecSourceImplementation::_instance = nullptr; - - if(_powerManagerPlugin) - { - _powerManagerPlugin->Unregister(_pwrMgrNotification.baseInterface()); - _powerManagerPlugin.Reset(); - } - _registeredEventHandlers = false; - - DeinitializeIARM(); - } - - Core::hresult HdmiCecSourceImplementation::Configure(PluginHost::IShell* service) - { - LOGINFO("Configure"); - ASSERT(service != nullptr); - PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; - PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; - Core::hresult res = Core::ERROR_GENERAL; - string msg; - if (Utils::IARM::init()) { - //Initialize cecEnableStatus to false in ctor - cecEnableStatus = false; - - logicalAddressDeviceType = "None"; - logicalAddress = 0xFF; - - //CEC plugin functionalities will only work if CECmgr is available. If plugin Initialize failure upper layer will call dtor directly. - InitializeIARM(); - InitializePowerManager(service); - - // load persistence setting - loadSettings(); - try - { - //TODO(MROLLINS) this is probably per process so we either need to be running in our own process or be carefull no other plugin is calling it - device::Manager::Initialize(); - std::string strVideoPort = device::Host::getInstance().getDefaultVideoPortName(); - device::VideoOutputPort vPort = device::Host::getInstance().getVideoOutputPort(strVideoPort.c_str()); - if (vPort.isDisplayConnected()) - { - std::vector edidVec; - vPort.getDisplay().getEDIDBytes(edidVec); - //Set LG vendor id if connected with LG TV - if(edidVec.at(8) == 0x1E && edidVec.at(9) == 0x6D) - { - isLGTvConnected = true; - } - LOGINFO("manufacturer byte from edid :%x: %x isLGTvConnected :%d",edidVec.at(8),edidVec.at(9),isLGTvConnected); - } - } - catch(...) - { - LOGWARN("Exception in getting edid info .\r\n"); - } - - // get power state: - ASSERT (_powerManagerPlugin); - if (_powerManagerPlugin){ - res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev); - if (Core::ERROR_NONE == res) - { - powerState = (pwrStateCur == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON)?0:1 ; - LOGINFO("Current state is PowerManagerPlugin: (%d) powerState :%d \n",pwrStateCur,powerState); - } - } - - if (cecSettingEnabled) - { - try - { - CECEnable(); - } - catch(...) - { - LOGWARN("Exception while enabling CEC settings .\r\n"); - } - } - } else { - msg = "IARM bus is not available"; - LOGERR("IARM bus is not available. Failed to activate HdmiCecSource Plugin"); - } - ASSERT(_powerManagerPlugin); - registerEventHandlers(); - return Core::ERROR_NONE; - } - - void HdmiCecSourceImplementation::registerEventHandlers() - { - ASSERT (_powerManagerPlugin); - - if(!_registeredEventHandlers && _powerManagerPlugin) { - _registeredEventHandlers = true; - _powerManagerPlugin->Register(_pwrMgrNotification.baseInterface()); - } - - - } - - Core::hresult HdmiCecSourceImplementation::Register(Exchange::IHdmiCecSource::INotification* notification) - { - - LOGINFO("Register"); - if(notification != nullptr){ - _adminLock.Lock(); - if(std::find(_hdmiCecSourceNotifications.begin(), _hdmiCecSourceNotifications.end(), notification) == _hdmiCecSourceNotifications.end()) - { - _hdmiCecSourceNotifications.push_back(notification); - notification->AddRef(); - } - else - { - LOGERR("Same notification is registered already"); - } - _adminLock.Unlock(); - } - - return Core::ERROR_NONE; - } - - - Core::hresult HdmiCecSourceImplementation::Unregister(Exchange::IHdmiCecSource::INotification* notification) - { - LOGINFO("Unregister"); - if(notification != nullptr){ - _adminLock.Lock(); - std::list::iterator index = std::find(_hdmiCecSourceNotifications.begin(), _hdmiCecSourceNotifications.end(), notification); - if(index != _hdmiCecSourceNotifications.end()) - { - (*index)->Release(); - _hdmiCecSourceNotifications.erase(index); - } - else - { - LOGERR("Notification is not registered"); - } - _adminLock.Unlock(); - } - - return Core::ERROR_NONE; - } - - void HdmiCecSourceImplementation::addDevice(const int logicalAddress) { - - if(!HdmiCecSourceImplementation::_instance) - return; - - if ( logicalAddress >= LogicalAddress::UNREGISTERED){ - LOGERR("Logical Address NOT Allocated Or its not valid"); - return; - } - - if ( !(BIT_CHECK(HdmiCecSourceImplementation::_instance->deviceList[logicalAddress].m_deviceInfoStatus, BIT_DEVICE_PRESENT)) ) - { - BIT_SET(HdmiCecSourceImplementation::_instance->deviceList[logicalAddress].m_deviceInfoStatus, BIT_DEVICE_PRESENT); - HdmiCecSourceImplementation::_instance->deviceList[logicalAddress].m_logicalAddress = LogicalAddress(logicalAddress); - HdmiCecSourceImplementation::_instance->m_numberOfDevices++; - LOGINFO("New cec ligical address add notification send: \r\n"); - std::list::const_iterator index(_hdmiCecSourceNotifications.begin()); - while (index != _hdmiCecSourceNotifications.end()) { - (*index)->OnDeviceAdded(logicalAddress); - index++; - } - } - //Two source devices can have same logical address. - requestCecDevDetails(logicalAddress); - } - - void HdmiCecSourceImplementation::removeDevice(const int logicalAddress) { - if(!HdmiCecSourceImplementation::_instance) - return; - - if ( logicalAddress >= LogicalAddress::UNREGISTERED ){ - LOGERR("Logical Address NOT Allocated Or its not valid"); - return; - } - - if (BIT_CHECK(HdmiCecSourceImplementation::_instance->deviceList[logicalAddress].m_deviceInfoStatus, BIT_DEVICE_PRESENT)) - { - _instance->m_numberOfDevices--; - _instance->deviceList[logicalAddress].clear(); - LOGINFO("Cec ligical address remove notification send: \r\n"); - std::list::const_iterator index(_hdmiCecSourceNotifications.begin()); - while (index != _hdmiCecSourceNotifications.end()) { - (*index)->OnDeviceRemoved(logicalAddress); - index++; - } - - } - } - - - Core::hresult HdmiCecSourceImplementation::GetActiveSourceStatus(bool &isActiveSource, bool &success) - { - isActiveSource = isDeviceActiveSource; - success = true; - return Core::ERROR_NONE; - } - - uint32_t HdmiCecSourceImplementation::sendKeyPressEvent(const int logicalAddress, int keyCode) - { - if(!(_instance->smConnection)) - { - return Core::ERROR_GENERAL; - } - LOGINFO(" SendKeyPressEvent logicalAddress 0x%x keycode 0x%x\n",logicalAddress,keyCode); - switch(keyCode) - { - case VOLUME_UP: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_VOLUME_UP)),100); - break; - case VOLUME_DOWN: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_VOLUME_DOWN)), 100); - break; - case MUTE: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_MUTE)), 100); - break; - case UP: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_UP)), 100); - break; - case DOWN: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_DOWN)), 100); - break; - case LEFT: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_LEFT)), 100); - break; - case RIGHT: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_RIGHT)), 100); - break; - case SELECT: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_SELECT)), 100); - break; - case HOME: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_HOME)), 100); - break; - case BACK: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_BACK)), 100); - break; - case NUMBER_0: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_0)), 100); - break; - case NUMBER_1: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_1)), 100); - break; - case NUMBER_2: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_2)), 100); - break; - case NUMBER_3: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_3)), 100); - break; - case NUMBER_4: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_4)), 100); - break; - case NUMBER_5: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_5)), 100); - break; - case NUMBER_6: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_6)), 100); - break; - case NUMBER_7: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_7)), 100); - break; - case NUMBER_8: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_8)), 100); - break; - case NUMBER_9: - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlPressed(UICommand::UI_COMMAND_NUM_9)), 100); - break; - - } - return Core::ERROR_NONE; - } - - Core::hresult HdmiCecSourceImplementation::SendKeyPressEvent(const uint32_t &logicalAddress,const uint32_t &keyCode, HdmiCecSourceSuccess &success) - { - SendKeyInfo keyInfo; - try { - keyInfo.logicalAddr = logicalAddress; - keyInfo.keyCode = keyCode; - } catch (const std::invalid_argument& e) { - std::cerr << "Invalid input: " << e.what() << std::endl; - success.success = false; - return Core::ERROR_GENERAL; - } - std::unique_lock lk(m_sendKeyEventMutex); - m_SendKeyQueue.push(keyInfo); - m_sendKeyEventThreadRun = true; - m_sendKeyCV.notify_one(); - LOGINFO("Post send key press event to queue size:%d \n",(int)m_SendKeyQueue.size()); - success.success = true; - return Core::ERROR_NONE; - } - - void HdmiCecSourceImplementation::sendKeyReleaseEvent(const int logicalAddress) - { - LOGINFO(" sendKeyReleaseEvent logicalAddress 0x%x \n",logicalAddress); - if(!(_instance->smConnection)) - { - return; - } - _instance->smConnection->sendTo(LogicalAddress(logicalAddress), MessageEncoder().encode(UserControlReleased()), 100); - - } - - Core::hresult HdmiCecSourceImplementation::SendStandbyMessage(HdmiCecSourceSuccess &success) - { - bool ret = false; - - if(true == cecEnableStatus) - { - if (smConnection){ - try - { - smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(Standby())); - ret = true; - } - catch(...) - { - LOGWARN("Exception while sending CEC StandBy Message"); - } - } - else { - LOGWARN("smConnection is NULL"); - } - } - else - LOGWARN("cecEnableStatus=false"); - - if(ret) - { - success.success = true; - return Core::ERROR_NONE; - } - else{ - success.success = false; - return Core::ERROR_GENERAL; - } - } - - void HdmiCecSourceImplementation::InitializePowerManager(PluginHost::IShell *service) - { - LOGINFO("Connect the COM-RPC socket\n"); - _powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager")) - .withIShell(service) - .withRetryIntervalMS(200) - .withRetryCount(25) - .createInterface(); - registerEventHandlers(); - } - - const void HdmiCecSourceImplementation::InitializeIARM() - { - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG, dsHdmiEventHandler) ); - } - - void HdmiCecSourceImplementation::DeinitializeIARM() - { - if (Utils::IARM::isConnected()) - { - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG,dsHdmiEventHandler) ); - } - } - void HdmiCecSourceImplementation::threadHotPlugEventHandler(int data) - { - LOGINFO("entry threadHotPlugEventHandler \r\n"); - if(!HdmiCecSourceImplementation::_instance) - return; - - LOGINFO("Pocessing IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG event status:%d \r\n",data); - HdmiCecSourceImplementation::_instance->onHdmiHotPlug(data); - //Trigger CEC device poll here - pthread_cond_signal(&(_instance->m_condSig)); - - LOGINFO("Exit threadHotPlugEventHandler \r\n"); - } - - void HdmiCecSourceImplementation::dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiCecSourceImplementation::_instance || !_instance->cecEnableStatus) - { - LOGINFO("Return from dsHdmiEventHandler due HdmiCecSourceImplementation::_instance:%p cecEnableStatus:%d \r\n", HdmiCecSourceImplementation::_instance, _instance->cecEnableStatus); - return; - } - - if (owner && !strcmp(owner, IARM_BUS_DSMGR_NAME) && (IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG == eventId)) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - if(eventData) - { - int hdmi_hotplug_event = eventData->data.hdmi_hpd.event; - LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG event data:%d \r\n", hdmi_hotplug_event); - std::thread worker(threadHotPlugEventHandler,hdmi_hotplug_event); - worker.detach(); - } - } - } - - void HdmiCecSourceImplementation::onPowerModeChanged(const PowerState currentState, const PowerState newState) - { - if(!HdmiCecSourceImplementation::_instance) - return; - - LOGINFO("Event IARM_BUS_PWRMGR_EVENT_MODECHANGED: State Changed %d -- > %d\r", - currentState, newState); - if (WPEFramework::Exchange::IPowerManager::POWER_STATE_ON == newState) - { - powerState = 0; - HdmiCecSourceImplementation::_instance->getLogicalAddress(); // get the updated LA after wakeup - } - else - powerState = 1; - } - - void HdmiCecSourceImplementation::onHdmiHotPlug(int connectStatus) - { - if (HDMI_HOT_PLUG_EVENT_CONNECTED == connectStatus) - { - LOGINFO ("onHdmiHotPlug Status : %d ", connectStatus); - getPhysicalAddress(); - getLogicalAddress(); - try - { - std::string strVideoPort = device::Host::getInstance().getDefaultVideoPortName(); - device::VideoOutputPort vPort = device::Host::getInstance().getVideoOutputPort(strVideoPort.c_str()); - if (vPort.isDisplayConnected()) - { - std::vector edidVec; - vPort.getDisplay().getEDIDBytes(edidVec); - //Set LG vendor id if connected with LG TV - if(edidVec.at(8) == 0x1E && edidVec.at(9) == 0x6D) - { - isLGTvConnected = true; - } - LOGINFO("manufacturer byte from edid :%x: %x isLGTvConnected :%d",edidVec.at(8),edidVec.at(9),isLGTvConnected); - } - } - catch(...) - { - LOGWARN("Exception in getting edid info .\r\n"); - } - if(smConnection) - { - try - { - LOGINFO(" sending ReportPhysicalAddress response physical_addr :%s logicalAddress :%x \n",physical_addr.toString().c_str(), logicalAddress.toInt()); - smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(ReportPhysicalAddress(physical_addr,logicalAddress.toInt()))); - - LOGINFO("Command: GiveDeviceVendorID sending VendorID response :%s\n", \ - (isLGTvConnected)?lgVendorId.toString().c_str():appVendorId.toString().c_str()); - if(isLGTvConnected) - smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(DeviceVendorID(lgVendorId))); - else - smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(DeviceVendorID(appVendorId))); - } - catch(...) - { - LOGWARN("Exception while sending Messages onHdmiHotPlug\n"); - } - } - } - return; - } - - bool HdmiCecSourceImplementation::loadSettings() - { - Core::File file; - file = CEC_SETTING_ENABLED_FILE; - - if( file.Open()) - { - JsonObject parameters; - parameters.IElement::FromFile(file); - bool isConfigAdded = false; - - if( parameters.HasLabel(CEC_SETTING_ENABLED)) - { - getBoolParameter(CEC_SETTING_ENABLED, cecSettingEnabled); - LOGINFO("CEC_SETTING_ENABLED present value:%d",cecSettingEnabled); - } - else - { - parameters[CEC_SETTING_ENABLED] = true; - cecSettingEnabled = true; - isConfigAdded = true; - LOGINFO("CEC_SETTING_ENABLED not present set dafult true:\n "); - } - - if( parameters.HasLabel(CEC_SETTING_OTP_ENABLED)) - { - getBoolParameter(CEC_SETTING_OTP_ENABLED, cecOTPSettingEnabled); - LOGINFO("CEC_SETTING_OTP_ENABLED present value :%d",cecOTPSettingEnabled); - } - else - { - parameters[CEC_SETTING_OTP_ENABLED] = true; - cecOTPSettingEnabled = true; - isConfigAdded = true; - LOGINFO("CEC_SETTING_OTP_ENABLED not present set dafult true:\n "); - } - if( parameters.HasLabel(CEC_SETTING_OSD_NAME)) - { - std::string osd_name; - getStringParameter(CEC_SETTING_OSD_NAME, osd_name); - osdName = osd_name.c_str(); - LOGINFO("CEC_SETTING_OTP_ENABLED present osd_name :%s",osdName.toString().c_str()); - } - else - { - parameters[CEC_SETTING_OSD_NAME] = osdName.toString(); - LOGINFO("CEC_SETTING_OSD_NMAE not present set dafult value :%s\n ",osdName.toString().c_str()); - isConfigAdded = true; - } - unsigned int vendorId = (defaultVendorId.at(0) <<16) | ( defaultVendorId.at(1) << 8 ) | defaultVendorId.at(2); - if( parameters.HasLabel(CEC_SETTING_VENDOR_ID)) - { - getNumberParameter(CEC_SETTING_VENDOR_ID, vendorId); - LOGINFO("CEC_SETTING_VENDOR_ID present :%x ",vendorId); - } - else - { - LOGINFO("CEC_SETTING_VENDOR_ID not present set dafult value :%x \n ",vendorId); - parameters[CEC_SETTING_VENDOR_ID] = vendorId; - isConfigAdded = true; - } - - appVendorId = {(uint8_t)(vendorId >> 16 & 0xff),(uint8_t)(vendorId >> 8 & 0xff),(uint8_t) (vendorId & 0xff)}; - LOGINFO("appVendorId : %s vendorId :%x \n",appVendorId.toString().c_str(), vendorId ); - - if(isConfigAdded) - { - LOGINFO("isConfigAdded true so update file:\n "); - file.Destroy(); - file.Create(); - parameters.IElement::ToFile(file); - - } - - file.Close(); - } - else - { - LOGINFO("CEC_SETTING_ENABLED_FILE file not present create with default settings "); - file.Open(false); - if (!file.IsOpen()) - file.Create(); - - JsonObject parameters; - unsigned int vendorId = (defaultVendorId.at(0) <<16) | ( defaultVendorId.at(1) << 8 ) | defaultVendorId.at(2); - parameters[CEC_SETTING_ENABLED] = true; - parameters[CEC_SETTING_OTP_ENABLED] = true; - parameters[CEC_SETTING_OSD_NAME] = osdName.toString(); - parameters[CEC_SETTING_VENDOR_ID] = vendorId; - - cecSettingEnabled = true; - cecOTPSettingEnabled = true; - parameters.IElement::ToFile(file); - - file.Close(); - - } - - return cecSettingEnabled; - } - - Core::hresult HdmiCecSourceImplementation::SetEnabled(const bool &enabled, HdmiCecSourceSuccess &success) - { - LOGINFO("Entered SetEnabled "); - - if (cecSettingEnabled != enabled) - { - Utils::persistJsonSettings (CEC_SETTING_ENABLED_FILE, CEC_SETTING_ENABLED, JsonValue(enabled)); - cecSettingEnabled = enabled; - } - if(true == enabled) - { - CECEnable(); - } - else - { - CECDisable(); - } - success.success = true; - return Core::ERROR_NONE; - } - - Core::hresult HdmiCecSourceImplementation::SetOTPEnabled(const bool &enabled, HdmiCecSourceSuccess &success) - { - if (cecOTPSettingEnabled != enabled) - { - LOGINFO("persist SetOTPEnabled "); - Utils::persistJsonSettings (CEC_SETTING_ENABLED_FILE, CEC_SETTING_OTP_ENABLED, JsonValue(enabled)); - cecOTPSettingEnabled = enabled; - } - success.success = true; - return Core::ERROR_NONE; - } - - void HdmiCecSourceImplementation::CECEnable(void) - { - LOGINFO("Entered CECEnable"); - - if (cecEnableStatus) - { - LOGWARN("CEC Already Enabled"); - return; - } - - if(0 == libcecInitStatus) - { - try - { - LibCCEC::getInstance().init("HdmiCecSource"); - } - catch (const std::exception& e) - { - LOGWARN("CEC exception caught from LibCCEC::getInstance().init()"); - } - } - libcecInitStatus++; - - m_sendKeyEventThreadExit = false; - try { - if (m_sendKeyEventThread.get().joinable()) { - m_sendKeyEventThread.get().join(); - } - m_sendKeyEventThread = Utils::ThreadRAII(std::thread(threadSendKeyEvent)); - } catch(const std::system_error& e) { - LOGERR("exception in creating threadSendKeyEvent %s", e.what()); - } - - - //Acquire CEC Addresses - getPhysicalAddress(); - getLogicalAddress(); - - smConnection = new Connection(logicalAddress.toInt(),false,"ServiceManager::Connection::"); - smConnection->open(); - msgProcessor = new HdmiCecSourceProcessor(*smConnection); - msgFrameListener = new HdmiCecSourceFrameListener(*msgProcessor); - smConnection->addFrameListener(msgFrameListener); - - cecEnableStatus = true; - - if(smConnection) - { - LOGINFO("Command: sending GiveDevicePowerStatus \r\n"); - smConnection->sendTo(LogicalAddress::TV, MessageEncoder().encode(GiveDevicePowerStatus())); - LOGINFO("Command: sending request active Source isDeviceActiveSource is set to false\r\n"); - smConnection->sendTo(LogicalAddress::BROADCAST, MessageEncoder().encode(RequestActiveSource())); - isDeviceActiveSource = false; - LOGINFO("Command: GiveDeviceVendorID sending VendorID response :%s\n", \ - (isLGTvConnected)?lgVendorId.toString().c_str():appVendorId.toString().c_str()); - if(isLGTvConnected) - smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(DeviceVendorID(lgVendorId))); - else - smConnection->sendTo(LogicalAddress(LogicalAddress::BROADCAST), MessageEncoder().encode(DeviceVendorID(appVendorId))); - - LOGWARN("Start Update thread %p", smConnection ); - m_updateThreadExit = false; - _instance->m_lockUpdate = PTHREAD_MUTEX_INITIALIZER; - _instance->m_condSigUpdate = PTHREAD_COND_INITIALIZER; - try { - if (m_UpdateThread.get().joinable()) { - m_UpdateThread.get().join(); - } - m_UpdateThread = Utils::ThreadRAII(std::thread(threadUpdateCheck)); - } catch(const std::system_error& e) { - LOGERR("exception in creating threadUpdateCheck %s", e.what()); - } - - LOGWARN("Start Thread %p", smConnection ); - m_pollThreadExit = false; - _instance->m_numberOfDevices = 0; - _instance->m_lock = PTHREAD_MUTEX_INITIALIZER; - _instance->m_condSig = PTHREAD_COND_INITIALIZER; - try { - if (m_pollThread.get().joinable()) { - m_pollThread.get().join(); - } - m_pollThread = Utils::ThreadRAII(std::thread(threadRun)); - } catch(const std::system_error& e) { - LOGERR("exception in creating threadRun %s", e.what()); - } - - } - return; - } - - void HdmiCecSourceImplementation::CECDisable(void) - { - LOGINFO("Entered CECDisable "); - - if(!cecEnableStatus) - { - LOGWARN("CEC Already Disabled "); - return; - } - - { - m_sendKeyEventThreadExit = true; - std::unique_lock lk(m_sendKeyEventMutex); - m_sendKeyEventThreadRun = true; - m_sendKeyCV.notify_one(); - } - try - { - if (m_sendKeyEventThread.get().joinable()) - m_sendKeyEventThread.get().join(); - } - catch(const std::system_error& e) - { - LOGERR("system_error exception in thread join %s", e.what()); - } - catch(const std::exception& e) - { - LOGERR("exception in thread join %s", e.what()); - } - - if (smConnection != NULL) - { - LOGWARN("Stop Thread %p", smConnection ); - - m_updateThreadExit = true; - //Trigger codition to exit poll loop - pthread_mutex_lock(&(_instance->m_lockUpdate)); //Join mutex lock to wait until thread is in its wait condition - pthread_cond_signal(&(_instance->m_condSigUpdate)); - pthread_mutex_unlock(&(_instance->m_lockUpdate)); - if (m_UpdateThread.get().joinable()) {//Join thread to make sure it's deleted before moving on. - m_UpdateThread.get().join(); - } - LOGWARN("Deleted update Thread %p", smConnection ); - - m_pollThreadExit = true; - //Trigger codition to exit poll loop - pthread_mutex_lock(&(_instance->m_lock)); //Join mutex lock to wait until thread is in its wait condition - pthread_cond_signal(&(_instance->m_condSig)); - pthread_mutex_unlock(&(_instance->m_lock)); - if (m_pollThread.get().joinable()) {//Join thread to make sure it's deleted before moving on. - m_pollThread.get().join(); - } - LOGWARN("Deleted Thread %p", smConnection ); - //Clear cec device cache. - removeAllCecDevices(); - - smConnection->close(); - delete smConnection; - delete msgProcessor; - delete msgFrameListener; - msgProcessor = NULL; - msgFrameListener = NULL; - smConnection = NULL; - } - cecEnableStatus = false; - - if(1 == libcecInitStatus) - { - try - { - LibCCEC::getInstance().term(); - } - catch (const std::exception& e) - { - LOGWARN("CEC exception caught from LibCCEC::getInstance().term() "); - } - } - - libcecInitStatus--; - - return; - } - - - void HdmiCecSourceImplementation::getPhysicalAddress() - { - LOGINFO("Entered getPhysicalAddress "); - - uint32_t physAddress = 0x0F0F0F0F; - try { - LibCCEC::getInstance().getPhysicalAddress(&physAddress); - physical_addr = {(uint8_t)((physAddress >> 24) & 0xFF),(uint8_t)((physAddress >> 16) & 0xFF),(uint8_t) ((physAddress >> 8) & 0xFF),(uint8_t)((physAddress) & 0xFF)}; - LOGINFO("getPhysicalAddress: physicalAddress: %s ", physical_addr.toString().c_str()); - } - catch (const std::exception& e) - { - LOGWARN("exception caught from getPhysicalAddress"); - } - return; - } - - void HdmiCecSourceImplementation::getLogicalAddress() - { - LOGINFO("Entered getLogicalAddress "); - - try{ - LogicalAddress addr = LibCCEC::getInstance().getLogicalAddress(DEV_TYPE_TUNER); - - std::string logicalAddrDeviceType = DeviceType(LogicalAddress(addr).getType()).toString().c_str(); - - LOGINFO("logical address obtained is %d , saved logical address is %d ", addr.toInt(), logicalAddress.toInt()); - - if (logicalAddress.toInt() != addr.toInt() || logicalAddressDeviceType != logicalAddrDeviceType) - { - logicalAddress = addr; - logicalAddressDeviceType = logicalAddrDeviceType; - if(smConnection) - smConnection->setSource(logicalAddress); //update initiator LA - } - } - catch (const std::exception& e) - { - LOGWARN("CEC exception caught from getLogicalAddress "); - } - return; - } - - Core::hresult HdmiCecSourceImplementation::GetEnabled(bool &enabled, bool &success) - { - LOGINFO("GetEnabled :%d ",cecEnableStatus); - enabled = cecEnableStatus; - success = true; - return Core::ERROR_NONE; - } - - Core::hresult HdmiCecSourceImplementation::GetOTPEnabled(bool &enabled, bool &success) - { - enabled = cecOTPSettingEnabled; - LOGINFO("GetOTPEnabled :%d ",cecOTPSettingEnabled); - success = true; - return Core::ERROR_NONE; - } - - Core::hresult HdmiCecSourceImplementation::GetOSDName(std::string &name, bool &success) - { - name = osdName.toString(); - LOGINFO("GetOSDName :%s ",name.c_str()); - success = true; - return Core::ERROR_NONE; - } - - Core::hresult HdmiCecSourceImplementation::SetOSDName(const std::string &name, HdmiCecSourceSuccess &success) - { - LOGINFO("SetOSDName :%s ",name.c_str()); - osdName = name.c_str(); - Utils::persistJsonSettings (CEC_SETTING_ENABLED_FILE, CEC_SETTING_OSD_NAME, JsonValue(name.c_str())); - success.success = true; - return Core::ERROR_NONE; - } - - Core::hresult HdmiCecSourceImplementation::GetVendorId(std::string &vendorid, bool &success) - { - vendorid = appVendorId.toString(); - LOGINFO("GetVendorId :%s ",vendorid.c_str()); - success = true; - return Core::ERROR_NONE; - } - - Core::hresult HdmiCecSourceImplementation::SetVendorId(const string &vendorid, HdmiCecSourceSuccess &success) - { - LOGINFO("SetVendorId :%s ",vendorid.c_str()); - unsigned int vendorIdInt = 0; - try - { - vendorIdInt = stoi(vendorid,NULL,16); - } - catch (...) - { - LOGWARN("Exception in setVendorIdWrapper set default value\n"); - vendorIdInt = 0x0019FB; - } - appVendorId = {(uint8_t)(vendorIdInt >> 16 & 0xff),(uint8_t)(vendorIdInt >> 8 & 0xff),(uint8_t) (vendorIdInt & 0xff)}; - Utils::persistJsonSettings (CEC_SETTING_ENABLED_FILE, CEC_SETTING_VENDOR_ID, JsonValue(vendorIdInt)); - LOGINFO("SetVendorId :%s ",appVendorId.toString().c_str()); - success.success = true; - return Core::ERROR_NONE; - } - - Core::hresult HdmiCecSourceImplementation::PerformOTPAction(HdmiCecSourceSuccess &success) - { - LOGINFO("PerformOTPAction "); - bool ret = false; - - if((true == cecEnableStatus) && (cecOTPSettingEnabled == true)) - { - if (smConnection) { - try - { - LOGINFO("Command: sending ImageViewOn TV \r\n"); - smConnection->sendTo(LogicalAddress::TV, MessageEncoder().encode(ImageViewOn())); - usleep(10000); - LOGINFO("Command: sending ActiveSource physical_addr :%s \r\n",physical_addr.toString().c_str()); - smConnection->sendTo(LogicalAddress::BROADCAST, MessageEncoder().encode(ActiveSource(physical_addr))); - usleep(10000); - isDeviceActiveSource = true; - LOGINFO("Command: sending GiveDevicePowerStatus \r\n"); - smConnection->sendTo(LogicalAddress::TV, MessageEncoder().encode(GiveDevicePowerStatus())); - ret = true; - } - catch(...) - { - LOGWARN("Exception while processing PerformOTPAction"); - } - } - else { - LOGWARN("smConnection is NULL"); - } - } - else - LOGWARN("cecEnableStatus=false"); - - if (ret){ - success.success = true; - return Core::ERROR_NONE; - } else { - success.success = false; - return Core::ERROR_GENERAL; - } - } - - Core::hresult HdmiCecSourceImplementation::GetDeviceList(uint32_t &numberofdevices, IHdmiCecSourceDeviceListIterator*& deviceList, bool &success) - { //sample servicemanager response: - std::vector localDevices; - Exchange::IHdmiCecSource::HdmiCecSourceDevices actual_hdmicecdevices = {0}; - - //Trigger CEC device poll here - pthread_cond_signal(&(_instance->m_condSig)); - - success = true; - LOGINFO("getDeviceListWrapper m_numberOfDevices :%d \n", HdmiCecSourceImplementation::_instance->m_numberOfDevices); - numberofdevices = HdmiCecSourceImplementation::_instance->m_numberOfDevices; - try - { - int i = 0; - for(i=0; i< LogicalAddress::UNREGISTERED; i++ ) { - if (BIT_CHECK(HdmiCecSourceImplementation::_instance->deviceList[i].m_deviceInfoStatus, BIT_DEVICE_PRESENT)) { - actual_hdmicecdevices.logicalAddress = HdmiCecSourceImplementation::_instance->deviceList[i].m_logicalAddress.toInt(); - actual_hdmicecdevices.osdName = HdmiCecSourceImplementation::_instance->deviceList[i].m_osdName.toString(); - actual_hdmicecdevices.vendorID = HdmiCecSourceImplementation::_instance->deviceList[i].m_vendorID.toString(); - localDevices.push_back(actual_hdmicecdevices); - } - } - } - catch (...) - { - LOGERR("Exception in api"); - success = false; - } - deviceList = (Core::Service>::Create(localDevices)); - return Core::ERROR_NONE; - } - - bool HdmiCecSourceImplementation::pingDeviceUpdateList (int idev) - { - bool isConnected = false; - //self ping is not required - if (idev == logicalAddress.toInt()){ - return isConnected; - } - if(!HdmiCecSourceImplementation::_instance) - { - LOGERR("HdmiCecSourceImplementation::_instance not existing"); - return isConnected; - } - if ( !(_instance->smConnection) || logicalAddress.toInt() == LogicalAddress::UNREGISTERED || (false==cecEnableStatus)){ - LOGERR("Exiting from pingDeviceUpdateList _instance->smConnection:%p, logicalAddress:%d, cecEnableStatus=%d", - _instance->smConnection, logicalAddress.toInt(), cecEnableStatus); - return isConnected; - } - - LOGWARN("PING for 0x%x \r\n",idev); - try { - _instance->smConnection->ping(logicalAddress, LogicalAddress(idev), Throw_e()); - } - catch(CECNoAckException &e) - { - if (BIT_CHECK(_instance->deviceList[idev].m_deviceInfoStatus, BIT_DEVICE_PRESENT)) { - LOGINFO("Device disconnected: %d \r\n",idev); - removeDevice (idev); - } else { - LOGINFO("Device is not connected: %d. Ping caught %s\r\n",idev, e.what()); - } - isConnected = false; - return isConnected;; - } - catch(IOException &e) - { - LOGINFO("Device is not reachable: %d. Ping caught %s\r\n",idev, e.what()); - isConnected = false; - return isConnected;; - } - catch(Exception &e) - { - LOGINFO("Ping caught %s \r\n",e.what()); - } - - /* If we get ACK, then the device is present in the network*/ - isConnected = true; - if ( !(BIT_CHECK(_instance->deviceList[idev].m_deviceInfoStatus, BIT_DEVICE_PRESENT)) ) - { - LOGINFO("Device connected: %d \r\n",idev); - addDevice (idev); - } - return isConnected; - } - - void HdmiCecSourceImplementation::removeAllCecDevices() { - int i = 0; - for(i=0; i< LogicalAddress::UNREGISTERED; i++ ) { - removeDevice (i); - } - } - - void HdmiCecSourceImplementation::sendUnencryptMsg(unsigned char* msg, int size) - { - LOGINFO("sendMessage "); - - if(true == cecEnableStatus) - { - std::vector buf; - buf.resize(size); - - int itr = 0; - for (itr= 0; itrsendAsync(frame); - } - else - LOGWARN("cecEnableStatus=false"); - return; - } - - void HdmiCecSourceImplementation::requestVendorID(const int newDevlogicalAddress) - { - //Get OSD name and vendor ID only from connected devices. Since devices are identified using polling - //Once OSD name and Vendor ID is updated. We have to poll again in next iteration also. Just to check - //a new device is reconnected with same logical address - unsigned char msg [2]; - unsigned int logicalAddr = logicalAddress.toInt(); - unsigned char sender = (unsigned char)(logicalAddr & 0x0f); - unsigned char receiver = (unsigned char) (newDevlogicalAddress & 0x0f); - - msg [0] = (sender<<4)|receiver; - //Request vendor id - msg [1] = 0x8c; - LOGINFO("Sending msg request vendor id %x %x", msg [0], msg [1]); - _instance->sendUnencryptMsg (msg, sizeof(msg)); - - } - - void HdmiCecSourceImplementation::requestOsdName(const int newDevlogicalAddress) - { - //Get OSD name and vendor ID only from connected devices. Since devices are identified using polling - //Once OSD name and Vendor ID is updated. We have to poll again in next iteration also. Just to check - //a new device is reconnected with same logical address - unsigned char msg [2]; - unsigned int logicalAddr = logicalAddress.toInt(); - unsigned char sender = (unsigned char)(logicalAddr & 0x0f); - unsigned char receiver = (unsigned char) (newDevlogicalAddress & 0x0f); - - msg [0] = (sender<<4)|receiver; - //Request OSD name - msg [1] = 0x46; - LOGINFO("Sending msg request osd name %x %x", msg [0], msg [1]); - _instance->sendUnencryptMsg (msg, sizeof(msg)); - - } - - void HdmiCecSourceImplementation::requestCecDevDetails(const int newDevlogicalAddress) - { - //Get OSD name and vendor ID only from connected devices. Since devices are identified using polling - //Once OSD name and Vendor ID is updated. We have to poll again in next iteration also. Just to check - //a new device is reconnected with same logical address - requestVendorID (newDevlogicalAddress); - requestOsdName (newDevlogicalAddress); - } - - void HdmiCecSourceImplementation::threadRun() - { - if(!HdmiCecSourceImplementation::_instance) - return; - if(!(_instance->smConnection)) - return; - LOGINFO("Entering ThreadRun: _instance->m_pollThreadExit %d",_instance->m_pollThreadExit); - int i = 0; - pthread_mutex_lock(&(_instance->m_lock));//pthread_cond_wait should be mutex protected. //pthread_cond_wait will unlock the mutex and perfoms wait for the condition. - while (!_instance->m_pollThreadExit) { - bool isActivateUpdateThread = false; - LOGINFO("Starting cec device polling"); - for(i=0; i< LogicalAddress::UNREGISTERED; i++ ) { - bool isConnected = _instance->pingDeviceUpdateList(i); - if (isConnected){ - isActivateUpdateThread = isConnected; - } - - } - if (isActivateUpdateThread){ - //i any of devices is connected activate thread update check - pthread_cond_signal(&(_instance->m_condSigUpdate)); - } - //Wait for mutex signal here to continue the worker thread again. - pthread_cond_wait(&(_instance->m_condSig), &(_instance->m_lock)); - - } - pthread_mutex_unlock(&(_instance->m_lock)); - LOGINFO("%s: Thread exited", __FUNCTION__); - } - void HdmiCecSourceImplementation::threadSendKeyEvent() - { - if(!HdmiCecSourceImplementation::_instance) - return; - - SendKeyInfo keyInfo = {-1,-1}; - - while(!_instance->m_sendKeyEventThreadExit) - { - keyInfo.logicalAddr = -1; - keyInfo.keyCode = -1; - { - // Wait for a message to be added to the queue - std::unique_lock lk(_instance->m_sendKeyEventMutex); - _instance->m_sendKeyCV.wait(lk, []{return (_instance->m_sendKeyEventThreadRun == true);}); - } - - if (_instance->m_sendKeyEventThreadExit == true) - { - LOGINFO(" threadSendKeyEvent Exiting"); - _instance->m_sendKeyEventThreadRun = false; - break; - } - - if (_instance->m_SendKeyQueue.empty()) { - _instance->m_sendKeyEventThreadRun = false; - continue; - } - - keyInfo = _instance->m_SendKeyQueue.front(); - _instance->m_SendKeyQueue.pop(); - - LOGINFO("sendRemoteKeyThread : logical addr:0x%x keyCode: 0x%x queue size :%d \n",keyInfo.logicalAddr,keyInfo.keyCode,(int)_instance->m_SendKeyQueue.size()); - _instance->sendKeyPressEvent(keyInfo.logicalAddr,keyInfo.keyCode); - _instance->sendKeyReleaseEvent(keyInfo.logicalAddr); - } - LOGINFO("%s: Thread exited", __FUNCTION__); - } - void HdmiCecSourceImplementation::threadUpdateCheck() - { - if(!HdmiCecSourceImplementation::_instance) - return; - if(!(_instance->smConnection)) - return; - LOGINFO("Entering ThreadUpdate: _instance->m_updateThreadExit %d",_instance->m_updateThreadExit); - int i = 0; - pthread_mutex_lock(&(_instance->m_lockUpdate));//pthread_cond_wait should be mutex protected. //pthread_cond_wait will unlock the mutex and perfoms wait for the condition. - while (!_instance->m_updateThreadExit) { - //Wait for mutex signal here to continue the worker thread again. - pthread_cond_wait(&(_instance->m_condSigUpdate), &(_instance->m_lockUpdate)); - - LOGINFO("Starting cec device update check"); - for(i=0; ((i< LogicalAddress::UNREGISTERED)&&(!_instance->m_updateThreadExit)); i++ ) { - //If details are not updated. update now. - if (BIT_CHECK(HdmiCecSourceImplementation::_instance->deviceList[i].m_deviceInfoStatus, BIT_DEVICE_PRESENT)) - { - int itr = 0; - bool retry = true; - int iCounter = 0; - for (itr = 0; ((itr<5)&&(retry)); itr++){ - - if (!HdmiCecSourceImplementation::_instance->deviceList[i].m_isOSDNameUpdated){ - iCounter = 0; - while ((!_instance->m_updateThreadExit) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; - } - - HdmiCecSourceImplementation::_instance->requestOsdName (i); - retry = true; - } - else { - retry = false; - } - - if (!HdmiCecSourceImplementation::_instance->deviceList[i].m_isVendorIDUpdated){ - iCounter = 0; - while ((!_instance->m_updateThreadExit) && (iCounter < (2*10))) { //sleep for 1sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; - } - - HdmiCecSourceImplementation::_instance->requestVendorID (i); - retry = true; - } - } - if (retry){ - LOGINFO("cec device: %d update time out", i); - } - } - } - - } - pthread_mutex_unlock(&(_instance->m_lockUpdate)); - LOGINFO("%s: Thread exited", __FUNCTION__); - } - - - void HdmiCecSourceImplementation::sendDeviceUpdateInfo(const int logicalAddress) - { - LOGINFO("Device info updated notification send: for logical address:%d\r\n", logicalAddress); - std::list::const_iterator index(_hdmiCecSourceNotifications.begin()); - while (index != _hdmiCecSourceNotifications.end()) { - (*index)->OnDeviceInfoUpdated(logicalAddress); - index++; - } - } - - void HdmiCecSourceImplementation::sendActiveSourceEvent() - { - LOGWARN(" sendActiveSourceEvent isDeviceActiveSource: %d ",isDeviceActiveSource); - std::list::const_iterator index(_hdmiCecSourceNotifications.begin()); - while (index != _hdmiCecSourceNotifications.end()) { - (*index)->OnActiveSourceStatusUpdated(isDeviceActiveSource); - index++; - } - } - - void HdmiCecSourceImplementation::SendStandbyMsgEvent(const int logicalAddress) - { - std::list::const_iterator index(_hdmiCecSourceNotifications.begin()); - while (index != _hdmiCecSourceNotifications.end()) { - (*index)->StandbyMessageReceived(logicalAddress); - index++; - } - } - - void HdmiCecSourceImplementation::SendKeyReleaseMsgEvent(const int logicalAddress) - { - std::list::const_iterator index(_hdmiCecSourceNotifications.begin()); - while (index != _hdmiCecSourceNotifications.end()) { - (*index)->OnKeyReleaseEvent(logicalAddress); - index++; - } - } - - void HdmiCecSourceImplementation::SendKeyPressMsgEvent(const int logicalAddress,const int keyCode) - { - std::list::const_iterator index(_hdmiCecSourceNotifications.begin()); - while (index != _hdmiCecSourceNotifications.end()) { - (*index)->OnKeyPressEvent(logicalAddress,keyCode); - index++; - } - } - - } // namespace Plugin -} // namespace WPEFramework diff --git a/HdmiCecSource/HdmiCecSourceImplementation.h b/HdmiCecSource/HdmiCecSourceImplementation.h deleted file mode 100644 index 6239dab52..000000000 --- a/HdmiCecSource/HdmiCecSourceImplementation.h +++ /dev/null @@ -1,346 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2025 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. -**/ - -#pragma once - -#include -#include -#include - -#include "ccec/FrameListener.hpp" -#include "ccec/Connection.hpp" -#include "libIARM.h" -#include "ccec/Assert.hpp" -#include "ccec/Messages.hpp" -#include "ccec/MessageDecoder.hpp" -#include "ccec/MessageProcessor.hpp" -#include - -#undef Assert // this define from Connection.hpp conflicts with WPEFramework - -#include "Module.h" - -#include "UtilsBIT.h" -#include "UtilsThreadRAII.h" - -#include -#include "PowerManagerInterface.h" -#include - -using namespace WPEFramework; -using PowerState = WPEFramework::Exchange::IPowerManager::PowerState; -using ThermalTemperature = WPEFramework::Exchange::IPowerManager::ThermalTemperature; - -namespace WPEFramework { - - namespace Plugin { - class HdmiCecSourceFrameListener : public FrameListener - { - public: - HdmiCecSourceFrameListener(MessageProcessor &processor) : processor(processor) {} - void notify(const CECFrame &in) const; - ~HdmiCecSourceFrameListener() {} - private: - MessageProcessor &processor; - }; - - class HdmiCecSourceProcessor : public MessageProcessor - { - public: - HdmiCecSourceProcessor(Connection &conn) : conn(conn) {} - void process (const ActiveSource &msg, const Header &header); - void process (const InActiveSource &msg, const Header &header); - void process (const ImageViewOn &msg, const Header &header); - void process (const TextViewOn &msg, const Header &header); - void process (const RequestActiveSource &msg, const Header &header); - void process (const Standby &msg, const Header &header); - void process (const GetCECVersion &msg, const Header &header); - void process (const CECVersion &msg, const Header &header); - void process (const SetMenuLanguage &msg, const Header &header); - void process (const GiveOSDName &msg, const Header &header); - void process (const GivePhysicalAddress &msg, const Header &header); - void process (const GiveDeviceVendorID &msg, const Header &header); - void process (const SetOSDString &msg, const Header &header); - void process (const SetOSDName &msg, const Header &header); - void process (const RoutingChange &msg, const Header &header); - void process (const RoutingInformation &msg, const Header &header); - void process (const SetStreamPath &msg, const Header &header); - void process (const GetMenuLanguage &msg, const Header &header); - void process (const ReportPhysicalAddress &msg, const Header &header); - void process (const DeviceVendorID &msg, const Header &header); - void process (const GiveDevicePowerStatus &msg, const Header &header); - void process (const ReportPowerStatus &msg, const Header &header); - void process (const UserControlPressed &msg, const Header &header); - void process (const UserControlReleased &msg, const Header &header); - void process (const FeatureAbort &msg, const Header &header); - void process (const Abort &msg, const Header &header); - void process (const Polling &msg, const Header &header); - private: - Connection conn; - void printHeader(const Header &header) - { - printf("Header : From : %s \n", header.from.toString().c_str()); - printf("Header : to : %s \n", header.to.toString().c_str()); - } - - }; - -#define BIT_DEVICE_PRESENT (0) - - class CECDeviceInfo_2 { - public: - - LogicalAddress m_logicalAddress; - VendorID m_vendorID; - OSDName m_osdName; - // - short m_deviceInfoStatus; - bool m_isOSDNameUpdated; - bool m_isVendorIDUpdated; - std::mutex m_; - std::condition_variable cv_; - std::unique_lock lk; - - CECDeviceInfo_2() - : m_logicalAddress(0),m_vendorID(0,0,0),m_osdName("NA"), m_isOSDNameUpdated (false), m_isVendorIDUpdated (false) - { - BITMASK_CLEAR(m_deviceInfoStatus, 0xFFFF); //Clear all bits - } - - void clear( ) - { - m_logicalAddress = 0; - m_vendorID = VendorID(0,0,0); - m_osdName = "NA"; - BITMASK_CLEAR(m_deviceInfoStatus, 0xFFFF); //Clear all bits - m_isOSDNameUpdated = false; - m_isVendorIDUpdated = false; - } - - bool update ( const VendorID &vendorId) { - bool isVendorIdUpdated = false; - if (!m_isVendorIDUpdated) - isVendorIdUpdated = true; //First time no need to cross check the value. Since actual value can be default value - else - isVendorIdUpdated = (m_vendorID.toString().compare(vendorId.toString())==0)?false:true; - - m_isVendorIDUpdated = true; - m_vendorID = vendorId; - return isVendorIdUpdated; - } - - bool update ( const OSDName &osdName ) { - bool isOSDNameUpdated = false; - if (!m_isOSDNameUpdated) - isOSDNameUpdated = true; //First time no need to cross check the value. Since actual value can be default value - else - isOSDNameUpdated = (m_osdName.toString().compare(osdName.toString())==0)?false:true; - - m_isOSDNameUpdated = true; - m_osdName = osdName; - return isOSDNameUpdated; - } - - }; - // This is a server for a JSONRPC communication channel. - // For a plugin to be capable to handle JSONRPC, inherit from PluginHost::JSONRPC. - // By inheriting from this class, the plugin realizes the interface PluginHost::IDispatcher. - // This realization of this interface implements, by default, the following methods on this plugin - // - exists - // - register - // - unregister - // Any other methood to be handled by this plugin can be added can be added by using the - // templated methods Register on the PluginHost::JSONRPC class. - // As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC, - // this class exposes a public method called, Notify(), using this methods, all subscribed clients - // will receive a JSONRPC message as a notification, in case this method is called. - class HdmiCecSourceImplementation : public Exchange::IHdmiCecSource { - enum { - VOLUME_UP = 0x41, - VOLUME_DOWN = 0x42, - MUTE = 0x43, - UP = 0x01, - DOWN = 0x02, - LEFT = 0x03, - RIGHT = 0x04, - SELECT = 0x00, - HOME = 0x09, - BACK = 0x0D, - NUMBER_0 = 0x20, - NUMBER_1 = 0x21, - NUMBER_2 = 0x22, - NUMBER_3 = 0x23, - NUMBER_4 = 0x24, - NUMBER_5 = 0x25, - NUMBER_6 = 0x26, - NUMBER_7 = 0x27, - NUMBER_8 = 0x28, - NUMBER_9 = 0x29 - }; - public: - HdmiCecSourceImplementation(); - virtual ~HdmiCecSourceImplementation(); - void onPowerModeChanged(const PowerState currentState, const PowerState newState); - void registerEventHandlers(); - static HdmiCecSourceImplementation* _instance; - CECDeviceInfo_2 deviceList[16]; - pthread_cond_t m_condSig; - pthread_mutex_t m_lock; - pthread_cond_t m_condSigUpdate; - pthread_mutex_t m_lockUpdate; - bool cecEnableStatus; - - void SendStandbyMsgEvent(const int logicalAddress); - void SendKeyPressMsgEvent(const int logicalAddress,const int keyCode); - void SendKeyReleaseMsgEvent(const int logicalAddress); - void sendActiveSourceEvent(); - void addDevice(const int logicalAddress); - void removeDevice(const int logicalAddress); - void sendUnencryptMsg(unsigned char* msg, int size); - void sendDeviceUpdateInfo(const int logicalAddress); - void sendKeyReleaseEvent(const int logicalAddress); - typedef struct sendKeyInfo - { - int logicalAddr; - int keyCode; - }SendKeyInfo; - BEGIN_INTERFACE_MAP(HdmiCecSourceImplementation) - INTERFACE_ENTRY(Exchange::IHdmiCecSource) - END_INTERFACE_MAP - - - private: - class PowerManagerNotification : public Exchange::IPowerManager::IModeChangedNotification { - private: - PowerManagerNotification(const PowerManagerNotification&) = delete; - PowerManagerNotification& operator=(const PowerManagerNotification&) = delete; - - public: - explicit PowerManagerNotification(HdmiCecSourceImplementation& parent) - : _parent(parent) - { - } - ~PowerManagerNotification() override = default; - - public: - void OnPowerModeChanged(const PowerState currentState, const PowerState newState) override - { - _parent.onPowerModeChanged(currentState, newState); - } - - template - T* baseInterface() - { - static_assert(std::is_base_of(), "base type mismatch"); - return static_cast(this); - } - - BEGIN_INTERFACE_MAP(PowerManagerNotification) - INTERFACE_ENTRY(Exchange::IPowerManager::IModeChangedNotification) - END_INTERFACE_MAP - - private: - HdmiCecSourceImplementation& _parent; - - }; - // We do not allow this plugin to be copied !! - HdmiCecSourceImplementation(const HdmiCecSourceImplementation&) = delete; - HdmiCecSourceImplementation& operator=(const HdmiCecSourceImplementation&) = delete; - - - - //End methods - std::string logicalAddressDeviceType; - bool cecSettingEnabled; - bool cecOTPSettingEnabled; - Connection *smConnection; - int m_numberOfDevices; - bool m_pollThreadExit; - Utils::ThreadRAII m_pollThread; - bool m_updateThreadExit; - Utils::ThreadRAII m_UpdateThread; - bool m_sendKeyEventThreadExit; - bool m_sendKeyEventThreadRun; - Utils::ThreadRAII m_sendKeyEventThread; - std::mutex m_sendKeyEventMutex; - std::queue m_SendKeyQueue; - std::condition_variable m_sendKeyCV; - - HdmiCecSourceProcessor *msgProcessor; - HdmiCecSourceFrameListener *msgFrameListener; - void InitializePowerManager(PluginHost::IShell *service); - const void InitializeIARM(); - void DeinitializeIARM(); - static void dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - void onHdmiHotPlug(int connectStatus); - bool loadSettings(); - void persistSettings(bool enableStatus); - void persistOTPSettings(bool enableStatus); - void persistOSDName(const char *name); - void persistVendorId(unsigned int vendorID); - void CECEnable(void); - void CECDisable(void); - void getPhysicalAddress(); - void getLogicalAddress(); - void cecAddressesChanged(int changeStatus); - bool pingDeviceUpdateList (int idev); - void removeAllCecDevices(); - void requestVendorID(const int newDevlogicalAddress); - void requestOsdName(const int newDevlogicalAddress); - void requestCecDevDetails(const int logicalAddress); - static void threadRun(); - static void threadUpdateCheck(); - static void threadSendKeyEvent(); - static void threadHotPlugEventHandler(int data); - static void threadCecDaemonInitHandler(); - static void threadCecStatusUpdateHandler(int data); - uint32_t sendKeyPressEvent(const int logicalAddress, int keyCode); - PowerManagerInterfaceRef _powerManagerPlugin; - Core::Sink _pwrMgrNotification; - bool _registeredEventHandlers; - private: - mutable Core::CriticalSection _adminLock; - std::list _hdmiCecSourceNotifications; - - public: - Core::hresult SetEnabled(const bool &enabled, HdmiCecSourceSuccess &success) override; - Core::hresult GetEnabled(bool &enabled, bool &success) override; - Core::hresult SetOTPEnabled(const bool &enabled, HdmiCecSourceSuccess &success) override; - Core::hresult GetOTPEnabled(bool &enabled, bool &success) override; - Core::hresult SetOSDName(const string &name, HdmiCecSourceSuccess &success) override; - Core::hresult GetOSDName(string &name, bool &success) override; - Core::hresult SetVendorId(const string &vendorid, HdmiCecSourceSuccess &success) override; - Core::hresult GetVendorId(string &vendorid, bool &success) override; - Core::hresult PerformOTPAction(HdmiCecSourceSuccess &success) override; - Core::hresult SendStandbyMessage(HdmiCecSourceSuccess &success) override; - Core::hresult SendKeyPressEvent(const uint32_t &logicalAddress,const uint32_t &keyCode, HdmiCecSourceSuccess &success) override; - Core::hresult GetActiveSourceStatus(bool &isActiveSource, bool &success) override; - Core::hresult GetDeviceList(uint32_t &numberofdevices, IHdmiCecSourceDeviceListIterator*& deviceList, bool &success) override; - Core::hresult Configure(PluginHost::IShell* service) override; - Core::hresult Register(Exchange::IHdmiCecSource::INotification *notification) override; - Core::hresult Unregister(Exchange::IHdmiCecSource::INotification *notification) override; - - - }; - } // namespace Plugin -} // namespace WPEFramework - - - - diff --git a/HdmiCecSource/Module.cpp b/HdmiCecSource/Module.cpp deleted file mode 100644 index a05f06664..000000000 --- a/HdmiCecSource/Module.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2025 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 "Module.h" - -MODULE_NAME_DECLARATION(BUILD_REFERENCE) diff --git a/HdmiCecSource/Module.h b/HdmiCecSource/Module.h deleted file mode 100644 index 3b75197fe..000000000 --- a/HdmiCecSource/Module.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2025 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. -**/ - -#pragma once -#ifndef MODULE_NAME -#define MODULE_NAME Plugin_HdmiCecSource -#endif - -#include -#include - -#undef EXTERNAL -#define EXTERNAL diff --git a/HdmiCecSource/README.md b/HdmiCecSource/README.md deleted file mode 100644 index 06e17c69f..000000000 --- a/HdmiCecSource/README.md +++ /dev/null @@ -1,9 +0,0 @@ ------------------ -Build: - -bitbake wpeframework-service-plugins - ------------------ -Test: - -curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "rdk.org.HdmiCecSource.1."}' http://127.0.0.1:9998/jsonrpc diff --git a/HdmiInput/CHANGELOG.md b/HdmiInput/CHANGELOG.md deleted file mode 100644 index 3e73c3186..000000000 --- a/HdmiInput/CHANGELOG.md +++ /dev/null @@ -1,27 +0,0 @@ -# Changelog - -All notable changes to this RDK Service will be documented in this file. - -* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. - -* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: - * **Added** for new features. - * **Changed** for changes in existing functionality. - * **Deprecated** for soon-to-be removed features. - * **Removed** for now removed features. - * **Fixed** for any bug fixes. - * **Security** in case of vulnerabilities. - -* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. - -## [1.4.0] - 2025-02-17 -### Added -- Added support for Getting the Maximum HDMI Compatibility version for the given port. - -## [1.0.0] - 2025-02-17 -### Added -- Add CHANGELOG - -### Change -- Reset API version to 1.0.0 -- Change README to inform how to update changelog and API version diff --git a/HdmiInput/CMakeLists.txt b/HdmiInput/CMakeLists.txt deleted file mode 100644 index b5d667a4a..000000000 --- a/HdmiInput/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -set(PLUGIN_NAME HdmiInput) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) - -set(PLUGIN_HDMIINPUT_STARTUPORDER "" CACHE STRING "To configure startup order of HdmiInput plugin") - -find_package(${NAMESPACE}Plugins REQUIRED) -if (USE_THUNDER_R4) - find_package(${NAMESPACE}COM REQUIRED) -else () - find_package(${NAMESPACE}Protocols REQUIRED) -endif (USE_THUNDER_R4) - -add_library(${MODULE_NAME} SHARED - HdmiInput.cpp - Module.cpp - ) - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -target_compile_definitions(${MODULE_NAME} PRIVATE MODULE_NAME=Plugin_${PLUGIN_NAME}) - -target_include_directories(${MODULE_NAME} PRIVATE ../helpers) - -if (USE_THUNDER_R4) -target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}COM::${NAMESPACE}COM) -else () -target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Protocols::${NAMESPACE}Protocols) -endif (USE_THUNDER_R4) - - -find_package(DS) -find_package(IARMBus) - -target_include_directories(${MODULE_NAME} PRIVATE ${DS_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PRIVATE ../helpers) - -set_source_files_properties(HdmiInput.cpp PROPERTIES COMPILE_FLAGS "-fexceptions") - -target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${DS_LIBRARIES} ) - -install(TARGETS ${MODULE_NAME} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -write_config(${PLUGIN_NAME}) diff --git a/HdmiInput/HdmiInput.conf.in b/HdmiInput/HdmiInput.conf.in deleted file mode 100644 index e16bde27f..000000000 --- a/HdmiInput/HdmiInput.conf.in +++ /dev/null @@ -1,4 +0,0 @@ -precondition = ["Platform"] -callsign = "org.rdk.HdmiInput" -autostart = "false" -startuporder = "@PLUGIN_HDMIINPUT_STARTUPORDER@" diff --git a/HdmiInput/HdmiInput.config b/HdmiInput/HdmiInput.config deleted file mode 100644 index 2b918b142..000000000 --- a/HdmiInput/HdmiInput.config +++ /dev/null @@ -1,7 +0,0 @@ -set (autostart false) -set (preconditions Platform) -set (callsign "org.rdk.HdmiInput") - -if(PLUGIN_HDMIINPUT_STARTUPORDER) -set (startuporder ${PLUGIN_HDMIINPUT_STARTUPORDER}) -endif() diff --git a/HdmiInput/HdmiInput.cpp b/HdmiInput/HdmiInput.cpp deleted file mode 100644 index e45efa093..000000000 --- a/HdmiInput/HdmiInput.cpp +++ /dev/null @@ -1,1431 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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 "HdmiInput.h" -#include "UtilsJsonRpc.h" -#include "UtilsIarm.h" - -#include "hdmiIn.hpp" -#include "exception.hpp" -#include "dsUtl.h" -#include "dsError.h" -#include "dsMgr.h" -#include "host.hpp" - -#include -#include - -#define HDMI_HOT_PLUG_EVENT_CONNECTED 0 -#define HDMI_HOT_PLUG_EVENT_DISCONNECTED 1 - -#define HDMIINPUT_METHOD_GET_HDMI_INPUT_DEVICES "getHDMIInputDevices" -#define HDMIINPUT_METHOD_WRITE_EDID "writeEDID" -#define HDMIINPUT_METHOD_READ_EDID "readEDID" -#define HDMIINPUT_METHOD_READ_RAWHDMISPD "getRawHDMISPD" -#define HDMIINPUT_METHOD_READ_HDMISPD "getHDMISPD" -#define HDMIINPUT_METHOD_SET_EDID_VERSION "setEdidVersion" -#define HDMIINPUT_METHOD_GET_EDID_VERSION "getEdidVersion" -#define HDMIINPUT_METHOD_SET_MIXER_LEVELS "setMixerLevels" -#define HDMIINPUT_METHOD_START_HDMI_INPUT "startHdmiInput" -#define HDMIINPUT_METHOD_STOP_HDMI_INPUT "stopHdmiInput" -#define HDMIINPUT_METHOD_SCALE_HDMI_INPUT "setVideoRectangle" -#define HDMIINPUT_METHOD_SUPPORTED_GAME_FEATURES "getSupportedGameFeatures" -#define HDMIINPUT_METHOD_GAME_FEATURE_STATUS "getHdmiGameFeatureStatus" - -#define HDMIINPUT_EVENT_ON_DEVICES_CHANGED "onDevicesChanged" -#define HDMIINPUT_EVENT_ON_SIGNAL_CHANGED "onSignalChanged" -#define HDMIINPUT_EVENT_ON_STATUS_CHANGED "onInputStatusChanged" -#define HDMIINPUT_EVENT_ON_VIDEO_MODE_UPDATED "videoStreamInfoUpdate" -#define HDMIINPUT_EVENT_ON_GAME_FEATURE_STATUS_CHANGED "hdmiGameFeatureStatusUpdate" -#define HDMIINPUT_EVENT_ON_AVI_CONTENT_TYPE_CHANGED "hdmiContentTypeUpdate" -#define HDMIINPUT_METHOD_GET_LOW_LATENCY_MODE "getTVLowLatencyMode" -#define HDMIINPUT_METHOD_GET_AV_LATENCY "getAVLatency" -#define HDMIINPUT_METHOD_GET_HDMI_COMPATIBILITY_VERSION "getHdmiVersion" - -#define HDMICECSINK_CALLSIGN "org.rdk.HdmiCecSink" -#define HDMICECSINK_CALLSIGN_VER HDMICECSINK_CALLSIGN".1" -#define TVSETTINGS_CALLSIGN "org.rdk.tv.ControlSettings" -#define TVSETTINGS_CALLSIGN_VER TVSETTINGS_CALLSIGN".2" - -// TODO: remove this -#define registerMethod(...) for (uint8_t i = 1; GetHandler(i); i++) GetHandler(i)->Register(__VA_ARGS__) - -#define API_VERSION_NUMBER_MAJOR 1 -#define API_VERSION_NUMBER_MINOR 4 -#define API_VERSION_NUMBER_PATCH 0 - -static int audio_output_delay = 100; -static int video_latency = 20; -#define TVMGR_GAME_MODE_EVENT "gameModeEvent" -static bool lowLatencyMode = false; -#define SERVER_DETAILS "127.0.0.1:9998" -static int planeType = 0; -static bool isAudioBalanceSet = false; -using namespace std; - -namespace WPEFramework -{ - namespace { - - static Plugin::Metadata metadata( - // Version (Major, Minor, Patch) - API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH, - // Preconditions - {}, - // Terminations - {}, - // Controls - {} - ); - } - - namespace Plugin - { - SERVICE_REGISTRATION(HdmiInput, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); - - HdmiInput* HdmiInput::_instance = nullptr; - - HdmiInput::HdmiInput() - : PluginHost::JSONRPC() - { - HdmiInput::_instance = this; - - m_tv_client = nullptr; - m_client = nullptr; - //InitializeIARM(); - - CreateHandler({2}); - - registerMethod(HDMIINPUT_METHOD_GET_HDMI_INPUT_DEVICES, &HdmiInput::getHDMIInputDevicesWrapper, this); - registerMethod(HDMIINPUT_METHOD_WRITE_EDID, &HdmiInput::writeEDIDWrapper, this); - registerMethod(HDMIINPUT_METHOD_READ_EDID, &HdmiInput::readEDIDWrapper, this); - registerMethod(HDMIINPUT_METHOD_READ_RAWHDMISPD, &HdmiInput::getRawHDMISPDWrapper, this); - registerMethod(HDMIINPUT_METHOD_READ_HDMISPD, &HdmiInput::getHDMISPDWrapper, this); - registerMethod(HDMIINPUT_METHOD_SET_EDID_VERSION, &HdmiInput::setEdidVersionWrapper, this); - registerMethod(HDMIINPUT_METHOD_GET_EDID_VERSION, &HdmiInput::getEdidVersionWrapper, this); - registerMethod(HDMIINPUT_METHOD_START_HDMI_INPUT, &HdmiInput::startHdmiInput, this); - registerMethod(HDMIINPUT_METHOD_STOP_HDMI_INPUT, &HdmiInput::stopHdmiInput, this); - registerMethod(HDMIINPUT_METHOD_SCALE_HDMI_INPUT, &HdmiInput::setVideoRectangleWrapper, this); - registerMethod(HDMIINPUT_METHOD_SET_MIXER_LEVELS, &HdmiInput::setMixerLevels, this); - registerMethod(HDMIINPUT_METHOD_SUPPORTED_GAME_FEATURES, &HdmiInput::getSupportedGameFeatures, this); - registerMethod(HDMIINPUT_METHOD_GAME_FEATURE_STATUS, &HdmiInput::getHdmiGameFeatureStatusWrapper, this); - registerMethod(HDMIINPUT_METHOD_GET_AV_LATENCY, &HdmiInput::getAVLatency, this); - registerMethod(HDMIINPUT_METHOD_GET_LOW_LATENCY_MODE, &HdmiInput::getTVLowLatencyMode, this); - registerMethod(HDMIINPUT_METHOD_GET_HDMI_COMPATIBILITY_VERSION, &HdmiInput::getHdmiVersionWrapper, this); - m_primVolume = DEFAULT_PRIM_VOL_LEVEL; - m_inputVolume = DEFAULT_INPUT_VOL_LEVEL; - } - - HdmiInput::~HdmiInput() - { - } - - const string HdmiInput::Initialize(PluginHost::IShell * service ) - { - LOGINFO("Entering HdmiInput::Initialize"); - ASSERT(service != nullptr); - ASSERT(m_service == nullptr); - - m_service = service; - m_service->AddRef(); - - HdmiInput::_instance = this; - InitializeIARM(); - - subscribeForTvMgrEvent("gameModeEvent"); - LOGINFO("Exiting HdmiInput::Initialize"); - return (string()); - } - - uint32_t HdmiInput::subscribeForTvMgrEvent(const char* eventName) - { - uint32_t err = Core::ERROR_NONE; - LOGINFO("Attempting to subscribe for event: %s\n", eventName); - Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T(SERVER_DETAILS))); - if (nullptr == m_tv_client) { - getControlSettingsPlugin(); - if (nullptr == m_tv_client) { - LOGERR("JSONRPC: %s: client initialization failed", TVSETTINGS_CALLSIGN_VER); - err = Core::ERROR_UNAVAILABLE; - } - } - - if(err == Core::ERROR_NONE) { - /* Register handlers for Event reception. */ - if(strcmp(eventName, TVMGR_GAME_MODE_EVENT) == 0) { - err =m_tv_client->Subscribe(1000, eventName, &HdmiInput::onGameModeEventHandler, this); - } - else { - LOGERR("Failed to subscribe for %s with code %d", eventName, err); - } - } - return err; - } - - void setResponseArray(JsonObject& response, const char* key, const vector& items) - { - JsonArray arr; - for(auto& i : items) arr.Add(JsonValue(i)); - - response[key] = arr; - - string json; - response.ToString(json); - } - - void HdmiInput::Deinitialize(PluginHost::IShell* service ) - { - ASSERT(service == m_service); - m_service->Release(); - m_service = nullptr; - - HdmiInput::_instance = nullptr; - - DeinitializeIARM(); - } - - void HdmiInput::InitializeIARM() - { - if (Utils::IARM::init()) - { - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, dsHdmiEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, dsHdmiSignalStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, dsHdmiStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, dsHdmiVideoModeEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, dsHdmiGameFeatureStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE, dsHdmiAviContentTypeEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_AV_LATENCY, dsHdmiAVLatencyEventHandler) ); - } - } - - void HdmiInput::DeinitializeIARM() - { - if (Utils::IARM::isConnected()) - { - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, dsHdmiEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, dsHdmiSignalStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, dsHdmiStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, dsHdmiVideoModeEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, dsHdmiGameFeatureStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE,dsHdmiAviContentTypeEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_AV_LATENCY,dsHdmiAVLatencyEventHandler) ); - } - } - - uint32_t HdmiInput::startHdmiInput(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - - string sPortId = parameters["portId"].String(); - bool audioMix = parameters["requestAudioMix"].Boolean(); - int portId = 0; - bool topMostPlane = parameters["topMost"].Boolean(); - - //planeType = 0 - primary, 1 - secondary video plane type - planeType = 0; - try { - portId = stoi(sPortId); - if (parameters.HasLabel("plane")){ - string sPlaneType = parameters["plane"].String(); - planeType = stoi(sPlaneType); - if(!(planeType == 0 || planeType == 1))// planeType has to be primary(0) or secondary(1) - { - LOGWARN("planeType is invalid\n"); - returnResponse(false); - } - } - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - bool success = true; - try - { - device::HdmiInput::getInstance().selectPort(portId,audioMix,planeType,topMostPlane); - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(sPortId); - success = false; - } - returnResponse(success); - - } - - uint32_t HdmiInput::stopHdmiInput(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - bool success = true; - try - { - // Restoring the Audio Mixer Levels when the Input is stopped. - if (isAudioBalanceSet){ - device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_PRIMARY,MAX_PRIM_VOL_LEVEL); - device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_SYSTEM,DEFAULT_INPUT_VOL_LEVEL); - isAudioBalanceSet = false; - } - planeType = -1;// plane index when stopping hdmi input - device::HdmiInput::getInstance().selectPort(-1); - } - catch (const device::Exception& err) - { - LOGWARN("HdmiInputService::stopHdmiInput Failed"); - success = false; - } - returnResponse(success); - - } - uint32_t HdmiInput::setMixerLevels(const JsonObject& parameters, JsonObject& response) - { - returnIfParamNotFound(parameters, "primaryVolume"); - returnIfParamNotFound(parameters, "inputVolume"); - - int primVol = 0, inputVol = 0; - try { - primVol = parameters["primaryVolume"].Number(); - inputVol = parameters["inputVolume"].Number() ; - } catch(...) { - LOGERR("Incompatible params passed !!!\n"); - response["success"] = false; - returnResponse(false); - } - - if( (primVol >=0) && (inputVol >=0) ) { - m_primVolume = primVol; - m_inputVolume = inputVol; - } - else { - LOGERR("Incompatible params passed !!!\n"); - response["success"] = false; - returnResponse(false); - } - - if(m_primVolume > MAX_PRIM_VOL_LEVEL) { - LOGWARN("Primary Volume greater than limit. Set to MAX_PRIM_VOL_LEVEL(100) !!!\n"); - m_primVolume = MAX_PRIM_VOL_LEVEL; - } - if(m_inputVolume > DEFAULT_INPUT_VOL_LEVEL) { - LOGWARN("Input Volume greater than limit. Set to DEFAULT_INPUT_VOL_LEVEL(100) !!!\n"); - m_inputVolume = DEFAULT_INPUT_VOL_LEVEL; - } - LOGINFO("GLOBAL primary Volume=%d input Volume=%d \n",m_primVolume , m_inputVolume ); - - try{ - - device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_PRIMARY,primVol); - device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_SYSTEM,inputVol); - } - catch(...){ - LOGWARN("Not setting SoC volume !!!\n"); - returnResponse(false); - } - isAudioBalanceSet = true; - returnResponse(true); - } - - uint32_t HdmiInput::setVideoRectangleWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - bool result = true; - if (!parameters.HasLabel("x") && !parameters.HasLabel("y")) - { - result = false; - response["message"] = "please specif coordinates (x,y)"; - } - - if (!parameters.HasLabel("w") && !parameters.HasLabel("h")) - { - result = false; - response["message"] = "please specify window width and height (w,h)"; - } - - if (result) - { - int x = 0; - int y = 0; - int w = 0; - int h = 0; - - try - { - if (parameters.HasLabel("x")) - { - x = std::stoi(parameters["x"].String()); - } - if (parameters.HasLabel("y")) - { - y = std::stoi(parameters["y"].String()); - } - if (parameters.HasLabel("w")) - { - w = std::stoi(parameters["w"].String()); - } - if (parameters.HasLabel("h")) - { - h = std::stoi(parameters["h"].String()); - } - } - catch (const std::exception& err) { - LOGWARN("Invalid paramater X: %s,Y: %s, W: %s, H:%s ", parameters["x"].String().c_str(),parameters["y"].String().c_str(),parameters["w"].String().c_str(),parameters["h"].String().c_str()); - returnResponse(false); - } - - result = setVideoRectangle(x, y, w, h); - if (false == result) { - LOGWARN("HdmiInputService::setVideoRectangle Failed"); - response["message"] = "failed to set scale"; - } - } - - returnResponse(result); - - } - - bool HdmiInput::setVideoRectangle(int x, int y, int width, int height) - { - bool ret = true; - - try - { - device::HdmiInput::getInstance().scaleVideo(x, y, width, height); - } - catch (const device::Exception& err) - { - ret = false; - } - - return ret; - } - - uint32_t HdmiInput::getHDMIInputDevicesWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - response["devices"] = getHDMIInputDevices(); - - returnResponse(true); - } - - uint32_t HdmiInput::writeEDIDWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - int deviceId; - std::string message; - - if (parameters.HasLabel("deviceId") && parameters.HasLabel("message")) - { - getNumberParameter("deviceId", deviceId); - message = parameters["message"].String(); - } - else - { - LOGWARN("Required parameters are not passed"); - returnResponse(false); - } - - - writeEDID(deviceId, message); - returnResponse(true); - - } - - uint32_t HdmiInput::readEDIDWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - string sPortId = parameters.HasLabel("deviceId") ? parameters["deviceId"].String() : "0";; - int portId = 0; - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - string edid = readEDID (portId); - response["EDID"] = edid; - if (edid.empty()) { - returnResponse(false); - } - else { - returnResponse(true); - } - } - - JsonArray HdmiInput::getHDMIInputDevices() - { - JsonArray list; - try - { - int num = device::HdmiInput::getInstance().getNumberOfInputs(); - if (num > 0) { - int i = 0; - for (i = 0; i < num; i++) { - //Input ID is aleays 0-indexed, continuous number starting 0 - JsonObject hash; - hash["id"] = i; - std::stringstream locator; - locator << "hdmiin://localhost/deviceid/" << i; - hash["locator"] = locator.str(); - hash["connected"] = device::HdmiInput::getInstance().isPortConnected(i) ? "true" : "false"; - LOGWARN("HdmiInputService::getHDMIInputDevices id %d, locator=[%s], connected=[%s]", i, hash["locator"].String().c_str(), hash["connected"].String().c_str()); - list.Add(hash); - } - } - } - catch (const std::exception& e) { - LOGWARN("HdmiInputService::getHDMIInputDevices Failed"); - } - - return list; - } - - void HdmiInput::writeEDID(int deviceId, std::string message) - { - - } - - std::string HdmiInput::readEDID(int iPort) - { - vector edidVec({'u','n','k','n','o','w','n' }); - string edidbase64 = ""; - try - { - vector edidVec2; - device::HdmiInput::getInstance().getEDIDBytesInfo (iPort, edidVec2); - edidVec = edidVec2;//edidVec must be "unknown" unless we successfully get to this line - - //convert to base64 - uint16_t size = min(edidVec.size(), (size_t)numeric_limits::max()); - - LOGWARN("HdmiInput::readEDID size:%u edidVec.size:%d", size, (int)edidVec.size()); - - if(edidVec.size() > (size_t)numeric_limits::max()) { - LOGERR("Size too large to use ToString base64 wpe api"); - return edidbase64; - } - - Core::ToString((uint8_t*)&edidVec[0], size, true, edidbase64); - - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return edidbase64; - } - - /** - * @brief This function is used to translate HDMI input hotplug to - * deviceChanged event. - * - * @param[in] input Number of input port integer. - * @param[in] connection status of input port integer. - */ - void HdmiInput::hdmiInputHotplug( int input , int connect) - { - LOGWARN("hdmiInputHotplug [%d, %d]", input, connect); - - JsonObject params; - params["devices"] = getHDMIInputDevices(); - sendNotify(HDMIINPUT_EVENT_ON_DEVICES_CHANGED, params); - } - - /** - * @brief This function is used to translate HDMI input signal change to - * signalChanged event. - * - * @param[in] port HDMI In port id. - * @param[in] signalStatus signal status of HDMI In port. - */ - void HdmiInput::hdmiInputSignalChange( int port , int signalStatus) - { - LOGWARN("hdmiInputSignalStatus [%d, %d]", port, signalStatus); - - JsonObject params; - params["id"] = port; - std::stringstream locator; - locator << "hdmiin://localhost/deviceid/" << port; - params["locator"] = locator.str(); - - switch (signalStatus) { - case dsHDMI_IN_SIGNAL_STATUS_NOSIGNAL: - params["signalStatus"] = "noSignal"; - break; - - case dsHDMI_IN_SIGNAL_STATUS_UNSTABLE: - params["signalStatus"] = "unstableSignal"; - break; - - case dsHDMI_IN_SIGNAL_STATUS_NOTSUPPORTED: - params["signalStatus"] = "notSupportedSignal"; - break; - - case dsHDMI_IN_SIGNAL_STATUS_STABLE: - params["signalStatus"] = "stableSignal"; - break; - - default: - params["signalStatus"] = "none"; - break; - } - - sendNotify(HDMIINPUT_EVENT_ON_SIGNAL_CHANGED, params); - } - - /** - * @brief This function is used to translate HDMI input status change to - * inputStatusChanged event. - * - * @param[in] port HDMI In port id. - * @param[bool] isPresented HDMI In presentation started/stopped. - */ - void HdmiInput::hdmiInputStatusChange( int port , bool isPresented) - { - LOGWARN("hdmiInputStatus [%d, %d]", port, isPresented); - - JsonObject params; - params["id"] = port; - std::stringstream locator; - locator << "hdmiin://localhost/deviceid/" << port; - params["locator"] = locator.str(); - - if(isPresented) { - params["status"] = "started"; - } - else { - params["status"] = "stopped"; - } - params["plane"] = planeType; - sendNotify(HDMIINPUT_EVENT_ON_STATUS_CHANGED, params); - } - - /** - * @brief This function is used to translate HDMI input video mode change to - * videoStreamInfoUpdate event. - * - * @param[in] port HDMI In port id. - * @param[dsVideoPortResolution_t] video resolution data - */ - void HdmiInput::hdmiInputVideoModeUpdate( int port , dsVideoPortResolution_t resolution) - { - LOGWARN("hdmiInputVideoModeUpdate [%d]", port); - - JsonObject params; - params["id"] = port; - std::stringstream locator; - locator << "hdmiin://localhost/deviceid/" << port; - params["locator"] = locator.str(); - - switch(resolution.pixelResolution) { - case dsVIDEO_PIXELRES_720x480: - params["width"] = 720; - params["height"] = 480; - break; - - case dsVIDEO_PIXELRES_720x576: - params["width"] = 720; - params["height"] = 576; - break; - - case dsVIDEO_PIXELRES_1280x720: - params["width"] = 1280; - params["height"] = 720; - break; - - case dsVIDEO_PIXELRES_1920x1080: - params["width"] = 1920; - params["height"] = 1080; - break; - - case dsVIDEO_PIXELRES_3840x2160: - params["width"] = 3840; - params["height"] = 2160; - break; - - case dsVIDEO_PIXELRES_4096x2160: - params["width"] = 4096; - params["height"] = 2160; - break; - - default: - params["width"] = 1920; - params["height"] = 1080; - break; - } - - params["progressive"] = (!resolution.interlaced); - - switch(resolution.frameRate) { - case dsVIDEO_FRAMERATE_24: - params["frameRateN"] = 24000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_25: - params["frameRateN"] = 25000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_30: - params["frameRateN"] = 30000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_50: - params["frameRateN"] = 50000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_60: - params["frameRateN"] = 60000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_23dot98: - params["frameRateN"] = 24000; - params["frameRateD"] = 1001; - break; - - case dsVIDEO_FRAMERATE_29dot97: - params["frameRateN"] = 30000; - params["frameRateD"] = 1001; - break; - - case dsVIDEO_FRAMERATE_59dot94: - params["frameRateN"] = 60000; - params["frameRateD"] = 1001; - break; - - default: - params["frameRateN"] = 60000; - params["frameRateD"] = 1000; - break; - } - - sendNotify(HDMIINPUT_EVENT_ON_VIDEO_MODE_UPDATED, params); - } - - void HdmiInput::getHdmiCecSinkPlugin() - { - - if(m_client == nullptr) - { - LOGINFO("getting the hdmicecsink client\n"); - string token; - - // TODO: use interfaces and remove token - auto security = m_service->QueryInterfaceByCallsign("SecurityAgent"); - if (security != nullptr) { - string payload = "http://localhost"; - if (security->CreateToken( - static_cast(payload.length()), - reinterpret_cast(payload.c_str()), - token) - == Core::ERROR_NONE) { - LOGINFO("HdmiInput got security token\n"); - } - else { - LOGINFO("HdmiInput failed to get security token\n"); - } - security->Release(); - } - else { - LOGINFO("No security agent\n"); - } - - string query = "token=" + token; - Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T("127.0.0.1:9998"))); - m_client = new WPEFramework::JSONRPC::LinkType(_T(HDMICECSINK_CALLSIGN_VER), (_T(HDMICECSINK_CALLSIGN_VER)), false, query); - LOGINFO("HdmiInput getHdmiCecSinkPlugin init m_client\n"); - } - } - - void HdmiInput::reportLatencyInfoToHdmiCecSink() - { - - PluginHost::IShell::state state; - if ((getServiceState(m_service, HDMICECSINK_CALLSIGN, state) == Core::ERROR_NONE) && (state == PluginHost::IShell::state::ACTIVATED)) { - LOGINFO("%s is active", HDMICECSINK_CALLSIGN); - - getHdmiCecSinkPlugin(); - if (!m_client) { - LOGERR("HdmiCecSink Initialisation failed\n"); - } - else { - JsonObject hdmiCecSinkResult; - JsonObject param; - - param["audioOutputDelay"] = std::to_string(audio_output_delay); - param["videoLatency"] = std::to_string(video_latency); - param["lowLatencyMode"] = std::to_string(lowLatencyMode); - param["audioOutputCompensated"] ="3";//hard-coded for now - LOGINFO("latency - Info: %d : %d, %d\n",audio_output_delay,video_latency,lowLatencyMode); - m_client->Invoke(2000, "setLatencyInfo", param, hdmiCecSinkResult); - if (!hdmiCecSinkResult["success"].Boolean()) { - LOGERR("HdmiCecSink Plugin returned error\n"); - } - } - } - else { - LOGERR("HdmiCecSink plugin not ready\n"); - } - - - } - void HdmiInput::dsHdmiAVLatencyEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_AV_LATENCY == eventId) - { - LOGINFO("received the latency mode change event in dsHdmiAVLatencyEventHandler\n"); - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - audio_output_delay = eventData->data.hdmi_in_av_latency.audio_output_delay; - video_latency= eventData->data.hdmi_in_av_latency.video_latency; - - // HdmiInput::_instance->hdmiInAVLatencyChange(audio_output_delay,video_latency); - LOGINFO("Latency Info Change occurs: AV Latencies -- Report to HdmiCecSink\n"); - HdmiInput::_instance->reportLatencyInfoToHdmiCecSink(); - } - } - - void HdmiInput::onGameModeEventHandler(const JsonObject& parameters) - { - LOGINFO("Entered in onGameModeEventHandler\n"); - lowLatencyMode = parameters["lowLatencyMode"].Boolean(); - LOGINFO("Low Latency Mode : %d\n", lowLatencyMode); - HdmiInput::_instance->reportLatencyInfoToHdmiCecSink(); - } - - void HdmiInput::dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmiin_hotplug_port = eventData->data.hdmi_in_connect.port; - int hdmiin_hotplug_conn = eventData->data.hdmi_in_connect.isPortConnected; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG event data:%d", hdmiin_hotplug_port); - - HdmiInput::_instance->hdmiInputHotplug(hdmiin_hotplug_port, hdmiin_hotplug_conn ? HDMI_HOT_PLUG_EVENT_CONNECTED : HDMI_HOT_PLUG_EVENT_DISCONNECTED); - } - } - - void HdmiInput::dsHdmiSignalStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_sig_status.port; - int hdmi_in_signal_status = eventData->data.hdmi_in_sig_status.status; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS event port: %d, signal status: %d", hdmi_in_port,hdmi_in_signal_status); - - HdmiInput::_instance->hdmiInputSignalChange(hdmi_in_port, hdmi_in_signal_status); - - } - } - - void HdmiInput::dsHdmiStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_status.port; - bool hdmi_in_status = eventData->data.hdmi_in_status.isPresented; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS event port: %d, started: %d", hdmi_in_port,hdmi_in_status); - - HdmiInput::_instance->hdmiInputStatusChange(hdmi_in_port, hdmi_in_status); - - } - } - - void HdmiInput::dsHdmiVideoModeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_video_mode.port; - dsVideoPortResolution_t resolution = {}; - resolution.pixelResolution = eventData->data.hdmi_in_video_mode.resolution.pixelResolution; - resolution.interlaced = eventData->data.hdmi_in_video_mode.resolution.interlaced; - resolution.frameRate = eventData->data.hdmi_in_video_mode.resolution.frameRate; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE event port: %d, pixelResolution: %d, interlaced : %d, frameRate: %d \n", hdmi_in_port,resolution.pixelResolution, resolution.interlaced, resolution.frameRate); - - HdmiInput::_instance->hdmiInputVideoModeUpdate(hdmi_in_port, resolution); - - } - } - - void HdmiInput::dsHdmiGameFeatureStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_allm_mode.port; - bool allm_mode = eventData->data.hdmi_in_allm_mode.allm_mode; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS event port: %d, ALLM Mode: %d", hdmi_in_port,allm_mode); - - HdmiInput::_instance->hdmiInputALLMChange(hdmi_in_port, allm_mode); - } - } - - void HdmiInput::hdmiInputALLMChange( int port , bool allm_mode) - { - JsonObject params; - params["id"] = port; - params["gameFeature"] = "ALLM"; - params["mode"] = allm_mode; - - sendNotify(HDMIINPUT_EVENT_ON_GAME_FEATURE_STATUS_CHANGED, params); - } - - void HdmiInput::dsHdmiAviContentTypeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_content_type.port; - int avi_content_type = eventData->data.hdmi_in_content_type.aviContentType; - LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE event port: %d, Content Type : %d", hdmi_in_port,avi_content_type); - HdmiInput::_instance->hdmiInputAviContentTypeChange(hdmi_in_port, avi_content_type); - } - } - - void HdmiInput::hdmiInputAviContentTypeChange( int port , int content_type) - { - JsonObject params; - params["id"] = port; - params["aviContentType"] = content_type; - sendNotify(HDMIINPUT_EVENT_ON_AVI_CONTENT_TYPE_CHANGED, params); - } - - uint32_t HdmiInput::getSupportedGameFeatures(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - vector supportedFeatures; - try - { - device::HdmiInput::getInstance().getSupportedGameFeatures (supportedFeatures); - for (size_t i = 0; i < supportedFeatures.size(); i++) - { - LOGINFO("Supported Game Feature [%d]: %s\n",(int)i,supportedFeatures.at(i).c_str()); - } - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION0(); - } - - if (supportedFeatures.empty()) { - returnResponse(false); - } - else { - setResponseArray(response, "supportedGameFeatures", supportedFeatures); - returnResponse(true); - } - } - - uint32_t HdmiInput::getHdmiGameFeatureStatusWrapper(const JsonObject& parameters, JsonObject& response) - { - string sPortId = parameters["portId"].String(); - string sGameFeature = parameters["gameFeature"].String(); - int portId = 0; - - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - returnIfParamNotFound(parameters, "gameFeature"); - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - if (strcmp (sGameFeature.c_str(), "ALLM") == 0) - { - bool allm = getHdmiALLMStatus(portId); - LOGWARN("HdmiInput::getHdmiGameFeatureStatusWrapper ALLM MODE:%d", allm); - response["mode"] = allm; - } - else - { - LOGWARN("HdmiInput::getHdmiGameFeatureStatusWrapper Mode is not supported. Supported mode: ALLM"); - response["message"] = "Mode is not supported. Supported mode: ALLM"; - returnResponse(false); - } - returnResponse(true); - } - - bool HdmiInput::getHdmiALLMStatus(int iPort) - { - bool allm = false; - - try - { - device::HdmiInput::getInstance().getHdmiALLMStatus (iPort, &allm); - LOGWARN("HdmiInput::getHdmiALLMStatus ALLM MODE: %d", allm); - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return allm; - } - - uint32_t HdmiInput::getRawHDMISPDWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - - string sPortId = parameters["portId"].String(); - int portId = 0; - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - string spdInfo = getRawHDMISPD (portId); - response["HDMISPD"] = spdInfo; - if (spdInfo.empty()) { - returnResponse(false); - } - else { - returnResponse(true); - } - } - - uint32_t HdmiInput::getHDMISPDWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - - string sPortId = parameters["portId"].String(); - int portId = 0; - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - string spdInfo = getHDMISPD (portId); - response["HDMISPD"] = spdInfo; - if (spdInfo.empty()) { - returnResponse(false); - } - else { - returnResponse(true); - } - } - - std::string HdmiInput::getRawHDMISPD(int iPort) - { - LOGINFO("HdmiInput::getHDMISPDInfo"); - vector spdVect({'u','n','k','n','o','w','n' }); - std::string spdbase64 = ""; - try - { - LOGWARN("HdmiInput::getHDMISPDInfo"); - vector spdVect2; - device::HdmiInput::getInstance().getHDMISPDInfo(iPort, spdVect2); - spdVect = spdVect2;//edidVec must be "unknown" unless we successfully get to this line - - //convert to base64 - uint16_t size = min(spdVect.size(), (size_t)numeric_limits::max()); - - LOGWARN("HdmiInput::getHDMISPD size:%u spdVec.size:%d", size, (int)spdVect.size()); - - if(spdVect.size() > (size_t)numeric_limits::max()) { - LOGERR("Size too large to use ToString base64 wpe api"); - return spdbase64; - } - - LOGINFO("------------getHDMISPD: "); - for (unsigned int itr =0; itr < spdVect.size(); itr++) { - LOGINFO("%02X ", spdVect[itr]); - } - Core::ToString((uint8_t*)&spdVect[0], size, false, spdbase64); - - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return spdbase64; - } - - std::string HdmiInput::getHDMISPD(int iPort) - { - LOGINFO("HdmiInput::getHDMISPDInfo"); - vector spdVect({'u','n','k','n','o','w','n' }); - std::string spdbase64 = ""; - try - { - LOGWARN("HdmiInput::getHDMISPDInfo"); - vector spdVect2; - device::HdmiInput::getInstance().getHDMISPDInfo(iPort, spdVect2); - spdVect = spdVect2;//edidVec must be "unknown" unless we successfully get to this line - - //convert to base64 - uint16_t size = min(spdVect.size(), (size_t)numeric_limits::max()); - - LOGWARN("HdmiInput::getHDMISPD size:%u spdVec.size:%d", size, (int)spdVect.size()); - - if(spdVect.size() > (size_t)numeric_limits::max()) { - LOGERR("Size too large to use ToString base64 wpe api"); - return spdbase64; - } - - LOGINFO("------------getHDMISPD: "); - for (unsigned int itr =0; itr < spdVect.size(); itr++) { - LOGINFO("%02X ", spdVect[itr]); - } - if (spdVect.size() > 0) { - struct dsSpd_infoframe_st pre; - memcpy(&pre,spdVect.data(),sizeof(struct dsSpd_infoframe_st)); - - char str[200] = {0}; - snprintf(str, sizeof(str), "Packet Type:%02X,Version:%u,Length:%u,vendor name:%s,product des:%s,source info:%02X" -,pre.pkttype,pre.version,pre.length,pre.vendor_name,pre.product_des,pre.source_info); - spdbase64 = str; - } - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return spdbase64; - } - - uint32_t HdmiInput::setEdidVersionWrapper(const JsonObject& parameters, JsonObject& response) - { - int portId = 0; - - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - returnIfParamNotFound(parameters, "edidVersion"); - string sPortId = parameters["portId"].String(); - string sVersion = parameters["edidVersion"].String(); - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - int edidVer = -1; - if (strcmp (sVersion.c_str(), "HDMI1.4") == 0) { - edidVer = HDMI_EDID_VER_14; - } - else if (strcmp (sVersion.c_str(), "HDMI2.0") == 0) { - edidVer = HDMI_EDID_VER_20; - } - - if (edidVer < 0) { - returnResponse(false); - } - bool result = setEdidVersion (portId, edidVer); - if (result == false) { - returnResponse(false); - } - else { - returnResponse(true); - } - } - - uint32_t HdmiInput::getAVLatency(const JsonObject& parameters, JsonObject& response) - { - int audio_output_delay = 0; - int video_latency = 0; - - LOGINFO("calling HdmiInput::getHdmiDAL_AudioVideoLatency \n"); - try - { - device::HdmiInput::getInstance().getAVLatency(&audio_output_delay,&video_latency); - LOGINFO("HdmiInput::getHdmiDAL_AudioVideoLatency Audio Latency: %d, Video Latency: %d\n", audio_output_delay,video_latency); - response["AudioLatency"] = audio_output_delay; - response["VideoLatency"] = video_latency; - returnResponse(true); - } - catch(const device::Exception& err) - { - std::string api = "getHdmiDAL_AudioVideoLatency"; - LOG_DEVICE_EXCEPTION1(std::string(api)); - response["message"] = "Invalid response from getHdmiDAL_AudioVideoLatency"; - LOGINFO("ERROR:HdmiInput::getHdmiDAL_AudioVideoLatency Audio Latency: %d, Video Latency: %d\n", audio_output_delay,video_latency); - returnResponse(false); - } - - } - uint32_t HdmiInput::getHdmiVersionWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - string sPortId = parameters["portId"].String(); - int portId = 0; - - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - dsHdmiMaxCapabilityVersion_t hdmiCapVersion = HDMI_COMPATIBILITY_VERSION_14; - - try { - device::HdmiInput::getInstance().getHdmiVersion(portId, &(hdmiCapVersion)); - LOGWARN("HdmiInput::getHdmiVersion Hdmi Version:%d", hdmiCapVersion); - } - catch (const device::Exception& err) { - LOG_DEVICE_EXCEPTION1(std::to_string(portId)); - returnResponse(false); - } - - - switch ((int)hdmiCapVersion){ - case HDMI_COMPATIBILITY_VERSION_14: - response["HdmiCapabilityVersion"] = "1.4"; - break; - case HDMI_COMPATIBILITY_VERSION_20: - response["HdmiCapabilityVersion"] = "2.0"; - break; - case HDMI_COMPATIBILITY_VERSION_21: - response["HdmiCapabilityVersion"] = "2.1"; - break; - } - - - if(hdmiCapVersion == HDMI_COMPATIBILITY_VERSION_MAX) - { - returnResponse(false); - }else{ - returnResponse(true); - } - } - - uint32_t HdmiInput::getServiceState(PluginHost::IShell* shell, const string& callsign, PluginHost::IShell::state& state) - { - LOGINFO("entering getServiceState\n"); - uint32_t result; - auto interface = shell->QueryInterfaceByCallsign(callsign); - LOGINFO("received interface:\n"); - - if (interface == nullptr) { - result = Core::ERROR_UNAVAILABLE; - LOGINFO("no IShell\n"); - } - else { - result = Core::ERROR_NONE; - state = interface->State(); - LOGINFO("IShell state\n"); - interface->Release(); - } - LOGINFO("at the end of getSErviceState\n"); - return result; - } - - void HdmiInput::getControlSettingsPlugin() - { - LOGINFO("entering getControlSettingsPlugin\n"); - if(m_tv_client == nullptr) - { - LOGINFO("in if case\n"); - string token; - - // TODO: use interfaces and remove token - auto security = m_service->QueryInterfaceByCallsign("SecurityAgent"); - LOGINFO("received security code\n"); - if (security != nullptr) { - string payload = "http://localhost"; - if (security->CreateToken( - static_cast(payload.length()), - reinterpret_cast(payload.c_str()), - token) - == Core::ERROR_NONE) - { - LOGINFO("ControlSettings got security token\n"); - } - else { - LOGINFO("ControlSettings failed to get security token\n"); - } - security->Release(); - } - else { - LOGINFO("No security agent\n"); - } - - string query = "token=" + token; - Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T("127.0.0.1:9998"))); - m_tv_client = new WPEFramework::JSONRPC::LinkType(_T(TVSETTINGS_CALLSIGN_VER), (_T(TVSETTINGS_CALLSIGN_VER)), false, query); - LOGINFO("HdmiInput getControlSettingsPlugin init m_tv_client\n"); - } - } - - uint32_t HdmiInput::getTVLowLatencyMode(const JsonObject& parameters, JsonObject& response) - { - PluginHost::IShell::state state; - LOGINFOMETHOD(); - if ((getServiceState(m_service, TVSETTINGS_CALLSIGN, state) == Core::ERROR_NONE) && (state == PluginHost::IShell::state::ACTIVATED)) - { - LOGINFO("%s is active", TVSETTINGS_CALLSIGN); - - getControlSettingsPlugin(); - if(!m_tv_client) - { - LOGERR("TV Settings Initialisation failed\n"); - } - else{ - - JsonObject result; - JsonObject param; - - - int llmode = 0; - m_tv_client->Invoke(2000, "getLowLatencyState", param, result); - - if(result["success"].Boolean()) - { - string value = result.HasLabel("lowLatencyState") ? result["lowLatencyState"].String() : ""; - llmode = stoi(value); - - LOGINFO("value of the result: %d\n",llmode); - - if(llmode){ - response["lowLatencyMode"] = true; - LOGINFO("Low Latency Mode is enabled\n"); - returnResponse(true); - } - else{ - response["lowLatencyMode"] = false; - LOGINFO("Low Latency Mode is disabled\n"); - returnResponse(true); - } - } - else{ - - LOGERR("control settings Plugin returned error\n"); - returnResponse(false); - - } - } - } - else - { - LOGERR("control settings Plugin not ready\n"); - returnResponse(false); - } - - returnResponse(true); - } - - int HdmiInput::setEdidVersion(int iPort, int iEdidVer) - { - bool ret = true; - try - { - device::HdmiInput::getInstance().setEdidVersion (iPort, iEdidVer); - LOGWARN("HdmiInput::setEdidVersion EDID Version:%d", iEdidVer); - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - ret = false; - } - return ret; - } - - uint32_t HdmiInput::getEdidVersionWrapper(const JsonObject& parameters, JsonObject& response) - { - string sPortId = parameters["portId"].String(); - int portId = 0; - - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - int edidVer = getEdidVersion (portId); - switch (edidVer) - { - case HDMI_EDID_VER_14: - response["edidVersion"] = "HDMI1.4"; - break; - case HDMI_EDID_VER_20: - response["edidVersion"] = "HDMI2.0"; - break; - } - - if (edidVer < 0) { - returnResponse(false); - } - else { - returnResponse(true); - } - } - - int HdmiInput::getEdidVersion(int iPort) - { - int edidVersion = -1; - - try - { - device::HdmiInput::getInstance().getEdidVersion (iPort, &edidVersion); - LOGWARN("HdmiInput::getEdidVersion EDID Version:%d", edidVersion); - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return edidVersion; - } - - } // namespace Plugin -} // namespace WPEFramework diff --git a/HdmiInput/HdmiInput.h b/HdmiInput/HdmiInput.h deleted file mode 100644 index ff93202e5..000000000 --- a/HdmiInput/HdmiInput.h +++ /dev/null @@ -1,139 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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. -**/ - -#pragma once - -#include "libIBus.h" - -#include "Module.h" -#include "dsTypes.h" - -#define DEFAULT_PRIM_VOL_LEVEL 25 -#define MAX_PRIM_VOL_LEVEL 100 -#define DEFAULT_INPUT_VOL_LEVEL 100 - -namespace WPEFramework { - - namespace Plugin { - - // This is a server for a JSONRPC communication channel. - // For a plugin to be capable to handle JSONRPC, inherit from PluginHost::JSONRPC. - // By inheriting from this class, the plugin realizes the interface PluginHost::IDispatcher. - // This realization of this interface implements, by default, the following methods on this plugin - // - exists - // - register - // - unregister - // Any other methood to be handled by this plugin can be added can be added by using the - // templated methods Register on the PluginHost::JSONRPC class. - // As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC, - // this class exposes a public method called, Notify(), using this methods, all subscribed clients - // will receive a JSONRPC message as a notification, in case this method is called. - class HdmiInput : public PluginHost::IPlugin, public PluginHost::JSONRPC { - private: - - // We do not allow this plugin to be copied !! - HdmiInput(const HdmiInput&) = delete; - HdmiInput& operator=(const HdmiInput&) = delete; - - void InitializeIARM(); - void DeinitializeIARM(); - int m_primVolume; - int m_inputVolume; //Player Volume - - //Begin methods - uint32_t getHDMIInputDevicesWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t writeEDIDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t readEDIDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getRawHDMISPDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getHDMISPDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setEdidVersionWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getEdidVersionWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t startHdmiInput(const JsonObject& parameters, JsonObject& response); - uint32_t stopHdmiInput(const JsonObject& parameters, JsonObject& response); - uint32_t setMixerLevels(const JsonObject& parameters, JsonObject& response); - uint32_t setVideoRectangleWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getSupportedGameFeatures(const JsonObject& parameters, JsonObject& response); - uint32_t getHdmiGameFeatureStatusWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getAVLatency(const JsonObject& parameters, JsonObject& response); - uint32_t getTVLowLatencyMode(const JsonObject& parameters, JsonObject& response); - uint32_t getHdmiVersionWrapper(const JsonObject& parameters, JsonObject& response); - //End methods - - JsonArray getHDMIInputDevices(); - void writeEDID(int deviceId, std::string message); - std::string readEDID(int iPort); - std::string getRawHDMISPD(int iPort); - std::string getHDMISPD(int iPort); - int setEdidVersion(int iPort, int iEdidVer); - int getEdidVersion(int iPort); - bool getHdmiALLMStatus(int iPort); - - bool setVideoRectangle(int x, int y, int width, int height); - - void getControlSettingsPlugin(); - void getHdmiCecSinkPlugin(void); - PluginHost::IShell* m_service = nullptr; - WPEFramework::JSONRPC::LinkType* m_client; - WPEFramework::JSONRPC::LinkType* m_tv_client; - std::vector m_clientRegisteredEventNames; - uint32_t getServiceState(PluginHost::IShell* shell, const string& callsign, PluginHost::IShell::state& state); - - void hdmiInputHotplug( int input , int connect); - static void dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInputSignalChange( int port , int signalStatus); - static void dsHdmiSignalStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInputStatusChange( int port , bool isPresented); - static void dsHdmiStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInputVideoModeUpdate( int port , dsVideoPortResolution_t resolution); - static void dsHdmiVideoModeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInputALLMChange( int port , bool allmMode); - static void dsHdmiGameFeatureStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInputAviContentTypeChange(int port, int content_type); - static void dsHdmiAviContentTypeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInAVLatencyChange(int audio_output_delay,int video_latency); - static void dsHdmiAVLatencyEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void reportLatencyInfoToHdmiCecSink(); - void onGameModeEventHandler(const JsonObject& parameters); - uint32_t subscribeForTvMgrEvent(const char* eventName); - public: - HdmiInput(); - virtual ~HdmiInput(); - virtual const string Initialize(PluginHost::IShell* shell) override; - virtual void Deinitialize(PluginHost::IShell* service) override; - virtual string Information() const override { return {}; } - - void terminate(); - - BEGIN_INTERFACE_MAP(HdmiInput) - INTERFACE_ENTRY(PluginHost::IPlugin) - INTERFACE_ENTRY(PluginHost::IDispatcher) - END_INTERFACE_MAP - - public: - static HdmiInput* _instance; - }; - } // namespace Plugin -} // namespace WPEFramework diff --git a/HdmiInput/Module.cpp b/HdmiInput/Module.cpp deleted file mode 100644 index ce759b615..000000000 --- a/HdmiInput/Module.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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 "Module.h" - -MODULE_NAME_DECLARATION(BUILD_REFERENCE) diff --git a/HdmiInput/Module.h b/HdmiInput/Module.h deleted file mode 100644 index 54e672c37..000000000 --- a/HdmiInput/Module.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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. -**/ - -#pragma once -#ifndef MODULE_NAME -#define MODULE_NAME Plugin_HdmiInput -#endif - -#include -#include - -#undef EXTERNAL -#define EXTERNAL diff --git a/HdmiInput/README.md b/HdmiInput/README.md deleted file mode 100644 index 998e3280d..000000000 --- a/HdmiInput/README.md +++ /dev/null @@ -1,9 +0,0 @@ ------------------ -Build: - -bitbake wpeframework-service-plugins - ------------------ -Test: - -curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "HdmiInput.1."}' http://127.0.0.1:9998/jsonrpc diff --git a/HdmiInput/cmake/FindDS.cmake b/HdmiInput/cmake/FindDS.cmake deleted file mode 100644 index 926c02e0d..000000000 --- a/HdmiInput/cmake/FindDS.cmake +++ /dev/null @@ -1,57 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find Display Settings library -# Once done this will define -# DS_FOUND - System has DS -# DS_INCLUDE_DIRS - The DS include directories -# DS_LIBRARIES - The libraries needed to use DS -# DS_FLAGS - The flags needed to use DS -# - -find_package(PkgConfig) - -find_library(DS_LIBRARIES NAMES ds) -find_path(DS_INCLUDE_DIRS NAMES hdmiIn.hpp PATH_SUFFIXES rdk/ds) - -set(DS_LIBRARIES ${DS_LIBRARIES}) -set(DS_LIBRARIES ${DS_LIBRARIES} CACHE PATH "Path to DS library") -set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS}) -set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} CACHE PATH "Path to DS include") - - -find_library(DS_LIBRARIES NAMES ds) -#find_library(DSHAL_LIBRARIES NAMES dshalcli) -#find_path(DS_INCLUDE_DIRS NAMES manager.hpp PATH_SUFFIXES rdk/ds) -find_path(DSHAL_INCLUDE_DIRS NAMES dsTypes.h PATH_SUFFIXES rdk/halif/ds-hal) -find_path(DSRPC_INCLUDE_DIRS NAMES dsMgr.h PATH_SUFFIXES rdk/ds-rpc) - -#set(DS_LIBRARIES ${DS_LIBRARIES} ${DSHAL_LIBRARIES}) -#set(DS_LIBRARIES ${DS_LIBRARIES} CACHE PATH "Path to DS library") -set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} ${DSHAL_INCLUDE_DIRS} ${DSRPC_INCLUDE_DIRS}) -#set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} CACHE PATH "Path to DS include") - - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(DS DEFAULT_MSG DS_INCLUDE_DIRS DS_LIBRARIES) - -mark_as_advanced( - DS_FOUND - DS_INCLUDE_DIRS - DS_LIBRARIES - DS_LIBRARY_DIRS - DS_FLAGS) diff --git a/HdmiInput/cmake/FindIARMBus.cmake b/HdmiInput/cmake/FindIARMBus.cmake deleted file mode 100644 index bc716bcd9..000000000 --- a/HdmiInput/cmake/FindIARMBus.cmake +++ /dev/null @@ -1,44 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find IARMBus -# Once done this will define -# IARMBUS_FOUND - System has IARMBus -# IARMBUS_INCLUDE_DIRS - The IARMBus include directories -# IARMBUS_LIBRARIES - The libraries needed to use IARMBus -# IARMBUS_FLAGS - The flags needed to use IARMBus -# - -find_package(PkgConfig) - -find_library(IARMBUS_LIBRARIES NAMES IARMBus) -find_path(IARMIR_INCLUDE_DIRS NAMES sysMgr.h PATH_SUFFIXES rdk/iarmmgrs/sysmgr) - -set(IARMBUS_LIBRARIES ${IARMBUS_LIBRARIES} CACHE PATH "Path to IARMBus library") -set(IARMBUS_INCLUDE_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS} ${SYSMGR_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS../sysmgr} ) -set(IARMBUS_INCLUDE_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS} ${SYSMGR_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS../sysmgr} CACHE PATH "Path to IARMBus include") - - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(IARMBUS DEFAULT_MSG IARMBUS_INCLUDE_DIRS IARMBUS_LIBRARIES) - -mark_as_advanced( - IARMBUS_FOUND - IARMBUS_INCLUDE_DIRS - IARMBUS_LIBRARIES - IARMBUS_LIBRARY_DIRS - IARMBUS_FLAGS) diff --git a/L2HalMock/README.md b/L2HalMock/README.md deleted file mode 100644 index 1a0892172..000000000 --- a/L2HalMock/README.md +++ /dev/null @@ -1,139 +0,0 @@ - -README contains all the dependencies based on the peru yml file and steps to build the emulator binaries.All the run time instructions ,VM setup instructions and package dependency instructions are captured in this repo - - - -# Utils dependencis for ubuntu 22.04 machine ------------------------------------------------- - - - - -## Generic dependencies ---------------------- -sudo apt install -y git - -pip install flake8 - -sudo pip install peru - -sudo apt-get install -y libtool - -suod apt install -y autoconf - -sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa -y - -sudo apt update - -sudo apt install -y g++-9 gcc-9 - -sudo apt-get install -y libglib2.0-dev - -sudo apt-get install -y libdbus-1-dev - -sudo apt-get install -y curl - - -# Install system-level dependencies -RUN apt-get update && \ - apt-get install -y \ - git \ - wget \ - vim \ - build-essential \ - libtool \ - autoconf \ - g++-9 \ - gcc-9 \ - libglib2.0-dev \ - libdbus-1-dev \ - curl \ - cmake \ - ninja-build \ - net-tools \ - netcat \ - psmisc \ - libusb-1.0-0-dev \ - zlib1g-dev \ - libssl-dev \ - python3-pip \ - libjsoncpp-dev \ - libjansson4 \ - libjansson-dev \ - libcurl4-openssl-dev \ - libwebsocketpp-dev \ - libwebsockets-dev \ - libboost-all-dev - -# Create a directory in the image where you want to copy the files -RUN mkdir -p /usr/lib/aarch64-linux-gnu/ - -# Copy files from the host machine to the image -RUN cp -r /usr/lib/x86_64-linux-gnu/dbus-1.0 /usr/lib/aarch64-linux-gnu/ - -# Copy the custom config files to the appropriate location in the image -COPY dbus/system.conf /usr/share/dbus-1/system.conf -COPY dbus/session.conf /usr/share/dbus-1/session.conf - - -## Thuder dependencies --------------------- -sudo apt install -y build-essential cmake ninja-build libusb-1.0-0-dev zlib1g-dev libssl-dev - -sudo apt install -y python3-pip - -pip install jsonref - -## Hdmicec emulator hal dependencies ----------------------------------- -sudo apt-get install -y libjsoncpp-dev - -sudo apt-get install -y libjansson4 libjansson-dev - -sudo apt-get install -y libcurl4-openssl-dev - -sudo apt-get install -y libwebsocketpp-dev - -sudo apt-get install -y libwebsockets-dev - -pip install websockets - -sudo apt-get install -y libboost-all-dev - -## flask server dependencies ----------------------------- -sudo pip install pandas - -sudo pip install beautifulsoup4 - -sudo pip install flask - -sudo pip install colorama - --------------------------------------------------- -# pre-setup -# clone rdk-e/rdkservices repository -# After cloning rdkservices.git, clone the repository https://github.com/rdk-e/FLASK-FOR-HAL-MOCK -# switch to branch peru, copy the peru.yaml file present insde the repo to L2HalMock folder inside rdkservices - -# Build step ------------------------------------------------ -./build.sh - -# Using Debug Build we can build individual modules ------------------------------------------------ -./debug_build.sh - -# Execute the framework ------------------------------------------------ -./run.sh - -# For executing test scripts ------------------------------------------------ -cd workspace/deps/rdk/flask/Test_Framework - -update details in Config.py - -python3 TestManager.py - - diff --git a/L2HalMock/README_CICD b/L2HalMock/README_CICD deleted file mode 100644 index ffebc8c98..000000000 --- a/L2HalMock/README_CICD +++ /dev/null @@ -1,18 +0,0 @@ - README FOR CI CD HAL MOCK WORKFLOW - - - ---> HAL_MOCK yml is the workflow file designed to pull/setup the container/docker, build the binaries and execute testcases on the hal mock virtual environment. ---> A pull request/push on from a branch to sprint,release,develop and main triggers the HAL_MOCK yml. ---> Paths excluded in the yaml file are tools,tests,.github workflows and readme docs. Which makes the workflow to not trigger job when changes happens in any of these files. ---> Conditional commit message check has also been enabled in the workflow,which allows the user to trigger the hal mock environment job only when user specifies hdmicecsource_halmock in the commit message. ---> Workflow steps are:- - --> pull the customized docker from JFROG artifactory. - --> clone and build the required binaries for the mock environment inside docker. - --> make all services up - --> execute the currently developed testcases (L2) on Hdmicec source. - --> generate a test report containing the execution details. - --> fetch the report, upload it as an artifact. - --> users can download this test report artifact from the executed job summary. - --> stop all services ---> Destroy the container/Docker diff --git a/L2HalMock/Sample_Flask_Script.py b/L2HalMock/Sample_Flask_Script.py deleted file mode 100644 index 705bee3dd..000000000 --- a/L2HalMock/Sample_Flask_Script.py +++ /dev/null @@ -1,127 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -import requests -import json - -flask_server = "127.0.0.1:8000" - -config_data = { - "apiName": "setDeviceConfig", - "arguments": { - "devices": [ - { - "device": [ - {"name": "xione_uk"}, - {"islocal": 1}, - {"type": "source"}, - {"powerState": 1}, - {"physicalAddress": "301"}, - {"logicalAddress": "3"}, - {"vendorId": "4567"}, - {"osdName": "404753747265616D696E672054776F"}, - {"optionalProperty1": "value1"}, - {"optionalProperty2": "value2"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 1}, - {"physicalAddress": "304"}, - {"logicalAddress": "4"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"optionalProperty1": "value1"}, - {"optionalProperty2": "value2"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 1}, - {"physicalAddress": "304"}, - {"logicalAddress": "9"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"optionalProperty1": "value1"}, - {"optionalProperty2": "value2"} - ] - }, - { - "device": [ - {"name": "hisense"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 1}, - {"physicalAddress": "0"}, - {"logicalAddress": "0"}, - {"vendorId": "0x4567"}, - {"osdName": "545620426F78"}, - {"optionalProperty1": "value1"}, - {"optionalProperty2": "value2"} - ] - } - ] - } - } - -api_data = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecOpen": [ - { "return": 1 }, - { "outParams": [{"handle": 2345678}] } - ] - }, - { - "HdmiCecGetLogicalAddress": [ - { "return": 0 }, - { "outParams": [{"logicalAddress": "0x4"}] } - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - { "return": 0 }, - { "outParams": [{"physicalAddress": "0x304"}] } - ] - } - ] - } - } - - -# fetch the cec network data from flask using http get requests -createDevice_response = requests.get("http://{}/Database.setDeviceConfig/{}".format(flask_server, json.dumps(config_data))) -print(createDevice_response.text) - -# fetch the api overrides data from flask using http get requests -createApiOverrides_response = requests.get("http://{}/Hdmicec.setAPIConfig/{}".format(flask_server, json.dumps(api_data))) -print(createApiOverrides_response.text) - - diff --git a/L2HalMock/build.sh b/L2HalMock/build.sh deleted file mode 100644 index 5f1232471..000000000 --- a/L2HalMock/build.sh +++ /dev/null @@ -1,221 +0,0 @@ -#!/bin/bash - -# Access the passed plugins inside the script -SelectedPlugins="$1" - -echo "Building for Plugins: $SelectedPlugins" - -# Check for the presence of "string to find" -if grep -q "HdmiCecSource" <<< "$SelectedPlugins"; then - echo "Found: $SelectedPlugins" - HdmiCecSource="ON" -fi - -if grep -q "HdmiCecSink" <<< "$SelectedPlugins"; then - echo "Found: $SelectedPlugins" - HdmiCecSink="ON" -fi - -# Define ANSI color codes for green -GREEN='\033[0;32m' # Green text -NC='\033[0m' # No color (resets to default) - -SCRIPT=$(readlink -f "$0") -SCRIPTS_DIR=`dirname "$SCRIPT"` -RDK_DIR=$SCRIPTS_DIR/../ -WORKSPACE=$SCRIPTS_DIR/workspace -rm -rf $WORKSPACE; -mkdir $WORKSPACE; - -cd $WORKSPACE -echo -e "${GREEN}========================================Building thunder tools===============================================${NC}" -git clone -b R4_4 https://github.com/rdkcentral/ThunderTools.git -cmake -G Ninja -S ThunderTools -B $WORKSPACE/build/ThunderTools -DCMAKE_INSTALL_PREFIX="$WORKSPACE/install/usr" -cmake --build $WORKSPACE/build/ThunderTools --target install - -cd $WORKSPACE -echo -e "${GREEN}========================================Building Thunder===============================================${NC}" -git clone -b R4_4 https://github.com/rdkcentral/Thunder.git -cmake -G Ninja -S Thunder -B $WORKSPACE/build/Thunder -DBINDING="127.0.0.1" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_INSTALL_PREFIX="$WORKSPACE/install/usr" -DCMAKE_MODULE_PATH="${WORKSPACE}/install/usr/include/WPEFramework/Modules" -DDATA_PATH="${WORKSPACE}/install/usr/share/WPEFramework" -DPERSISTENT_PATH="${WORKSPACE}/install/var/wpeframework" -DPORT="55555" -DPROXYSTUB_PATH="${WORKSPACE}/install/usr/lib/wpeframework/proxystubs" -DSYSTEM_PATH="${WORKSPACE}/install/usr/lib/wpeframework/plugins" -DVOLATILE_PATH="tmp" -cmake --build $WORKSPACE/build/Thunder --target install - -echo -e "${GREEN}========================================Do peru sync===============================================${NC}" -(cp $SCRIPTS_DIR/peru.yaml . && peru sync && peru sync --no-cache) - - -echo -e "${GREEN}========================================Building flux===============================================${NC}" -(cd $WORKSPACE/deps/third-party/flux && autoreconf; autoreconf -f -i && ./configure && make && make install && cd -) - - -echo -e "${GREEN}========================================Building directfb===============================================${NC}" -(cd $WORKSPACE/deps/third-party/directfb && autoreconf; autoreconf -f -i && ./configure && make && make install && cd -) - - -echo -e "${GREEN}========================================Building log4c===============================================${NC}" -(cd $WORKSPACE/deps/third-party/log4c && autoreconf; autoreconf -f -i && ./configure && make && make install && cd -) - -set +e #exit on error -echo -e "${GREEN}========================================Building safeclib===============================================${NC}" -(cd $WORKSPACE/deps/third-party/safeclib && autoreconf; autoreconf -f -i && ./configure && make && make install && cd -) - -echo -e "${GREEN}========================================Building dbus===============================================${NC}" -(cd $WORKSPACE/deps/third-party/dbus/ && autoreconf; autoreconf -f -i && ./configure && make && make install && cd -) - -echo -e "${GREEN}========================================Build glib===============================================${NC}" -(cd $WORKSPACE/deps/third-party/glib && meson _build && ninja -C _build ) - -echo -e "${GREEN}========================================SafeC header===============================================${NC}" -# cp -r $WORKSPACE/deps/rdk/safec/recipes-common/safec-common-wrapper/files/safec_lib.h /usr/include -cp -r $SCRIPTS_DIR/patches/rdkservices/iarmbus/safec_lib.h /usr/include -cd $WORKSPACE/deps/rdk/safec/recipes-common/safec-common-wrapper/files -# ls -cp -r $WORKSPACE/deps/third-party/safeclib/include/safe_str_lib.h /usr/include -# cp -r $SCRIPTS_DIR/patches/rdkservices/iarmbus/safe_str_lib.h /usr/include -cp -r $WORKSPACE/deps/third-party/safeclib/include/safe_config.h /usr/include -cp -r $WORKSPACE/deps/third-party/safeclib/include/safe_lib_errno.h /usr/include -cp -r $WORKSPACE/deps/third-party/safeclib/include/safe_types.h /usr/include -cp -r $WORKSPACE/deps/third-party/safeclib/include/safe_compile.h /usr/include -cp -r $WORKSPACE/deps/third-party/safeclib/include/safe_mem_lib.h /usr/include -cp -r $WORKSPACE/deps/third-party/dbus/dbus/*.h /usr/include/dbus-1.0/dbus -cp -r /usr/local/lib/libsafec* /usr/lib/ -cp -r $WORKSPACE/deps/third-party/glib/_build/glib/glibconfig.h /usr/include -cp -r $WORKSPACE/deps/rdk/halif-power_manager/include/*.h /usr/include -cp -r $WORKSPACE/deps/rdk/halif-deepsleep_manager/include/deepSleepMgr.h /usr/include -cp -r $WORKSPACE/deps/rdk/SyscallWrapper/source/secure_wrapper.h /usr/include -cp -r $WORKSPACE/deps/rdk/iarmmgrs/mfr/include/*.h /usr/include -cp -r $WORKSPACE/deps/rdk/iarmmgrs/hal/include/*.h /usr/include -cp -r $WORKSPACE/deps/rdk/iarmmgrs/sysmgr/include/*.h /usr/include -set +e #exit on error - - -echo -e "${GREEN}========================================iarmmgrs-emulator===============================================${NC}" -(cd $WORKSPACE/deps/rdk/iarmmgrs-emulator && ./build.sh) -mkdir -p $WORKSPACE/deps/rdk/iarmmgrs/install/lib -cp -r $WORKSPACE/deps/rdk/iarmmgrs-emulator/power/*.so $WORKSPACE/deps/rdk/iarmmgrs/install/lib -cp -r $WORKSPACE/deps/rdk/iarmmgrs-emulator/ir/*.so $WORKSPACE/deps/rdk/iarmmgrs/install/lib - -echo "Entering directory $PWD" -cp $SCRIPTS_DIR/env.sh $WORKSPACE/env.sh -cp $SCRIPTS_DIR/invokeEnv.sh $WORKSPACE/deps/rdk/env.sh -cd $WORKSPACE -set -e #exit on error -source ./env.sh - -set -x #enable debugging mode -# Build IARM -echo -e "${GREEN}========================================Build IARM===============================================${NC}" -cd $WORKSPACE/deps/rdk/iarmbus/ -rm build.sh -cp $SCRIPTS_DIR/patches/rdkservices/iarmbus/build.sh $WORKSPACE/deps/rdk/iarmbus/ -(cd $WORKSPACE/deps/rdk/iarmbus/ && ./build.sh) - -# Build DSHalMrg -echo -e "${GREEN}========================================Build DSHalMrg===============================================${NC}" -# Build DSHalMrg -(cd $WORKSPACE/deps/rdk/devicesettings/hal && make && make install) - -echo -e "${GREEN}========================================Build DeviceSettings===============================================${NC}" -# Build DeviceSettings -cd /usr/include/ -mkdir wdmp-c -cp $SCRIPTS_DIR/patches/rdkservices/files/wdmp-c.h /usr/include/wdmp-c -cp $SCRIPTS_DIR/patches/rdkservices/rfcapi.h /usr/include -cp $WORKSPACE/deps/rdk/halif-deepsleep_manager/include/deepSleepMgr.h /usr/include -(cd $WORKSPACE/deps/rdk/devicesettings/ && ./build.sh) - -echo -e "${GREEN}========================================Build glib===============================================${NC}" -(cd $WORKSPACE/deps/third-party/glib && meson _build && ninja -C _build && ninja -C _build install) -cp $WORKSPACE/deps/third-party/glib/_build/glib/glibconfig.h /usr/include/glib-2.0 - -echo -e "${GREEN}========================================iarm_event_Sender===============================================${NC}" -(cd $WORKSPACE/deps/rdk/sender/ && ./build.sh) - - -echo -e "${GREEN}========================================Build iarmmgr===============================================${NC}" -# Build iarmmgr -cd $WORKSPACE/deps/rdk/iarmmgrs -patch -s -p1 < $SCRIPTS_DIR/patches/rdkservices/iarmmgrs/ds.patch -rm build.sh -cp $SCRIPTS_DIR/patches/rdkservices/iarmmgrs/build.sh $WORKSPACE/deps/rdk/iarmmgrs -(cd $WORKSPACE/deps/rdk/iarmmgrs && ./build.sh) - -echo -e "${GREEN}========================================Build HdmiCec===============================================${NC}" -# Build HdmiCec -mv $WORKSPACE/deps/rdk/hdmicec/soc/L2HalMock/common $WORKSPACE/deps/rdk/hdmicec/soc/L2HalMock/common_bkp; -mv $WORKSPACE/deps/rdk/hdmicec/soc/L2HalMock/hdmicec-hal-emulator $WORKSPACE/deps/rdk/hdmicec/soc/L2HalMock/common -(cd $WORKSPACE/deps/rdk/hdmicec/ && ./build.sh) - -echo -e "${GREEN}========================================Build HdmiCecSource===============================================${NC}" -# Build HdmiCecSource -cd $WORKSPACE/install/usr/include/WPEFramework/Modules/ -patch -s -p0 < $SCRIPTS_DIR/patches/rdkservices/FindConfigGenerator_cmake.patch - -if grep -q "HdmiCecSource" <<< "$SelectedPlugins"; then -cp $SCRIPTS_DIR/patches/rdkservices/properties/HdmiCecSource/device.properties /etc/ -fi - -if grep -q "HdmiCecSink" <<< "$SelectedPlugins"; then -cp $SCRIPTS_DIR/patches/rdkservices/properties/HdmiCecSink/device.properties /etc/ -fi - -cd $WORKSPACE/ -#Run time dependency -mkdir -p $WORKSPACE/install/etc/WPEFramework/plugins -cp $SCRIPTS_DIR/patches/rdkservices/files/HdmiCecSource.json $WORKSPACE/install/etc/WPEFramework/plugins/ -cp $SCRIPTS_DIR/patches/rdkservices/files/HdmiCecSink.json $WORKSPACE/install/etc/WPEFramework/plugins/ - -#Code Coverage patch -# cd $RDK_DIR -# patch -s -p1 < $SCRIPTS_DIR/patches/rdkservices/HdmiCecSource.patch -# patch -s -p1 < $SCRIPTS_DIR/patches/rdkservices/HdmiCecSink.patch -# patch -s -p1 < $SCRIPTS_DIR/patches/rdkservices/FrontPanel.patch -# patch -s -p1 < $SCRIPTS_DIR/patches/rdkservices/Hdcp_Profile.patch - -#included CmakeHelperFunctions.cmake instead to during in CMakeLists.txt -cp ${WORKSPACE}/install/usr/lib/cmake/WPEFramework/common/CmakeHelperFunctions.cmake $WORKSPACE/install/usr/include/WPEFramework/Modules -cp -r $RDK_DIR/Tests/L2HALMockTests/. $WORKSPACE/deps/rdk/flask -cp $RDK_DIR/L2HalMock/patches/rdkservices/files/rfcapi.h $RDK_DIR/helpers - -#wdmp dependency -cd /usr/local/include/ -mkdir wdmp-c -cp $SCRIPTS_DIR/patches/rdkservices/files/wdmp-c.h /usr/local/include/wdmp-c - -cd /usr/include/ -mkdir rdk -cd /usr/include/rdk - - -sed -i 's/sendNotify/Notify/g' $RDK_DIR/HdmiCecSource/HdmiCecSource.cpp -sed -i 's/sendNotify/Notify/g' $RDK_DIR/HdmiCecSink/HdmiCecSink.cpp -sed -i 's/sendNotify/Notify/g' $RDK_DIR/HdcpProfile/HdcpProfile.cpp - -cd $RDK_DIR; -cmake -S . -B build \ --DCMAKE_INSTALL_PREFIX="$WORKSPACE/install/usr" \ --DCMAKE_MODULE_PATH="$WORKSPACE/install/usr/include/WPEFramework/Modules" \ --DRDK_SERVICE_L2HALMOCK=ON \ --DUSE_THUNDER_R4=ON \ --DPLUGIN_HDMICECSOURCE=$HdmiCecSource \ --DPLUGIN_HDMICECSINK=$HdmiCecSink \ --DCOMCAST_CONFIG=OFF \ --DCEC_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/hdmicec/ccec/include" \ --DOSAL_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/hdmicec/osal/include" \ --DCEC_HOST_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/hdmicec/host/include" \ --DDS_LIBRARIES="$SCRIPTS_DIR/workspace/deps/rdk/devicesettings/install/lib/libds.so" \ --DDS_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/devicesettings/ds/include" \ --DDSHAL_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/devicesettings/hal/include" \ --DDSRPC_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/devicesettings/rpc/include" \ --DIARMBUS_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/iarmbus/core/include" \ --DIARMRECEIVER_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/iarmmgrs/receiver/include" \ --DIARMPWR_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/iarmmgrs/hal/include" \ --DCEC_LIBRARIES="$SCRIPTS_DIR/workspace/deps/rdk/hdmicec/install/lib/libRCEC.so" \ --DIARMBUS_LIBRARIES="$SCRIPTS_DIR/workspace/deps/rdk/iarmbus/install/libIARMBus.so" \ --DDSHAL_LIBRARIES="$SCRIPTS_DIR/workspace/deps/rdk/devicesettings/install/lib/libdshalcli.so" \ --DCEC_HAL_LIBRARIES="$SCRIPTS_DIR/workspace/deps/rdk/hdmicec/install/lib/libRCECHal.so" \ --DOSAL_LIBRARIES="$SCRIPTS_DIR/workspace/deps/rdk/hdmicec/install/lib/libRCECOSHal.so" \ --DCMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage -Wall -Werror -Wno-error=format=-Wl,-wrap,system -Wl,-wrap,popen -Wl,-wrap,syslog" - -(cd $RDK_DIR && cmake --build build --target install) - -set +x #disable debugging mode diff --git a/L2HalMock/dbus/session.conf b/L2HalMock/dbus/session.conf deleted file mode 100644 index cf9662c10..000000000 --- a/L2HalMock/dbus/session.conf +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - session - - - - - unix:tmpdir=/tmp - - - EXTERNAL - - - - - - - - - - - - - - /etc/dbus-1/session.conf - - - session.d - - /etc/dbus-1/session.d - - - /etc/dbus-1/session-local.conf - - contexts/dbus_contexts - - - - - 1000000000 - 250000000 - 1000000000 - 250000000 - 1000000000 - - 120000 - 240000 - 150000 - 100000 - 10000 - 100000 - 10000 - 50000 - 50000 - 50000 - - diff --git a/L2HalMock/dbus/system.conf b/L2HalMock/dbus/system.conf deleted file mode 100644 index c7314d515..000000000 --- a/L2HalMock/dbus/system.conf +++ /dev/null @@ -1,229 +0,0 @@ - - - - - - - - - - - system - - - - messagebus - - - - - - - - - - - - /usr/libexec/dbus-daemon-launch-helper - - - - /var/run/dbus/pid - - - - - - - - EXTERNAL - - - - unix:path=/run/dbus/system_bus_socket - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /etc/dbus-1/system.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - system.d - - /etc/dbus-1/system.d - - - - /etc/dbus-1/system-local.conf - - contexts/dbus_contexts - - - - diff --git a/L2HalMock/debug_build.sh b/L2HalMock/debug_build.sh deleted file mode 100644 index 4c1fd7899..000000000 --- a/L2HalMock/debug_build.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash - -# Define ANSI color codes for green -GREEN='\033[0;32m' # Green text -YELLOW='\033[0;33m' # Yellow text -NC='\033[0m' # No color (resets to default) - -SCRIPT=$(readlink -f "$0") -SCRIPTS_DIR=`dirname "$SCRIPT"` -RDK_DIR=$SCRIPTS_DIR/../ -WORKSPACE=$SCRIPTS_DIR/workspace - -PS3='Please enter your choice: ' -options=("Build IARM" "Build DeviceSettings" "Build HdmiCec" "Build rdkservices" "Build All" "Quit") -# set -x #enable debugging mode -select opt in "${options[@]}" -do - case $opt in - "Build IARM") - echo "you chose choice $opt" - # Build IARM - echo -e "${GREEN}========================================Build IARM===============================================${NC}" - (cd $WORKSPACE/deps/rdk/iarmbus/ && ./build.sh) - ;; - "Build DeviceSettings") - echo "you chose choice $opt" - echo -e "${GREEN}========================================Build DeviceSettings===============================================${NC}" - # Build DeviceSettings - (cd $WORKSPACE/deps/rdk/devicesettings/ && ./build.sh) - ;; - - "Build HdmiCec") - echo "you chose choice $opt" - echo -e "${GREEN}========================================Build HdmiCec===============================================${NC}" - # Build HdmiCec - (cd $WORKSPACE/deps/rdk/hdmicec/ && ./build.sh) - ;; - - "Build rdkservices") - echo "you chose choice $opt" - echo -e "${GREEN}========================================Build rdkservices===============================================${NC}" - cd $RDK_DIR; - - cmake -S . -B build \ - -DCMAKE_INSTALL_PREFIX="$WORKSPACE/install/usr" \ - -DCMAKE_MODULE_PATH="$WORKSPACE/install/usr/include/WPEFramework/Modules" \ - -DPLUGIN_HDMICECSOURCE=ON \ - -DPLUGIN_HDMICECSINK=ON \ - -DUSE_THUNDER_R4=ON \ - -DCOMCAST_CONFIG=OFF \ - -DCEC_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/hdmicec/ccec/include" \ - -DOSAL_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/hdmicec/osal/include" \ - -DCEC_HOST_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/hdmicec/host/include" \ - -DDS_LIBRARIES="$SCRIPTS_DIR/workspace/deps/rdk/devicesettings/install/lib/libds.so" \ - -DDS_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/devicesettings/ds/include" \ - -DDSHAL_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/devicesettings/hal/include" \ - -DDSRPC_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/devicesettings/rpc/include" \ - -DIARMBUS_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/iarmbus/core/include" \ - -DIARMRECEIVER_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/iarmmgrs/receiver/include" \ - -DIARMPWR_INCLUDE_DIRS="$SCRIPTS_DIR/workspace/deps/rdk/iarmmgrs/hal/include" \ - -DCEC_LIBRARIES="$SCRIPTS_DIR/workspace/deps/rdk/hdmicec/install/lib/libRCEC.so" \ - -DIARMBUS_LIBRARIES="$SCRIPTS_DIR/workspace/deps/rdk/iarmbus/install/libIARMBus.so" \ - -DDSHAL_LIBRARIES="$SCRIPTS_DIR/workspace/deps/rdk/devicesettings/install/lib/libdshalcli.so" \ - -DCEC_HAL_LIBRARIES="$SCRIPTS_DIR/workspace/deps/rdk/hdmicec/install/lib/libRCECHal.so" \ - -DOSAL_LIBRARIES="$SCRIPTS_DIR/workspace/deps/rdk/hdmicec/install/lib/libRCECOSHal.so" \ - -DCMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage -Wall -Werror -Wno-error=format=-Wl,-wrap,system -Wl,-wrap,popen -Wl,-wrap,syslog" - - (cd $RDK_DIR && cmake --build build --target install) - ;; - - "Build All") - echo "you chose choice $opt" - echo -e "${GREEN}========================================Building All===============================================${NC}" - ./build.sh - ;; - - "Quit") - break - ;; - *) echo "invalid option $REPLY";; - esac - echo -e "${YELLOW}1) Build IARM 2) Build DeviceSettings 3) Build HdmiCec 4) Build rdkservices 5) Build All 6) Quit${NC}" -done - -set +x #disable debugging mode diff --git a/L2HalMock/env.sh b/L2HalMock/env.sh deleted file mode 100644 index fa6841913..000000000 --- a/L2HalMock/env.sh +++ /dev/null @@ -1,91 +0,0 @@ -set -x #enable debugging mode - -source /root/.bashrc -#If Local compliation enable below -# source ~/.bashrc - -export PLATFORM_SOC=intel - -SCRIPT=$(readlink -f "$0") -#SCRIPTS_DIR=`dirname "$SCRIPT"` -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -export BUILDS_DIR=$SCRIPT_DIR/workspace -export RDK_PROJECT_ROOT_PATH=$SCRIPT_DIR/workspace/deps/rdk -export COMBINED_ROOT=$BUILDS_DIR -export NUM_DIR=$BUILDS_DIR/96e2377 -export DS_PATH=$BUILDS_DIR/deps/rdk/devicesettings -export USE_DBUS=y -export TOOLCHAIN_DIR=$COMBINED_ROOT/sdk/toolchain/staging_dir -export CROSS_TOOLCHAIN=/usr -export CROSS_COMPILE=$CROSS_TOOLCHAIN/bin/i686-cm-linux -export CC=gcc-9 -export CXX=g++-9 -export OPENSOURCE_BASE=/usr -#export DFB_ROOT=$TOOLCHAIN_DIR -export DFB_LIB=$TOOLCHAIN_DIR/lib -export IARM_PATH=$BUILDS_DIR/deps/rdk/iarmbus -export FUSION_PATH=$BUILDS_DIR/deps/rdk/fusiondale -export SDK_FSROOT=$COMBINED_ROOT/sdk/fsroot/ramdisk -export FSROOT=$COMBINED_ROOT -export GLIB_INCLUDE_PATH=$CROSS_TOOLCHAIN/include/glib-2.0 -export GLIB_LIBRARY_PATH=/usr/local/lib -# export GLIB_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu -export GLIB_CONFIG_INCLUDE_PATH=$GLIB_LIBRARY_PATH/glib-2.0 -export GLIB_CONFIG_PATH=$GLIB_LIBRARY_PATH/glib-2.0 -export GLIBS='-lglib-2.0 -lz' - -export MFR_PATH=$COMBINED_ROOT/ri/mpe_os/platforms/intel/groveland/mfrlibs -export MFR_FPD_PATH=$COMBINED_ROOT/mfrlibs -export _ENABLE_WAKEUP_KEY=-D_ENABLE_WAKEUP_KEY -export RF4CE_PATH=$COMBINED_ROOT/rf4ce/ -export USE_GREEN_PEAK_RF4CE_INTERFACE=-DUSE_GREEN_PEAK_RF4CE_INTERFACE - -export IARM_LIB_PATH=$BUILDS_DIR/deps/rdk/iarmbus/install -THUNDER_LIB_PATH=$BUILDS_DIR/install/usr/lib -THUNDER_PATH=$BUILDS_DIR/install/usr/bin - -export SAFEC_INCLUDE_PATH=$BUILDS_DIR/deps/third-party/safeclib/src/.libs/ - -#export SAFECLIB_PATH=$BUILDS_DIR/deps/third-party/safeclib/include/ -export SAFEC_INCLUDE_PATH=/usr/local/include/libsafec - -export DFB_INCLUDE_PATH=/usr/local/include/directfb - -export HDMICEC_PATH=$BUILDS_DIR/deps/rdk/hdmicec -#export CCEC_HOST=${HDMICEC_PATH}/host/include/ccec/host -#export INCLUDE_DRI_IARMBUS=${HDMICEC_PATH}/ccec/drivers/include/ccec/drivers/iarmbus -#export CCEC_INCLUDE_CCEC=${HDMICEC_PATH}/ccec/include/ccec -#export DS_HAL_INCLUDE=${DS_PATH}/hal/include -#export DS_RPC_INCLUDE=${DS_PATH}/rpc/include -#export DS_DS_INCLUDE=${DS_PATH}/ds/include -#export IARM_CORE_INC=$BUILDS_DIR/deps/rdk/iarmbus/core/include -#export INCLUDE_OSAL=$BUILDS_DIR/deps/rdk/hdmicec/osal/include/osal -#export NUM_HAL_INCLUDE=$BUILDS_DIR/96e2377/hal/include -#export NUM_COMMON_INC=$NUM_DIR/mfr/common/include -#export NUM_IR_INC=$NUM_DIR/ir/include -#export NUM_POW_INC=$NUM_DIR/power/include -#export NUM_PWMGR_INC=$NUM_DIR/pwrmgr2/include -#export NUM_REC_INC=$NUM_DIR/receiver/include -HDMICEC_LIB_PATH=${HDMICEC_PATH}/install/lib - -DS_LIB_PATH=${DS_PATH}/install/lib - -export LD_LIBRARY_PATH=${THUNDER_LIB_PATH}:${IARM_LIB_PATH}:${HDMICEC_LIB_PATH}:${DS_LIB_PATH} - -DS_INCLUDE_PATH=${DS_PATH}/ds/include -IARM_INCLUDE_PATH=${IARM_PATH}/core/include -IARM_LIB_PATH=${IARM_PATH}/install -export IARM_MGRS_PATH=$BUILDS_DIR/deps/rdk/iarmmgrs -export IARM_MGRS=$BUILDS_DIR/deps/rdk/iarmmgrs -export GLIB_HEADER_PATH=$CROSS_TOOLCHAIN/include/glib-2.0 -export PLATFORM_SOC=L2HalMock -export UTILS_PATH=$IARM_MGRS/utils - -# Temporary -PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin - -export PATH=${IARM_MGRS}:${HDMICEC_PATH}:${HDMICEC_LIB_PATH}:${DS_PATH}:${IARM_PATH}:${IARM_LIB_PATH}:${DS_INCLUDE_PATH}:${DS_LIB_PATH}:${THUNDER_PATH}:${PATH} - -set +x #disable debugging mode - -echo "Done!" diff --git a/L2HalMock/generate_coveragereport.sh b/L2HalMock/generate_coveragereport.sh deleted file mode 100644 index 853a65684..000000000 --- a/L2HalMock/generate_coveragereport.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# Define ANSI color codes for green -GREEN='\033[0;32m' # Green text -NC='\033[0m' # No color (resets to default) - -SCRIPT=$(readlink -f "$0") -SCRIPTS_DIR=`dirname "$SCRIPT"` -RDK_DIR=$SCRIPTS_DIR/../ - -echo -e "${GREEN}======================== Kill WPEFramework ====================================${NC}" -killall -QUIT WPEFramework -sleep 5 -echo -e "${GREEN}======================== Generate coverage Report ====================================${NC}" -cp ${RDK_DIR}/Tests/L2HALMockTests/Test_Framework/.lcovrc_halmock ~/.lcovrc - -lcov -c -o coverage.info -d ${RDK_DIR}/build/ -lcov -r coverage.info '/usr/include/*' '*/install/usr/include/*' '*/ccec/*' '*/helpers/*' -o filtered_coverage.info - -genhtml -o coverage -t "HALMock RDKServices Coverage" filtered_coverage.info \ No newline at end of file diff --git a/L2HalMock/invokeEnv.sh b/L2HalMock/invokeEnv.sh deleted file mode 100644 index 779c9c056..000000000 --- a/L2HalMock/invokeEnv.sh +++ /dev/null @@ -1,4 +0,0 @@ -set -x #enable debugging mode - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/../../../env.sh diff --git a/L2HalMock/manifest.txt b/L2HalMock/manifest.txt deleted file mode 100644 index 370998f9b..000000000 --- a/L2HalMock/manifest.txt +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -# - -# - - - -# - - - - - - diff --git a/L2HalMock/manifest.xml b/L2HalMock/manifest.xml deleted file mode 100644 index f79b9287f..000000000 --- a/L2HalMock/manifest.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -# - -# - - ---- -diff --git a/FrontPanel/FrontPanel.cpp b/FrontPanel/FrontPanel.cpp -index e8a1dc5a..25bd6bf3 100644 ---- a/FrontPanel/FrontPanel.cpp -+++ b/FrontPanel/FrontPanel.cpp -@@ -67,6 +67,7 @@ - #define API_VERSION_NUMBER_MINOR 0 - #define API_VERSION_NUMBER_PATCH 6 - -+extern "C" void __gcov_exit(); - namespace - { - -@@ -224,6 +225,7 @@ namespace WPEFramework - patternUpdateTimer.Revoke(m_updateTimer); - - DeinitializeIARM(); -+ __gcov_exit(); - } - void FrontPanel::powerModeChange(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { diff --git a/L2HalMock/patches/rdkservices/Hdcp_Profile.patch b/L2HalMock/patches/rdkservices/Hdcp_Profile.patch deleted file mode 100644 index d017c75d3..000000000 --- a/L2HalMock/patches/rdkservices/Hdcp_Profile.patch +++ /dev/null @@ -1,23 +0,0 @@ -Signed-off-by: Kishore Darmaradje ---- -diff --git a/HdcpProfile/HdcpProfile.cpp b/HdcpProfile/HdcpProfile.cpp -index 4eb5a3b0..40ec7c6c 100644 ---- a/HdcpProfile/HdcpProfile.cpp -+++ b/HdcpProfile/HdcpProfile.cpp -@@ -46,7 +46,7 @@ - #define API_VERSION_NUMBER_MAJOR 1 - #define API_VERSION_NUMBER_MINOR 0 - #define API_VERSION_NUMBER_PATCH 9 -- -+extern "C" void __gcov_exit(); - namespace WPEFramework - { - namespace { -@@ -102,6 +102,7 @@ namespace WPEFramework - //No need to run device::Manager::DeInitialize for individual plugin. As it is a singleton instance - //and shared among all wpeframework plugins - DeinitializeIARM(); -+ __gcov_exit(); - } - - void HdcpProfile::InitializeIARM() diff --git a/L2HalMock/patches/rdkservices/HdmiCecSink.json b/L2HalMock/patches/rdkservices/HdmiCecSink.json deleted file mode 100644 index 1fa252075..000000000 --- a/L2HalMock/patches/rdkservices/HdmiCecSink.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "locator":"libWPEFrameworkHdmiCecSink.so", - "classname":"HdmiCecSink", - "precondition":[ - "Platform" - ], - "callsign":"org.rdk.HdmiCecSink", - "autostart":true -} - diff --git a/L2HalMock/patches/rdkservices/HdmiCecSink.patch b/L2HalMock/patches/rdkservices/HdmiCecSink.patch deleted file mode 100644 index 066c274bd..000000000 --- a/L2HalMock/patches/rdkservices/HdmiCecSink.patch +++ /dev/null @@ -1,33 +0,0 @@ -Signed-off-by: Kishore Darmaradje ---- -diff --git a/HdmiCecSink/HdmiCecSink.cpp b/HdmiCecSink/HdmiCecSink.cpp -index 6dd5c229..ac078ca0 100644 ---- a/HdmiCecSink/HdmiCecSink.cpp -+++ b/HdmiCecSink/HdmiCecSink.cpp -@@ -172,7 +172,7 @@ static float cecVersion = 1.4; - static AllDeviceTypes allDevicetype = ALL_DEVICE_TYPES; - static std::vector rcProfile = {RC_PROFILE_TV}; - static std::vector deviceFeatures = {DEVICE_FEATURES_TV}; -- -+extern "C" void __gcov_exit(); - #define API_VERSION_NUMBER_MAJOR 1 - #define API_VERSION_NUMBER_MINOR 3 - #define API_VERSION_NUMBER_PATCH 7 -@@ -848,6 +848,7 @@ namespace WPEFramework - HdmiCecSink::_instance = nullptr; - DeinitializeIARM(); - LOGWARN(" HdmiCecSink Deinitialize() Done"); -+ __gcov_exit(); - } - - const void HdmiCecSink::InitializeIARM() -@@ -3418,7 +3419,8 @@ namespace WPEFramework - void HdmiCecSink::getCecVersion() - { - RFC_ParamData_t param = {0}; -- WDMP_STATUS status = getRFCParameter((char*)"thunderapi", TR181_HDMICECSINK_CEC_VERSION, ¶m); -+ // WDMP_STATUS status = getRFCParameter((char*)"thunderapi", TR181_HDMICECSINK_CEC_VERSION, ¶m); -+ WDMP_STATUS status = WDMP_FAILURE; - if(WDMP_SUCCESS == status && param.type == WDMP_STRING) { - LOGINFO("CEC Version from RFC = [%s] \n", param.value); - cecVersion = atof(param.value); diff --git a/L2HalMock/patches/rdkservices/HdmiCecSource.patch b/L2HalMock/patches/rdkservices/HdmiCecSource.patch deleted file mode 100644 index 24384b01e..000000000 --- a/L2HalMock/patches/rdkservices/HdmiCecSource.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/HdmiCecSource/HdmiCecSource.cpp b/HdmiCecSource/HdmiCecSource.cpp -index dbefbd1d..c9480ebc 100644 ---- a/HdmiCecSource/HdmiCecSource.cpp -+++ b/HdmiCecSource/HdmiCecSource.cpp -@@ -91,7 +91,7 @@ static int32_t powerState = 1; - static PowerStatus tvPowerState = 1; - static bool isDeviceActiveSource = false; - static bool isLGTvConnected = false; -- -+extern "C" void __gcov_exit(); - namespace WPEFramework - { - namespace { -@@ -521,6 +521,7 @@ namespace WPEFramework - smConnection = NULL; - - DeinitializeIARM(); -+ __gcov_exit(); - } - - void HdmiCecSource::sendKeyPressEvent(const int logicalAddress, int keyCode) diff --git a/L2HalMock/patches/rdkservices/SinkCoverage.patch b/L2HalMock/patches/rdkservices/SinkCoverage.patch deleted file mode 100644 index 9e01e5c11..000000000 --- a/L2HalMock/patches/rdkservices/SinkCoverage.patch +++ /dev/null @@ -1,23 +0,0 @@ -Signed-off-by: Kishore Darmaradje ---- -diff --git a/HdmiCecSink/HdmiCecSink.cpp b/HdmiCecSink/HdmiCecSink.cpp -index 6dd5c229..9d6dbb93 100644 ---- a/HdmiCecSink/HdmiCecSink.cpp -+++ b/HdmiCecSink/HdmiCecSink.cpp -@@ -172,7 +172,7 @@ static float cecVersion = 1.4; - static AllDeviceTypes allDevicetype = ALL_DEVICE_TYPES; - static std::vector rcProfile = {RC_PROFILE_TV}; - static std::vector deviceFeatures = {DEVICE_FEATURES_TV}; -- -+extern "C" void __gcov_exit(); - #define API_VERSION_NUMBER_MAJOR 1 - #define API_VERSION_NUMBER_MINOR 3 - #define API_VERSION_NUMBER_PATCH 7 -@@ -848,6 +848,7 @@ namespace WPEFramework - HdmiCecSink::_instance = nullptr; - DeinitializeIARM(); - LOGWARN(" HdmiCecSink Deinitialize() Done"); -+ __gcov_exit(); - } - - const void HdmiCecSink::InitializeIARM() diff --git a/L2HalMock/patches/rdkservices/files/CMakeLists.txt b/L2HalMock/patches/rdkservices/files/CMakeLists.txt deleted file mode 100644 index 969a3c635..000000000 --- a/L2HalMock/patches/rdkservices/files/CMakeLists.txt +++ /dev/null @@ -1,70 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2023 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. -### - -cmake_minimum_required(VERSION 3.3) -project(halmock) -find_package(WPEFramework PATHS ${WORKSPACE}/install/usr/lib/cmake/WPEFramework) -set(CMAKE_ROOT_DIR "${WORKSPACE}") -set(URL_INCLUDE_DIR "${WORKSPACE}/Thunder/Source/websocket") -# All packages that did not deliver a CMake Find script (and some deprecated scripts that need to be removed) -# are located in the cmake directory. Include it in the search. -list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") - -option(COMCAST_CONFIG "Comcast services configuration" ON) -if(COMCAST_CONFIG) - include(services.cmake) -endif() - -option(PLUGIN_OCICONTAINER "Include OCIContainer plugin" OFF) -option(PLUGIN_RUSTBRIDGE "Include RustBridge plugin" OFF) - -if(RDK_SERVICES_TEST) - include(tests.cmake) -endif() - -# Library installation section -string(TOLOWER ${NAMESPACE} STORAGE_DIRECTORY) - -# for writing pc and config files -include(${WORKSPACE}/install/usr/lib/cmake/WPEFramework/common/CmakeHelperFunctions.cmake) - -if(PLUGIN_HDMICECSOURCE) - add_subdirectory(HdmiCecSource) -endif() - -if(WPEFRAMEWORK_CREATE_IPKG_TARGETS) - set(CPACK_GENERATOR "DEB") - set(CPACK_DEB_COMPONENT_INSTALL ON) - set(CPACK_COMPONENTS_GROUPING IGNORE) - - set(CPACK_DEBIAN_PACKAGE_NAME "${WPEFRAMEWORK_PLUGINS_OPKG_NAME}") - set(CPACK_DEBIAN_PACKAGE_VERSION "${WPEFRAMEWORK_PLUGINS_OPKG_VERSION}") - set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${WPEFRAMEWORK_PLUGINS_OPKG_ARCHITECTURE}") - set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${WPEFRAMEWORK_PLUGINS_OPKG_MAINTAINER}") - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${WPEFRAMEWORK_PLUGINS_OPKG_DESCRIPTION}") - set(CPACK_PACKAGE_FILE_NAME "${WPEFRAMEWORK_PLUGINS_OPKG_FILE_NAME}") - - # list of components from which packages will be generated - set(CPACK_COMPONENTS_ALL - ${NAMESPACE}WebKitBrowser - WPEInjectedBundle - ) - - include(CPack) -endif() diff --git a/L2HalMock/patches/rdkservices/files/FrontPanel.json b/L2HalMock/patches/rdkservices/files/FrontPanel.json deleted file mode 100644 index dd829935e..000000000 --- a/L2HalMock/patches/rdkservices/files/FrontPanel.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "locator":"libWPEFrameworkFrontPanel.so", - "classname":"FrontPanel", - "precondition":[ - "Platform" - ], - "callsign":"org.rdk.FrontPanel", - "autostart":true -} diff --git a/L2HalMock/patches/rdkservices/files/HdcpProfile.json b/L2HalMock/patches/rdkservices/files/HdcpProfile.json deleted file mode 100644 index e69f03172..000000000 --- a/L2HalMock/patches/rdkservices/files/HdcpProfile.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "locator":"libWPEFrameworkHdcpProfile.so", - "classname":"HdcpProfile", - "precondition":[ - "Platform" - ], - "callsign":"org.rdk.HdcpProfile", - "autostart":true -} diff --git a/L2HalMock/patches/rdkservices/files/HdmiCecSink.json b/L2HalMock/patches/rdkservices/files/HdmiCecSink.json deleted file mode 100644 index 1fa252075..000000000 --- a/L2HalMock/patches/rdkservices/files/HdmiCecSink.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "locator":"libWPEFrameworkHdmiCecSink.so", - "classname":"HdmiCecSink", - "precondition":[ - "Platform" - ], - "callsign":"org.rdk.HdmiCecSink", - "autostart":true -} - diff --git a/L2HalMock/patches/rdkservices/files/HdmiCecSource.json b/L2HalMock/patches/rdkservices/files/HdmiCecSource.json deleted file mode 100644 index 45476e244..000000000 --- a/L2HalMock/patches/rdkservices/files/HdmiCecSource.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "locator":"libWPEFrameworkHdmiCecSource.so", - "classname":"HdmiCecSource", - "precondition":[ - "Platform" - ], - "callsign":"org.rdk.HdmiCecSource", - "autostart":true -} diff --git a/L2HalMock/patches/rdkservices/files/HdmiCecSource/CMakeLists.txt b/L2HalMock/patches/rdkservices/files/HdmiCecSource/CMakeLists.txt deleted file mode 100644 index d5360e1d7..000000000 --- a/L2HalMock/patches/rdkservices/files/HdmiCecSource/CMakeLists.txt +++ /dev/null @@ -1,73 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. -set(PLUGIN_NAME HdmiCecSource) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) - -set(PLUGIN_HDMICECSOURCE_STARTUPORDER "" CACHE STRING "To configure startup order of HdmiCecSource plugin") -set_source_files_properties(HdmiCecSource.cpp PROPERTIES COMPILE_FLAGS "-fexceptions") - -find_package(${NAMESPACE}Plugins REQUIRED) - -add_library(${MODULE_NAME} SHARED - HdmiCecSource.cpp - Module.cpp) - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -find_package(DS) -find_package(IARMBus) -find_package(CEC) - -target_include_directories(${MODULE_NAME} PUBLIC ${URL_INCLUDE_DIR}) -target_include_directories(${MODULE_NAME} PUBLIC ${DS_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PUBLIC ${DSHAL_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PUBLIC ${DSRPC_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PUBLIC ${CEC_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PUBLIC ${OSAL_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PUBLIC ${CEC_HOST_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PUBLIC ${CEC_IARM_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PUBLIC ${IARMBUS_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PUBLIC ${IARMIR_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PUBLIC ${IARMRECEIVER_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PUBLIC ${IARMPWR_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/helpers) - -file(GLOB libraries ${DS_LIBRARIES}/*.so) -foreach(lib ${libraries}) - target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${lib}) -endforeach(lib) - -file(GLOB libraries ${IARM_LIBRARIES}/*.so) -foreach(lib ${libraries}) - target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${lib}) -endforeach(lib) - -file(GLOB libraries ${CEC_LIBRARIES}/*.so) -foreach(lib ${libraries}) - target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${lib}) -endforeach(lib) - -if (NOT RDK_SERVICES_TEST) - target_compile_options(${MODULE_NAME} PRIVATE -Wno-error=deprecated) -endif () - -install(TARGETS ${MODULE_NAME} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -write_config(${PLUGIN_NAME}) diff --git a/L2HalMock/patches/rdkservices/files/cmake/FindCEC.cmake b/L2HalMock/patches/rdkservices/files/cmake/FindCEC.cmake deleted file mode 100644 index eddd7ebd9..000000000 --- a/L2HalMock/patches/rdkservices/files/cmake/FindCEC.cmake +++ /dev/null @@ -1,62 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find IARMBus -# Once done this will define -# IARMBUS_FOUND - System has IARMBus -# IARMBUS_INCLUDE_DIRS - The IARMBus include directories -# IARMBUS_LIBRARIES - The libraries needed to use IARMBus -# IARMBUS_FLAGS - The flags needed to use IARMBus -# - -find_package(PkgConfig) - -#find_library(CEC_LIBRARIES NAMES RCEC) -#find_library(CEC_IARM_LIBRARIES NAMES RCECIARMBusHal) -#find_library(OSAL_LIBRARIES NAMES RCECOSHal) - -#find_path(CEC_INCLUDE_DIRS NAMES ccec PATH_SUFFIXES ccec/include) -#find_path(OSAL_INCLUDE_DIRS NAMES osal PATH_SUFFIXES osal/include) -#find_path(CEC_HOST_INCLUDE_DIRS NAMES ccec/host PATH_SUFFIXES host/include) -#find_path(CEC_IARM_INCLUDE_DIRS NAMES ccec/drivers/iarmbus PATH_SUFFIXES ccec/drivers/include) - -#set(CEC_LIBRARIES "-Wl,--no-as-needed" ${CEC_LIBRARIES} ${CEC_IARM_LIBRARIES} ${OSAL_LIBRARIES} "-Wl,--as-needed") - -#set(CEC_LIBRARIES ${CEC_LIBRARIES} CACHE PATH "Path to library") - -#set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} ${OSAL_INCLUDE_DIRS} ${CEC_HOST_INCLUDE_DIRS} ${CEC_IARM_INCLUDE_DIRS}) -#set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} CACHE PATH "Path to include directories") - -set(CEC_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/hdmicec/ccec/include) -set(OSAL_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/hdmicec/osal/include) -set(CEC_HOST_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/hdmicec/host/include) -set(CEC_IARM_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/hdmicec/ccec/drivers/include) -message(STATUS "Anooj CEC_INCLUDE_DIRS: ${CEC_INCLUDE_DIRS}") -set(CEC_DIRS ${CEC_INCLUDE_DIRS} ${OSAL_INCLUDE_DIRS} ${CEC_HOST_INCLUDE_DIRS} ${CEC_IARM_INCLUDE_DIRS}) -message(STATUS "Anooj CEC_DIRS: ${CEC_DIRS}") -set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} CACHE PATH "Path to include directories") -set(CEC_LIBRARIES ${CMAKE_ROOT_DIR}/deps/rdk/hdmicec/install/lib) - -include(FindPackageHandleStandardArgs) -#FIND_PACKAGE_HANDLE_STANDARD_ARGS(IARMBUS DEFAULT_MSG IARMBUS_INCLUDE_DIRS IARMBUS_LIBRARIES) - -mark_as_advanced( - CEC_FOUND - CEC_INCLUDE_DIRS - CEC_LIBRARIES - CEC_LIBRARY_DIRS - CEC_FLAGS) diff --git a/L2HalMock/patches/rdkservices/files/cmake/FindDS.cmake b/L2HalMock/patches/rdkservices/files/cmake/FindDS.cmake deleted file mode 100644 index 49ce8de99..000000000 --- a/L2HalMock/patches/rdkservices/files/cmake/FindDS.cmake +++ /dev/null @@ -1,57 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find Display Settings library -# Once done this will define -# DS_FOUND - System has DS -# DS_INCLUDE_DIRS - The DS include directories -# DS_LIBRARIES - The libraries needed to use DS -# DS_FLAGS - The flags needed to use DS -# - -find_package(PkgConfig) - -#find_library(DS_LIBRARIES NAMES ds) -#find_library(DSHAL_LIBRARIES NAMES dshalcli) -#find_library(OEMHAL_LIBRARIES NAMES ds-hal) -#find_library(IARMBUS_LIBRARIES NAMES IARMBus) -#find_path(DS_INCLUDE_DIRS NAMES manager.hpp PATH_SUFFIXES ds/include) -#find_path(DSHAL_INCLUDE_DIRS NAMES dsTypes.h PATHS hal/include/) -#find_path(DSRPC_INCLUDE_DIRS NAMES dsMgr.h PATH_SUFFIXES rpc/include) - -#set(DS_LIBRARIES ${DS_LIBRARIES} ${DSHAL_LIBRARIES}) -#set(DS_LIBRARIES ${DS_LIBRARIES} CACHE PATH "Path to DS library") -#set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} ${DSHAL_INCLUDE_DIRS} ${DSRPC_INCLUDE_DIRS}) -set(DS_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/devicesettings/ds/include) -set(DSHAL_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/devicesettings/hal/include) -set(DSRPC_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/devicesettings/rpc/include) -set(DS_DIRS ${DS_INCLUDE_DIRS} ${DSHAL_INCLUDE_DIRS} ${DSRPC_INCLUDE_DIRS}) -set(DS_LIBRARIES ${CMAKE_ROOT_DIR}/deps/rdk/devicesettings/install/lib) -#set(DS_INCLUDE_DIRS ${DSHAL_INCLUDE_DIRS}) -#set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} CACHE PATH "Path to DS include") - - - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(DS DEFAULT_MSG DS_INCLUDE_DIRS DS_LIBRARIES) - -mark_as_advanced( - DS_FOUND - DS_INCLUDE_DIRS - DS_LIBRARIES - DS_LIBRARY_DIRS - DS_FLAGS) diff --git a/L2HalMock/patches/rdkservices/files/cmake/FindIARMBus.cmake b/L2HalMock/patches/rdkservices/files/cmake/FindIARMBus.cmake deleted file mode 100644 index acede4496..000000000 --- a/L2HalMock/patches/rdkservices/files/cmake/FindIARMBus.cmake +++ /dev/null @@ -1,43 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find IARMBus -# Once done this will define -# IARMBUS_FOUND - System has IARMBus -# IARMBUS_INCLUDE_DIRS - The IARMBus include directories -# IARMBUS_LIBRARIES - The libraries needed to use IARMBus -# IARMBUS_FLAGS - The flags needed to use IARMBus -# - -find_package(PkgConfig) - -set(IARMBUS_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/iarmbus/core/include) -set(IARMIR_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/iarmmgrs/ir/include) -set(IARMRECEIVER_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/iarmmgrs/receiver/include) -set(IARMPWR_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/iarmmgrs/hal/include) -set(IARM_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS} ${IARMRECEIVER_INCLUDE_DIRS} ${IARMPWR_INCLUDE_DIRS}) -set(IARM_LIBRARIES ${CMAKE_ROOT_DIR}/deps/rdk/iarmbus/install/) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(IARMBUS DEFAULT_MSG IARMBUS_INCLUDE_DIRS IARMBUS_LIBRARIES) - -mark_as_advanced( - IARMBUS_FOUND - IARMBUS_INCLUDE_DIRS - IARMBUS_LIBRARIES - IARMBUS_LIBRARY_DIRS - IARMBUS_FLAGS) diff --git a/L2HalMock/patches/rdkservices/files/rfcapi.h b/L2HalMock/patches/rdkservices/files/rfcapi.h deleted file mode 100644 index d92f6d15e..000000000 --- a/L2HalMock/patches/rdkservices/files/rfcapi.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * If not stated otherwise in this file or this component's Licenses.txt file the - * following copyright and licenses apply: - * - * Copyright 2016 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. -*/ - -#ifndef RFCAPI_H_ -#define RFCAPI_H_ - -#include -#include - -#define RFCVAR_FILE "/opt/secure/RFC/rfcVariable.ini" -#define TR181STORE_FILE "/opt/secure/RFC/tr181store.ini" - -#ifdef __cplusplus -extern "C" -{ -#endif -#ifndef RDKC -#include -#endif - -#define MAX_PARAM_LEN (2*1024) - -#ifdef RDKC -typedef enum -{ - SUCCESS=0, - FAILURE, - NONE, - EMPTY -}DATATYPE; -#endif - -#ifdef RDKC -typedef struct _RFC_Param_t { - char name[MAX_PARAM_LEN]; - char value[MAX_PARAM_LEN]; - DATATYPE type; -} RFC_ParamData_t; -#else -typedef struct _RFC_Param_t { - char name[MAX_PARAM_LEN]; - char value[MAX_PARAM_LEN]; - DATA_TYPE type; -} RFC_ParamData_t; -#endif -#ifdef RDKC -int getRFCParameter(const char* pcParameterName, RFC_ParamData_t *pstParamData); -#else -WDMP_STATUS getRFCParameter(const char *pcCallerID, const char* pcParameterName, RFC_ParamData_t *pstParamData); -WDMP_STATUS setRFCParameter(const char *pcCallerID, const char* pcParameterName, const char* pcParameterValue, DATA_TYPE eDataType); -const char* getRFCErrorString(WDMP_STATUS code); -bool isRFCEnabled(const char *); -bool isFileInDirectory(const char *, const char *); -#endif -#ifdef __cplusplus -} -#endif - -#endif diff --git a/L2HalMock/patches/rdkservices/files/wdmp-c.h b/L2HalMock/patches/rdkservices/files/wdmp-c.h deleted file mode 100644 index b339e5c0c..000000000 --- a/L2HalMock/patches/rdkservices/files/wdmp-c.h +++ /dev/null @@ -1,261 +0,0 @@ -/** -* Copyright 2016 Comcast Cable Communications Management, LLC -* -* 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. -* -*/ -#ifndef __WDMP_C_H__ -#define __WDMP_C_H__ - -#include -#include - - -typedef enum -{ - WDMP_STRING = 0, - WDMP_INT, - WDMP_UINT, - WDMP_BOOLEAN, - WDMP_DATETIME, - WDMP_BASE64, - WDMP_LONG, - WDMP_ULONG, - WDMP_FLOAT, - WDMP_DOUBLE, - WDMP_BYTE, - WDMP_NONE -} DATA_TYPE; - -typedef enum -{ - WDMP_SUCCESS = 0, /**< Success. */ - WDMP_FAILURE, /**< General Failure */ - WDMP_ERR_TIMEOUT, - WDMP_ERR_NOT_EXIST, - WDMP_ERR_INVALID_PARAMETER_NAME, - WDMP_ERR_INVALID_PARAMETER_TYPE, - WDMP_ERR_INVALID_PARAMETER_VALUE, - WDMP_ERR_NOT_WRITABLE, - WDMP_ERR_SETATTRIBUTE_REJECTED, - WDMP_ERR_NAMESPACE_OVERLAP, - WDMP_ERR_UNKNOWN_COMPONENT, - WDMP_ERR_NAMESPACE_MISMATCH, - WDMP_ERR_UNSUPPORTED_NAMESPACE, - WDMP_ERR_DP_COMPONENT_VERSION_MISMATCH, - WDMP_ERR_INVALID_PARAM, - WDMP_ERR_UNSUPPORTED_DATATYPE, - WDMP_STATUS_RESOURCES, - WDMP_ERR_WIFI_BUSY, - WDMP_ERR_INVALID_ATTRIBUTES, - WDMP_ERR_WILDCARD_NOT_SUPPORTED, - WDMP_ERR_SET_OF_CMC_OR_CID_NOT_SUPPORTED, - WDMP_ERR_VALUE_IS_EMPTY, - WDMP_ERR_VALUE_IS_NULL, - WDMP_ERR_DATATYPE_IS_NULL, - WDMP_ERR_CMC_TEST_FAILED, - WDMP_ERR_NEW_CID_IS_MISSING, - WDMP_ERR_CID_TEST_FAILED, - WDMP_ERR_SETTING_CMC_OR_CID, - WDMP_ERR_INVALID_INPUT_PARAMETER, - WDMP_ERR_ATTRIBUTES_IS_NULL, - WDMP_ERR_NOTIFY_IS_NULL, - WDMP_ERR_INVALID_WIFI_INDEX, - WDMP_ERR_INVALID_RADIO_INDEX, - WDMP_ERR_ATOMIC_GET_SET_FAILED, - WDMP_ERR_DEFAULT_VALUE -} WDMP_STATUS; - -typedef struct -{ - char *name; - char *value; - DATA_TYPE type; -} param_t; - -typedef enum -{ - GET = 0, - GET_ATTRIBUTES, - SET, - SET_ATTRIBUTES, - TEST_AND_SET, - REPLACE_ROWS, - ADD_ROWS, - DELETE_ROW -} REQ_TYPE; - -typedef struct -{ - char *paramNames[512]; - size_t paramCnt; -} get_req_t; - -typedef struct -{ - param_t *param; - size_t paramCnt; -} set_req_t; - -typedef struct -{ - param_t *param; - char *newCid; - char *oldCid; - char *syncCmc; - size_t paramCnt; -} test_set_req_t; - - -typedef struct -{ - size_t paramCnt; - char **names; - char **values; -} TableData; - -typedef struct -{ - char *objectName; - TableData *rows; - size_t rowCnt; -} table_req_t; - -typedef struct { - REQ_TYPE reqType; - union { - get_req_t *getReq; - set_req_t *setReq; - table_req_t *tableReq; - test_set_req_t *testSetReq; - } u; -} req_struct; - -typedef struct -{ - char *name; - uint64_t start; - uint32_t duration; -} money_trace_span; - -typedef struct -{ - money_trace_span *spans; - size_t count; -} money_trace_spans; - -typedef struct -{ - char **paramNames; - size_t paramCnt; - param_t **params; - size_t *retParamCnt; -} get_res_t; - -typedef struct -{ - char *syncCMC; - char *syncCID; - param_t *params; -} param_res_t; - -typedef struct -{ - char *newObj; -} table_res_t; - -typedef struct -{ - REQ_TYPE reqType; - union { - get_res_t *getRes; - param_res_t *paramRes; - table_res_t *tableRes; - } u; - money_trace_spans *timeSpan; - WDMP_STATUS *retStatus; - size_t paramCnt; -} res_struct; - -/*----------------------------------------------------------------------------*/ -/* Macros */ -/*----------------------------------------------------------------------------*/ -/* none */ - -/*----------------------------------------------------------------------------*/ -/* Data Structures */ -/*----------------------------------------------------------------------------*/ -/* none */ - -/*----------------------------------------------------------------------------*/ -/* File Scoped Variables */ -/*----------------------------------------------------------------------------*/ -/* none */ - -/*----------------------------------------------------------------------------*/ -/* Function Prototypes */ -/*----------------------------------------------------------------------------*/ -/* none */ - -/*----------------------------------------------------------------------------*/ -/* External Functions */ -/*----------------------------------------------------------------------------*/ - -/** -* To convert json string to struct -* -* @note If the reqObj returned is not NULL, the value pointed at by -* bytes must be freed using wdmp_free_req_struct() by the caller. -* -* @param payload [in] payload JSON string to be converted -* @param reqObj [out] the resulting req_struct structure if successful -*/ - -void wdmp_parse_request(char * payload, req_struct **reqObj); - - -/** -* To convert response struct to json string - -* @param resObj [in] the response structure to be converted -* @param payload [out] the resulting payload string if successful -*/ - -void wdmp_form_response(res_struct *resObj, char **payload); - -/** -* Free the req_struct structure if allocated by the wdmp-c library. -* -* @note Do not call this function on the req_struct structure if the wdmp-c -* library did not create the structure! -* -* @param msg [in] the req_struct structure to free -*/ -void wdmp_free_req_struct( req_struct *reqObj ); - -/** -* Free the res_struct structure if allocated by the wdmp-c library. -* -* @note Do not call this function on the res_struct structure if the wdmp-c -* library did not create the structure! -* -* @param msg [in] the res_struct structure to free -*/ -void wdmp_free_res_struct( res_struct *resObj ); - -/*----------------------------------------------------------------------------*/ -/* Internal functions */ -/*----------------------------------------------------------------------------*/ -/* none */ - -#endif diff --git a/L2HalMock/patches/rdkservices/iarmbus/build.sh b/L2HalMock/patches/rdkservices/iarmbus/build.sh deleted file mode 100755 index 34c29ea9b..000000000 --- a/L2HalMock/patches/rdkservices/iarmbus/build.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -########################################################################## -# If not stated otherwise in this file or this component's Licenses.txt -# file the following copyright and licenses apply: -# -# Copyright 2016 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. -########################################################################## -# -set -x - -source $PWD/../env.sh - -export LDFLAGS="`pkg-config --libs libsafec`" -export USE_DBUS=y -export CXX=g++ -make -if [ $? -ne 0 ] ; then - echo IarmBus Build Failed - exit 1 -else - echo IarmBus Build Success - exit 0 -fi diff --git a/L2HalMock/patches/rdkservices/iarmmgrs/Makefile b/L2HalMock/patches/rdkservices/iarmmgrs/Makefile deleted file mode 100644 index 0e3bd8b74..000000000 --- a/L2HalMock/patches/rdkservices/iarmmgrs/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -########################################################################## -# If not stated otherwise in this file or this component's Licenses.txt -# file the following copyright and licenses apply: -# -# Copyright 2016 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. -########################################################################## -# -# List of Libraries -install_dir := ../install/bin -install_lib_dir := ../install/lib - -exe_ds := dsmgr - -executable := $(exe_ds) - -.PHONY: clean all $(executable) install - -all: clean $(executable) install - -$(executable): - $(MAKE) -C $@ - -install: - echo "Creating directory.." - mkdir -p $(install_dir) - mkdir -p $(install_lib_dir) - echo "Copying files now.." - cp $(exe_ds)/*Main $(install_dir) - -clean: - rm -rf $(install_dir) - rm -rf $(install_lib_dir) \ No newline at end of file diff --git a/L2HalMock/patches/rdkservices/iarmmgrs/build.sh b/L2HalMock/patches/rdkservices/iarmmgrs/build.sh deleted file mode 100644 index a708a63e8..000000000 --- a/L2HalMock/patches/rdkservices/iarmmgrs/build.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -########################################################################## -# If not stated otherwise in this file or this component's Licenses.txt -# file the following copyright and licenses apply: -# -# Copyright 2016 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. -########################################################################## -# -set -x - -source $PWD/../env.sh - -export USE_DBUS=y -# export CXX=g++ -make -if [ $? -ne 0 ] ; then - echo iarmmgr Build Failed - exit 1 -else - echo iarmmgr Build Success - exit 0 -fi \ No newline at end of file diff --git a/L2HalMock/patches/rdkservices/iarmmgrs/ds.patch b/L2HalMock/patches/rdkservices/iarmmgrs/ds.patch deleted file mode 100644 index 0d55a76dd..000000000 --- a/L2HalMock/patches/rdkservices/iarmmgrs/ds.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff --git a/dsmgr/dsMgrPwrEventListener.c b/dsmgr/dsMgrPwrEventListener.c -index 034b733..90674d0 100644 ---- a/dsmgr/dsMgrPwrEventListener.c -+++ b/dsmgr/dsMgrPwrEventListener.c -@@ -117,7 +117,7 @@ void initPwrEventListner() - } - - try { -- device::Manager::load(); -+ device::Manager::Initialize(); - INT_DEBUG("device::Manager::load success.\n"); - } - catch (...){ -diff --git a/power/pwrMgr.c b/power/pwrMgr.c -index 550df26..df0e80b 100755 ---- a/power/pwrMgr.c -+++ b/power/pwrMgr.c -@@ -845,15 +845,15 @@ void performReboot(const char * requestor, const char * reboot_reason_custom, co - char * reboot_reason_other_cpy = strdup(reboot_reason_other); - - std::thread async_reboot_thread([requestor_cpy, reboot_reason_custom_cpy, reboot_reason_other_cpy] () { -- v_secure_system("echo 0 > /opt/.rebootFlag"); -+ // v_secure_system("echo 0 > /opt/.rebootFlag"); - sleep(5); - if(0 == access("/rebootNow.sh", F_OK)) - { -- v_secure_system("/rebootNow.sh -s '%s' -r '%s' -o '%s'", requestor_cpy, reboot_reason_custom_cpy, reboot_reason_other_cpy); -+ // v_secure_system("/rebootNow.sh -s '%s' -r '%s' -o '%s'", requestor_cpy, reboot_reason_custom_cpy, reboot_reason_other_cpy); - } - else - { -- v_secure_system("/lib/rdk/rebootNow.sh -s '%s' -r '%s' -o '%s'", requestor_cpy, reboot_reason_custom_cpy, reboot_reason_other_cpy); -+ // v_secure_system("/lib/rdk/rebootNow.sh -s '%s' -r '%s' -o '%s'", requestor_cpy, reboot_reason_custom_cpy, reboot_reason_other_cpy); - } - free(requestor_cpy); - free(reboot_reason_custom_cpy); diff --git a/L2HalMock/patches/rdkservices/iarmmgrs/dsmgr/Makefile b/L2HalMock/patches/rdkservices/iarmmgrs/dsmgr/Makefile deleted file mode 100644 index de4f5d5a4..000000000 --- a/L2HalMock/patches/rdkservices/iarmmgrs/dsmgr/Makefile +++ /dev/null @@ -1,75 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 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. -### - -RM := rm -rf -CFLAGS := -g -fPIC -D_REENTRANT -Wall -OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) -CPPLAGS := -g -fPIC -D_REENTRANT -Wall -EXECUTABLE = dsSrvMain -INCLUDE = -I. \ - -I$(IARM_PATH)/core/ \ - -I$(IARM_PATH)/core/include \ - -I$(IARM_MGRS)/sysmgr/include \ - -I$(IARM_MGRS)/hal/include \ - -I$(IARM_MGRS)/mfr/include \ - -I$(DS_PATH)/rpc/include \ - -I$(DS_PATH)/hal/include \ - -I$(DS_PATH)/ds/include \ - -I$(DS_PATH)/hal/src \ - -I$(GLIB_HEADER_PATH)/ \ - -I$(GLIB_HEADER_PATH)/glib/ \ - -I$(GLIB_CONFIG_PATH)/../lib/glib-2.0/include/ \ - -I$(GLIB_INCLUDE_PATH)/ \ - -I$(DFB_ROOT)/usr/local/include/directfb \ - -I$(SAFEC_INCLUDE_PATH) - -INSTALL := $(PWD)/install - -CFLAGS += $(INCLUDE) - -# LDFLAGS +=-Wl,--copy-dt-needed-entries,-rpath,$(SDK_FSROOT)/usr/local/lib -# LDFLAGS += -L$(IARM_PATH)/install -lIARMBus -# LDFLAGS += -L$(DS_PATH)/install/lib -lds -ldshalcli - -# LDFLAGS := -L$(CEC_ROOT)/ccec/drivers/iarmbus/install/lib -L$(CEC_ROOT)/osal/src/install/lib -L$(CEC_ROOT)/soc/$(PLATFORM_SOC)/common/install/lib -L$(CEC_ROOT)/ccec/src/install/lib -LDFLAGS += -L$(IARM_PATH)/install -L$(CEC_ROOT)/ccec/iarmbus -LDFLAGS += -L$(FUSION_PATH) -L$(DFB_LIB) -L$(OPENSOURCE_BASE)/lib -L$(GLIB_LIBRARY_PATH) -L$(DS_PATH)/install/lib -L$(SAFEC_LIB_PATH) $(GLIBS) -lIARMBus -lpthread -ldirect -lfusion -ldshalsrv -lds -lds-hal -lsafec-3.5 -lglib-2.0 -# LDFLAGS += -lnexus # couldn't find nexus and not sure if it is really needed yet. -# LDFLAGS += -L$(DS_PATH)/install/lib -lds -ldshalcli - -# LDFLAGS += -L /home/administrator/PROJECT/GIT_COMMIT/work/LATEST_COMMIT/rdkservices/L2HalMock/workspace/deps/rdk/iarmbus/install -lIARMBus -# LDFLAGS += -L /home/administrator/PROJECT/GIT_COMMIT/work/LATEST_COMMIT/rdkservices/L2HalMock/workspace/deps/rdk/devicesettings/install/lib -ldshalcli -ldshalsrv -lds - -all:clean executable - @echo "Build Finished...." - -executable: $(OBJS) - $(CXX) $(CFLAGS) $(OBJS) -o $(EXECUTABLE) $(LDFLAGS) - -%.o: %.c - @echo "Building $@ ...." - $(CXX) -c $< $(CFLAGS) -o $@ - -%.o: %.cpp - @echo "Building $@ ...." - $(CXX) -c $< $(CFLAGS) -o $@ - -clean: - @echo "Cleaning the directory..." - @$(RM) $(OBJS) $(EXECUTABLE) \ No newline at end of file diff --git a/L2HalMock/patches/rdkservices/iarmmgrs/dsmgr/dsMgr.c b/L2HalMock/patches/rdkservices/iarmmgrs/dsmgr/dsMgr.c deleted file mode 100644 index d7cc18ad4..000000000 --- a/L2HalMock/patches/rdkservices/iarmmgrs/dsmgr/dsMgr.c +++ /dev/null @@ -1,1035 +0,0 @@ -/* - * If not stated otherwise in this file or this component's Licenses.txt file the - * following copyright and licenses apply: - * - * Copyright 2016 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. -*/ - - - -/** -* @defgroup iarmmgrs -* @{ -* @defgroup dsmgr -* @{ -**/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "libIARM.h" -#include "libIBusDaemon.h" -#include "dsMgrInternal.h" -#include "libIBus.h" -#include "iarmUtil.h" - -#include "sysMgr.h" - -#include "dsMgr.h" -#include "dsUtl.h" -#include "dsError.h" -#include "dsTypes.h" -#include "dsRpc.h" -#include "dsVideoPort.h" -#include "dsVideoResolutionSettings.h" -#include "dsDisplay.h" -#include "dsAudioSettings.h" -#include "dsAudio.h" -#include "safec_lib.h" -#include "rfcapi.h" -#include "dsMgrPwrEventListener.h" - -extern IARM_Result_t _dsSetResolution(void *arg); -extern IARM_Result_t _dsGetResolution(void *arg); -extern IARM_Result_t _dsInitResolution(void *arg); -extern IARM_Result_t _dsGetAudioPort(void *arg); -extern IARM_Result_t _dsGetStereoMode(void *arg); -extern IARM_Result_t _dsSetStereoMode(void *arg); -extern IARM_Result_t _dsGetEDID(void *arg); -extern IARM_Result_t _dsGetEDIDBytes(void *arg); -extern IARM_Result_t _dsGetVideoPort(void *arg); -extern IARM_Result_t _dsIsDisplayConnected(void *arg); -extern IARM_Result_t _dsGetStereoAuto(void *arg); -extern IARM_Result_t _dsIsDisplaySurround(void *arg); -extern IARM_Result_t _dsGetForceDisable4K(void *arg); -extern IARM_Result_t _dsSetBackgroundColor(void *arg); -extern IARM_Result_t _dsGetIgnoreEDIDStatus(void *arg); -extern bool isComponentPortPresent(); - -extern bool dsGetHDMIDDCLineStatus(void); -static int _SetVideoPortResolution(); -static int _SetResolution(intptr_t* handle,dsVideoPortType_t PortType); -static void _EventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); -static IARM_Result_t _SysModeChange(void *arg); -static void dumpHdmiEdidInfo(dsDisplayEDID_t* pedidData); -static int iTuneReady = 0; -static dsDisplayEvent_t edisplayEventStatus = dsDISPLAY_EVENT_MAX; -static pthread_t edsHDMIHPDThreadID; // HDMI HPD - HDMI Hot Plug detect events -static pthread_mutex_t tdsMutexLock; -static pthread_cond_t tdsMutexCond; -static void* _DSMgrResnThreadFunc(void *arg); -static void _setAudioMode(); -void _setEASAudioMode(); -static int iResnCount = 5; -static int iInitResnFlag = 0; -static bool bHDCPAuthenticated = false; -static bool bPwrMgeRFCEnabled = false; -IARM_Bus_Daemon_SysMode_t isEAS = IARM_BUS_SYS_MODE_NORMAL; // Default is Normal Mode - -#define RFC_PWRMGR2 "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Power.PwrMgr2.Enable" - -/*DSMgr Glib variables */ -/* For glib APIs*/ -#include -GMainLoop *dsMgr_Gloop = NULL; -static gboolean heartbeatMsg(gpointer data); -static gboolean _SetResolutionHandler(gpointer data); -static guint hotplug_event_src = 0; -static gboolean dumpEdidOnChecksumDiff(gpointer data); -static bool IsIgnoreEdid_gs = false; - -static intptr_t getVideoPortHandle(_dsVideoPortType_t port) -{ - /* Get the HDMI Video Port Parameter */ - dsVideoPortGetHandleParam_t vidPortParam; - memset(&vidPortParam, 0, sizeof(vidPortParam)); - vidPortParam.type = port; - vidPortParam.index = 0; - _dsGetVideoPort(&vidPortParam); - return vidPortParam.handle; -} - -static bool isHDMIConnected() -{ - /* Get the Display connection status */ - dsVideoPortIsDisplayConnectedParam_t ConParam; - memset(&ConParam, 0, sizeof(ConParam)); - ConParam.handle = getVideoPortHandle(dsVIDEOPORT_TYPE_HDMI); - _dsIsDisplayConnected(&ConParam); - return ConParam.connected; -} - -IARM_Result_t DSMgr_Start() -{ - FILE *fDSCtrptr = NULL; - IARM_Bus_SYSMgr_GetSystemStates_Param_t tuneReadyParam; - - - setvbuf(stdout, NULL, _IOLBF, 0); - INT_INFO("Entering [%s] - [%s] - disabling io redirect buf \r\n", __FUNCTION__, IARM_BUS_DSMGR_NAME); - - /* Register with IARM Libs and Connect */ - IARM_Bus_Init(IARM_BUS_DSMGR_NAME); - IARM_Bus_Connect(); - IARM_Bus_RegisterEvent(IARM_BUS_DSMGR_EVENT_MAX); - - /*Initialize the DS Manager - DS Srv and DS HAL */ - dsMgr_init(); - - iInitResnFlag = 1; - dsEdidIgnoreParam_t ignoreEdidParam; - memset(&ignoreEdidParam,0,sizeof(ignoreEdidParam)); - ignoreEdidParam.handle = dsVIDEOPORT_TYPE_HDMI; - _dsGetIgnoreEDIDStatus(&ignoreEdidParam); - IsIgnoreEdid_gs = ignoreEdidParam.ignoreEDID; - __TIMESTAMP();printf("ResOverride DSMgr_Start IsIgnoreEdid_gs: %d\n", IsIgnoreEdid_gs); - /*Register the Events */ - IARM_Bus_RegisterEventHandler(IARM_BUS_SYSMGR_NAME,IARM_BUS_SYSMGR_EVENT_SYSTEMSTATE,_EventHandler); - IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG,_EventHandler); - IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDCP_STATUS,_EventHandler); - - /*Register EAS handler so that we can ensure audio settings for EAS */ - IARM_Bus_RegisterCall(IARM_BUS_COMMON_API_SysModeChange, _SysModeChange); - - RFC_ParamData_t rfcParam; - // WDMP_STATUS status = getRFCParameter("dsMgr", RFC_PWRMGR2, &rfcParam); - WDMP_STATUS status = WDMP_SUCCESS; - if(strncmp(rfcParam.value, "true",4) == 0) - { - bPwrMgeRFCEnabled= true; - __TIMESTAMP(); printf("dsMgr:RFC PwrMgr2 feature enabled \r\n"); - } - - if(bPwrMgeRFCEnabled) - { - /*Refactored dsMGR code*/ - initPwrEventListner(); - } - /* Create Thread for listening Hot Plug events */ - pthread_mutex_init (&tdsMutexLock, NULL); - pthread_cond_init (&tdsMutexCond, NULL); - pthread_create (&edsHDMIHPDThreadID, NULL, _DSMgrResnThreadFunc, NULL); - - /* Read the HDMI DDC Line delay to be introduced - * for setting the resolution - * The DDC line is used for EDID and HDCP Negotiation - */ - fDSCtrptr = fopen("/opt/ddcDelay","r"); - if (NULL != fDSCtrptr) - { - if(0 > fscanf(fDSCtrptr,"%d",&iResnCount)) - { - INT_INFO("Error: fscanf on ddcDelay failed"); - } - fclose (fDSCtrptr); - } - __TIMESTAMP(); printf("Retry DS manager Resolution count is iResnCount = %d \r\n",iResnCount); - - - IARM_Bus_Call(IARM_BUS_SYSMGR_NAME, IARM_BUS_SYSMGR_API_GetSystemStates, &tuneReadyParam, sizeof(tuneReadyParam)); - __TIMESTAMP(); printf("Tune Ready Status on start up is %d \r\n",tuneReadyParam.TuneReadyStatus.state); - - /* Read the Tune Ready status on startup and update the tune ready flag */ - if(1 == tuneReadyParam.TuneReadyStatus.state) - { - iTuneReady = 1; - } - - /* Create Main loop for DS Manager */ - dsMgr_Gloop = g_main_loop_new ( NULL , FALSE ); - if(dsMgr_Gloop != NULL){ - g_timeout_add_seconds (300 , heartbeatMsg , dsMgr_Gloop); - } - else { - INT_INFO("Fails to Create a main Loop for [%s] \r\n",IARM_BUS_DSMGR_NAME); - } - - if(!isHDMIConnected()) - { - __TIMESTAMP();printf("HDMI not connected at bootup -Schedule a handler to set the resolution .. \r\n"); - _SetVideoPortResolution(); - } - return IARM_RESULT_SUCCESS; -} - -IARM_Result_t DSMgr_Loop() -{ - - /* DS Mgr loop */ - if(dsMgr_Gloop) - { - g_main_loop_run (dsMgr_Gloop); - g_main_loop_unref(dsMgr_Gloop); - } - return IARM_RESULT_SUCCESS; -} - -static gboolean heartbeatMsg(gpointer data) -{ - time_t curr = 0; - time(&curr); - INT_INFO("I-ARM BUS DS Mgr: HeartBeat at %s\r\n", ctime(&curr)); - return TRUE; -} - -IARM_Result_t DSMgr_Stop() -{ - - if(dsMgr_Gloop) - { - g_main_loop_quit(dsMgr_Gloop); - } - - IARM_Bus_Disconnect(); - IARM_Bus_Term(); - pthread_mutex_destroy (&tdsMutexLock); - pthread_cond_destroy (&tdsMutexCond); - - return IARM_RESULT_SUCCESS; -} - -/** - * @fn static IARM_Result_t _SysModeChange(void *arg){ - * @brief This function is a event handler which returns current system - * mode using IARM. It returns mode as "NORMAL", "WAREHOUSE","EAS" or "UNKNOWN". - * - * @param[in] void pointer to void, containing IARM_Bus_CommonAPI_SysModeChange_Param_t data. - * - * @return variable of IARM_Result_t type. - * @retval IARM_RESULT_SUCCESS On function completion. - */ -static IARM_Result_t _SysModeChange(void *arg) -{ - IARM_Bus_CommonAPI_SysModeChange_Param_t *param = (IARM_Bus_CommonAPI_SysModeChange_Param_t *)arg; - IARM_Bus_Daemon_SysMode_t isNextEAS = IARM_BUS_SYS_MODE_NORMAL; - - __TIMESTAMP();printf("[DSMgr] Recvd Sysmode Change::New mode --> %d,Old mode --> %d",param->newMode,param->oldMode); - - if ((param->newMode == IARM_BUS_SYS_MODE_EAS) || - (param->newMode == IARM_BUS_SYS_MODE_NORMAL)) - { - isNextEAS = param->newMode; - } - else - { - /* Do not process any other mode change as of now for DS Manager.. */ - return IARM_RESULT_SUCCESS; - } - - if ((isEAS == IARM_BUS_SYS_MODE_EAS) && (isNextEAS == IARM_BUS_SYS_MODE_NORMAL) ) { - isEAS = IARM_BUS_SYS_MODE_NORMAL; - _setAudioMode(); - } - else if ((isEAS == IARM_BUS_SYS_MODE_NORMAL) && (isNextEAS == IARM_BUS_SYS_MODE_EAS) ) { - /* - * Change the Audio Mode to Stereo if Current Audio Setting is Paasthrough - */ - isEAS = IARM_BUS_SYS_MODE_EAS; - _setEASAudioMode(); - - } - else { - /* no op for no mode change */ - } - return IARM_RESULT_SUCCESS; -} - -static void setBGColor(dsVideoBackgroundColor_t color) -{ - /* Get the HDMI Video Port Parameter */ - dsVideoPortGetHandleParam_t vidPortParam; - memset(&vidPortParam, 0, sizeof(vidPortParam)); - vidPortParam.type = dsVIDEOPORT_TYPE_HDMI; - vidPortParam.index = 0; - _dsGetVideoPort(&vidPortParam); - vidPortParam.handle; - - if(vidPortParam.handle != NULL) - { - dsSetBackgroundColorParam_t setBGColorParam; - memset(&setBGColorParam, 0, sizeof(setBGColorParam)); - setBGColorParam.color = color; - setBGColorParam.handle= vidPortParam.handle; - _dsSetBackgroundColor(&setBGColorParam); - } -} - - -/*Event Handler for DS Manager And Sys Manager Events */ -static void _EventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) -{ - /*Handle only Sys Manager Events */ - if (strcmp(owner, IARM_BUS_SYSMGR_NAME) == 0) - { - /* Only handle state events */ - if (eventId != IARM_BUS_SYSMGR_EVENT_SYSTEMSTATE) return; - // __TIMESTAMP();printf("_sysMgrEventHandler invoked in DS Manager\r\n"); - IARM_Bus_SYSMgr_EventData_t *sysEventData = (IARM_Bus_SYSMgr_EventData_t*)data; - IARM_Bus_SYSMgr_SystemState_t stateId = sysEventData->data.systemStates.stateId; - int state = sysEventData->data.systemStates.state; - __TIMESTAMP();printf("_sysEventHandler invoked for stateid %d of state %d \r\n", stateId, state); - switch(stateId) { - case IARM_BUS_SYSMGR_SYSSTATE_TUNEREADY: - __TIMESTAMP();printf("Tune Ready Evenets in DS Manager \r\n"); - - if (0 == iTuneReady) - { - iTuneReady = 1; - - /* Set audio mode from persistent */ - _setAudioMode(); - - /* Un-block the Resolution Settings Thread */ - pthread_mutex_lock(&tdsMutexLock); - pthread_cond_signal(&tdsMutexCond); - pthread_mutex_unlock(&tdsMutexLock); - } - break; - default: - break; - } - }else if (strcmp(owner,IARM_BUS_DSMGR_NAME) == 0) - { - switch (eventId) { - case IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG: - { - - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - - __TIMESTAMP();printf("[DsMgr] Got HDMI %s Event \r\n",(eventData->data.hdmi_hpd.event == dsDISPLAY_EVENT_CONNECTED ? "Connect" : "Disconnect")); - - setBGColor(dsVIDEO_BGCOLOR_NONE); - - /* Un-Block the Resolution Settings Thread */ - pthread_mutex_lock(&tdsMutexLock); - edisplayEventStatus = ((eventData->data.hdmi_hpd.event == dsDISPLAY_EVENT_CONNECTED) ? dsDISPLAY_EVENT_CONNECTED : dsDISPLAY_EVENT_DISCONNECTED); - pthread_cond_signal(&tdsMutexCond); - pthread_mutex_unlock(&tdsMutexLock); - - } - break; - case IARM_BUS_DSMGR_EVENT_HDCP_STATUS: - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - IARM_Bus_SYSMgr_EventData_t HDCPeventData; - int status = eventData->data.hdmi_hdcp.hdcpStatus; - //__TIMESTAMP();printf("%s: IARM_BUS_DSMGR_EVENT_HDCP_STATUS event status :%d \r\n",__FUNCTION__, status); - - /* HDCP is enabled */ - HDCPeventData.data.systemStates.stateId = IARM_BUS_SYSMGR_SYSSTATE_HDCP_ENABLED; - HDCPeventData.data.systemStates.state = 1; - if (status == dsHDCP_STATUS_AUTHENTICATED ) - { - __TIMESTAMP();printf("Changed status to HDCP Authentication Pass !!!!!!!! ..\r\n"); - HDCPeventData.data.systemStates.state = 1; - bHDCPAuthenticated = true; - __TIMESTAMP();printf("HDCP success - Removed hotplug_event_src Time source %d and set resolution immediately \r\n",hotplug_event_src); - if(hotplug_event_src) - { - g_source_remove(hotplug_event_src); - hotplug_event_src = 0; - } - setBGColor(dsVIDEO_BGCOLOR_NONE); - if (!IsIgnoreEdid_gs) { - _SetVideoPortResolution(); - } - g_timeout_add_seconds((guint)1,dumpEdidOnChecksumDiff,NULL); - } - else if (status == dsHDCP_STATUS_AUTHENTICATIONFAILURE ) - { - __TIMESTAMP();printf("Changed status to HDCP Authentication Fail !!!!!!!! ..\r\n"); - HDCPeventData.data.systemStates.state = 0; - setBGColor(dsVIDEO_BGCOLOR_BLUE); - bHDCPAuthenticated = false; - if (!IsIgnoreEdid_gs) { - _SetVideoPortResolution(); - } - g_timeout_add_seconds((guint)1,dumpEdidOnChecksumDiff,NULL); - } - - IARM_Bus_BroadcastEvent(IARM_BUS_SYSMGR_NAME, (IARM_EventId_t) IARM_BUS_SYSMGR_EVENT_SYSTEMSTATE, (void *)&HDCPeventData, sizeof(HDCPeventData)); - - } - break; - default: - break; - } - } -} - -/* Set Video resolution on HDMI Hot Plug or Tune Ready events */ -static int _SetVideoPortResolution() -{ - intptr_t _hdmihandle = 0; - intptr_t _comphandle = 0; - bool connected=false; - int iCount = 0; - - - __TIMESTAMP(); printf("%s:Enter \r\n",__FUNCTION__); - - _hdmihandle = getVideoPortHandle(dsVIDEOPORT_TYPE_HDMI); - if(_hdmihandle != NULL) - { - - usleep(100*1000); //wait for 100 milli seconds - - - /* - * Check for HDMI DDC Line when HDMI is connected. - */ - connected = isHDMIConnected(); - if(iInitResnFlag && connected) - { - - #ifdef _INIT_RESN_SETTINGS - /*Wait for iResnCount*/ - while(iCount < iResnCount) - { - sleep(1); //wait for 1 sec - if (dsGetHDMIDDCLineStatus()) - { - break; - } - __TIMESTAMP(); printf ("Waiting for HDMI DDC Line to be ready for resolution Change...\r\n"); - iCount++; - } - #endif - } - - /*Set HDMI Resolution if Connected else COomponent or Composite Resolution */ - if(connected){ - - __TIMESTAMP(); printf("Setting HDMI resolution.......... \r\n"); - _SetResolution(&_hdmihandle,dsVIDEOPORT_TYPE_HDMI); - } - else { - _comphandle = getVideoPortHandle(dsVIDEOPORT_TYPE_COMPONENT); - - if (NULL != _comphandle) - { - __TIMESTAMP();printf("Setting Component/Composite Resolution.......... \r\n"); - _SetResolution(&_comphandle,dsVIDEOPORT_TYPE_COMPONENT); - } - else - { - __TIMESTAMP();printf("%s: NULL Handle for component\r\n",__FUNCTION__); - - intptr_t _compositehandle = getVideoPortHandle(dsVIDEOPORT_TYPE_BB); - - if (NULL != _compositehandle) - { - __TIMESTAMP();printf("Setting BB Composite Resolution.......... \r\n"); - _SetResolution(&_compositehandle,dsVIDEOPORT_TYPE_BB); - } - else - { - __TIMESTAMP();printf("%s: NULL Handle for Composite \r\n",__FUNCTION__); - intptr_t _rfhandle = getVideoPortHandle(dsVIDEOPORT_TYPE_RF); - if (NULL != _rfhandle) - { - __TIMESTAMP();printf("Setting RF Resolution.......... \r\n"); - _SetResolution(&_rfhandle,dsVIDEOPORT_TYPE_RF); - } - else - { - __TIMESTAMP();printf("%s: NULL Handle for RF \r\n",__FUNCTION__); - } - } - } - - } - } - else - { - __TIMESTAMP();printf("%s: NULL Handle for HDMI \r\n",__FUNCTION__); - } - __TIMESTAMP();printf("%s:Exit \r\n",__FUNCTION__); - return 0; -} - -/** - * @brief This Function does following : - * Read Persisted resolution - * Verify Persisted resolution with Platform and EDID resolution - * If fails set best EDID resolution supported by platform - * If fails Default to 720P - * If 720p is not supported by TV , Default to 480p - * @param void pointer Device Handle - * * @param Connection Status - ** @return void pointer (NULL) - */ -static int _SetResolution(intptr_t* handle,dsVideoPortType_t PortType) -{ - errno_t rc = -1; - intptr_t _displayHandle = 0; - int numResolutions = 0,i=0; - intptr_t _handle = *handle; - bool IsValidResolution = false; - dsVideoPortSetResolutionParam_t Setparam; - dsVideoPortGetResolutionParam_t Getparam; - dsVideoPortResolution_t *setResn = NULL; - dsDisplayEDID_t edidData; - dsDisplayGetEDIDParam_t Edidparam; - /* - * Default Resolution Compatible check is false - Do not Force compatible resolution on startup - */ - Setparam.forceCompatible = false; - - /*Initialize the struct*/ - memset(&edidData, 0, sizeof(edidData)); - - /* Return if Handle is NULL */ - if (_handle == NULL) - { - __TIMESTAMP();printf("_SetResolution - Got NULL Handle ..\r\n"); - return 0; - } - - /*Get the User Persisted Resolution Based on Handle */ - memset(&Getparam,0,sizeof(Getparam)); - Getparam.handle = _handle; - Getparam.toPersist = true; - _dsGetResolution(&Getparam); - dsVideoPortResolution_t *presolution = &Getparam.resolution; - __TIMESTAMP();printf("Got User Persisted Resolution - %s..\r\n",presolution->name); - - - if (PortType == dsVIDEOPORT_TYPE_HDMI) { - /*Get The Display Handle */ - dsGetDisplay(dsVIDEOPORT_TYPE_HDMI, 0, &_displayHandle); - if (_displayHandle) - { - /* Get the EDID Display Handle */ - memset(&Edidparam,0,sizeof(Edidparam)); - Edidparam.handle = _displayHandle; - _dsGetEDID(&Edidparam); - rc = memcpy_s(&edidData,sizeof(edidData), &Edidparam.edid, sizeof(Edidparam.edid)); - if(rc!=EOK) - { - ERR_CHK(rc); - } - dumpHdmiEdidInfo(&edidData); - numResolutions = edidData.numOfSupportedResolution; - __TIMESTAMP();printf("numResolutions is %d \r\n",numResolutions); - - /* If HDMI is connected and Low power Mode. - The TV might not Transmit the EDID information - Change the Resolution in Next Hot plug - DO not set the Resolution if TV is in DVI mode. - */ - if ((0 == numResolutions) || (!(edidData.hdmiDeviceType))) - { - - __TIMESTAMP();printf("Do not Set Resolution..The HDMI is not Ready !! \r\n"); - __TIMESTAMP();printf("numResolutions = %d edidData.hdmiDeviceType = %d !! \r\n",numResolutions,edidData.hdmiDeviceType); - return 0; - } - - /* - * Check if Persisted Resolution matches with - * TV Resolution list - */ - for (i = 0; i < numResolutions; i++) - { - setResn = &(edidData.suppResolutionList[i]); - printf("presolution->name : %s, resolution->name : %s\r\n",presolution->name,setResn->name); - if ((strcmp(presolution->name,setResn->name) == 0 )) - { - __TIMESTAMP();printf("Breaking..Got Platform Resolution - %s..\r\n",setResn->name); - IsValidResolution = true; - Setparam.forceCompatible = true; - break; - } - } - /* - * The Persisted Resolution Does not matches with TV resolution list - * Set the Best Resolution Supported by TV and Platform - */ - if (false == IsValidResolution) - { - /* Set the Best Resolution Supported by TV and Platform*/ - for (i = numResolutions-1; i >= 0; i--) - { - setResn = &(edidData.suppResolutionList[i]); - int pNumResolutions = dsUTL_DIM(kResolutions); - for (int j = pNumResolutions-1; j >=0; j--) - { - dsVideoPortResolution_t *pfResolution = &kResolutions[j]; - if (0 == (strcmp(pfResolution->name,setResn->name))) - { - __TIMESTAMP();printf("[DsMgr] Set Best TV Supported Resolution %s \r\n",pfResolution->name); - IsValidResolution = true; - break; - } - } - if (IsValidResolution) - { - break; - } - } - } - /* - * The Persisted Resolution Does not matches with TV and Platform - * Resolution List - * Force PLatform Default Resolution - */ - if (false == IsValidResolution) - { - /* Check if the Default platform resolution is supported by Platfrom resolution List i.e 720p */ - dsVideoPortResolution_t *defaultResn; - defaultResn = &kResolutions[kDefaultResIndex]; - for (i = 0; i < numResolutions; i++) - { - setResn = &(edidData.suppResolutionList[i]); - //printf("\n presolution->name : %s, resolution->name : %s\n",defaultResn->name,setResn->name); - if ((strcmp(defaultResn->name,setResn->name) == 0 )) - { - IsValidResolution = true; - __TIMESTAMP();printf("Breaking..Got Default Platform Resolution - %s..\r\n",setResn->name); - break; - } - } - } - - if (false == IsValidResolution) - { - /*Take 480p as resolution if both above cases fail */ - for (i = 0; i < numResolutions; i++) - { - setResn = &(edidData.suppResolutionList[i]); - if ((strcmp("480p",setResn->name) == 0 )) - { - __TIMESTAMP();printf("Breaking..Default to 480p Resolution - %s..\r\n",setResn->name); - IsValidResolution = true; - break; - } - } - } - - if (false == IsValidResolution) - { - /* Boot with the Resolution Supported by TV and Platform*/ - for (i = 0; i < numResolutions; i++) - { - setResn = &(edidData.suppResolutionList[i]); - size_t numResolutions = dsUTL_DIM(kResolutions); - for (size_t j = 0; j < numResolutions; j++) - { - dsVideoPortResolution_t *pfResolution = &kResolutions[j]; - if (0 == (strcmp(pfResolution->name,setResn->name))) - { - __TIMESTAMP();printf("[DsMgr] Boot with TV Supported Resolution %s \r\n",pfResolution->name); - IsValidResolution = true; - break; - } - } - } - } - } - } - else if (PortType == dsVIDEOPORT_TYPE_COMPONENT || PortType == dsVIDEOPORT_TYPE_BB || PortType == dsVIDEOPORT_TYPE_RF) - { - /* Set the Component / Composite Resolution */ - numResolutions = dsUTL_DIM(kResolutions); - for (i = 0; i < numResolutions; i++) - { - setResn = &kResolutions[i]; - if ((strcmp(presolution->name,setResn->name) == 0 )) - { - __TIMESTAMP();printf("Breaking..Got Platform Resolution - %s..\r\n",setResn->name); - IsValidResolution = true; - break; - } - } - } - /* If the Persisted Resolution settings does not matches with Platform Resolution - - Force Default on Component/Composite - This is to keep upward compatible and if we intend to - remove any resolution from Dynamic Resolution List - */ - if(false == IsValidResolution) - { - setResn = &kResolutions[kDefaultResIndex]; - } - - /* Set The Video Port Resolution in Requested Handle */ - Setparam.handle = _handle; - Setparam.toPersist = false; - - /* If 4K support is disabled and last known resolution is 4K, default to 720p (aka default resolution) */ - dsForceDisable4KParam_t res_4K_override; - memset(&res_4K_override, 0, sizeof(res_4K_override)); - _dsGetForceDisable4K((void *) &res_4K_override); - if(true == res_4K_override.disable) - { - if(0 == strncmp(presolution->name, "2160", 4)) - { - __TIMESTAMP();printf("User persisted 4K resolution. Now limiting to default (720p?) as 4K support is now disabled.\n"); - setResn = &kResolutions[kDefaultResIndex]; - } - } - - Setparam.resolution = *setResn; - - /* Call during Init*/ - #ifdef _INIT_RESN_SETTINGS - if(0 == iInitResnFlag) - { - printf("Init Platform Resolution - %s..\r\n",setResn->name); - _dsInitResolution(&Setparam); - return 0 ; - } - #endif - - _dsSetResolution(&Setparam); - return 0 ; -} - -/** - * @brief Thread entry fuction to post Resolution on Hot Plug and Tune ready Events - * - * This functions changes the device resolution on Hot Plug and Tune ready Events - * - * @param void pointer (NULL) - * - * @return void pointer (NULL) - */ -static void* _DSMgrResnThreadFunc(void *arg) -{ - - /* Loop */ - while (1) - { - __TIMESTAMP(); printf ("_DSMgrResnThreadFunc... wait for for HDMI or Tune Ready Events \r\n"); - - /*Wait for the Event*/ - pthread_mutex_lock(&tdsMutexLock); - pthread_cond_wait(&tdsMutexCond, &tdsMutexLock); - pthread_mutex_unlock(&tdsMutexLock); - - __TIMESTAMP();printf("%s: Setting Resolution On:: HDMI %s Event with TuneReady status = %d \r\n",__FUNCTION__, (edisplayEventStatus == dsDISPLAY_EVENT_CONNECTED ? "Connect" : "Disconnect"),iTuneReady); - - - //On hot plug event , Remove event source - if(hotplug_event_src) - { - g_source_remove(hotplug_event_src); - __TIMESTAMP();printf("Removed Hot Plug Event Time source %d \r\n",hotplug_event_src); - hotplug_event_src = 0; - } - - /*Set the Resolution only on HDMI Hot plug Connect and Tune Ready events */ - if((1 == iTuneReady) && (dsDISPLAY_EVENT_CONNECTED == edisplayEventStatus)) { - /*Set Video Output Port Resolution */ - if(bHDCPAuthenticated) - { - _SetVideoPortResolution(); - } - /* Set audio mode on HDMI hot plug */ - _setAudioMode(); - }/*Set the Resolution only on HDMI Hot plug - Disconnect and Tune Ready event */ - else if((1 == iTuneReady) && (dsDISPLAY_EVENT_DISCONNECTED == edisplayEventStatus)) { - /* * To avoid reoslution settings of HDMI hot plug when TV goes from power OFF to ON condition - * Delay the setting of resolution by 5 sec. This will help to filter out un-necessary - * resolution settings on HDMI hot plug. - */ - bHDCPAuthenticated = false; - if(isComponentPortPresent()) - { - hotplug_event_src = g_timeout_add_seconds((guint)5,_SetResolutionHandler,dsMgr_Gloop); - __TIMESTAMP();printf("Schedule a handler to set the resolution after 5 sec for %d time src.. \r\n",hotplug_event_src); - } - } - - } - return arg; -} - - -static gboolean _SetResolutionHandler(gpointer data) -{ - __TIMESTAMP();printf("Set Video Resolution after delayed time .. \r\n"); - _SetVideoPortResolution(); - hotplug_event_src = 0; - return FALSE; -} - - -void _setEASAudioMode() -{ - - if (isEAS != IARM_BUS_SYS_MODE_EAS) { - __TIMESTAMP();printf("EAS Not In progress..Do not Modify Audio \r\n"); - return; - } - - dsAudioGetHandleParam_t getHandle; - dsAudioSetStereoModeParam_t setMode; - int numPorts, i = 0; - - numPorts = dsUTL_DIM(kSupportedPortTypes); - for (i=0; i < numPorts; i++) - { - const dsAudioPortType_t *audioPort = &kSupportedPortTypes[i]; - memset(&getHandle, 0, sizeof(getHandle)); - getHandle.type = *audioPort; - getHandle.index = 0; - _dsGetAudioPort (&getHandle); - - memset(&setMode, 0, sizeof(setMode)); - setMode.handle = getHandle.handle; - setMode.toPersist = false; - _dsGetStereoMode(&setMode); - - if (setMode.mode == dsAUDIO_STEREO_PASSTHRU) { - /* In EAS, fallsback to Stereo */ - setMode.mode = dsAUDIO_STEREO_STEREO; - } - - __TIMESTAMP();printf("EAS Audio mode for audio port %d is : %d \r\n",getHandle.type, setMode.mode); - setMode.toPersist = false; - _dsSetStereoMode (&setMode); - } -} -/** - * @brief Local function to get and set audio mode - * - * This functions gets the audio mode from persistent and sets it - * - * @param NULL - * - * @return NULL - */ -static void _setAudioMode() -{ - if (isEAS == IARM_BUS_SYS_MODE_EAS) { - __TIMESTAMP();printf("EAS In progress..Do not Modify Audio \r\n"); - return; - } - - dsAudioGetHandleParam_t getHandle; - dsAudioSetStereoModeParam_t setMode; - int numPorts, i = 0; - - numPorts = dsUTL_DIM(kSupportedPortTypes); - for (i=0; i < numPorts; i++) - { - const dsAudioPortType_t *audioPort = &kSupportedPortTypes[i]; - memset(&getHandle, 0, sizeof(getHandle)); - getHandle.type = *audioPort; - getHandle.index = 0; - _dsGetAudioPort (&getHandle); - - memset(&setMode, 0, sizeof(setMode)); - setMode.handle = getHandle.handle; - setMode.toPersist = true; - _dsGetStereoMode(&setMode); - if (getHandle.type == dsAUDIOPORT_TYPE_SPDIF) { - } - else if (getHandle.type == dsAUDIOPORT_TYPE_HDMI) { - //check if it is connected - intptr_t vHandle = 0; - int autoMode = 0; - bool connected = 0; - bool IsSurround = false; - { - dsVideoPortGetHandleParam_t param; - memset(¶m, 0, sizeof(param)); - param.type = dsVIDEOPORT_TYPE_HDMI; - param.index = 0; - _dsGetVideoPort(¶m); - vHandle = param.handle; - //printf("Audio port has HDMI handle\r\n"); - } - { - dsVideoPortIsDisplayConnectedParam_t param; - memset(¶m, 0, sizeof(param)); - param.handle = vHandle; - _dsIsDisplayConnected(¶m); - connected = param.connected; - //printf("Audio port HDMI is connected to sink %d\r\n", connected); - } - - if (!(connected)) { - __TIMESTAMP();printf("HDMI Not Connected ..Do not Set Audio on HDMI !!! \r\n"); - continue; - } - - { - dsAudioSetStereoAutoParam_t param; - memset(¶m, 0, sizeof(param)); - param.handle = getHandle.handle; - _dsGetStereoAuto(¶m); - autoMode = param.autoMode; - //printf("Audio port HDMI is Auto mode %d\r\n", autoMode); - } - - //printf("Audio port HDMI %d is connected %d Auto mode %d\r\n", vHandle, connected, autoMode); - if (autoMode) { - /* If auto, then force surround */ - setMode.mode = dsAUDIO_STEREO_SURROUND; - } - - if (0) /* Do not enforce surround protection, let HAL do it*/ - { - dsVideoPortIsDisplaySurroundParam_t param; - param.handle = vHandle; - param.surround = false; - _dsIsDisplaySurround(¶m); - IsSurround = param.surround; - } - else - { - IsSurround = true; - } - if (!(IsSurround)) { - /* If Surround not supported , then force Stereo */ - setMode.mode = dsAUDIO_STEREO_STEREO; - __TIMESTAMP();printf("Surround mode not Supported on HDMI ..Set Stereo \r\n"); - } - } - __TIMESTAMP();printf("Audio mode for audio port %d is : %d \r\n",getHandle.type, setMode.mode); - setMode.toPersist = false; - _dsSetStereoMode (&setMode); - } -} - -/* This functions Dump the HDMI EDID Information of the box. - * - * @param NULL - * - * @return NULL - */ -static void dumpHdmiEdidInfo(dsDisplayEDID_t* pedidData) -{ - __TIMESTAMP();printf("Connected HDMI Display Device Info !!!!!\r\n"); - - if (NULL == pedidData) { - __TIMESTAMP(); printf("Received EDID is NULL \r\n"); - return; - } - - if(pedidData->monitorName) - printf("HDMI Monitor Name is %s \r\n",pedidData->monitorName); - printf("HDMI Manufacturing ID is %d \r\n",pedidData->serialNumber); - printf("HDMI Product Code is %d \r\n",pedidData->productCode); - printf("HDMI Device Type is %s \r\n",pedidData->hdmiDeviceType?"HDMI":"DVI"); - printf("HDMI Sink Device %s a Repeater \r\n",pedidData->isRepeater?"is":"is not"); - printf("HDMI Physical Address is %d:%d:%d:%d \r\n",pedidData->physicalAddressA, - pedidData->physicalAddressB,pedidData->physicalAddressC,pedidData->physicalAddressD); -} - - -static gboolean dumpEdidOnChecksumDiff(gpointer data) { - __TIMESTAMP();printf("dumpEdidOnChecksumDiff HDMI-EDID Dump>>>>>>>>>>>>>>\r\n"); - intptr_t _displayHandle = 0; - dsGetDisplay(dsVIDEOPORT_TYPE_HDMI, 0, &_displayHandle); - if (_displayHandle) { - int length = 0; - dsDisplayGetEDIDBytesParam_t EdidBytesParam; - static int cached_EDID_checksum = 0; - int current_EDID_checksum = 0; - memset(&EdidBytesParam,0,sizeof(EdidBytesParam)); - EdidBytesParam.handle = _displayHandle; - _dsGetEDIDBytes(&EdidBytesParam); - length = EdidBytesParam.length; - - if((length > 0) && (length <= 512)) { - unsigned char* edidBytes = EdidBytesParam.bytes; - for (int i = 0; i < (length / 128); i++) - current_EDID_checksum += edidBytes[(i+1)*128 - 1]; - - if((cached_EDID_checksum == 0) || (current_EDID_checksum != cached_EDID_checksum)) { - cached_EDID_checksum = current_EDID_checksum; - __TIMESTAMP();printf("HDMI-EDID Dump BEGIN>>>>>>>>>>>>>>\r\n"); - for (int i = 0; i < length; i++) { - if (i % 16 == 0) { - printf("\r\n"); - } - if (i % 128 == 0) { - printf("\r\n"); - } - printf("%02X ", edidBytes[i]); - } - printf("\nHDMI-EDID Dump END>>>>>>>>>>>>>>\r\n"); - } - } - } - return false; -} - -/** @} */ -/** @} */ diff --git a/L2HalMock/patches/rdkservices/patchRemove.patch b/L2HalMock/patches/rdkservices/patchRemove.patch deleted file mode 100644 index 7fa5a1147..000000000 --- a/L2HalMock/patches/rdkservices/patchRemove.patch +++ /dev/null @@ -1,58 +0,0 @@ -Signed-off-by: Kishore Darmaradje ---- -diff --git a/HdmiCecSource/CMakeLists.txt b/HdmiCecSource/CMakeLists.txt -index daabbee3..bd14cca5 100644 ---- a/HdmiCecSource/CMakeLists.txt -+++ b/HdmiCecSource/CMakeLists.txt -@@ -40,6 +40,23 @@ target_include_directories(${MODULE_NAME} PRIVATE ${DS_INCLUDE_DIRS}) - - target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${CEC_LIBRARIES} ${DS_LIBRARIES} ) - -+if(HALMOCK_PROJECT) -+file(GLOB libraries ${DS_LIBRARIES}/*.so) -+foreach(lib ${libraries}) -+ target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${lib}) -+endforeach(lib) -+ -+file(GLOB libraries ${IARM_LIBRARIES}/*.so) -+foreach(lib ${libraries}) -+ target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${lib}) -+endforeach(lib) -+ -+file(GLOB libraries ${CEC_LIBRARIES}/*.so) -+foreach(lib ${libraries}) -+ target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${lib}) -+endforeach(lib) -+endif() -+ - if (NOT RDK_SERVICES_TEST) - target_compile_options(${MODULE_NAME} PRIVATE -Wno-error=deprecated) - endif () -diff --git a/cmake/FindCEC.cmake b/cmake/FindCEC.cmake -index a55dbbd2..e9c2b3b5 100644 ---- a/cmake/FindCEC.cmake -+++ b/cmake/FindCEC.cmake -@@ -34,7 +34,9 @@ find_path(OSAL_INCLUDE_DIRS NAMES osal/Mutex.hpp PATH_SUFFIXES osal/include) - find_path(CEC_HOST_INCLUDE_DIRS NAMES ccec/host/RDK.hpp PATH_SUFFIXES host/include) - find_path(CEC_IARM_INCLUDE_DIRS NAMES ccec/drivers/iarmbus/CecIARMBusMgr.h PATH_SUFFIXES ccec/drivers/include) - -+if(NOT HALMOCK_PROJECT) - set(CEC_LIBRARIES "-Wl,--no-as-needed" ${CEC_LIBRARIES} ${CEC_IARM_LIBRARIES} ${OSAL_LIBRARIES} "-Wl,--as-needed") -+endif() - - set(CEC_LIBRARIES ${CEC_LIBRARIES} CACHE PATH "Path to CEC library") - -diff --git a/cmake/FindDS.cmake b/cmake/FindDS.cmake -index b858fffc..15ea879c 100644 ---- a/cmake/FindDS.cmake -+++ b/cmake/FindDS.cmake -@@ -33,7 +33,9 @@ find_path(DS_INCLUDE_DIRS NAMES manager.hpp PATH_SUFFIXES rdk/ds) - find_path(DSHAL_INCLUDE_DIRS NAMES dsTypes.h PATH_SUFFIXES rdk/ds-hal) - find_path(DSRPC_INCLUDE_DIRS NAMES dsMgr.h PATH_SUFFIXES rdk/ds-rpc) - -+if(NOT HALMOCK_PROJECT) - set(DS_LIBRARIES ${DS_LIBRARIES} ${DSHAL_LIBRARIES}) -+endif() - set(DS_LIBRARIES ${DS_LIBRARIES} CACHE PATH "Path to DS library") - set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} ${DSHAL_INCLUDE_DIRS} ${DSRPC_INCLUDE_DIRS}) - set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} CACHE PATH "Path to DS include") diff --git a/L2HalMock/patches/rdkservices/properties/HdmiCecSink/device.properties b/L2HalMock/patches/rdkservices/properties/HdmiCecSink/device.properties deleted file mode 100644 index 97edd1918..000000000 --- a/L2HalMock/patches/rdkservices/properties/HdmiCecSink/device.properties +++ /dev/null @@ -1 +0,0 @@ -RDK_PROFILE=TV diff --git a/L2HalMock/patches/rdkservices/properties/HdmiCecSource/device.properties b/L2HalMock/patches/rdkservices/properties/HdmiCecSource/device.properties deleted file mode 100644 index 2170d504c..000000000 --- a/L2HalMock/patches/rdkservices/properties/HdmiCecSource/device.properties +++ /dev/null @@ -1 +0,0 @@ -RDK_PROFILE=STB diff --git a/L2HalMock/patches/rdkservices/rdkservices_patch.patch b/L2HalMock/patches/rdkservices/rdkservices_patch.patch deleted file mode 100644 index 896d9dce5..000000000 --- a/L2HalMock/patches/rdkservices/rdkservices_patch.patch +++ /dev/null @@ -1,276 +0,0 @@ -Signed-off-by: Kishore Darmaradje ---- -diff -Naur rdkservices_org/cmake/FindCEC.cmake rdkservices/cmake/FindCEC.cmake ---- rdkservices_org/cmake/FindCEC.cmake 2024-01-23 09:20:14.254329106 -0500 -+++ rdkservices/cmake/FindCEC.cmake 2024-01-23 09:38:36.752032679 -0500 -@@ -25,21 +25,31 @@ - - find_package(PkgConfig) - --find_library(CEC_LIBRARIES NAMES RCEC) --find_library(CEC_IARM_LIBRARIES NAMES RCECIARMBusHal) --find_library(OSAL_LIBRARIES NAMES RCECOSHal) -- --find_path(CEC_INCLUDE_DIRS NAMES ccec/Connection.hpp PATH_SUFFIXES ccec/include) --find_path(OSAL_INCLUDE_DIRS NAMES osal/Mutex.hpp PATH_SUFFIXES osal/include) --find_path(CEC_HOST_INCLUDE_DIRS NAMES ccec/host/RDK.hpp PATH_SUFFIXES host/include) --find_path(CEC_IARM_INCLUDE_DIRS NAMES ccec/drivers/iarmbus/CecIARMBusMgr.h PATH_SUFFIXES ccec/drivers/include) -- --set(CEC_LIBRARIES "-Wl,--no-as-needed" ${CEC_LIBRARIES} ${CEC_IARM_LIBRARIES} ${OSAL_LIBRARIES} "-Wl,--as-needed") -- --set(CEC_LIBRARIES ${CEC_LIBRARIES} CACHE PATH "Path to CEC library") -- --set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} ${OSAL_INCLUDE_DIRS} ${CEC_HOST_INCLUDE_DIRS} ${CEC_IARM_INCLUDE_DIRS}) --set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} CACHE PATH "Path to CEC include") -+#find_library(CEC_LIBRARIES NAMES RCEC) -+#find_library(CEC_IARM_LIBRARIES NAMES RCECIARMBusHal) -+#find_library(OSAL_LIBRARIES NAMES RCECOSHal) -+ -+#find_path(CEC_INCLUDE_DIRS NAMES ccec PATH_SUFFIXES ccec/include) -+#find_path(OSAL_INCLUDE_DIRS NAMES osal PATH_SUFFIXES osal/include) -+#find_path(CEC_HOST_INCLUDE_DIRS NAMES ccec/host PATH_SUFFIXES host/include) -+#find_path(CEC_IARM_INCLUDE_DIRS NAMES ccec/drivers/iarmbus PATH_SUFFIXES ccec/drivers/include) -+ -+#set(CEC_LIBRARIES "-Wl,--no-as-needed" ${CEC_LIBRARIES} ${CEC_IARM_LIBRARIES} ${OSAL_LIBRARIES} "-Wl,--as-needed") -+ -+#set(CEC_LIBRARIES ${CEC_LIBRARIES} CACHE PATH "Path to library") -+ -+#set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} ${OSAL_INCLUDE_DIRS} ${CEC_HOST_INCLUDE_DIRS} ${CEC_IARM_INCLUDE_DIRS}) -+#set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} CACHE PATH "Path to include directories") -+ -+set(CEC_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/hdmicec/ccec/include) -+set(OSAL_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/hdmicec/osal/include) -+set(CEC_HOST_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/hdmicec/host/include) -+set(CEC_IARM_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/hdmicec/ccec/drivers/include) -+message(STATUS "Anooj CEC_INCLUDE_DIRS: ${CEC_INCLUDE_DIRS}") -+set(CEC_DIRS ${CEC_INCLUDE_DIRS} ${OSAL_INCLUDE_DIRS} ${CEC_HOST_INCLUDE_DIRS} ${CEC_IARM_INCLUDE_DIRS}) -+message(STATUS "Anooj CEC_DIRS: ${CEC_DIRS}") -+set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} CACHE PATH "Path to include directories") -+set(CEC_LIBRARIES ${CMAKE_ROOT_DIR}/deps/rdk/hdmicec/install/lib) - - include(FindPackageHandleStandardArgs) - #FIND_PACKAGE_HANDLE_STANDARD_ARGS(IARMBUS DEFAULT_MSG IARMBUS_INCLUDE_DIRS IARMBUS_LIBRARIES) -diff -Naur rdkservices_org/cmake/FindDS.cmake rdkservices/cmake/FindDS.cmake ---- rdkservices_org/cmake/FindDS.cmake 2024-01-23 09:20:14.254329106 -0500 -+++ rdkservices/cmake/FindDS.cmake 2024-01-23 09:20:26.374459926 -0500 -@@ -25,18 +25,24 @@ - - find_package(PkgConfig) - --find_library(DS_LIBRARIES NAMES ds) --find_library(DSHAL_LIBRARIES NAMES dshalcli) --find_library(OEMHAL_LIBRARIES NAMES ds-hal) --find_library(IARMBUS_LIBRARIES NAMES IARMBus) --find_path(DS_INCLUDE_DIRS NAMES manager.hpp PATH_SUFFIXES ds/include) --find_path(DSHAL_INCLUDE_DIRS NAMES dsTypes.h PATH_SUFFIXES hal/include) --find_path(DSRPC_INCLUDE_DIRS NAMES dsMgr.h PATH_SUFFIXES rpc/include) -- --set(DS_LIBRARIES ${DS_LIBRARIES} ${DSHAL_LIBRARIES}) --set(DS_LIBRARIES ${DS_LIBRARIES} CACHE PATH "Path to DS library") --set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} ${DSHAL_INCLUDE_DIRS} ${DSRPC_INCLUDE_DIRS}) --set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} CACHE PATH "Path to DS include") -+#find_library(DS_LIBRARIES NAMES ds) -+#find_library(DSHAL_LIBRARIES NAMES dshalcli) -+#find_library(OEMHAL_LIBRARIES NAMES ds-hal) -+#find_library(IARMBUS_LIBRARIES NAMES IARMBus) -+#find_path(DS_INCLUDE_DIRS NAMES manager.hpp PATH_SUFFIXES ds/include) -+#find_path(DSHAL_INCLUDE_DIRS NAMES dsTypes.h PATHS hal/include/) -+#find_path(DSRPC_INCLUDE_DIRS NAMES dsMgr.h PATH_SUFFIXES rpc/include) -+ -+#set(DS_LIBRARIES ${DS_LIBRARIES} ${DSHAL_LIBRARIES}) -+#set(DS_LIBRARIES ${DS_LIBRARIES} CACHE PATH "Path to DS library") -+#set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} ${DSHAL_INCLUDE_DIRS} ${DSRPC_INCLUDE_DIRS}) -+set(DS_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/devicesettings/ds/include) -+set(DSHAL_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/devicesettings/hal/include) -+set(DSRPC_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/devicesettings/rpc/include) -+set(DS_DIRS ${DS_INCLUDE_DIRS} ${DSHAL_INCLUDE_DIRS} ${DSRPC_INCLUDE_DIRS}) -+set(DS_LIBRARIES ${CMAKE_ROOT_DIR}/deps/rdk/devicesettings/install/lib) -+#set(DS_INCLUDE_DIRS ${DSHAL_INCLUDE_DIRS}) -+#set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} CACHE PATH "Path to DS include") - - - -diff -Naur rdkservices_org/cmake/FindIARMBus.cmake rdkservices/cmake/FindIARMBus.cmake ---- rdkservices_org/cmake/FindIARMBus.cmake 2024-01-23 09:20:14.254329106 -0500 -+++ rdkservices/cmake/FindIARMBus.cmake 2024-01-23 09:20:26.374459926 -0500 -@@ -25,15 +25,12 @@ - - find_package(PkgConfig) - --find_library(IARMBUS_LIBRARIES NAMES IARMBus) --find_path(IARMBUS_INCLUDE_DIRS NAMES libIARM.h PATH_SUFFIXES core/include) --find_path(IARMIR_INCLUDE_DIRS NAMES irMgr.h PATH_SUFFIXES ir/include) --find_path(IARMRECEIVER_INCLUDE_DIRS NAMES receiverMgr.h PATH_SUFFIXES receiver/include) --find_path(IARMPWR_INCLUDE_DIRS NAMES pwrMgr.h PATH_SUFFIXES hal/include) -- --set(IARMBUS_LIBRARIES ${IARMBUS_LIBRARIES} CACHE PATH "Path to IARMBus library") --set(IARMBUS_INCLUDE_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS} ${IARMRECEIVER_INCLUDE_DIRS} ${IARMPWR_INCLUDE_DIRS}) --set(IARMBUS_INCLUDE_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS} ${IARMRECEIVER_INCLUDE_DIRS} ${IARMPWR_INCLUDE_DIRS} CACHE PATH "Path to IARMBus include") -+set(IARMBUS_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/iarmbus/core/include) -+set(IARMIR_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/iarmmgrs/ir/include) -+set(IARMRECEIVER_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/iarmmgrs/receiver/include) -+set(IARMPWR_INCLUDE_DIRS ${CMAKE_ROOT_DIR}/deps/rdk/iarmmgrs/hal/include) -+set(IARM_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS} ${IARMRECEIVER_INCLUDE_DIRS} ${IARMPWR_INCLUDE_DIRS}) -+set(IARM_LIBRARIES ${CMAKE_ROOT_DIR}/deps/rdk/iarmbus/install/) - - include(FindPackageHandleStandardArgs) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(IARMBUS DEFAULT_MSG IARMBUS_INCLUDE_DIRS IARMBUS_LIBRARIES) -diff -Naur rdkservices_org/CMakeLists.txt rdkservices/CMakeLists.txt ---- rdkservices_org/CMakeLists.txt 2024-01-23 09:20:14.254329106 -0500 -+++ rdkservices/CMakeLists.txt 2024-01-23 09:20:26.378459949 -0500 -@@ -1,69 +1,70 @@ --### --# If not stated otherwise in this file or this component's LICENSE --# file the following copyright and licenses apply: --# --# Copyright 2023 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. --### -- --cmake_minimum_required(VERSION 3.3) -- --find_package(WPEFramework) -- --# All packages that did not deliver a CMake Find script (and some deprecated scripts that need to be removed) --# are located in the cmake directory. Include it in the search. --list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") -- --option(COMCAST_CONFIG "Comcast services configuration" ON) --if(COMCAST_CONFIG) -- include(services.cmake) --endif() -- --option(PLUGIN_OCICONTAINER "Include OCIContainer plugin" OFF) --option(PLUGIN_RUSTBRIDGE "Include RustBridge plugin" OFF) -- --if(RDK_SERVICES_TEST) -- include(tests.cmake) --endif() -- --# Library installation section --string(TOLOWER ${NAMESPACE} STORAGE_DIRECTORY) -- --# for writing pc and config files --include(CmakeHelperFunctions) -- --if(PLUGIN_HDMICECSOURCE) -- add_subdirectory(HdmiCecSource) --endif() -- --if(WPEFRAMEWORK_CREATE_IPKG_TARGETS) -- set(CPACK_GENERATOR "DEB") -- set(CPACK_DEB_COMPONENT_INSTALL ON) -- set(CPACK_COMPONENTS_GROUPING IGNORE) -- -- set(CPACK_DEBIAN_PACKAGE_NAME "${WPEFRAMEWORK_PLUGINS_OPKG_NAME}") -- set(CPACK_DEBIAN_PACKAGE_VERSION "${WPEFRAMEWORK_PLUGINS_OPKG_VERSION}") -- set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${WPEFRAMEWORK_PLUGINS_OPKG_ARCHITECTURE}") -- set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${WPEFRAMEWORK_PLUGINS_OPKG_MAINTAINER}") -- set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${WPEFRAMEWORK_PLUGINS_OPKG_DESCRIPTION}") -- set(CPACK_PACKAGE_FILE_NAME "${WPEFRAMEWORK_PLUGINS_OPKG_FILE_NAME}") -- -- # list of components from which packages will be generated -- set(CPACK_COMPONENTS_ALL -- ${NAMESPACE}WebKitBrowser -- WPEInjectedBundle -- ) -- -- include(CPack) --endif() -+### -+# If not stated otherwise in this file or this component's LICENSE -+# file the following copyright and licenses apply: -+# -+# Copyright 2023 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. -+### -+ -+cmake_minimum_required(VERSION 3.3) -+project(halmock) -+find_package(WPEFramework PATHS ${WORKSPACE}/install/usr/lib/cmake/WPEFramework) -+set(CMAKE_ROOT_DIR "${WORKSPACE}") -+set(URL_INCLUDE_DIR "${WORKSPACE}/Thunder/Source/websocket") -+# All packages that did not deliver a CMake Find script (and some deprecated scripts that need to be removed) -+# are located in the cmake directory. Include it in the search. -+list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") -+ -+option(COMCAST_CONFIG "Comcast services configuration" ON) -+if(COMCAST_CONFIG) -+ include(services.cmake) -+endif() -+ -+option(PLUGIN_OCICONTAINER "Include OCIContainer plugin" OFF) -+option(PLUGIN_RUSTBRIDGE "Include RustBridge plugin" OFF) -+ -+if(RDK_SERVICES_TEST) -+ include(tests.cmake) -+endif() -+ -+# Library installation section -+string(TOLOWER ${NAMESPACE} STORAGE_DIRECTORY) -+ -+# for writing pc and config files -+include(${WORKSPACE}/install/usr/lib/cmake/WPEFramework/common/CmakeHelperFunctions.cmake) -+ -+if(PLUGIN_HDMICECSOURCE) -+ add_subdirectory(HdmiCecSource) -+endif() -+ -+if(WPEFRAMEWORK_CREATE_IPKG_TARGETS) -+ set(CPACK_GENERATOR "DEB") -+ set(CPACK_DEB_COMPONENT_INSTALL ON) -+ set(CPACK_COMPONENTS_GROUPING IGNORE) -+ -+ set(CPACK_DEBIAN_PACKAGE_NAME "${WPEFRAMEWORK_PLUGINS_OPKG_NAME}") -+ set(CPACK_DEBIAN_PACKAGE_VERSION "${WPEFRAMEWORK_PLUGINS_OPKG_VERSION}") -+ set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${WPEFRAMEWORK_PLUGINS_OPKG_ARCHITECTURE}") -+ set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${WPEFRAMEWORK_PLUGINS_OPKG_MAINTAINER}") -+ set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${WPEFRAMEWORK_PLUGINS_OPKG_DESCRIPTION}") -+ set(CPACK_PACKAGE_FILE_NAME "${WPEFRAMEWORK_PLUGINS_OPKG_FILE_NAME}") -+ -+ # list of components from which packages will be generated -+ set(CPACK_COMPONENTS_ALL -+ ${NAMESPACE}WebKitBrowser -+ WPEInjectedBundle -+ ) -+ -+ include(CPack) -+endif() -diff -Naur rdkservices_org/HdmiCecSource/CMakeLists.txt rdkservices/HdmiCecSource/CMakeLists.txt ---- rdkservices_org/HdmiCecSource/CMakeLists.txt 2024-01-23 09:20:14.194328162 -0500 -+++ rdkservices/HdmiCecSource/CMakeLists.txt 2024-01-23 09:40:13.224387067 -0500 -@@ -34,9 +34,9 @@ - find_package(IARMBus) - find_package(CEC) - --target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS} ../helpers) --target_include_directories(${MODULE_NAME} PRIVATE ${CEC_INCLUDE_DIRS}) --target_include_directories(${MODULE_NAME} PRIVATE ${DS_INCLUDE_DIRS}) -+target_include_directories(${MODULE_NAME} PRIVATE ${IARM_DIRS} ../helpers) -+target_include_directories(${MODULE_NAME} PRIVATE ${CEC_DIRS}) -+target_include_directories(${MODULE_NAME} PRIVATE ${DS_DIRS}) - - target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${CEC_LIBRARIES} ${DS_LIBRARIES} ) - diff --git a/L2HalMock/patches/rdkservices/rfcapi.h b/L2HalMock/patches/rdkservices/rfcapi.h deleted file mode 100644 index d92f6d15e..000000000 --- a/L2HalMock/patches/rdkservices/rfcapi.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * If not stated otherwise in this file or this component's Licenses.txt file the - * following copyright and licenses apply: - * - * Copyright 2016 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. -*/ - -#ifndef RFCAPI_H_ -#define RFCAPI_H_ - -#include -#include - -#define RFCVAR_FILE "/opt/secure/RFC/rfcVariable.ini" -#define TR181STORE_FILE "/opt/secure/RFC/tr181store.ini" - -#ifdef __cplusplus -extern "C" -{ -#endif -#ifndef RDKC -#include -#endif - -#define MAX_PARAM_LEN (2*1024) - -#ifdef RDKC -typedef enum -{ - SUCCESS=0, - FAILURE, - NONE, - EMPTY -}DATATYPE; -#endif - -#ifdef RDKC -typedef struct _RFC_Param_t { - char name[MAX_PARAM_LEN]; - char value[MAX_PARAM_LEN]; - DATATYPE type; -} RFC_ParamData_t; -#else -typedef struct _RFC_Param_t { - char name[MAX_PARAM_LEN]; - char value[MAX_PARAM_LEN]; - DATA_TYPE type; -} RFC_ParamData_t; -#endif -#ifdef RDKC -int getRFCParameter(const char* pcParameterName, RFC_ParamData_t *pstParamData); -#else -WDMP_STATUS getRFCParameter(const char *pcCallerID, const char* pcParameterName, RFC_ParamData_t *pstParamData); -WDMP_STATUS setRFCParameter(const char *pcCallerID, const char* pcParameterName, const char* pcParameterValue, DATA_TYPE eDataType); -const char* getRFCErrorString(WDMP_STATUS code); -bool isRFCEnabled(const char *); -bool isFileInDirectory(const char *, const char *); -#endif -#ifdef __cplusplus -} -#endif - -#endif diff --git a/L2HalMock/patches/thunder/JSON_Value.patch b/L2HalMock/patches/thunder/JSON_Value.patch deleted file mode 100644 index 35d3e7de2..000000000 --- a/L2HalMock/patches/thunder/JSON_Value.patch +++ /dev/null @@ -1,16 +0,0 @@ -Signed-off-by: Kishore Darmaradje ---- -diff --git a/Source/core/JSONRPC.h b/Source/core/JSONRPC.h -index 7b48a579..015c18b8 100644 ---- a/Source/core/JSONRPC.h -+++ b/Source/core/JSONRPC.h -@@ -149,7 +149,8 @@ namespace Core { - Text = _T("Requested service is not available."); - break; - default: -- Code = ApplicationErrorCodeBase - static_cast(frameworkError); -+ // Code = ApplicationErrorCodeBase - static_cast(frameworkError); -+ Code = frameworkError; - Text = Core::ErrorToString(frameworkError); - break; - } diff --git a/L2HalMock/run.sh b/L2HalMock/run.sh deleted file mode 100644 index 4f33bdb1f..000000000 --- a/L2HalMock/run.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash - -#Fetch the Args -GivenPlugins="$1" - -echo "Starting Services for Plugins: $GivenPlugins" - -echo "Found: $GivenPlugins" - - -# Define ANSI color codes for green -GREEN='\033[0;32m' # Green text -NC='\033[0m' # No color (resets to default) - -# Define ANSI color codes for green -GREEN='\033[0;32m' # Green text -NC='\033[0m' # No color (resets to default) - -SCRIPT=$(readlink -f "$0") -SCRIPTS_DIR=`dirname "$SCRIPT"` -WORKSPACE=$SCRIPTS_DIR/workspace - -# Define the port to check and maximum number of seconds to wait -flask_port=8000 -timeout_duration=60 - -# Function to wait for a port to become available -wait_for_port() { - local port="$1" - local timeout="$2" - - for ((i=0; i peru_temp.yaml -echo "Substituted peru.yaml:" -cat peru_temp.yaml -# Move the substituted file to replace the original peru.yaml -chmod 777 peru_temp.yaml -rm -rf peru.yaml -mv peru_temp.yaml peru.yaml -cat peru.yaml - -chmod 644 peru.yaml -# Run peru commands -echo "Running peru sync..." -#peru sync --no-cache -v - -#peru sync && peru sync --no-cache -#peru sync --no-cache - -# Clean up -#rm peru.yaml diff --git a/L2HalMock/sendEvents.sh b/L2HalMock/sendEvents.sh deleted file mode 100644 index 1e3e398ca..000000000 --- a/L2HalMock/sendEvents.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - - -# Define ANSI color codes for green -GREEN='\033[0;32m' # Green text -NC='\033[0m' # No color (resets to default) - -# Define ANSI color codes for green -GREEN='\033[0;32m' # Green text -NC='\033[0m' # No color (resets to default) - -SCRIPT=$(readlink -f "$0") -SCRIPTS_DIR=`dirname "$SCRIPT"` -WORKSPACE=$SCRIPTS_DIR/workspace -SENDER=$WORKSPACE/deps/rdk/sender/ - -echo -e "${GREEN}========================================Run IARM_event_sender===============================================${NC}" -cd $SENDER -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:$WORKSPACE/deps/rdk/iarm_event_sender:$WORKSPACE/deps/rdk/iarmbus/install -./IARM_event_sender cecmgrstatus -./IARM_event_sender dsmrghotplug 0 -./IARM_event_sender dsmrghotplug 1 -./IARM_event_sender dsmrgInhotplug 0 -./IARM_event_sender dsmrgInhotplug 1 -./IARM_event_sender powerModeUpdate 0 1 -./IARM_event_sender hdcpstatusEvent 1 - - diff --git a/L2HalMock/startCEC.sh b/L2HalMock/startCEC.sh deleted file mode 100644 index 729a62f38..000000000 --- a/L2HalMock/startCEC.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -# Define ANSI color codes for green -GREEN='\033[0;32m' # Green text -NC='\033[0m' # No color (resets to default) - -# Define ANSI color codes for green -GREEN='\033[0;32m' # Green text -NC='\033[0m' # No color (resets to default) - -SCRIPT=$(readlink -f "$0") -SCRIPTS_DIR=`dirname "$SCRIPT"` -WORKSPACE=$SCRIPTS_DIR/workspace - -echo -e "${GREEN}========================================Stop all existing services===============================================${NC}" - -killall -9 IARMDaemonMain -killall -9 CecDaemonMain -killall -9 WPEFramework - -pkill IARMDaemonMain -pkill CecDaemonMain -pkill WPEFramework - -echo -e "${GREEN}========================================Run iarmbus===============================================${NC}" -cd $WORKSPACE -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ -deps/rdk/iarmbus/install/bin/IARMDaemonMain & - -unset LD_LIBRARY_PATH - -echo -e "${GREEN}========================================Run cec deamon===============================================${NC}" -cd $WORKSPACE -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/:$WORKSPACE/deps/rdk/hdmicec/install/lib:$WORKSPACE/deps/rdk/hdmicec/ccec/drivers/test:$WORKSPACE/deps/rdk/iarmbus/install/ -deps/rdk/hdmicec/install/bin/CecDaemonMain & - - -echo -e "${GREEN}========================================Run rdkservices===============================================${NC}" -cd $WORKSPACE -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH/usr/local/lib/:$WORKSPACE/deps/rdk/hdmicec/install/lib:$WORKSPACE/deps/rdk/hdmicec/ccec/drivers/test:$WORKSPACE/deps/rdk/iarmbus/install/:$WORKSPACE/install/usr/lib:$WORKSPACE/deps/rdk/devicesettings/install/lib -$WORKSPACE/install/usr/bin/WPEFramework -f -c $WORKSPACE/install/etc/WPEFramework/config.json & diff --git a/L2HalMock/start_services/CecDaemon.py b/L2HalMock/start_services/CecDaemon.py deleted file mode 100644 index b7245d159..000000000 --- a/L2HalMock/start_services/CecDaemon.py +++ /dev/null @@ -1,32 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -import os -import sys -import subprocess -directory_path_cec_daemon = "/home/teuser/.local/bin/act-hdmicecsource-test-poc/deps/rdk/hdmicec/install/bin" - -# Change the current working directory -os.chdir(directory_path_cec_daemon) -result_cec = subprocess.run(['./CecDaemonMain'], stdout=subprocess.PIPE) -output_cec = result_cec.communicate()[0].decode() -sys.stdout.write(output_cec) diff --git a/L2HalMock/start_services/IarmDaemon.py b/L2HalMock/start_services/IarmDaemon.py deleted file mode 100644 index a5f1d503d..000000000 --- a/L2HalMock/start_services/IarmDaemon.py +++ /dev/null @@ -1,35 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -import subprocess -import sys -import os -directory_path_iarm = "/home/teuser/.local/bin/act-hdmicecsource-test-poc/deps/rdk/iarmbus/install/bin" -directory_path_cec_daemon = "/home/teuser/.local/bin/act-hdmicecsource-test-poc/deps/rdk/hdmicec/install/bin" - -# Change the current working directory -os.chdir(directory_path_iarm) -result = subprocess.run(['./IARMDaemonMain'], stdout=subprocess.PIPE) -output = result.communicate()[0].decode() -print(result.stdout.decode()) -print(result.stdout.read().decode()) -sys.stdout.write(output) diff --git a/L2HalMock/start_services/ReadMe.txt b/L2HalMock/start_services/ReadMe.txt deleted file mode 100644 index af5b1aaf5..000000000 --- a/L2HalMock/start_services/ReadMe.txt +++ /dev/null @@ -1,16 +0,0 @@ -Repository has 6 files - -1. start_run.py to start all the services -2. stop_run.py to stop all the services -3. To run start_run.py use the command python3 start_tun.py -4. The logs wrt each services will be appended to the respective paths given in start_run.py - -Instructions to be followed while running start_run.py - -1. Open IarmDaemon.py & cecDaemon.py file and in the working directory variable, update the relative path till the act-hdmicecsource-test-poc (the path to this folder) from your local VM in the variables directory_iarm & directory_cec_daemon respectively - -2.Open Thunder.py file and update the path of WPEFramework/config.json in the variable directory_thunder - -3. Open start_run.py file , check if all the scripts that are called here are present in the same directory hierarchy. - - \ No newline at end of file diff --git a/L2HalMock/start_services/Thunder.py b/L2HalMock/start_services/Thunder.py deleted file mode 100644 index 7d32bdc31..000000000 --- a/L2HalMock/start_services/Thunder.py +++ /dev/null @@ -1,37 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -import subprocess -import sys -import os - -directory_thunder = "/home/teuser/.local/bin/thunder/install/etc/WPEFramework" #update the path to WPEFramework/config.json here - -# Change the current working directory -#os.chdir(directory_thunder) - -# Open a file for writing the output and error -with open("log_file", "w") as logfile: - # Run the command and redirect the output and error to the file - result = subprocess.run(["WPEFramework", "-f", "-c", "config.json"], cwd=directory_thunder, stdout=logfile, stderr=logfile) - -print(result) diff --git a/L2HalMock/start_services/start_run.py b/L2HalMock/start_services/start_run.py deleted file mode 100644 index 08aaf9019..000000000 --- a/L2HalMock/start_services/start_run.py +++ /dev/null @@ -1,60 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -import subprocess -import logging -import time -# Configure logging -logging.basicConfig(level=logging.DEBUG) -# Run first Python script - - -# Run the script with arguments - -Flask = subprocess.Popen(['python3', 'startup.py'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - -if Flask: - print("$$$ Flask service is UP $$$") - -time.sleep(2) - -processA = subprocess.Popen(['python3', 'IarmDaemon.py'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - -time.sleep(2) -if processA: - print("$$$ IarmDaemon is up $$$") - -processB = subprocess.Popen(['python3', 'CecDaemon.py'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - -time.sleep(5) - -if processB: - print("$$$ CecDaemon is up $$$") - -processC = subprocess.Popen(['python3','Thunder.py'], stdout = subprocess.PIPE, stderr=subprocess.STDOUT) - -if processC: - print("$$$ WPEFramework is up $$$") - -time.sleep(5) - - diff --git a/L2HalMock/start_services/startup.py b/L2HalMock/start_services/startup.py deleted file mode 100644 index 8a9fa3f5b..000000000 --- a/L2HalMock/start_services/startup.py +++ /dev/null @@ -1,36 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -import subprocess -import sys -import os - -directory_path_flask = "/home/teuser/L2Testing/Flask" #update the path to FLASK repository here (wherever its being cloned in the VM) - -# Change the current working directory -os.chdir(directory_path_flask) - -with open("log_file_flask", "w") as logfile: - # Run the command and redirect the output and error to the file - result = subprocess.run(["python3", "startup.py"], cwd=directory_path_flask, stdout=logfile, stderr=logfile) - -print(result) diff --git a/L2HalMock/start_services/stop_run.py b/L2HalMock/start_services/stop_run.py deleted file mode 100644 index c1d14b9b2..000000000 --- a/L2HalMock/start_services/stop_run.py +++ /dev/null @@ -1,75 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -import subprocess -import os -import signal - -process_name = "python3" -process_name_thunder = "WPEFramework" -process_name_iARM ="IARMDaemonMain" -process_name_cec ="CecDaemonMain" -output = subprocess.check_output(["ps", "aux"]) -try: - pids = [] - # Parse the output to find the PID - for line in output.decode().splitlines(): - if process_name in line: - - pid = int(line.split()[1]) - pids.append(pid) - else: - pass - if process_name_thunder in line: - pid = int(line.split()[1]) - pids.append(pid) - print("Killing WPEFramework service") - else: - pass - if process_name_iARM in line: - pid = int(line.split()[1]) - pids.append(pid) - print("Killing IARM Daemon") - else: - pass - if process_name_cec in line: - pid = int(line.split()[1]) - pids.append(pid) - print("killing CEC Daemon") - else: - pass - if pids is not None: - for each_pid in pids: - # os.system("sudo kill %s" % (each_pid, )) - try: - os.system("kill -9 %s" % (each_pid, )) - except: - print("process already killed") - else: - print("They are no services up wrt HAL Mock setup") -except: - pass - # os.kill(each_pid, signal.SIGTERM) - - -#kill /home/teuser/.local/bin/start_shell_Script.py -#time.sleep(5) diff --git a/L2HalMock/stop.sh b/L2HalMock/stop.sh deleted file mode 100644 index c41001de0..000000000 --- a/L2HalMock/stop.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - - -# Define ANSI color codes for green -GREEN='\033[0;32m' # Green text -NC='\033[0m' # No color (resets to default) - -# Define ANSI color codes for green -GREEN='\033[0;32m' # Green text -NC='\033[0m' # No color (resets to default) - -SCRIPT=$(readlink -f "$0") -SCRIPTS_DIR=`dirname "$SCRIPT"` -WORKSPACE=$SCRIPTS_DIR/workspace - -# Define the port to check and maximum number of seconds to wait -flask_port=8000 -timeout_duration=60 -echo -e "${GREEN}========================================Stop all existing services===============================================${NC}" -#Stop flask -fuser -k ${flask_port}/tcp -killall -9 python3 -killall -9 IARMDaemonMain -killall -9 CecDaemonMain -killall -9 WPEFramework - -pkill python3 -pkill IARMDaemonMain -pkill CecDaemonMain -pkill WPEFramework diff --git a/L2HalMock/temp.txt b/L2HalMock/temp.txt deleted file mode 100644 index 8b1378917..000000000 --- a/L2HalMock/temp.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/L2HalMock/workflowConfig.env b/L2HalMock/workflowConfig.env deleted file mode 100644 index 8b1378917..000000000 --- a/L2HalMock/workflowConfig.env +++ /dev/null @@ -1 +0,0 @@ - diff --git a/L2HalMock/workspace/deps/rdk/flask/Test_Framework/Config.py b/L2HalMock/workspace/deps/rdk/flask/Test_Framework/Config.py deleted file mode 100644 index 8c17e131b..000000000 --- a/L2HalMock/workspace/deps/rdk/flask/Test_Framework/Config.py +++ /dev/null @@ -1,259 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# This config file contains all the configurable parameters required for Test Framework -import os -# IP & port details of Flask server -flask_server_ip = "127.0.0.1:8000" - -# Define the paths of Websocket server & WPEFramework -# Define the paths of Websocket server & WPEFramework -WPEFramework_restart = os.getcwd() -os.chdir("../Flask") - -directory_websocket = os.getcwd() -os.chdir("../../../../install/etc/WPEFramework") - -directory_thunder = os.getcwd() -os.chdir(WPEFramework_restart) - -# Define the path where WPEFramework logs needs to be stored -file_name = 'log_file.txt' -WPEFramework_logs_path = os.path.abspath(file_name) - -# Data required for setDeviceConfig api -config_data = { - "apiName": "setDeviceConfig", - "arguments": { - "devices": [ - { - "device": [ - {"name": "xione_uk"}, - {"islocal": 1}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "301"}, - {"logicalAddress": "3"}, - {"vendorId": "4567"}, - {"osdName": "404753747265616D696E672054776F"}, - {"optionalProperty1": "value1"}, - {"optionalProperty2": "value2"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "304"}, - {"logicalAddress": "4"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"optionalProperty1": "value1"}, - {"optionalProperty2": "value2"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "304"}, - {"logicalAddress": "9"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"optionalProperty1": "value1"}, - {"optionalProperty2": "value2"} - ] - } - ] - } - } - -# Data required for setAPIConfig api -api_data = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecOpen": [ - { "return": 0 }, - { "outParams": [{"handle": 2345678}] } - ] - }, - { - "HdmiCecGetLogicalAddress": [ - { "return": 0 }, - { "outParams": [{"logicalAddress": "0x3"}] } - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - { "return": 0 }, - { "outParams": [{"physicalAddress": "0x304"}] } - ] - } - ] - } - } - -# Device data for HiSense TV -hisense_device_data = { - "device": [ - {"name": "hisense"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 0}, - {"physicalAddress": "0"}, - {"logicalAddress": "6"}, - {"vendorId": "0x4567"}, - {"osdName": "545620426F78"}, - {"optionalProperty1": "value1"}, - {"optionalProperty2": "value2"} - ] - } - -# Invalid device data for Xione US -invalid_device_data = { - "device": [ - {"name": "xione_us"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 0}, - {"physicalAddress": "333"}, - {"logicalAddress": "77"}, - {"vendorId": "4444"}, - {"osdName": "3333"}, - {"optionalProperty1": "value1"}, - {"optionalProperty2": "value2"} - ] - } - -# Send message data for sendStandbyMessage -sendStandbyMessage = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x03", - "0x36" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } - } - -# message send to know the current power status of device -getPowerStatusMessage = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x03", - "0x8F" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } - } - -# message for perform OTP Action -performOTPActionMessage = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x03", - "0x04" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } - } - -# api overrides data in which return value for HdmiCecOpen is set to -1 -cec_minus_one = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecOpen": [ - {"return": -1}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecGetLogicalAddress": [ - {"return": 0}, - {"outParams": [{"logicalAddress": "0x3"}]} - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - {"return": 0}, - {"outParams": [{"physicalAddress": "0x304"}]} - ] - } - ] - } - } diff --git a/L2HalMock/workspace/deps/rdk/flask/Test_Framework/HdmiCecSource/Testcases/TCID004.py b/L2HalMock/workspace/deps/rdk/flask/Test_Framework/HdmiCecSource/Testcases/TCID004.py deleted file mode 100644 index a1f91b100..000000000 --- a/L2HalMock/workspace/deps/rdk/flask/Test_Framework/HdmiCecSource/Testcases/TCID004.py +++ /dev/null @@ -1,117 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID004 -# Testcase Description : To verify that standby message is successfully triggered -# and got proper logs in thunder. Hit the curl command for sendStandbyMessage and send the corresponding -# messages to hal. Verify the output response. Also, wake up the devices by sending cec message as post condition - -import json -import requests -import time -import Config -import subprocess -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -op=subprocess.run(['netstat', '-ntlp'],capture_output=True,text=True) -print(op.stdout) -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -print("TC Description - To verify that standby message is successfully triggered and get proper logs in thunder. Hit the curl command for sendStandbyMessage and send the corresponding messages to hal. Verify the output response. Also, wake up the devices by sending cec message as post condition") -#send messages required for getting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.getPowerStatusMessage))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the powerstatus of local device") -else: - Utils.error_log("sendMessage emulation failed for querying the powerstatus of local device") -time.sleep(3) -print("") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.send_standby_message) -if curl_response: - Utils.warning_log("send_standby_message curl command sent from the test runner") -else: - Utils.error_log("send_standby_message curl command failed") -# send messages required for sendStandbyMessage method -message2_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.sendStandbyMessage))) -if "200" in str(message2_response): - Utils.info_log("sendMessage emulation success for sending the remote device state as standby to local device") -else: - Utils.error_log("sendMessage emulation failed for sending the remote device state as standby to local device") -time.sleep(3) -print("") - -# send messages required for getting power status of device -message3_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.getPowerStatusMessage))) -time.sleep(3) -if "200" in str(message3_response): - Utils.info_log("sendMessage emulation success for querying the powerstatus of local device") -else: - Utils.error_log("sendMessage emulation failed for querying the powerstatus of local device") - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. We are expecting opcode : 36 in thunder logs' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID004' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - -# wake up the device from standby as post condition by sending message -message4_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.performOTPActionMessage))) -Utils.warning_log("Reset the device state to ON from standby") -time.sleep(3) - -# send messages required for getting power status of device -message5_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.getPowerStatusMessage))) -time.sleep(3) -Utils.info_log("send the emulated message to get the power status of local device") -op=subprocess.run(['netstat', '-ntlp'],capture_output=True,text=True) -print(op.stdout) - diff --git a/README.md b/README.md index 492a6c01d..9f8c61432 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ -# template -Template repository with common workflows for future clone +# entservices-inputoutput + +Following plugins are moved to dedicated repositories as per below table: + +| Plugin | Repository | +| --- | --- | +| avinput | https://github.com/rdkcentral/entservices-avinput | +| avoutput | https://github.com/rdkcentral/entservices-avoutput | +| hdcpprofile | https://github.com/rdkcentral/entservices-hdcpprofile | +| hdmicecsink | https://github.com/rdkcentral/entservices-hdmicecsink | +| hdmicecsource | https://github.com/rdkcentral/entservices-hdmicecsource | + +Any further code changes need to come from the above repositories on the `develop` branch. +Ongoing release changes for `8.0`, `8.1`, `8.2`, `8.3`, and `8.4` branches should still use this repository. diff --git a/Tests/.clang-format b/Tests/.clang-format deleted file mode 100755 index 423360be1..000000000 --- a/Tests/.clang-format +++ /dev/null @@ -1,108 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: WebKit -AccessModifierOffset: -4 -AlignAfterOpenBracket: DontAlign -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Right -AlignOperands: false -AlignTrailingComments: false -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: true - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakBeforeBinaryOperators: All -BreakBeforeBraces: WebKit -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeComma -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 0 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: false -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: false -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IncludeCategories: - - Regex: '^"config\.h"' - Priority: -1 - # The main header for a source file automatically gets category 0 - - Regex: '.*' - Priority: 1 - - Regex: '^<.*\.h>' - Priority: 2 -IncludeIsMainRegex: '(Test)?$' -IndentCaseLabels: false -IndentWidth: 4 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: Inner -ObjCBlockIndentWidth: 4 -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Left -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 4 -UseTab: Never -... diff --git a/Tests/L1Tests/.lcovrc_l1 b/Tests/L1Tests/.lcovrc_l1 deleted file mode 100644 index 879fe2ce5..000000000 --- a/Tests/L1Tests/.lcovrc_l1 +++ /dev/null @@ -1,181 +0,0 @@ -# -# /etc/lcovrc - system-wide defaults for LCOV -# -# To change settings for a single user, place a customized copy of this file -# at location ~/.lcovrc -# - -# Specify an external style sheet file (same as --css-file option of genhtml) -#genhtml_css_file = gcov.css - -# Specify coverage rate limits (in %) for classifying file entries -# HI: hi_limit <= rate <= 100 graph color: green -# MED: med_limit <= rate < hi_limit graph color: orange -# LO: 0 <= rate < med_limit graph color: red -genhtml_hi_limit = 75 -genhtml_med_limit = 50 - -# Width of line coverage field in source code view -genhtml_line_field_width = 12 - -# Width of branch coverage field in source code view -genhtml_branch_field_width = 16 - -# Width of overview image (used by --frames option of genhtml) -genhtml_overview_width = 80 - -# Resolution of overview navigation: this number specifies the maximum -# difference in lines between the position a user selected from the overview -# and the position the source code window is scrolled to (used by --frames -# option of genhtml) -genhtml_nav_resolution = 4 - -# Clicking a line in the overview image should show the source code view at -# a position a bit further up so that the requested line is not the first -# line in the window. This number specifies that offset in lines (used by -# --frames option of genhtml) -genhtml_nav_offset = 10 - -# Do not remove unused test descriptions if non-zero (same as -# --keep-descriptions option of genhtml) -genhtml_keep_descriptions = 0 - -# Do not remove prefix from directory names if non-zero (same as --no-prefix -# option of genhtml) -genhtml_no_prefix = 0 - -# Do not create source code view if non-zero (same as --no-source option of -# genhtml) -genhtml_no_source = 0 - -# Replace tabs with number of spaces in source view (same as --num-spaces -# option of genhtml) -genhtml_num_spaces = 8 - -# Highlight lines with converted-only data if non-zero (same as --highlight -# option of genhtml) -genhtml_highlight = 0 - -# Include color legend in HTML output if non-zero (same as --legend option of -# genhtml) -genhtml_legend = 0 - -# Use FILE as HTML prolog for generated pages (same as --html-prolog option of -# genhtml) -#genhtml_html_prolog = FILE - -# Use FILE as HTML epilog for generated pages (same as --html-epilog option of -# genhtml) -#genhtml_html_epilog = FILE - -# Use custom filename extension for pages (same as --html-extension option of -# genhtml) -#genhtml_html_extension = html - -# Compress all generated html files with gzip. -#genhtml_html_gzip = 1 - -# Include sorted overview pages (can be disabled by the --no-sort option of -# genhtml) -genhtml_sort = 1 - -# Include function coverage data display (can be disabled by the -# --no-func-coverage option of genhtml) -#genhtml_function_coverage = 1 - -# Include branch coverage data display (can be disabled by the -# --no-branch-coverage option of genhtml) -#genhtml_branch_coverage = 1 - -# Specify the character set of all generated HTML pages -genhtml_charset=UTF-8 - -# Allow HTML markup in test case description text if non-zero -genhtml_desc_html=0 - -# Specify the precision for coverage rates -#genhtml_precision=1 - -# Show missed counts instead of hit counts -#genhtml_missed=1 - -# Demangle C++ symbols -#genhtml_demangle_cpp=1 - -# Name of the tool used for demangling C++ function names -#genhtml_demangle_cpp_tool = c++filt - -# Specify extra parameters to be passed to the demangling tool -#genhtml_demangle_cpp_params = "" - -# Location of the gcov tool (same as --gcov-info option of geninfo) -#geninfo_gcov_tool = gcov - -# Adjust test names to include operating system information if non-zero -#geninfo_adjust_testname = 0 - -# Calculate checksum for each source code line if non-zero (same as --checksum -# option of geninfo if non-zero, same as --no-checksum if zero) -#geninfo_checksum = 1 - -# Specify whether to capture coverage data for external source files (can -# be overridden by the --external and --no-external options of geninfo/lcov) -#geninfo_external = 1 - -# Enable libtool compatibility mode if non-zero (same as --compat-libtool option -# of geninfo if non-zero, same as --no-compat-libtool if zero) -#geninfo_compat_libtool = 0 - -# Use gcov's --all-blocks option if non-zero -#geninfo_gcov_all_blocks = 1 - -# Specify compatiblity modes (same as --compat option of geninfo). -#geninfo_compat = libtool=on, hammer=auto, split_crc=auto - -# Adjust path to source files by removing or changing path components that -# match the specified pattern (Perl regular expression format) -#geninfo_adjust_src_path = /tmp/build => /usr/src - -# Specify if geninfo should try to automatically determine the base-directory -# when collecting coverage data. -geninfo_auto_base = 1 - -# Use gcov intermediate format? Valid values are 0, 1, auto -geninfo_intermediate = auto - -# Specify if exception branches should be excluded from branch coverage. -geninfo_no_exception_branch = 0 - -# Directory containing gcov kernel files -# lcov_gcov_dir = /proc/gcov - -# Location of the insmod tool -lcov_insmod_tool = /sbin/insmod - -# Location of the modprobe tool -lcov_modprobe_tool = /sbin/modprobe - -# Location of the rmmod tool -lcov_rmmod_tool = /sbin/rmmod - -# Location for temporary directories -lcov_tmp_dir = /tmp - -# Show full paths during list operation if non-zero (same as --list-full-path -# option of lcov) -lcov_list_full_path = 0 - -# Specify the maximum width for list output. This value is ignored when -# lcov_list_full_path is non-zero. -lcov_list_width = 80 - -# Specify the maximum percentage of file names which may be truncated when -# choosing a directory prefix in list output. This value is ignored when -# lcov_list_full_path is non-zero. -lcov_list_truncate_max = 20 - -# Specify if function coverage data should be collected and processed. -lcov_function_coverage = 1 - -# Specify if branch coverage data should be collected and processed. -lcov_branch_coverage = 0 diff --git a/Tests/L1Tests/CMakeLists.txt b/Tests/L1Tests/CMakeLists.txt deleted file mode 100755 index 337738823..000000000 --- a/Tests/L1Tests/CMakeLists.txt +++ /dev/null @@ -1,168 +0,0 @@ -# If not stated otherwise in this file or this component's LICENSE file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -cmake_minimum_required(VERSION 3.8) -set(PLUGIN_NAME L1TestsIO) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) - -set(CMAKE_CXX_STANDARD 11) - -find_package(${NAMESPACE}Plugins REQUIRED) - -set (TEST_SRC - tests/test_UtilsFile.cpp -) - -include(FetchContent) -FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/e39786088138f2749d64e9e90e0f9902daa77c40.zip -) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) -FetchContent_MakeAvailable(googletest) - -set (TEST_LIB - gmock_main - ${NAMESPACE}Plugins::${NAMESPACE}Plugins -) - -set (TEST_INC ../../helpers) - -######################################################################################### -# add_plugin_test_ex: Macro to add plugin tests, it will append to TEST_SRC, TEST_INC, -# and TEST_LIB. Args are positional. -# arg1: test file list as **string** -# arg2: include dir list as **string** -# arg3: plugin libs to link list as **string** -# -# sample invocation : -# add_plugin_test_ex(PLUGIN_NAME -# "test/file1.cpp;test/file2.cpp" -# "../../inc_dir1;../../inc_dir2" -# "${NAMESPACE}PluginName;${NAMESPACE}PluginNameImplementation") -# ----------------------------------------- OR ------------------------------------------ -# list(APPEND PLUGIN_NAME_SRC test/file1.cpp) -# list(APPEND PLUGIN_NAME_SRC test/file2.cpp) -# -# list(APPEND PLUGIN_NAME_INC ../../inc_dir1) -# list(APPEND PLUGIN_NAME_INC ../../inc_dir2) -# -# list(APPEND PLUGIN_NAME_LIB ${NAMESPACE}PluginName) -# list(APPEND PLUGIN_NAME_LIB ${NAMESPACE}PluginNameImplementation) -# -# add_plugin_test_ex(PLUGIN_NAME -# "${PLUGIN_NAME_SRC}" -# "${PLUGIN_NAME_INC}" -# "${PLUGIN_NAME_LIB}") -# -# NOTE: Alternatively test can choose to update `TEST_SRC`, `TEST_INC` & `TEST_LIB` -# directly (like in the case of Miracast) -######################################################################################### -macro(add_plugin_test_ex plugin_opt plugin_test_sources_str plugin_includes_str plugin_libs_str) - # Check if the plugin option is enabled - if(${plugin_opt}) - message(STATUS "${plugin_opt}=ON") - - string(REPLACE ";" ";" srclist "${plugin_test_sources_str}") - string(REPLACE ";" ";" inclist "${plugin_includes_str}") - string(REPLACE ";" ";" liblist "${plugin_libs_str}") - - foreach(item IN LISTS srclist) - # Add each test source file - list(APPEND TEST_SRC ${item}) - endforeach() - - foreach(item IN LISTS inclist) - # Add each include directory - list(APPEND TEST_INC ${item}) - endforeach() - - foreach(item IN LISTS liblist) - # Add each libraries to link - list(APPEND TEST_LIB ${item}) - endforeach() - else() - message(STATUS "${plugin_opt}=OFF") - endif() -endmacro() - -# helper to add plugin test -macro(add_plugin_test plugin_name test_files) - # Convert plugin name to uppercase for the option variable - string(TOUPPER "${plugin_name}" plugin_option) - set(plugin_opt "PLUGIN_${plugin_option}") - - add_plugin_test_ex(${plugin_opt} "${test_files}" "../../${plugin_name}" "${NAMESPACE}${plugin_name}") -endmacro() - -# PLUGIN_HDCPPROFILE -set (HDCPPROFILE_INC ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/HdcpProfile ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/helpers) -set (HDCPPROFILE_LIBS ${NAMESPACE}HdcpProfile ${NAMESPACE}HdcpProfileImplementation) -add_plugin_test_ex(PLUGIN_HDCPPROFILE tests/test_HdcpProfile.cpp "${HDCPPROFILE_INC}" "${HDCPPROFILE_LIBS}") - -# PLUGIN_HDMIINPUT -set (HDMIINPUT_INC ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/HdmiInput ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/helpers) -add_plugin_test_ex(PLUGIN_HDMIINPUT tests/test_HdmiInput.cpp "${HDMIINPUT_INC}" "${NAMESPACE}HdmiInput") - -# PLUGIN_HDMICEC2 -add_plugin_test_ex(PLUGIN_HDMICEC2 tests/test_HdmiCec2.cpp "../../HdmiCec_2" "${NAMESPACE}HdmiCec_2") - -# PLUGIN_HDMICECSINK -set (HDMICECSINK_INC ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/HdmiCecSink ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/helpers) -add_plugin_test_ex(PLUGIN_HDMICECSINK tests/test_HdmiCecSink.cpp "${HDMICECSINK_INC}" "${NAMESPACE}HdmiCecSink") - -# PLUGIN_HDMICECSOURCE -set (HDMICECSOURCE_INC ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/HdmiCecSource ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/helpers) -set (HDMICECSOURCE_LIBS ${NAMESPACE}HdmiCecSource ${NAMESPACE}HdmiCecSourceImplementation) -add_plugin_test_ex(PLUGIN_HDMICECSOURCE tests/test_HdmiCecSource.cpp "${HDMICECSOURCE_INC}" "${HDMICECSOURCE_LIBS}") - -# PLUGIN_AVINPUT -set (AVINPUT_INC ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/AVInput ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/helpers) -add_plugin_test_ex(PLUGIN_AVINPUT tests/test_AVInput.cpp "${AVINPUT_INC}" "${NAMESPACE}AVInput") - -add_library(${MODULE_NAME} SHARED ${TEST_SRC}) - -if (RDK_SERVICES_L1_TEST) - find_library(TESTMOCKLIB_LIBRARIES NAMES L1TestMocklib) - if (TESTMOCKLIB_LIBRARIES) - message ("Found mock libraries ${TESTMOCKLIB_LIBRARIES} library") - target_link_libraries(${MODULE_NAME} ${TESTMOCKLIB_LIBRARIES}) - else (TESTMOCKLIB_LIBRARIES) - message ("Require ${TESTMOCKLIB_LIBRARIES} library") - endif (TESTMOCKLIB_LIBRARIES) -endif (RDK_SERVICES_L1_TEST) - -include_directories(${TEST_INC}) - -target_link_directories(${MODULE_NAME} PUBLIC ${CMAKE_INSTALL_PREFIX}/lib/wpeframework/plugins) - -target_link_libraries(${MODULE_NAME} ${TEST_LIB}) - -target_include_directories(${MODULE_NAME} - PUBLIC - $ - $ - ${CMAKE_SOURCE_DIR}/../entservices-testframework/Tests/mocks - ${CMAKE_SOURCE_DIR}/../entservices-testframework/Tests/mocks/devicesettings - ${CMAKE_SOURCE_DIR}/../entservices-testframework/Tests/mocks/thunder - ${CMAKE_SOURCE_DIR}/../Thunder/Source/plugins - ) - -install(TARGETS ${MODULE_NAME} DESTINATION lib) -write_config(${PLUGIN_NAME}) - - diff --git a/Tests/L1Tests/tests/test_AVInput.cpp b/Tests/L1Tests/tests/test_AVInput.cpp deleted file mode 100644 index fae90a904..000000000 --- a/Tests/L1Tests/tests/test_AVInput.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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 - -#include "AVInput.h" - -#include "HdmiInputMock.h" -#include "ThunderPortability.h" - -using namespace WPEFramework; - -using ::testing::NiceMock; - -class AVInputTest : public ::testing::Test { -protected: - Core::ProxyType plugin; - Core::JSONRPC::Handler& handler; - DECL_CORE_JSONRPC_CONX connection; - string response; - - AVInputTest() - : plugin(Core::ProxyType::Create()) - , handler(*(plugin)) - , INIT_CONX(1, 0) - { - } - virtual ~AVInputTest() = default; -}; - -class AVInputDsTest : public AVInputTest { -protected: - HdmiInputImplMock *p_hdmiInputImplMock = nullptr ; - - AVInputDsTest() - : AVInputTest() - { - p_hdmiInputImplMock = new NiceMock ; - device::HdmiInput::setImpl(p_hdmiInputImplMock); - } - virtual ~AVInputDsTest() override - { - device::HdmiInput::setImpl(nullptr); - if (p_hdmiInputImplMock != nullptr) - { - delete p_hdmiInputImplMock; - p_hdmiInputImplMock = nullptr; - } - } -}; - -TEST_F(AVInputTest, RegisteredMethods) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("numberOfInputs"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("currentVideoMode"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("contentProtected"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setEdid2AllmSupport"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getEdid2AllmSupport"))); -} - -TEST_F(AVInputTest, contentProtected) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("contentProtected"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"isContentProtected\":true,\"success\":true}")); -} - -TEST_F(AVInputDsTest, numberOfInputs) -{ - ON_CALL(*p_hdmiInputImplMock, getNumberOfInputs()) - .WillByDefault(::testing::Return(1)); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("numberOfInputs"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"numberOfInputs\":1,\"success\":true}")); -} - -TEST_F(AVInputDsTest, currentVideoMode) -{ - ON_CALL(*p_hdmiInputImplMock, getCurrentVideoMode()) - .WillByDefault(::testing::Return(string("unknown"))); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("currentVideoMode"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"currentVideoMode\":\"unknown\",\"success\":true}")); -} - -TEST_F(AVInputDsTest, getEdid2AllmSupport) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getEdid2AllmSupport"), _T("{\"portId\": \"0\",\"allmSupport\":true}"), response)); - EXPECT_EQ(response, string("{\"allmSupport\":true,\"success\":true}")); -} - - -TEST_F(AVInputDsTest, setEdid2AllmSupport) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setEdid2AllmSupport"), _T("{\"portId\": \"0\",\"allmSupport\":true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - diff --git a/Tests/L1Tests/tests/test_HdcpProfile.cpp b/Tests/L1Tests/tests/test_HdcpProfile.cpp deleted file mode 100755 index f0f6a06f2..000000000 --- a/Tests/L1Tests/tests/test_HdcpProfile.cpp +++ /dev/null @@ -1,516 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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 - -#include "HdcpProfile.h" - -#include "FactoriesImplementation.h" -#include "HostMock.h" -#include "ManagerMock.h" -#include "VideoOutputPortConfigMock.h" -#include "VideoOutputPortMock.h" -#include "IarmBusMock.h" -#include "ServiceMock.h" -#include "dsMgr.h" -#include "dsDisplay.h" -#include "ThunderPortability.h" -#include "PowerManagerMock.h" - -#include -#include -#include -#include -#include "COMLinkMock.h" -#include "WrapsMock.h" -#include "IarmBusMock.h" -#include "WorkerPoolImplementation.h" -#include "HdcpProfileImplementation.h" - -using namespace WPEFramework; - -using ::testing::NiceMock; - -class HDCPProfileTest : public ::testing::Test { -protected: - Core::ProxyType plugin; - Core::JSONRPC::Handler& handler; - DECL_CORE_JSONRPC_CONX connection; - Core::JSONRPC::Message message; - string response; - - WrapsImplMock *p_wrapsImplMock = nullptr; - IarmBusImplMock *p_iarmBusImplMock = nullptr; - Core::ProxyType hdcpProfileImpl; - - NiceMock comLinkMock; - NiceMock service; - PLUGINHOST_DISPATCHER* dispatcher; - Core::ProxyType workerPool; - - NiceMock factoriesImplementation; - - HDCPProfileTest() - : plugin(Core::ProxyType::Create()) - , handler(*(plugin)) - , INIT_CONX(1, 0) - , workerPool(Core::ProxyType::Create(2, Core::Thread::DefaultStackSize(), 16)) - { - p_wrapsImplMock = new NiceMock; - printf("Pass created wrapsImplMock: %p ", p_wrapsImplMock); - Wraps::setImpl(p_wrapsImplMock); - - p_iarmBusImplMock = new NiceMock ; - IarmBus::setImpl(p_iarmBusImplMock); - - - ON_CALL(service, COMLink()) - .WillByDefault(::testing::Invoke( - [this]() { - TEST_LOG("Pass created comLinkMock: %p ", &comLinkMock); - return &comLinkMock; - })); - - - #ifdef USE_THUNDER_R4 - ON_CALL(comLinkMock, Instantiate(::testing::_, ::testing::_, ::testing::_)) - .WillByDefault(::testing::Invoke( - [&](const RPC::Object& object, const uint32_t waitTime, uint32_t& connectionId) { - hdcpProfileImpl = Core::ProxyType::Create(); - TEST_LOG("Pass created hdcpProfileImpl: %p ", &hdcpProfileImpl); - return &hdcpProfileImpl; - })); - #else - ON_CALL(comLinkMock, Instantiate(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)) - .WillByDefault(::testing::Return(hdcpProfileImpl)); - #endif /*USE_THUNDER_R4 */ - - PluginHost::IFactories::Assign(&factoriesImplementation); - - Core::IWorkerPool::Assign(&(*workerPool)); - workerPool->Run(); - - dispatcher = static_cast( - plugin->QueryInterface(PLUGINHOST_DISPATCHER_ID)); - dispatcher->Activate(&service); - - EXPECT_EQ(string(""), plugin->Initialize(&service)); - - } - virtual ~HDCPProfileTest() override - { - TEST_LOG("HdcpProfileTest Destructor"); - - plugin->Deinitialize(&service); - - dispatcher->Deactivate(); - dispatcher->Release(); - - Core::IWorkerPool::Assign(nullptr); - workerPool.Release(); - - Wraps::setImpl(nullptr); - if (p_wrapsImplMock != nullptr) - { - delete p_wrapsImplMock; - p_wrapsImplMock = nullptr; - } - PluginHost::IFactories::Assign(nullptr); - IarmBus::setImpl(nullptr); - if (p_iarmBusImplMock != nullptr) - { - delete p_iarmBusImplMock; - p_iarmBusImplMock = nullptr; - } - - } -}; - -class HDCPProfileDsTest : public HDCPProfileTest { -protected: - HostImplMock *p_hostImplMock = nullptr ; - VideoOutputPortConfigImplMock *p_videoOutputPortConfigImplMock = nullptr ; - VideoOutputPortMock *p_videoOutputPortMock = nullptr ; - - HDCPProfileDsTest() - : HDCPProfileTest() - { - p_hostImplMock = new NiceMock ; - device::Host::setImpl(p_hostImplMock); - p_videoOutputPortConfigImplMock = new NiceMock ; - device::VideoOutputPortConfig::setImpl(p_videoOutputPortConfigImplMock); - p_videoOutputPortMock = new NiceMock ; - device::VideoOutputPort::setImpl(p_videoOutputPortMock); - } - virtual ~HDCPProfileDsTest() override - { - device::VideoOutputPort::setImpl(nullptr); - if (p_videoOutputPortMock != nullptr) - { - delete p_videoOutputPortMock; - p_videoOutputPortMock = nullptr; - } - device::VideoOutputPortConfig::setImpl(nullptr); - if (p_videoOutputPortConfigImplMock != nullptr) - { - delete p_videoOutputPortConfigImplMock; - p_videoOutputPortConfigImplMock = nullptr; - } - device::Host::setImpl(nullptr); - if (p_hostImplMock != nullptr) - { - delete p_hostImplMock; - p_hostImplMock = nullptr; - } - } -}; - -class HDCPProfileEventTest : public HDCPProfileDsTest { -protected: - NiceMock service; - NiceMock factoriesImplementation; - PLUGINHOST_DISPATCHER* dispatcher; - Core::JSONRPC::Message message; - - HDCPProfileEventTest() - : HDCPProfileDsTest() - { - PluginHost::IFactories::Assign(&factoriesImplementation); - - dispatcher = static_cast( - plugin->QueryInterface(PLUGINHOST_DISPATCHER_ID)); - dispatcher->Activate(&service); - } - - virtual ~HDCPProfileEventTest() override - { - dispatcher->Deactivate(); - dispatcher->Release(); - - PluginHost::IFactories::Assign(nullptr); - } -}; - -class HDCPProfileEventIarmTest : public HDCPProfileEventTest { -protected: - ManagerImplMock *p_managerImplMock = nullptr ; - IARM_EventHandler_t dsHdmiEventHandler; - - HDCPProfileEventIarmTest() - : HDCPProfileEventTest() - { - p_managerImplMock = new NiceMock ; - device::Manager::setImpl(p_managerImplMock); - - EXPECT_CALL(*p_managerImplMock, Initialize()) - .Times(::testing::AnyNumber()) - .WillRepeatedly(::testing::Return()); - - ON_CALL(*p_iarmBusImplMock, IARM_Bus_RegisterEventHandler(::testing::_, ::testing::_, ::testing::_)) - .WillByDefault(::testing::Invoke( - [&](const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) { - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG)) { - dsHdmiEventHandler = handler; - } - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDCP_STATUS)) { - dsHdmiEventHandler = handler; - } - return IARM_RESULT_SUCCESS; - })); - - EXPECT_EQ(string(""), plugin->Initialize(&service)); - } - - virtual ~HDCPProfileEventIarmTest() override - { - plugin->Deinitialize(&service); - device::Manager::setImpl(nullptr); - if (p_managerImplMock != nullptr) - { - delete p_managerImplMock; - p_managerImplMock = nullptr; - } - } -}; - -TEST_F(HDCPProfileTest, RegisteredMethods) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getHDCPStatus"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getSettopHDCPSupport"))); -} - -TEST_F(HDCPProfileDsTest, getHDCPStatus_isConnected_false) -{ - device::VideoOutputPort videoOutputPort; - - string videoPort(_T("HDMI0")); - - ON_CALL(*p_hostImplMock, getDefaultVideoPortName()) - .WillByDefault(::testing::Return(videoPort)); - ON_CALL(*p_videoOutputPortConfigImplMock, getPort(::testing::_)) - .WillByDefault(::testing::ReturnRef(videoOutputPort)); - ON_CALL(*p_videoOutputPortMock, isDisplayConnected()) - .WillByDefault(::testing::Return(false)); - ON_CALL(*p_videoOutputPortMock, getHDCPProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_2X)); - ON_CALL(*p_videoOutputPortMock, getHDCPStatus()) - .WillByDefault(::testing::Return(dsHDCP_STATUS_UNPOWERED)); - ON_CALL(*p_videoOutputPortMock, isContentProtected()) - .WillByDefault(::testing::Return(0)); - ON_CALL(*p_videoOutputPortMock, getHDCPReceiverProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_MAX)); - ON_CALL(*p_videoOutputPortMock, getHDCPCurrentProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_MAX)); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getHDCPStatus"), _T(""), response)); - EXPECT_THAT(response, ::testing::MatchesRegex(_T("\\{" - "\"HDCPStatus\":" - "\\{" - "\"isConnected\":false," - "\"isHDCPCompliant\":false," - "\"isHDCPEnabled\":false," - "\"hdcpReason\":0," - "\"supportedHDCPVersion\":\"[1-2]+.[1-4]\"," - "\"receiverHDCPVersion\":\"[1-2]+.[1-4]\"," - "\"currentHDCPVersion\":\"[1-2]+.[1-4]\"" - "\\}," - "\"success\":true" - "\\}"))); -} - -TEST_F(HDCPProfileDsTest, getHDCPStatus_isConnected_true) -{ - NiceMock videoOutputPortMock; - device::VideoOutputPort videoOutputPort; - - string videoPort(_T("HDMI0")); - - ON_CALL(*p_hostImplMock, getDefaultVideoPortName()) - .WillByDefault(::testing::Return(videoPort)); - ON_CALL(*p_videoOutputPortConfigImplMock, getPort(::testing::_)) - .WillByDefault(::testing::ReturnRef(videoOutputPort)); - ON_CALL(*p_videoOutputPortMock, isDisplayConnected()) - .WillByDefault(::testing::Return(true)); - ON_CALL(*p_videoOutputPortMock, getHDCPProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_2X)); - ON_CALL(*p_videoOutputPortMock, getHDCPStatus()) - .WillByDefault(::testing::Return(dsHDCP_STATUS_AUTHENTICATED)); - ON_CALL(*p_videoOutputPortMock, isContentProtected()) - .WillByDefault(::testing::Return(true)); - ON_CALL(*p_videoOutputPortMock, getHDCPReceiverProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_2X)); - ON_CALL(*p_videoOutputPortMock, getHDCPCurrentProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_2X)); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getHDCPStatus"), _T(""), response)); - EXPECT_THAT(response, ::testing::MatchesRegex(_T("\\{" - "\"HDCPStatus\":" - "\\{" - "\"isConnected\":true," - "\"isHDCPCompliant\":true," - "\"isHDCPEnabled\":true," - "\"hdcpReason\":2," - "\"supportedHDCPVersion\":\"[1-2]+.[1-4]\"," - "\"receiverHDCPVersion\":\"[1-2]+.[1-4]\"," - "\"currentHDCPVersion\":\"[1-2]+.[1-4]\"" - "\\}," - "\"success\":true" - "\\}"))); -} - -TEST_F(HDCPProfileDsTest, getSettopHDCPSupport_Hdcp_v1x) -{ - NiceMock videoOutputPortMock; - device::VideoOutputPort videoOutputPort; - - string videoPort(_T("HDMI0")); - - ON_CALL(*p_hostImplMock, getDefaultVideoPortName()) - .WillByDefault(::testing::Return(videoPort)); - ON_CALL(*p_videoOutputPortConfigImplMock, getPort(::testing::_)) - .WillByDefault(::testing::ReturnRef(videoOutputPort)); - ON_CALL(*p_videoOutputPortMock, getHDCPProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_1X)); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getSettopHDCPSupport"), _T(""), response)); - EXPECT_THAT(response, ::testing::MatchesRegex(_T("\\{" - "\"supportedHDCPVersion\":\"[1-2]+.[1-4]\"," - "\"isHDCPSupported\":true," - "\"success\":true" - "\\}"))); -} - -TEST_F(HDCPProfileDsTest, getSettopHDCPSupport_Hdcp_v2x) -{ - NiceMock videoOutputPortMock; - device::VideoOutputPort videoOutputPort; - - string videoPort(_T("HDMI0")); - - ON_CALL(*p_hostImplMock, getDefaultVideoPortName()) - .WillByDefault(::testing::Return(videoPort)); - ON_CALL(*p_videoOutputPortConfigImplMock, getPort(::testing::_)) - .WillByDefault(::testing::ReturnRef(videoOutputPort)); - ON_CALL(*p_videoOutputPortMock, getHDCPProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_2X)); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getSettopHDCPSupport"), _T(""), response)); - EXPECT_THAT(response, ::testing::MatchesRegex(_T("\\{" - "\"supportedHDCPVersion\":\"[1-2]+.[1-4]\"," - "\"isHDCPSupported\":true," - "\"success\":true" - "\\}"))); -} - -TEST_F(HDCPProfileEventIarmTest, onDisplayConnectionChanged) -{ - ASSERT_TRUE(dsHdmiEventHandler != nullptr); - - Core::Event onDisplayConnectionChanged(false, true); - - NiceMock videoOutputPortMock; - device::VideoOutputPort videoOutputPort; - - string videoPort(_T("HDMI0")); - - ON_CALL(*p_hostImplMock, getDefaultVideoPortName()) - .WillByDefault(::testing::Return(videoPort)); - ON_CALL(*p_videoOutputPortConfigImplMock, getPort(::testing::_)) - .WillByDefault(::testing::ReturnRef(videoOutputPort)); - ON_CALL(*p_videoOutputPortMock, isDisplayConnected()) - .WillByDefault(::testing::Return(true)); - ON_CALL(*p_videoOutputPortMock, getHDCPProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_2X)); - ON_CALL(*p_videoOutputPortMock, getHDCPStatus()) - .WillByDefault(::testing::Return(dsHDCP_STATUS_AUTHENTICATED)); - ON_CALL(*p_videoOutputPortMock, isContentProtected()) - .WillByDefault(::testing::Return(true)); - ON_CALL(*p_videoOutputPortMock, getHDCPReceiverProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_2X)); - ON_CALL(*p_videoOutputPortMock, getHDCPCurrentProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_2X)); - - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - - //EXPECT_EQ(text, string(_T(""))); - EXPECT_THAT(text, ::testing::MatchesRegex(_T("\\{" - "\"jsonrpc\":\"2.0\"," - "\"method\":\"client.events.onDisplayConnectionChanged\"," - "\"params\":" - "\\{\"HDCPStatus\":" - "\\{" - "\"isConnected\":true," - "\"isHDCPCompliant\":true," - "\"isHDCPEnabled\":true," - "\"hdcpReason\":2," - "\"supportedHDCPVersion\":\"2.2\"," - "\"receiverHDCPVersion\":\"2.2\"," - "\"currentHDCPVersion\":\"2.2\"" - "\\}" - "\\}" - "\\}"))); - - onDisplayConnectionChanged.SetEvent(); - - return Core::ERROR_NONE; - })); - - EVENT_SUBSCRIBE(0, _T("onDisplayConnectionChanged"), _T("client.events"), message); - - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_hpd.event = dsDISPLAY_EVENT_CONNECTED; - dsHdmiEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG, &eventData, 0); - - EXPECT_EQ(Core::ERROR_NONE, onDisplayConnectionChanged.Lock()); - - EVENT_UNSUBSCRIBE(0, _T("onDisplayConnectionChanged"), _T("client.events"), message); -} - -TEST_F(HDCPProfileEventIarmTest, onHdmiOutputHDCPStatusEvent) -{ - ASSERT_TRUE(dsHdmiEventHandler != nullptr); - - Core::Event onDisplayConnectionChanged(false, true); - - NiceMock videoOutputPortMock; - device::VideoOutputPort videoOutputPort; - - string videoPort(_T("HDMI0")); - - ON_CALL(*p_hostImplMock, getDefaultVideoPortName()) - .WillByDefault(::testing::Return(videoPort)); - ON_CALL(*p_videoOutputPortConfigImplMock, getPort(::testing::_)) - .WillByDefault(::testing::ReturnRef(videoOutputPort)); - ON_CALL(*p_videoOutputPortMock, isDisplayConnected()) - .WillByDefault(::testing::Return(true)); - ON_CALL(*p_videoOutputPortMock, getHDCPProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_2X)); - ON_CALL(*p_videoOutputPortMock, getHDCPStatus()) - .WillByDefault(::testing::Return(dsHDCP_STATUS_AUTHENTICATED)); - ON_CALL(*p_videoOutputPortMock, isContentProtected()) - .WillByDefault(::testing::Return(true)); - ON_CALL(*p_videoOutputPortMock, getHDCPReceiverProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_2X)); - ON_CALL(*p_videoOutputPortMock, getHDCPCurrentProtocol()) - .WillByDefault(::testing::Return(dsHDCP_VERSION_2X)); - - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - - EXPECT_THAT(text, ::testing::MatchesRegex(_T("\\{" - "\"jsonrpc\":\"2.0\"," - "\"method\":\"client.events.onDisplayConnectionChanged\"," - "\"params\":" - "\\{\"HDCPStatus\":" - "\\{" - "\"isConnected\":true," - "\"isHDCPCompliant\":true," - "\"isHDCPEnabled\":true," - "\"hdcpReason\":2," - "\"supportedHDCPVersion\":\"2.2\"," - "\"receiverHDCPVersion\":\"2.2\"," - "\"currentHDCPVersion\":\"2.2\"" - "\\}" - "\\}" - "\\}"))); - - onDisplayConnectionChanged.SetEvent(); - - return Core::ERROR_NONE; - })); - - EVENT_SUBSCRIBE(0, _T("onDisplayConnectionChanged"), _T("client.events"), message); - - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_hdcp.hdcpStatus = dsDISPLAY_HDCPPROTOCOL_CHANGE; - dsHdmiEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDCP_STATUS, &eventData, 0); - - EXPECT_EQ(Core::ERROR_NONE, onDisplayConnectionChanged.Lock()); - - EVENT_UNSUBSCRIBE(0, _T("onDisplayConnectionChanged"), _T("client.events"), message); -} diff --git a/Tests/L1Tests/tests/test_HdmiCec2.cpp b/Tests/L1Tests/tests/test_HdmiCec2.cpp deleted file mode 100644 index 0ba40518c..000000000 --- a/Tests/L1Tests/tests/test_HdmiCec2.cpp +++ /dev/null @@ -1,644 +0,0 @@ -/* - * 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 - -#include "HdmiCec.h" -#include "HdmiCec_2.h" - -#include "FactoriesImplementation.h" - - -#include "IarmBusMock.h" -#include "ServiceMock.h" -#include "devicesettings.h" -#include "HdmiCecMock.h" -#include "DisplayMock.h" -#include "VideoOutputPortMock.h" -#include "HostMock.h" -#include "ManagerMock.h" -#include "PowerManagerMock.h" -#include "ThunderPortability.h" - -using namespace WPEFramework; - -class HdmiCec_2Test : public ::testing::Test { -protected: - Core::ProxyType plugin; - Core::JSONRPC::Handler& handler; - DECL_CORE_JSONRPC_CONX connection; - string response; - - HdmiCec_2Test() - : plugin(Core::ProxyType::Create()) - , handler(*(plugin)) - , INIT_CONX(1, 0) - { - } - virtual ~HdmiCec_2Test() = default; -}; -class HdmiCec_2DsTest : public HdmiCec_2Test { -protected: - LibCCECImplMock *p_libCCECImplMock = nullptr ; - ConnectionImplMock *p_connectionImplMock = nullptr ; - HdmiCec_2DsTest() - : HdmiCec_2Test() - { - p_libCCECImplMock = new testing::NiceMock ; - LibCCEC::setImpl(p_libCCECImplMock); - } - virtual ~HdmiCec_2DsTest() override - { - LibCCEC::setImpl(nullptr); - if (p_libCCECImplMock != nullptr) - { - delete p_libCCECImplMock; - p_libCCECImplMock = nullptr; - } - } -}; - -class HdmiCec_2InitializedTest : public HdmiCec_2Test { -protected: - IarmBusImplMock *p_iarmBusImplMock = nullptr ; - ManagerImplMock *p_managerImplMock = nullptr ; - HostImplMock *p_hostImplMock = nullptr ; - LibCCECImplMock *p_libCCECImplMock = nullptr ; - ConnectionImplMock *p_connectionImplMock = nullptr ; - VideoOutputPortMock *p_videoOutputPortMock = nullptr ; - MessageEncoderMock *p_messageEncoderMock = nullptr ; - - IARM_EventHandler_t cecMgrEventHandler; - IARM_EventHandler_t dsHdmiEventHandler; - IARM_EventHandler_t pwrMgrEventHandler; - - DisplayMock *p_displayMock = nullptr ; - - HdmiCec_2InitializedTest() - : HdmiCec_2Test() - { - p_iarmBusImplMock = new testing::NiceMock ; - IarmBus::setImpl(p_iarmBusImplMock); - - p_hostImplMock = new testing::NiceMock ; - device::Host::setImpl(p_hostImplMock); - - p_managerImplMock = new testing::NiceMock ; - device::Manager::setImpl(p_managerImplMock); - - p_libCCECImplMock = new testing::NiceMock ; - LibCCEC::setImpl(p_libCCECImplMock); - - p_messageEncoderMock = new testing::NiceMock ; - MessageEncoder::setImpl(p_messageEncoderMock); - - p_connectionImplMock = new testing::NiceMock ; - Connection::setImpl(p_connectionImplMock); - - p_videoOutputPortMock = new testing::NiceMock ; - device::VideoOutputPort::setImpl(p_videoOutputPortMock); - - p_displayMock = new testing::NiceMock ; - device::Display::setImpl(p_displayMock); - - //OnCall required for intialize to run properly - ON_CALL(*p_hostImplMock, getVideoOutputPort(::testing::_)) - .WillByDefault(::testing::ReturnRef(device::VideoOutputPort::getInstance())); - - ON_CALL(*p_videoOutputPortMock, getDisplay()) - .WillByDefault(::testing::ReturnRef(device::Display::getInstance())); - - ON_CALL(*p_videoOutputPortMock, isDisplayConnected()) - .WillByDefault(::testing::Return(true)); - - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::ReturnRef(CECFrame::getInstance())); - - ON_CALL(*p_displayMock, getEDIDBytes(::testing::_)) - .WillByDefault(::testing::Invoke( - [&](std::vector &edidVec2) { - edidVec2 = std::vector({ 't', 'e', 's', 't' }); - })); - - ON_CALL(*p_iarmBusImplMock, IARM_Bus_RegisterEventHandler(::testing::_, ::testing::_, ::testing::_)) - .WillByDefault(::testing::Invoke( - [&](const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) { - if ((string(IARM_BUS_CECMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_CECMGR_EVENT_DAEMON_INITIALIZED)) { - EXPECT_TRUE(handler != nullptr); - cecMgrEventHandler = handler; - } - if ((string(IARM_BUS_CECMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_CECMGR_EVENT_STATUS_UPDATED)) { - EXPECT_TRUE(handler != nullptr); - cecMgrEventHandler = handler; - } - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiEventHandler = handler; - } - if ((string(IARM_BUS_PWRMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_PWRMGR_EVENT_MODECHANGED)) { - EXPECT_TRUE(handler != nullptr); - pwrMgrEventHandler = handler; - } - - return IARM_RESULT_SUCCESS; - })); - - ON_CALL(*p_iarmBusImplMock, IARM_Bus_Call) - .WillByDefault( - [](const char* ownerName, const char* methodName, void* arg, size_t argLen) { - if (strcmp(methodName, IARM_BUS_PWRMGR_API_GetPowerState) == 0) { - auto* param = static_cast(arg); - param->curState = IARM_BUS_PWRMGR_POWERSTATE_ON; - } - return IARM_RESULT_SUCCESS; - }); - - - EXPECT_EQ(string(""), plugin->Initialize(nullptr)); - //Set enabled needs to be - ON_CALL(*p_libCCECImplMock, getLogicalAddress(::testing::_)) - .WillByDefault(::testing::Return(1)); - ON_CALL(*p_connectionImplMock, open()) - .WillByDefault(::testing::Return()); - ON_CALL(*p_connectionImplMock, addFrameListener(::testing::_)) - .WillByDefault(::testing::Return()); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setEnabled"), _T("{\"enabled\": true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - } - virtual ~HdmiCec_2InitializedTest() override - { - int lCounter = 0; - while ((Plugin::HdmiCec_2::_instance->deviceList[0].m_isOSDNameUpdated) && (lCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - lCounter ++; - } - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setEnabled"), _T("{\"enabled\": false}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - plugin->Deinitialize(nullptr); - IarmBus::setImpl(nullptr); - if (p_iarmBusImplMock != nullptr) - { - delete p_iarmBusImplMock; - p_iarmBusImplMock = nullptr; - } - device::Display::setImpl(nullptr); - if (p_displayMock != nullptr) - { - delete p_displayMock; - p_displayMock = nullptr; - } - device::VideoOutputPort::setImpl(nullptr); - if (p_videoOutputPortMock != nullptr) - { - delete p_videoOutputPortMock; - p_videoOutputPortMock = nullptr; - } - device::Manager::setImpl(nullptr); - if (p_managerImplMock != nullptr) - { - delete p_managerImplMock; - p_managerImplMock = nullptr; - } - device::Host::setImpl(nullptr); - if (p_hostImplMock != nullptr) - { - delete p_hostImplMock; - p_hostImplMock = nullptr; - } - LibCCEC::setImpl(nullptr); - if (p_libCCECImplMock != nullptr) - { - delete p_libCCECImplMock; - p_libCCECImplMock = nullptr; - } - Connection::setImpl(nullptr); - if (p_connectionImplMock != nullptr) - { - delete p_connectionImplMock; - p_connectionImplMock = nullptr; - } - MessageEncoder::setImpl(nullptr); - if (p_messageEncoderMock != nullptr) - { - delete p_messageEncoderMock; - p_messageEncoderMock = nullptr; - } - - } -}; -class HdmiCec_2InitializedEventTest : public HdmiCec_2InitializedTest { -protected: - testing::NiceMock service; - FactoriesImplementation factoriesImplementation; - PLUGINHOST_DISPATCHER* dispatcher; - Core::JSONRPC::Message message; - - HdmiCec_2InitializedEventTest() - : HdmiCec_2InitializedTest() - { - PluginHost::IFactories::Assign(&factoriesImplementation); - - dispatcher = static_cast( - plugin->QueryInterface(PLUGINHOST_DISPATCHER_ID)); - dispatcher->Activate(&service); - } - - virtual ~HdmiCec_2InitializedEventTest() override - { - dispatcher->Deactivate(); - dispatcher->Release(); - PluginHost::IFactories::Assign(nullptr); - - } -}; - -TEST_F(HdmiCec_2Test, RegisteredMethods) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getActiveSourceStatus"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getDeviceList"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getEnabled"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getOSDName"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getOTPEnabled"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getVendorId"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("performOTPAction"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("sendKeyPressEvent"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("sendStandbyMessage"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setEnabled"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setOSDName"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setOTPEnabled"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setVendorId"))); - -} - -TEST_F(HdmiCec_2DsTest, getEnabledFalse) -{ - //Without setting cecEnable to true. - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getEnabled"), _T(""), response)); - EXPECT_EQ(response, string("{\"enabled\":false,\"success\":true}")); -} - - -TEST_F(HdmiCec_2InitializedTest, getEnabledTrue) -{ - //Get enabled just checks if CEC is on, which is a global variable. - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getEnabled"), _T(""), response)); - EXPECT_EQ(response, string("{\"enabled\":true,\"success\":true}")); - -} - -TEST_F(HdmiCec_2InitializedTest, getActiveSourceStatusTrue) -{ - //SetsOTP to on. - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setOTPEnabled"), _T("{\"enabled\": true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - //Sets Activesource to true - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("performOTPAction"), _T("{\"enabled\": true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getActiveSourceStatus"), _T(""), response)); - EXPECT_EQ(response, string("{\"status\":true,\"success\":true}")); - - -} -TEST_F(HdmiCec_2InitializedTest, getActiveSourceStatusFalse) -{ - //ActiveSource is a local variable, no mocked functions to check. - //Active source is false by default. - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getActiveSourceStatus"), _T(""), response)); - EXPECT_EQ(response, string("{\"status\":false,\"success\":true}")); -} - - -TEST_F(HdmiCec_2InitializedTest, getDeviceList) -{ - int iCounter = 0; - //Checking to see if one of the values has been filled in (as the rest get filled in at the same time, and waiting if its not. - while ((!Plugin::HdmiCec_2::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; - } - - const char* val = "TEST"; - OSDName name = OSDName(val); - SetOSDName osdName = SetOSDName(name); - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - VendorID vendor(1,2,3); - DeviceVendorID vendorid(vendor); - - Plugin::HdmiCec_2Processor proc(Connection::getInstance()); - - proc.process(osdName, header); //calls the process that sets osdName for LogicalAddress = 1 - proc.process(vendorid, header); //calls the process that sets vendorID for LogicalAddress = 1 - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getDeviceList"), _T(""), response)); - - EXPECT_EQ(response, string(_T("{\"numberofdevices\":14,\"deviceList\":[{\"logicalAddress\":1,\"osdName\":\"TEST\",\"vendorID\":\"123\"},{\"logicalAddress\":2,\"osdName\":\"NA\",\"vendorID\":\"000\"},{\"logicalAddress\":3,\"osdName\":\"NA\",\"vendorID\":\"000\"},{\"logicalAddress\":4,\"osdName\":\"NA\",\"vendorID\":\"000\"},{\"logicalAddress\":5,\"osdName\":\"NA\",\"vendorID\":\"000\"},{\"logicalAddress\":6,\"osdName\":\"NA\",\"vendorID\":\"000\"},{\"logicalAddress\":7,\"osdName\":\"NA\",\"vendorID\":\"000\"},{\"logicalAddress\":8,\"osdName\":\"NA\",\"vendorID\":\"000\"},{\"logicalAddress\":9,\"osdName\":\"NA\",\"vendorID\":\"000\"},{\"logicalAddress\":10,\"osdName\":\"NA\",\"vendorID\":\"000\"},{\"logicalAddress\":11,\"osdName\":\"NA\",\"vendorID\":\"000\"},{\"logicalAddress\":12,\"osdName\":\"NA\",\"vendorID\":\"000\"},{\"logicalAddress\":13,\"osdName\":\"NA\",\"vendorID\":\"000\"},{\"logicalAddress\":14,\"osdName\":\"NA\",\"vendorID\":\"000\"}],\"success\":true}"))); - -} - -TEST_F(HdmiCec_2InitializedTest, getOTPEnabled) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setOTPEnabled"), _T("{\"enabled\": true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getOTPEnabled"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"enabled\":true,\"success\":true}")); - -} - -TEST_F(HdmiCec_2InitializedTest, sendStandbyMessage) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendStandbyMessage"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(HdmiCec_2InitializedTest, setOSDName) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setOSDName"), _T("{\"name\": \"CUSTOM8 Tv\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getOSDName"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"name\":\"CUSTOM8 Tv\",\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, setVendorId) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setVendorId"), _T("{\"vendorid\": \"0x0019FB\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getVendorId"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"vendorid\":\"019fb\",\"success\":true}")); - - -} -TEST_F(HdmiCec_2InitializedTest, setOTPEnabled) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setOTPEnabled"), _T("{\"enabled\": false}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} - -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEventUp) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_VOLUME_UP ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 65}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent2) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_VOLUME_DOWN ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 66}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent3) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_MUTE ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 67}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent4) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_UP ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 1}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent5) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_DOWN ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 2}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent6) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_LEFT ); - return CECFrame::getInstance(); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 3}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent7) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_RIGHT ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 4}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent8) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_SELECT ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 0}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent9) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_HOME ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 9}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent10) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_BACK ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 13}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent11) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_0 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 32}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent12) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_1 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 33}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent13) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_2 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 34}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent14) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_3 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 35}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent15) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_4 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 36}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent16) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_5 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 37}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent17) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_6 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 38}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent18) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_7 ); - return CECFrame::getInstance(); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 39}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent19) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_8 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 40}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCec_2InitializedTest, sendKeyPressEvent20) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_9 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 41}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} - diff --git a/Tests/L1Tests/tests/test_HdmiCecSink.cpp b/Tests/L1Tests/tests/test_HdmiCecSink.cpp deleted file mode 100755 index 2f570df1c..000000000 --- a/Tests/L1Tests/tests/test_HdmiCecSink.cpp +++ /dev/null @@ -1,502 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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 -#include -#include -#include - -#include "HdmiCecSink.h" -#include "FactoriesImplementation.h" -#include "IarmBusMock.h" -#include "ServiceMock.h" -#include "devicesettings.h" -#include "HdmiCec.h" -#include "HdmiCecMock.h" -#include "WrapsMock.h" -#include "RfcApiMock.h" -#include "ThunderPortability.h" -#include "PowerManagerMock.h" - -using namespace WPEFramework; -using ::testing::NiceMock; - -namespace -{ - static void removeFile(const char* fileName) - { - if (std::remove(fileName) != 0) - { - printf("File %s failed to remove\n", fileName); - perror("Error deleting file"); - } - else - { - printf("File %s successfully deleted\n", fileName); - } - } - - static void createFile(const char* fileName, const char* fileContent) - { - removeFile(fileName); - - std::ofstream fileContentStream(fileName); - fileContentStream << fileContent; - fileContentStream << "\n"; - fileContentStream.close(); - } -} - -class HdmiCecSinkWOInitializeTest : public ::testing::Test { -protected: - IarmBusImplMock *p_iarmBusImplMock = nullptr ; - ConnectionImplMock *p_connectionImplMock = nullptr ; - MessageEncoderMock *p_messageEncoderMock = nullptr ; - LibCCECImplMock *p_libCCECImplMock = nullptr ; - RfcApiImplMock *p_rfcApiImplMock = nullptr ; - WrapsImplMock *p_wrapsImplMock = nullptr ; - Core::ProxyType plugin; - Core::JSONRPC::Handler& handler; - DECL_CORE_JSONRPC_CONX connection; - NiceMock rfcApiImplMock; - NiceMock wrapsImplMock; - IARM_EventHandler_t dsHdmiEventHandler; - string response; - - HdmiCecSinkWOInitializeTest() - : plugin(Core::ProxyType::Create()) - , handler(*(plugin)) - , INIT_CONX(1, 0) - { - p_iarmBusImplMock = new NiceMock ; - IarmBus::setImpl(p_iarmBusImplMock); - - p_libCCECImplMock = new testing::NiceMock ; - LibCCEC::setImpl(p_libCCECImplMock); - - p_messageEncoderMock = new testing::NiceMock ; - MessageEncoder::setImpl(p_messageEncoderMock); - - p_connectionImplMock = new testing::NiceMock ; - Connection::setImpl(p_connectionImplMock); - - p_rfcApiImplMock = new testing::NiceMock ; - RfcApi::setImpl(p_rfcApiImplMock); - - p_wrapsImplMock = new testing::NiceMock ; - Wraps::setImpl(p_wrapsImplMock); /*Set up mock for fopen; - to use the mock implementation/the default behavior of the fopen function from Wraps class.*/ - - ON_CALL(*p_connectionImplMock, poll(::testing::_, ::testing::_)) - .WillByDefault(::testing::Invoke( - [&](const LogicalAddress &from, const Throw_e &doThrow) { - throw CECNoAckException(); - })); - - EXPECT_CALL(*p_libCCECImplMock, getPhysicalAddress(::testing::_)) - .WillRepeatedly(::testing::Invoke( - [&](uint32_t *physAddress) { - *physAddress = (uint32_t)0x12345678; - })); - - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::ReturnRef(CECFrame::getInstance())); - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::ReturnRef(CECFrame::getInstance())); - - ON_CALL(*p_iarmBusImplMock, IARM_Bus_RegisterEventHandler(::testing::_, ::testing::_, ::testing::_)) - .WillByDefault(::testing::Invoke( - [&](const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) { - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiEventHandler = handler; - } - return IARM_RESULT_SUCCESS; - })); - - ON_CALL(*p_connectionImplMock, open()) - .WillByDefault(::testing::Return()); - - } - - virtual ~HdmiCecSinkWOInitializeTest() override - { - IarmBus::setImpl(nullptr); - if (p_iarmBusImplMock != nullptr) - { - delete p_iarmBusImplMock; - p_iarmBusImplMock = nullptr; - } - LibCCEC::setImpl(nullptr); - if (p_libCCECImplMock != nullptr) - { - delete p_libCCECImplMock; - p_libCCECImplMock = nullptr; - } - Connection::setImpl(nullptr); - if (p_connectionImplMock != nullptr) - { - delete p_connectionImplMock; - p_connectionImplMock = nullptr; - } - MessageEncoder::setImpl(nullptr); - if (p_messageEncoderMock != nullptr) - { - delete p_messageEncoderMock; - p_messageEncoderMock = nullptr; - } - - RfcApi::setImpl(nullptr); - if (p_rfcApiImplMock != nullptr) - { - delete p_rfcApiImplMock; - p_rfcApiImplMock = nullptr; - } - - Wraps::setImpl(nullptr); - if (p_wrapsImplMock != nullptr) - { - delete p_wrapsImplMock; - p_wrapsImplMock = nullptr; - } - - } -}; - -class HdmiCecSinkTest : public HdmiCecSinkWOInitializeTest { -protected: - //Exchange::IPowerManager::IModeChangedNotification* _notification = nullptr; - - HdmiCecSinkTest() - : HdmiCecSinkWOInitializeTest() - { - removeFile("/etc/device.properties"); - createFile("/etc/device.properties", "RDK_PROFILE=TV"); - //EXPECT_CALL(PowerManagerMock::Mock(), Register(Exchange::IPowerManager::IModeChangedNotification* notification)) - // .WillOnce( - // [this](Exchange::IPowerManager::IModeChangedNotification* notification) -> uint32_t { - // _notification = notification; - // return Core::ERROR_NONE; - // }); - EXPECT_EQ(string(""), plugin->Initialize(nullptr)); - } - - virtual ~HdmiCecSinkTest() override - { - plugin->Deinitialize(nullptr); - removeFile("/etc/device.properties"); - } -}; - -class HdmiCecSinkDsTest : public HdmiCecSinkTest { -protected: - string response; - - HdmiCecSinkDsTest(): HdmiCecSinkTest() - { - ON_CALL(*p_iarmBusImplMock, IARM_Bus_Call) - .WillByDefault( - [](const char* ownerName, const char* methodName, void* arg, size_t argLen) { - if (strcmp(methodName, IARM_BUS_PWRMGR_API_GetPowerState) == 0) { - auto* param = static_cast(arg); - param->curState = IARM_BUS_PWRMGR_POWERSTATE_ON; - } - if (strcmp(methodName, IARM_BUS_DSMGR_API_dsHdmiInGetNumberOfInputs) == 0) { - auto* param = static_cast(arg); - param->result = dsERR_NONE; - param->numHdmiInputs = 3; - } - if (strcmp(methodName, IARM_BUS_DSMGR_API_dsHdmiInGetStatus) == 0) { - auto* param = static_cast(arg); - param->result = dsERR_NONE; - param->status.isPortConnected[1] = 1; - } - if (strcmp(methodName, IARM_BUS_DSMGR_API_dsGetHDMIARCPortId) == 0) { - auto* param = static_cast(arg); - param->portId = 1; - } - return IARM_RESULT_SUCCESS; - }); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setEnabled"), _T("{\"enabled\": true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - } - virtual ~HdmiCecSinkDsTest() override { - } -}; - -class HdmiCecSinkInitializedEventTest : public HdmiCecSinkDsTest { -protected: - NiceMock service; - NiceMock factoriesImplementation; - PLUGINHOST_DISPATCHER* dispatcher; - Core::JSONRPC::Message message; - - HdmiCecSinkInitializedEventTest(): HdmiCecSinkDsTest() - { - PluginHost::IFactories::Assign(&factoriesImplementation); - - dispatcher = static_cast( - plugin->QueryInterface(PLUGINHOST_DISPATCHER_ID)); - dispatcher->Activate(&service); - } - virtual ~HdmiCecSinkInitializedEventTest() override - { - dispatcher->Deactivate(); - dispatcher->Release(); - PluginHost::IFactories::Assign(nullptr); - } -}; - -class HdmiCecSinkInitializedEventDsTest : public HdmiCecSinkInitializedEventTest { -protected: - HdmiCecSinkInitializedEventDsTest(): HdmiCecSinkInitializedEventTest() - { - } - virtual ~HdmiCecSinkInitializedEventDsTest() override - { - } -}; - -TEST_F(HdmiCecSinkWOInitializeTest, NotSupportPlugin) -{ - removeFile("/etc/device.properties"); - EXPECT_EQ(string("Not supported"), plugin->Initialize(nullptr)); - createFile("/etc/device.properties", "RDK_PROFILE=STB"); - EXPECT_EQ(string("Not supported"), plugin->Initialize(nullptr)); - removeFile("/etc/device.properties"); - createFile("/etc/device.properties", "RDK_PROFILE=TV"); - EXPECT_EQ(string(""), plugin->Initialize(nullptr)); - plugin->Deinitialize(nullptr); - removeFile("/etc/device.properties"); - -} - -TEST_F(HdmiCecSinkTest, RegisteredMethods) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setEnabled"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setOSDName"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setVendorId"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getVendorId"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setActivePath"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setRoutingChange"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getDeviceList"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getActiveSource"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setActiveSource"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getActiveRoute"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setMenuLanguage"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("requestActiveSource"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setupARCRouting"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("requestShortAudioDescriptor"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("sendStandbyMessage"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("sendAudioDevicePowerOnMessage"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("sendKeyPressEvent"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("sendGetAudioStatusMessage"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getAudioDeviceConnectedStatus"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("requestAudioDevicePowerStatus"))); - -} - -TEST_F(HdmiCecSinkDsTest, setOSDNameParamMissing) -{ - - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setOSDName"), _T("{}"), response)); - EXPECT_EQ(response, string("")); - -} - -TEST_F(HdmiCecSinkDsTest, getOSDName) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setOSDName"), _T("{\"name\":\"CECTEST\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getOSDName"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"name\":\"CECTEST\",\"success\":true}")); - -} - -TEST_F(HdmiCecSinkDsTest, setVendorIdParamMissing) -{ - - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setVendorId"), _T("{}"), response)); - EXPECT_EQ(response, string("")); - -} - -TEST_F(HdmiCecSinkDsTest, getVendorId) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setVendorId"), _T("{\"vendorid\":\"0x0019FF\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getVendorId"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"vendorid\":\"019ff\",\"success\":true}")); - -} - -TEST_F(HdmiCecSinkDsTest, setActivePathMissingParam) -{ - - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setActivePath"), _T("{}"), response)); - EXPECT_EQ(response, string("")); - -} - -TEST_F(HdmiCecSinkDsTest, setActivePath) -{ - - EXPECT_CALL(*p_connectionImplMock, sendTo(::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(::testing::Invoke( - [&](const LogicalAddress &to, const CECFrame &frame, int timeout) { - EXPECT_EQ(to.toInt(), LogicalAddress::BROADCAST); - EXPECT_GT(timeout, 0); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setActivePath"), _T("{\"activePath\":\"2.0.0.0\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} - -TEST_F(HdmiCecSinkDsTest, setRoutingChangeInvalidParam) -{ - - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setRoutingChange"), _T("{\"oldPort\":\"HDMI0\"}"), response)); - EXPECT_EQ(response, string("")); - -} - -TEST_F(HdmiCecSinkDsTest, setRoutingChange) -{ - - std::this_thread::sleep_for(std::chrono::seconds(30)); - - EXPECT_CALL(*p_connectionImplMock, sendTo(::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(::testing::Invoke( - [&](const LogicalAddress &to, const CECFrame &frame, int timeout) { - EXPECT_EQ(to.toInt(), LogicalAddress::BROADCAST); - EXPECT_GT(timeout, 0); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setRoutingChange"), _T("{\"oldPort\":\"HDMI0\",\"newPort\":\"TV\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} - -TEST_F(HdmiCecSinkDsTest, setMenuLanguageInvalidParam) -{ - - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setMenuLanguage"), _T("{\"language\":""}"), response)); - EXPECT_EQ(response, string("")); - -} - -TEST_F(HdmiCecSinkDsTest, setMenuLanguage) -{ - - EXPECT_CALL(*p_connectionImplMock, sendTo(::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(::testing::Invoke( - [&](const LogicalAddress &to, const CECFrame &frame, int timeout) { - EXPECT_LE(to.toInt(), LogicalAddress::BROADCAST); - EXPECT_GT(timeout, 0); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setMenuLanguage"), _T("{\"language\":\"english\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} - -TEST_F(HdmiCecSinkDsTest, setupARCRoutingInvalidParam) -{ - - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setupARCRouting"), _T("{}"), response)); - EXPECT_EQ(response, string("")); - -} - -TEST_F(HdmiCecSinkDsTest, setupARCRouting) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setupARCRouting"), _T("{\"enabled\":\"true\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} - -TEST_F(HdmiCecSinkDsTest, sendKeyPressEventMissingParam) -{ - - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": }"), response)); - EXPECT_EQ(response, string("")); - -} - -TEST_F(HdmiCecSinkDsTest, sendKeyPressEvent) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 65}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} - -TEST_F(HdmiCecSinkInitializedEventDsTest, onHdmiOutputHDCPStatusEvent) -{ - - ASSERT_TRUE(dsHdmiEventHandler != nullptr); - - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_connect.port =dsHDMI_IN_PORT_1; - eventData.data.hdmi_in_connect.isPortConnected = true; - - EVENT_SUBSCRIBE(0, _T("onDevicesChanged"), _T("client.events.onDevicesChanged"), message); - - dsHdmiEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("onDevicesChanged"), _T("client.events.onDevicesChanged"), message); - -} - -TEST_F(HdmiCecSinkInitializedEventDsTest, powerModeChange) -{ - // ASSERT_TRUE(pwrMgrModeChangeEventHandler != nullptr); - - IARM_Bus_PWRMgr_EventData_t eventData; - eventData.data.state.newState =IARM_BUS_PWRMGR_POWERSTATE_ON; - eventData.data.state.curState =IARM_BUS_PWRMGR_POWERSTATE_STANDBY; - - (void) eventData; - - // pwrMgrModeChangeEventHandler(IARM_BUS_PWRMGR_NAME, IARM_BUS_PWRMGR_EVENT_MODECHANGED, &eventData , 0); -} - -TEST_F(HdmiCecSinkTest, DISABLED_getCecVersion) -{ - /*EXPECT_CALL(rfcApiImplMock, getRFCParameter(::testing::_, ::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [](char* pcCallerID, const char* pcParameterName, RFC_ParamData_t* pstParamData) { - EXPECT_EQ(string(pcCallerID), string("HdmiCecSink")); - EXPECT_EQ(string(pcParameterName), string("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.HdmiCecSink.CECVersion")); - strncpy(pstParamData->value, "1.4", sizeof(pstParamData->value)); - return WDMP_SUCCESS; - }));*/ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getCecVersion"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"CECVersion\":\"1.4\",\"success\":true}")); - -} diff --git a/Tests/L1Tests/tests/test_HdmiCecSource.cpp b/Tests/L1Tests/tests/test_HdmiCecSource.cpp deleted file mode 100755 index 3ae56adb5..000000000 --- a/Tests/L1Tests/tests/test_HdmiCecSource.cpp +++ /dev/null @@ -1,1441 +0,0 @@ -/* - * 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 -#include -#include -#include -#include - -#include "HdmiCecSourceImplementation.h" -#include "HdmiCec.h" -#include "HdmiCecSource.h" -#include "PowerManagerMock.h" -#include "FactoriesImplementation.h" -#include "IarmBusMock.h" -#include "ServiceMock.h" -#include "devicesettings.h" -#include "HdmiCecMock.h" -#include "DisplayMock.h" -#include "VideoOutputPortMock.h" -#include "HostMock.h" -#include "ManagerMock.h" -#include "ThunderPortability.h" -#include "COMLinkMock.h" -#include "HdmiCecSourceMock.h" -#include "WorkerPoolImplementation.h" -#include "WrapsMock.h" - -#define JSON_TIMEOUT (1000) - -using namespace WPEFramework; -using ::testing::NiceMock; - -namespace -{ - static void removeFile(const char* fileName) - { - if (std::remove(fileName) != 0) - { - printf("File %s failed to remove\n", fileName); - perror("Error deleting file"); - } - else - { - printf("File %s successfully deleted\n", fileName); - } - } - - static void createFile(const char* fileName, const char* fileContent) - { - removeFile(fileName); - - std::ofstream fileContentStream(fileName); - fileContentStream << fileContent; - fileContentStream << "\n"; - fileContentStream.close(); - } -} - -typedef enum : uint32_t { - HdmiCecSource_OnDeviceAdded = 0x00000001, - HdmiCecSource_OnDeviceRemoved = 0x00000002, - HdmiCecSource_OnDeviceInfoUpdated = 0x00000004, - HdmiCecSource_OnActiveSourceStatusUpdated = 0x00000008, - HdmiCecSource_StandbyMessageReceived = 0x00000010, - HdmiCecSource_OnKeyReleaseEvent = 0x00000020, - HdmiCecSource_OnKeyPressEvent = 0x00000040, -} HdmiCecSourceEventType_t; - - -class NotificationHandler : public Exchange::IHdmiCecSource::INotification { - private: - /** @brief Mutex */ - std::mutex m_mutex; - - /** @brief Condition variable */ - std::condition_variable m_condition_variable; - - /** @brief Event signalled flag */ - uint32_t m_event_signalled; - bool m_OnDeviceAdded_signalled =false; - bool m_onDeviceRemoved_signalled =false; - bool m_OnDeviceInfoUpdated_signalled =false; - bool m_OnActiveSourceStatusUpdated_signalled = false; - bool m_StandbyMessageReceived_signalled = false; - bool m_OnKeyReleaseEvent=false; - bool m_OnKeyPressEvent=false; - - - BEGIN_INTERFACE_MAP(Notification) - INTERFACE_ENTRY(Exchange::IHdmiCecSource::INotification) - END_INTERFACE_MAP - - public: - NotificationHandler(){} - ~NotificationHandler(){} - - void OnDeviceAdded(const int logicalAddress) override - { - TEST_LOG("OnDeviceAdded event trigger ***\n"); - std::unique_lock lock(m_mutex); - - TEST_LOG("LogicalAddress: %d\n", logicalAddress); - m_event_signalled |= HdmiCecSource_OnDeviceAdded; - m_OnDeviceAdded_signalled = true; - m_condition_variable.notify_one(); - - - } - void OnDeviceRemoved(const int logicalAddress) override - { - TEST_LOG("OnDeviceRemoved event trigger ***\n"); - std::unique_lock lock(m_mutex); - - TEST_LOG("LogicalAddress: %d\n", logicalAddress); - m_event_signalled |= HdmiCecSource_OnDeviceRemoved; - m_onDeviceRemoved_signalled = true; - m_condition_variable.notify_one(); - } - void OnDeviceInfoUpdated(const int logicalAddress) override - { - TEST_LOG("OnDeviceInfoUpdated event trigger ***\n"); - std::unique_lock lock(m_mutex); - - TEST_LOG("LogicalAddress: %d\n", logicalAddress); - m_event_signalled |= HdmiCecSource_OnDeviceInfoUpdated; - m_OnDeviceInfoUpdated_signalled = true; - m_condition_variable.notify_one(); - } - void OnActiveSourceStatusUpdated(const bool status) override - { - TEST_LOG("OnActiveSourceStatusUpdated event trigger ***\n"); - std::unique_lock lock(m_mutex); - - TEST_LOG("status: %d\n", status); - m_event_signalled |= HdmiCecSource_OnActiveSourceStatusUpdated; - m_OnActiveSourceStatusUpdated_signalled = true; - m_condition_variable.notify_one(); - } - void StandbyMessageReceived(const int logicalAddress) override - { - TEST_LOG("StandbyMessageReceived event trigger ***\n"); - std::unique_lock lock(m_mutex); - - TEST_LOG("LogicalAddress: %d\n", logicalAddress); - m_event_signalled |= HdmiCecSource_StandbyMessageReceived; - m_StandbyMessageReceived_signalled = true; - m_condition_variable.notify_one(); - } - void OnKeyReleaseEvent(const int logicalAddress) override - { - TEST_LOG("OnKeyReleaseEvent event trigger ***\n"); - std::unique_lock lock(m_mutex); - - TEST_LOG("LogicalAddress: %d\n", logicalAddress); - m_event_signalled |= HdmiCecSource_OnKeyReleaseEvent; - m_OnKeyReleaseEvent = true; - m_condition_variable.notify_one(); - } - void OnKeyPressEvent(const int logicalAddress, const int keyCode) override - { - TEST_LOG("OnKeyPressEvent event trigger ***\n"); - std::unique_lock lock(m_mutex); - - TEST_LOG("LogicalAddress: %d\n", logicalAddress); - TEST_LOG("KeyCode: %d\n", keyCode); - m_event_signalled |= HdmiCecSource_OnKeyPressEvent; - m_OnKeyPressEvent = true; - m_condition_variable.notify_one(); - } - - bool WaitForRequestStatus(uint32_t timeout_ms, HdmiCecSourceEventType_t expected_status) - { - std::unique_lock lock(m_mutex); - auto now = std::chrono::system_clock::now(); - std::chrono::milliseconds timeout(timeout_ms); - bool signalled = false; - - while (!(expected_status & m_event_signalled)) - { - if (m_condition_variable.wait_until(lock, now + timeout) == std::cv_status::timeout) - { - TEST_LOG("Timeout waiting for request status event"); - break; - } - } - - switch(m_event_signalled) - { - case HdmiCecSource_OnDeviceAdded: - signalled = m_OnDeviceAdded_signalled; - break; - case HdmiCecSource_OnDeviceRemoved: - signalled = m_onDeviceRemoved_signalled; - break; - case HdmiCecSource_OnDeviceInfoUpdated: - signalled = m_OnDeviceInfoUpdated_signalled; - break; - case HdmiCecSource_OnActiveSourceStatusUpdated: - signalled = m_OnActiveSourceStatusUpdated_signalled; - break; - case HdmiCecSource_StandbyMessageReceived: - signalled = m_StandbyMessageReceived_signalled; - break; - case HdmiCecSource_OnKeyReleaseEvent: - signalled = m_OnKeyReleaseEvent; - break; - case HdmiCecSource_OnKeyPressEvent: - signalled = m_OnKeyPressEvent; - break; - default: - signalled = false; - break; - } - - - signalled = m_event_signalled; - return signalled; - } - }; - - -class HdmiCecSourceTest : public ::testing::Test { -protected: - Core::ProxyType plugin; - Core::JSONRPC::Handler& handler; - DECL_CORE_JSONRPC_CONX connection; - string response; - IarmBusImplMock *p_iarmBusImplMock = nullptr ; - IARM_EventHandler_t cecMgrEventHandler; - IARM_EventHandler_t dsHdmiEventHandler; - IARM_EventHandler_t pwrMgrEventHandler; - ManagerImplMock *p_managerImplMock = nullptr ; - HostImplMock *p_hostImplMock = nullptr ; - VideoOutputPortMock *p_videoOutputPortMock = nullptr ; - DisplayMock *p_displayMock = nullptr ; - LibCCECImplMock *p_libCCECImplMock = nullptr ; - ConnectionImplMock *p_connectionImplMock = nullptr ; - MessageEncoderMock *p_messageEncoderMock = nullptr ; - WrapsImplMock *p_wrapsImplMock = nullptr; - ServiceMock *p_serviceMock = nullptr; - HdmiCecSourceMock *p_hdmiCecSourceMock = nullptr; - testing::NiceMock comLinkMock; - testing::NiceMock service; - Core::ProxyType workerPool; - Core::ProxyType HdmiCecSourceImplementationImpl; - Exchange::IHdmiCecSource::INotification *HdmiCecSourceNotification = nullptr; - - HdmiCecSourceTest() - : plugin(Core::ProxyType::Create()) - , handler(*(plugin)) - , INIT_CONX(1, 0) - , workerPool(Core::ProxyType::Create( - 2, Core::Thread::DefaultStackSize(), 16)) - { - p_iarmBusImplMock = new testing::NiceMock ; - IarmBus::setImpl(p_iarmBusImplMock); - - p_managerImplMock = new testing::NiceMock ; - device::Manager::setImpl(p_managerImplMock); - - p_hostImplMock = new testing::NiceMock ; - device::Host::setImpl(p_hostImplMock); - - p_videoOutputPortMock = new testing::NiceMock ; - device::VideoOutputPort::setImpl(p_videoOutputPortMock); - - p_displayMock = new testing::NiceMock ; - device::Display::setImpl(p_displayMock); - - p_libCCECImplMock = new testing::NiceMock ; - LibCCEC::setImpl(p_libCCECImplMock); - - p_connectionImplMock = new testing::NiceMock ; - Connection::setImpl(p_connectionImplMock); - - p_messageEncoderMock = new testing::NiceMock ; - MessageEncoder::setImpl(p_messageEncoderMock); - - p_serviceMock = new testing::NiceMock ; - - p_hdmiCecSourceMock = new NiceMock ; - - p_wrapsImplMock = new NiceMock ; - - Wraps::setImpl(p_wrapsImplMock); - - ON_CALL(*p_hdmiCecSourceMock, Register(::testing::_)) - .WillByDefault(::testing::Invoke( - [&](Exchange::IHdmiCecSource::INotification *notification){ - HdmiCecSourceNotification = notification; - return Core::ERROR_NONE;; - })); - - - ON_CALL(service, COMLink()) - .WillByDefault(::testing::Invoke( - [this]() { - TEST_LOG("Pass created comLinkMock: %p ", &comLinkMock); - return &comLinkMock; - })); - - //OnCall required for intialize to run properly - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::ReturnRef(CECFrame::getInstance())); - - ON_CALL(*p_videoOutputPortMock, getDisplay()) - .WillByDefault(::testing::ReturnRef(device::Display::getInstance())); - - ON_CALL(*p_videoOutputPortMock, isDisplayConnected()) - .WillByDefault(::testing::Return(true)); - - ON_CALL(*p_hostImplMock, getVideoOutputPort(::testing::_)) - .WillByDefault(::testing::ReturnRef(device::VideoOutputPort::getInstance())); - - ON_CALL(*p_displayMock, getEDIDBytes(::testing::_)) - .WillByDefault(::testing::Invoke( - [&](std::vector &edidVec2) { - edidVec2 = std::vector({ 't', 'e', 's', 't' }); - })); - //Set enabled needs to be - ON_CALL(*p_libCCECImplMock, getLogicalAddress(::testing::_)) - .WillByDefault(::testing::Return(0)); - - ON_CALL(*p_connectionImplMock, open()) - .WillByDefault(::testing::Return()); - ON_CALL(*p_connectionImplMock, addFrameListener(::testing::_)) - .WillByDefault(::testing::Return()); - ON_CALL(*p_iarmBusImplMock, IARM_Bus_RegisterEventHandler(::testing::_, ::testing::_, ::testing::_)) - .WillByDefault(::testing::Invoke( - [&](const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) { - if ((string(IARM_BUS_CECMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_CECMGR_EVENT_DAEMON_INITIALIZED)) { - EXPECT_TRUE(handler != nullptr); - cecMgrEventHandler = handler; - } - if ((string(IARM_BUS_CECMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_CECMGR_EVENT_STATUS_UPDATED)) { - EXPECT_TRUE(handler != nullptr); - cecMgrEventHandler = handler; - } - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiEventHandler = handler; - } - if ((string(IARM_BUS_PWRMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_PWRMGR_EVENT_MODECHANGED)) { - EXPECT_TRUE(handler != nullptr); - pwrMgrEventHandler = handler; - } - - return IARM_RESULT_SUCCESS; - })); - - } - virtual ~HdmiCecSourceTest() override - { - IarmBus::setImpl(nullptr); - if (p_iarmBusImplMock != nullptr) - { - delete p_iarmBusImplMock; - p_iarmBusImplMock = nullptr; - } - device::Manager::setImpl(nullptr); - if (p_managerImplMock != nullptr) - { - delete p_managerImplMock; - p_managerImplMock = nullptr; - } - device::Host::setImpl(nullptr); - if (p_hostImplMock != nullptr) - { - delete p_hostImplMock; - p_hostImplMock = nullptr; - } - device::VideoOutputPort::setImpl(nullptr); - if (p_videoOutputPortMock != nullptr) - { - delete p_videoOutputPortMock; - p_videoOutputPortMock = nullptr; - } - device::Display::setImpl(nullptr); - if (p_displayMock != nullptr) - { - delete p_displayMock; - p_displayMock = nullptr; - } - LibCCEC::setImpl(nullptr); - if (p_libCCECImplMock != nullptr) - { - delete p_libCCECImplMock; - p_libCCECImplMock = nullptr; - } - Connection::setImpl(nullptr); - if (p_connectionImplMock != nullptr) - { - delete p_connectionImplMock; - p_connectionImplMock = nullptr; - } - MessageEncoder::setImpl(nullptr); - if (p_messageEncoderMock != nullptr) - { - delete p_messageEncoderMock; - p_messageEncoderMock = nullptr; - } - - Core::IWorkerPool::Assign(nullptr); - workerPool.Release(); - - if (p_serviceMock != nullptr) - { - delete p_serviceMock; - p_serviceMock = nullptr; - } - - if (p_hdmiCecSourceMock != nullptr) - { - delete p_hdmiCecSourceMock; - p_hdmiCecSourceMock = nullptr; - } - - Wraps::setImpl(nullptr); - if (p_wrapsImplMock != nullptr) - { - delete p_wrapsImplMock; - p_wrapsImplMock = nullptr; - } - } -}; - -class HdmiCecSourceInitializedTest : public HdmiCecSourceTest { -protected: - HdmiCecSourceInitializedTest() - : HdmiCecSourceTest() - { - system("ls -lh /etc/"); - removeFile("/etc/device.properties"); - system("ls -lh /etc/"); - createFile("/etc/device.properties", "RDK_PROFILE=STB"); - system("ls -lh /etc/"); - EXPECT_EQ(string(""), plugin->Initialize(&service)); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setEnabled"), _T("{\"enabled\": true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - } - virtual ~HdmiCecSourceInitializedTest() override - { - int lCounter = 0; - while ((Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (lCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - lCounter ++; - } - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setEnabled"), _T("{\"enabled\": false}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - plugin->Deinitialize(&service); - removeFile("/etc/device.properties"); - - } -}; -class HdmiCecSourceInitializedEventTest : public HdmiCecSourceInitializedTest { -protected: - - FactoriesImplementation factoriesImplementation; - PLUGINHOST_DISPATCHER* dispatcher; - Core::JSONRPC::Message message; - - HdmiCecSourceInitializedEventTest() - : HdmiCecSourceInitializedTest() - { - PluginHost::IFactories::Assign(&factoriesImplementation); - - dispatcher = static_cast( - plugin->QueryInterface(PLUGINHOST_DISPATCHER_ID)); - dispatcher->Activate(&service); - } - - virtual ~HdmiCecSourceInitializedEventTest() override - { - dispatcher->Deactivate(); - dispatcher->Release(); - PluginHost::IFactories::Assign(nullptr); - - } -}; - -TEST_F(HdmiCecSourceInitializedTest, RegisteredMethods) -{ - - removeFile("/etc/device.properties"); - createFile("/etc/device.properties", "RDK_PROFILE=STB"); - - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getActiveSourceStatus"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getDeviceList"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getEnabled"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getOSDName"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getOTPEnabled"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getVendorId"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("performOTPAction"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("sendKeyPressEvent"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("sendStandbyMessage"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setEnabled"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setOSDName"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setOTPEnabled"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setVendorId"))); - - removeFile("/etc/device.properties"); - -} - -TEST_F(HdmiCecSourceInitializedTest, getEnabledTrue) -{ - //Get enabled just checks if CEC is on, which is a global variable. - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getEnabled"), _T(""), response)); - EXPECT_EQ(response, string("{\"enabled\":true,\"success\":true}")); - -} - -TEST_F(HdmiCecSourceInitializedTest, getActiveSourceStatusTrue) -{ - //SetsOTP to on. - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setOTPEnabled"), _T("{\"enabled\": true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - //Sets Activesource to true - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("performOTPAction"), _T("{\"enabled\": true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getActiveSourceStatus"), _T(""), response)); - EXPECT_EQ(response, string("{\"status\":true,\"success\":true}")); - - -} -TEST_F(HdmiCecSourceInitializedTest, getActiveSourceStatusFalse) -{ - //ActiveSource is a local variable, no mocked functions to check. - //Active source is false by default. - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getActiveSourceStatus"), _T(""), response)); - EXPECT_EQ(response, string("{\"status\":false,\"success\":true}")); -} - - -TEST_F(HdmiCecSourceInitializedTest, getDeviceList) -{ - int iCounter = 0; - //Checking to see if one of the values has been filled in (as the rest get filled in at the same time, and waiting if its not. - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; - } - - const char* val = "TEST"; - OSDName name = OSDName(val); - SetOSDName osdName = SetOSDName(name); - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - VendorID vendor(1,2,3); - DeviceVendorID vendorid(vendor); - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - - proc.process(osdName, header); //calls the process that sets osdName for LogicalAddress = 1 - proc.process(vendorid, header); //calls the process that sets vendorID for LogicalAddress = 1 - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getDeviceList"), _T(""), response)); - - EXPECT_EQ(response, string(_T("{\"numberofdevices\":14,\"deviceList\":[{\"logicalAddress\":1,\"vendorID\":\"123\",\"osdName\":\"TEST\"},{\"logicalAddress\":2,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":3,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":4,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":5,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":6,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":7,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":8,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":9,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":10,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":11,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":12,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":13,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":14,\"vendorID\":\"000\",\"osdName\":\"NA\"}],\"success\":true}"))); - - -} - - -TEST_F(HdmiCecSourceInitializedTest, getOTPEnabled) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setOTPEnabled"), _T("{\"enabled\": true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getOTPEnabled"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"enabled\":true,\"success\":true}")); - -} - -TEST_F(HdmiCecSourceInitializedTest, sendStandbyMessage) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendStandbyMessage"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(HdmiCecSourceInitializedTest, setOSDName) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setOSDName"), _T("{\"name\": \"CUSTOM8 Tv\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getOSDName"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"name\":\"CUSTOM8 Tv\",\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, setVendorId) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setVendorId"), _T("{\"vendorid\": \"0x0019FB\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getVendorId"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"vendorid\":\"019fb\",\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, setOTPEnabled) -{ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setOTPEnabled"), _T("{\"enabled\": false}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} - - -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEventUp) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_VOLUME_UP ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 65}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent2) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_VOLUME_DOWN ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 66}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent3) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_MUTE ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 67}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent4) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_UP ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 1}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent5) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_DOWN ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 2}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent6) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_LEFT ); - return CECFrame::getInstance(); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 3}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent7) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_RIGHT ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 4}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent8) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_SELECT ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 0}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent9) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_HOME ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 9}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent10) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_BACK ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 13}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent11) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_0 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 32}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent12) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_1 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 33}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent13) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_2 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 34}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent14) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_3 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 35}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent15) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_4 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 36}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent16) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_5 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 37}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent17) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_6 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 38}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent18) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_7 ); - return CECFrame::getInstance(); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 39}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent19) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_8 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 40}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} -TEST_F(HdmiCecSourceInitializedTest, sendKeyPressEvent20) -{ - ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) - .WillByDefault(::testing::Invoke( - [](const UserControlPressed& m) -> CECFrame& { - EXPECT_EQ(m.uiCommand.toInt(),UICommand::UI_COMMAND_NUM_9 ); - return CECFrame::getInstance(); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("sendKeyPressEvent"), _T("{\"logicalAddress\": 0, \"keyCode\": 41}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} - -//Failing to remove file when triggered on github. There might be some kind of permission issue. -TEST_F(HdmiCecSourceTest, DISABLED_NotSupportedPlugin) -{ - system("ls -lh /etc/"); - removeFile("/etc/device.properties"); - system("ls -lh /etc/"); - EXPECT_EQ(string("Not supported"), plugin->Initialize(&service)); - createFile("/etc/device.properties", "RDK_PROFILE=TV"); - system("ls -lh /etc/"); - EXPECT_EQ(string("Not supported"), plugin->Initialize(&service)); - removeFile("/etc/device.properties"); - system("ls -lh /etc/"); - createFile("/etc/device.properties", "RDK_PROFILE=STB"); - system("ls -lh /etc/"); - EXPECT_EQ(string(""), plugin->Initialize(&service)); - plugin->Deinitialize(&service); - removeFile("/etc/device.properties"); - system("ls -lh /etc/"); -} - -TEST_F(HdmiCecSourceInitializedTest, GetInformation) -{ - EXPECT_EQ("This HdmiCecSource PLugin Facilitates the HDMI CEC Source Control", plugin->Information()); -} - -TEST_F(HdmiCecSourceInitializedTest, activeSourceProcess) -{ - int iCounter = 0; - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; -} - - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - PhysicalAddress physicalAddress(0x0F,0x0F,0x0F,0x0F); - PhysicalAddress physicalAddress2(1,2,3,4); - ActiveSource activeSource(physicalAddress); - ActiveSource activeSource2(physicalAddress2); - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(activeSource2, header); - proc.process(activeSource, header); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getDeviceList"), _T(""), response)); - - EXPECT_EQ(response, string(_T("{\"numberofdevices\":14,\"deviceList\":[{\"logicalAddress\":1,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":2,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":3,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":4,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":5,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":6,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":7,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":8,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":9,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":10,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":11,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":12,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":13,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":14,\"vendorID\":\"000\",\"osdName\":\"NA\"}],\"success\":true}"))); - - -} - -TEST_F(HdmiCecSourceInitializedTest, imageViewOnProcess){ - int iCounter = 0; - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; -} - - - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - ImageViewOn imageViewOn; - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(imageViewOn, header); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getDeviceList"), _T(""), response)); - - EXPECT_EQ(response, string(_T("{\"numberofdevices\":14,\"deviceList\":[{\"logicalAddress\":1,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":2,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":3,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":4,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":5,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":6,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":7,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":8,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":9,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":10,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":11,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":12,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":13,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":14,\"vendorID\":\"000\",\"osdName\":\"NA\"}],\"success\":true}"))); - -} - -TEST_F(HdmiCecSourceInitializedEventTest, textViewOnProcess){ - int iCounter = 0; - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; -} - - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - TextViewOn textViewOn; - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(textViewOn, header); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getDeviceList"), _T(""), response)); - - EXPECT_EQ(response, string(_T("{\"numberofdevices\":14,\"deviceList\":[{\"logicalAddress\":1,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":2,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":3,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":4,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":5,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":6,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":7,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":8,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":9,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":10,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":11,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":12,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":13,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":14,\"vendorID\":\"000\",\"osdName\":\"NA\"}],\"success\":true}"))); - -} - -TEST_F(HdmiCecSourceInitializedEventTest, requestActiveSourceProccess){ - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setOTPEnabled"), _T("{\"enabled\": true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - //Sets Activesource to true - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("performOTPAction"), _T("{\"enabled\": true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - - EXPECT_CALL(*p_connectionImplMock, sendTo(::testing::_, ::testing::_)) - .WillRepeatedly(::testing::Invoke( - [&](const LogicalAddress &to, const CECFrame &frame) { - EXPECT_EQ(to.toInt(), 15); - })); - - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - RequestActiveSource requestActiveSource; - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(requestActiveSource, header); - -} - -TEST_F(HdmiCecSourceInitializedEventTest, standyProcess){ - Core::Sink notification; - uint32_t signalled = false; - p_hdmiCecSourceMock->AddRef(); - p_hdmiCecSourceMock->Register(¬ification); - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - Standby standby; - - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(standby, header); - - signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, HdmiCecSource_StandbyMessageReceived); - - EXPECT_TRUE(signalled); -} - - -TEST_F(HdmiCecSourceInitializedEventTest, requestGetCECVersionProcess){ - - EXPECT_CALL(*p_connectionImplMock, sendTo(::testing::_, ::testing::_)) - .WillRepeatedly(::testing::Invoke( - [&](const LogicalAddress &to, const CECFrame &frame) { - EXPECT_EQ(to.toInt(), 1); - })); - - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - GetCECVersion getCecVersion; - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(getCecVersion, header); - -} - - -TEST_F(HdmiCecSourceInitializedEventTest, CecVersionProcess){ - int iCounter = 0; - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; -} - - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - CECVersion cecVersion(Version::V_1_4); - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(cecVersion, header); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getDeviceList"), _T(""), response)); - - EXPECT_EQ(response, string(_T("{\"numberofdevices\":14,\"deviceList\":[{\"logicalAddress\":1,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":2,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":3,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":4,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":5,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":6,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":7,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":8,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":9,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":10,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":11,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":12,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":13,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":14,\"vendorID\":\"000\",\"osdName\":\"NA\"}],\"success\":true}"))); - -} - -TEST_F(HdmiCecSourceInitializedEventTest, giveOSDNameProcess){ - - EXPECT_CALL(*p_connectionImplMock, sendTo(::testing::_, ::testing::_)) - .WillRepeatedly(::testing::Invoke( - [&](const LogicalAddress &to, const CECFrame &frame) { - EXPECT_EQ(to.toInt(), 1); - })); - - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - GiveOSDName giveOSDName; - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(giveOSDName, header); - -} - -TEST_F(HdmiCecSourceInitializedEventTest, givePhysicalAddressProcess){ - - EXPECT_CALL(*p_connectionImplMock, sendTo(::testing::_, ::testing::_)) - .WillRepeatedly(::testing::Invoke( - [&](const LogicalAddress &to, const CECFrame &frame) { - EXPECT_EQ(to.toInt(), 15); - })); - - - Header header; - header.from = LogicalAddress(15); //specifies with logicalAddress in the deviceList we're using - - GivePhysicalAddress givePhysicalAddress; - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(givePhysicalAddress, header); - -} - -TEST_F(HdmiCecSourceInitializedEventTest, giveDeviceVendorIdProcess){ - - EXPECT_CALL(*p_connectionImplMock, sendTo(::testing::_, ::testing::_)) - .WillRepeatedly(::testing::Invoke( - [&](const LogicalAddress &to, const CECFrame &frame) { - EXPECT_EQ(to.toInt(), 15); - })); - - - Header header; - header.from = LogicalAddress(15); //specifies with logicalAddress in the deviceList we're using - - GiveDeviceVendorID giveDeviceVendorID; - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(giveDeviceVendorID, header); - -} - -TEST_F(HdmiCecSourceInitializedEventTest, setOSDNameProcess){ - Core::Sink notification; - uint32_t signalled = false; - p_hdmiCecSourceMock->AddRef(); - p_hdmiCecSourceMock->Register(¬ification); - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - OSDName osdName("Test"); - - SetOSDName setOSDName(osdName); - - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(setOSDName, header); - - signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, HdmiCecSource_OnDeviceInfoUpdated); - - EXPECT_TRUE(signalled); -} - -TEST_F(HdmiCecSourceInitializedEventTest, routingChangeProcess){ - int iCounter = 0; - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; - } - Core::Sink notification; - uint32_t signalled = false; - p_hdmiCecSourceMock->AddRef(); - p_hdmiCecSourceMock->Register(¬ification); - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - PhysicalAddress physicalAddress(0x0F,0x0F,0x0F,0x0F); - PhysicalAddress physicalAddress2(1,2,3,4); - - RoutingChange routingChange(physicalAddress,physicalAddress2); - - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(routingChange, header); - - signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, HdmiCecSource_OnActiveSourceStatusUpdated); - - EXPECT_TRUE(signalled); -} - -TEST_F(HdmiCecSourceInitializedEventTest, routingInformationProcess){ - int iCounter = 0; - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; - } - Core::Sink notification; - uint32_t signalled = false; - p_hdmiCecSourceMock->AddRef(); - p_hdmiCecSourceMock->Register(¬ification); - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - RoutingInformation routingInformation; - - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(routingInformation, header); - - signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, HdmiCecSource_OnActiveSourceStatusUpdated); - - EXPECT_TRUE(signalled); -} - -TEST_F(HdmiCecSourceInitializedEventTest, setStreamPathProcess){ - int iCounter = 0; - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; - } - Core::Sink notification; - uint32_t signalled = false; - p_hdmiCecSourceMock->AddRef(); - p_hdmiCecSourceMock->Register(¬ification); - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - PhysicalAddress physicalAddress(0x0F,0x0F,0x0F,0x0F); - - SetStreamPath setStreamPath(physicalAddress); - - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(setStreamPath, header); - - signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, HdmiCecSource_OnActiveSourceStatusUpdated); - - EXPECT_TRUE(signalled); -} - -TEST_F(HdmiCecSourceInitializedEventTest, reportPhysicalAddressProcess){ - - int iCounter = 0; - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; - } - - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - PhysicalAddress physicalAddress(0x0F,0x0F,0x0F,0x0F); - DeviceType deviceType(1); - - ReportPhysicalAddress reportPhysicalAddress(physicalAddress, deviceType); - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(reportPhysicalAddress, header); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getDeviceList"), _T(""), response)); - - EXPECT_EQ(response, string(_T("{\"numberofdevices\":14,\"deviceList\":[{\"logicalAddress\":1,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":2,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":3,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":4,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":5,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":6,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":7,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":8,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":9,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":10,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":11,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":12,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":13,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":14,\"vendorID\":\"000\",\"osdName\":\"NA\"}],\"success\":true}"))); - - -} - - -TEST_F(HdmiCecSourceInitializedEventTest, deviceVendorIDProcess){ - - int iCounter = 0; - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; - } - Core::Sink notification; - uint32_t signalled = false; - p_hdmiCecSourceMock->AddRef(); - p_hdmiCecSourceMock->Register(¬ification); - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - - VendorID vendorID(1,2,3); - - DeviceVendorID deviceVendorID(vendorID); - - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(deviceVendorID, header); - - signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, HdmiCecSource_OnDeviceInfoUpdated); - - EXPECT_TRUE(signalled); -} - - -TEST_F(HdmiCecSourceInitializedEventTest, GiveDevicePowerStatusProcess){ - - EXPECT_CALL(*p_connectionImplMock, sendTo(::testing::_, ::testing::_)) - .WillRepeatedly(::testing::Invoke( - [&](const LogicalAddress &to, const CECFrame &frame) { - EXPECT_EQ(to.toInt(), 1); - })); - - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - GiveDevicePowerStatus deviceDevicePowerStatus; - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(deviceDevicePowerStatus, header); - -} - -TEST_F(HdmiCecSourceInitializedEventTest, reportPowerStatusProcess){ - - int iCounter = 0; - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; - } - - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - PowerStatus powerStatus(0); - - ReportPowerStatus reportPowerStatus(powerStatus); - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(reportPowerStatus, header); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getDeviceList"), _T(""), response)); - - EXPECT_EQ(response, string(_T("{\"numberofdevices\":14,\"deviceList\":[{\"logicalAddress\":1,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":2,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":3,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":4,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":5,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":6,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":7,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":8,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":9,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":10,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":11,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":12,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":13,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":14,\"vendorID\":\"000\",\"osdName\":\"NA\"}],\"success\":true}"))); - - -} - -TEST_F(HdmiCecSourceInitializedEventTest, userControlPressedProcess){ - Core::Sink notification; - uint32_t signalled = false; - p_hdmiCecSourceMock->AddRef(); - p_hdmiCecSourceMock->Register(¬ification); - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - UserControlPressed userControlPressed(UICommand::UI_COMMAND_VOLUME_UP); - - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(userControlPressed, header); - - signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, HdmiCecSource_OnKeyPressEvent); - - EXPECT_TRUE(signalled); -} - -TEST_F(HdmiCecSourceInitializedEventTest, userControlReleasedrocess){ - Core::Sink notification; - uint32_t signalled = false; - p_hdmiCecSourceMock->AddRef(); - p_hdmiCecSourceMock->Register(¬ification); - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - UserControlReleased userControlReleased; - - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(userControlReleased, header); - - signalled = notification.WaitForRequestStatus(JSON_TIMEOUT, HdmiCecSource_OnKeyReleaseEvent); - - EXPECT_TRUE(signalled); -} - -TEST_F(HdmiCecSourceInitializedEventTest, abortProcess){ - - int iCounter = 0; - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; - } - - - Header header; - header.from = LogicalAddress(1); //specifies with logicalAddress in the deviceList we're using - - Abort abort; - - - Plugin::HdmiCecSourceProcessor proc(Connection::getInstance()); - proc.process(abort, header); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getDeviceList"), _T(""), response)); - - EXPECT_EQ(response, string(_T("{\"numberofdevices\":14,\"deviceList\":[{\"logicalAddress\":1,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":2,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":3,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":4,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":5,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":6,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":7,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":8,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":9,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":10,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":11,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":12,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":13,\"vendorID\":\"000\",\"osdName\":\"NA\"},{\"logicalAddress\":14,\"vendorID\":\"000\",\"osdName\":\"NA\"}],\"success\":true}"))); - -} - -TEST_F(HdmiCecSourceInitializedEventTest, hdmiEventHandler) -{ - int iCounter = 0; - while ((!Plugin::HdmiCecSourceImplementation::_instance->deviceList[0].m_isOSDNameUpdated) && (iCounter < (2*10))) { //sleep for 2sec. - usleep (100 * 1000); //sleep for 100 milli sec - iCounter ++; - } - - ASSERT_TRUE(dsHdmiEventHandler != nullptr); - EXPECT_CALL(*p_hostImplMock, getDefaultVideoPortName()) - .Times(1) - .WillOnce(::testing::Return("TEST")); - - - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_hpd.event = 0; - - EVENT_SUBSCRIBE(0, _T("onHdmiHotPlug"), _T("client.events.onHdmiHotPlug"), message); - - dsHdmiEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onHdmiHotPlug"), _T("client.events.onHdmiHotPlug"), message); -} - - -TEST_F(HdmiCecSourceInitializedEventTest, powerModeChanged) -{ - EXPECT_CALL(*p_libCCECImplMock, getLogicalAddress(::testing::_)) - .WillRepeatedly(::testing::Invoke( - [&](int devType) { - EXPECT_EQ(devType, 1); - return 0; - })); - - Plugin::HdmiCecSourceImplementation::_instance->onPowerModeChanged(WPEFramework::Exchange::IPowerManager::POWER_STATE_OFF, WPEFramework::Exchange::IPowerManager::POWER_STATE_ON); - - -} - diff --git a/Tests/L1Tests/tests/test_HdmiInput.cpp b/Tests/L1Tests/tests/test_HdmiInput.cpp deleted file mode 100644 index 9b0b1f668..000000000 --- a/Tests/L1Tests/tests/test_HdmiInput.cpp +++ /dev/null @@ -1,861 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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 - -#include "HdmiInput.h" - -#include "FactoriesImplementation.h" - -#include "HdmiInputMock.h" -#include "IarmBusMock.h" -#include "ServiceMock.h" - -#include "dsMgr.h" -#include "ThunderPortability.h" - -using namespace WPEFramework; - -using ::testing::NiceMock; - -class HdmiInputTest : public ::testing::Test { -protected: - Core::ProxyType plugin; - Core::JSONRPC::Handler& handler; - Core::JSONRPC::Handler& handlerV2; - DECL_CORE_JSONRPC_CONX connection; - string response; - - HdmiInputTest() - : plugin(Core::ProxyType::Create()) - , handler(*(plugin)) - , handlerV2(*(plugin->GetHandler(2))) - , INIT_CONX(1, 0) - { - } - virtual ~HdmiInputTest() = default; -}; - -class HdmiInputDsTest : public HdmiInputTest { -protected: - HdmiInputImplMock *p_hdmiInputImplMock = nullptr ; - - HdmiInputDsTest() - : HdmiInputTest() - { - p_hdmiInputImplMock = new NiceMock ; - device::HdmiInput::setImpl(p_hdmiInputImplMock); - } - virtual ~HdmiInputDsTest() override - { - device::HdmiInput::setImpl(nullptr); - if (p_hdmiInputImplMock != nullptr) - { - delete p_hdmiInputImplMock; - p_hdmiInputImplMock = nullptr; - } - } -}; - -class HdmiInputInitializedTest : public HdmiInputTest { -protected: - IarmBusImplMock *p_iarmBusImplMock = nullptr ; - IARM_EventHandler_t dsHdmiEventHandler; - IARM_EventHandler_t dsHdmiStatusEventHandler; - IARM_EventHandler_t dsHdmiSignalStatusEventHandler; - IARM_EventHandler_t dsHdmiVideoModeEventHandler; - IARM_EventHandler_t dsHdmiGameFeatureStatusEventHandler; - - // NiceMock service; - ServiceMock service; - - HdmiInputInitializedTest() - : HdmiInputTest() - { - p_iarmBusImplMock = new NiceMock ; - IarmBus::setImpl(p_iarmBusImplMock); - - EXPECT_CALL(service, QueryInterfaceByCallsign(::testing::_, ::testing::_)) - .Times(::testing::AnyNumber()) - .WillRepeatedly(::testing::Invoke( - [&](const uint32_t, const string& name) -> void* { - return nullptr; - })); - ON_CALL(*p_iarmBusImplMock, IARM_Bus_RegisterEventHandler(::testing::_, ::testing::_, ::testing::_)) - .WillByDefault(::testing::Invoke( - [&](const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) { - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiEventHandler = handler; - } - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiStatusEventHandler = handler; - } - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiSignalStatusEventHandler = handler; - } - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiVideoModeEventHandler = handler; - } - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiGameFeatureStatusEventHandler = handler; - } - return IARM_RESULT_SUCCESS; - })); - - EXPECT_EQ(string(""), plugin->Initialize(&service)); - } - virtual ~HdmiInputInitializedTest() override - { - plugin->Deinitialize(&service); - - IarmBus::setImpl(nullptr); - if (p_iarmBusImplMock != nullptr) - { - delete p_iarmBusImplMock; - p_iarmBusImplMock = nullptr; - } - } -}; - - -class HdmiInputInitializedEventTest : public HdmiInputInitializedTest { -protected: - NiceMock service; - NiceMock factoriesImplementation; - PLUGINHOST_DISPATCHER* dispatcher; - Core::JSONRPC::Message message; - - HdmiInputInitializedEventTest() - : HdmiInputInitializedTest() - { - PluginHost::IFactories::Assign(&factoriesImplementation); - - dispatcher = static_cast( - plugin->QueryInterface(PLUGINHOST_DISPATCHER_ID)); - dispatcher->Activate(&service); - } - - virtual ~HdmiInputInitializedEventTest() override - { - dispatcher->Deactivate(); - dispatcher->Release(); - - PluginHost::IFactories::Assign(nullptr); - } -}; - -class HdmiInputInitializedEventDsTest : public HdmiInputInitializedEventTest { -protected: - HdmiInputImplMock *p_hdmiInputImplMock = nullptr ; - - HdmiInputInitializedEventDsTest() - : HdmiInputInitializedEventTest() - { - p_hdmiInputImplMock = new NiceMock ; - device::HdmiInput::setImpl(p_hdmiInputImplMock); - } - - virtual ~HdmiInputInitializedEventDsTest() override - { - device::HdmiInput::setImpl(nullptr); - if (p_hdmiInputImplMock != nullptr) - { - delete p_hdmiInputImplMock; - p_hdmiInputImplMock = nullptr; - } - } -}; - -TEST_F(HdmiInputTest, RegisteredMethods) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getHDMIInputDevices"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("writeEDID"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("readEDID"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("getRawHDMISPD"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("getHDMISPD"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("setEdidVersion"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("getEdidVersion"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("startHdmiInput"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("stopHdmiInput"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setVideoRectangle"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getSupportedGameFeatures"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getHdmiGameFeatureStatus"))); - - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("getHDMIInputDevices"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("writeEDID"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("readEDID"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("startHdmiInput"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("stopHdmiInput"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("setVideoRectangle"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("getSupportedGameFeatures"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("getHdmiGameFeatureStatus"))); -} - -TEST_F(HdmiInputDsTest, getHDMIInputDevices) -{ - - ON_CALL(*p_hdmiInputImplMock, getNumberOfInputs()) - .WillByDefault(::testing::Return(1)); - ON_CALL(*p_hdmiInputImplMock, isPortConnected(::testing::_)) - .WillByDefault(::testing::Return(true)); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getHDMIInputDevices"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"devices\":[{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"connected\":\"true\"}],\"success\":true}")); -} - - -TEST_F(HdmiInputDsTest, writeEDIDEmpty) -{ - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("writeEDID"), _T("{\"message\": \"message\"}"), response)); - EXPECT_EQ(response, string("")); -} - - -TEST_F(HdmiInputDsTest, writeEDID) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("writeEDID"), _T("{\"deviceId\": 0, \"message\": \"message\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(HdmiInputDsTest, writeEDIDInvalid) -{ - ON_CALL(*p_hdmiInputImplMock, getEDIDBytesInfo(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, std::vector &edidVec2) { - edidVec2 = std::vector({ 't', 'e', 's', 't' }); - })); - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("readEDID"), _T("{\"deviceId\": \"b\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, readEDID) -{ - ON_CALL(*p_hdmiInputImplMock, getEDIDBytesInfo(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, std::vector &edidVec2) { - edidVec2 = std::vector({ 't', 'e', 's', 't' }); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("readEDID"), _T("{\"deviceId\": 0}"), response)); - EXPECT_EQ(response, string("{\"EDID\":\"dGVzdA==\",\"success\":true}")); -} - -TEST_F(HdmiInputDsTest, getRawHDMISPD) -{ - ON_CALL(*p_hdmiInputImplMock, getHDMISPDInfo(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, std::vector& edidVec2) { - edidVec2 = { 't', 'e', 's', 't' }; - })); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Invoke(connection, _T("getRawHDMISPD"), _T("{\"portId\":0}"), response)); - EXPECT_EQ(response, string("{\"HDMISPD\":\"dGVzdA\",\"success\":true}")); -} -TEST_F(HdmiInputDsTest, getRawHDMISPDInvalid) -{ - ON_CALL(*p_hdmiInputImplMock, getHDMISPDInfo(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, std::vector& edidVec2) { - edidVec2 = { 't', 'e', 's', 't' }; - })); - EXPECT_EQ(Core::ERROR_GENERAL, handlerV2.Invoke(connection, _T("getRawHDMISPD"), _T("{\"portId\":\"b\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, getHDMISPD) -{ - ON_CALL(*p_hdmiInputImplMock, getHDMISPDInfo(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, std::vector& edidVec2) { - edidVec2 = {'0','1','2','n', 'p', '1','2','3','4','5','6','7',0,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',0,'q','r'}; - })); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Invoke(connection, _T("getHDMISPD"), _T("{\"portId\":0}"), response)); - EXPECT_EQ(response, string("{\"HDMISPD\":\"Packet Type:30,Version:49,Length:50,vendor name:1234567,product des:abcdefghijklmno,source info:71\",\"success\":true}")); -} -TEST_F(HdmiInputDsTest, getHDMISPDInvalid) -{ - ON_CALL(*p_hdmiInputImplMock, getHDMISPDInfo(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, std::vector& edidVec2) { - edidVec2 = {'0','1','2','n', 'p', '0'}; - })); - EXPECT_EQ(Core::ERROR_GENERAL, handlerV2.Invoke(connection, _T("getHDMISPD"), _T("{\"portId\":\"b\"}"), response)); - EXPECT_EQ(response, string("")); -} - - -TEST_F(HdmiInputDsTest, setEdidVersionInvalid) -{ - EXPECT_EQ(Core::ERROR_GENERAL, handlerV2.Invoke(connection, _T("setEdidVersion"), _T("{\"portId\": \"b\", \"edidVersion\":\"HDMI1.4\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, setEdidVersion14) -{ - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Invoke(connection, _T("setEdidVersion"), _T("{\"portId\": \"0\", \"edidVersion\":\"HDMI1.4\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(HdmiInputDsTest, setEdidVersion20) -{ - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Invoke(connection, _T("setEdidVersion"), _T("{\"portId\": \"0\", \"edidVersion\":\"HDMI2.0\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(HdmiInputDsTest, setEdidVersionEmpty) -{ - EXPECT_EQ(Core::ERROR_GENERAL, handlerV2.Invoke(connection, _T("setEdidVersion"), _T("{\"portId\": \"0\", \"edidVersion\":\"\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, getEdidVersionInvalid) -{ - EXPECT_EQ(Core::ERROR_GENERAL, handlerV2.Invoke(connection, _T("getEdidVersion"), _T("{\"portId\": \"b\", \"edidVersion\":\"HDMI1.4\"}"), response)); - EXPECT_EQ(response, string("")); -} -TEST_F(HdmiInputDsTest, getEdidVersionVer14) -{ - ON_CALL(*p_hdmiInputImplMock, getEdidVersion(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iPort, int *edidVersion) { - *edidVersion = 0; - })); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Invoke(connection, _T("getEdidVersion"), _T("{\"portId\": \"0\"}"), response)); - EXPECT_EQ(response, string("{\"edidVersion\":\"HDMI1.4\",\"success\":true}")); -} -TEST_F(HdmiInputDsTest, getEdidVersionVer20) -{ - ON_CALL(*p_hdmiInputImplMock, getEdidVersion(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iPort, int *edidVersion) { - *edidVersion = 1; - })); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Invoke(connection, _T("getEdidVersion"), _T("{\"portId\": \"0\"}"), response)); - EXPECT_EQ(response, string("{\"edidVersion\":\"HDMI2.0\",\"success\":true}")); -} - -TEST_F(HdmiInputDsTest, startHdmiInputInvalid) -{ - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("startHdmiInput"), _T("{\"portId\": \"b\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, startHdmiInput) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("startHdmiInput"), _T("{\"portId\": \"0\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - - -TEST_F(HdmiInputDsTest, stopHdmiInput) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("stopHdmiInput"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(HdmiInputDsTest, setVideoRectangleInvalid) -{ - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setVideoRectangle"), _T("{\"x\": \"b\",\"y\": 0,\"w\": 1920,\"h\": 1080}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, setVideoRectangle) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setVideoRectangle"), _T("{\"x\": 0,\"y\": 0,\"w\": 1920,\"h\": 1080}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - - -TEST_F(HdmiInputDsTest, getSupportedGameFeatures) -{ - ON_CALL(*p_hdmiInputImplMock, getSupportedGameFeatures(::testing::_)) - .WillByDefault(::testing::Invoke( - [&](std::vector &supportedFeatures) { - supportedFeatures = {"ALLM"}; - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getSupportedGameFeatures"), _T("{\"supportedGameFeatures\": \"ALLM\"}"), response)); - EXPECT_EQ(response, string("{\"supportedGameFeatures\":[\"ALLM\"],\"success\":true}")); -} - - -TEST_F(HdmiInputDsTest, getHdmiGameFeatureStatusInvalidPort) -{ - ON_CALL(*p_hdmiInputImplMock, getHdmiALLMStatus(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, bool *allm) { - *allm = true; - })); - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getHdmiGameFeatureStatus"), _T("{\"portId\": \"b\",\"gameFeature\": \"ALLM\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, getHdmiGameFeatureStatus) -{ - ON_CALL(*p_hdmiInputImplMock, getHdmiALLMStatus(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, bool *allm) { - *allm = true; - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getHdmiGameFeatureStatus"), _T("{\"portId\": \"0\",\"gameFeature\": \"ALLM\"}"), response)); - EXPECT_EQ(response, string("{\"mode\":true,\"success\":true}")); -} -TEST_F(HdmiInputDsTest, getHdmiGameFeatureStatusInvalidFeature) -{ - ON_CALL(*p_hdmiInputImplMock, getHdmiALLMStatus(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, bool *allm) { - *allm = true; - })); - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getHdmiGameFeatureStatus"), _T("{\"portId\": \"0\",\"gameFeature\": \"Invalid\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputInitializedEventDsTest, onDevicesChanged) -{ - ASSERT_TRUE(dsHdmiEventHandler != nullptr); - ON_CALL(*p_hdmiInputImplMock, getNumberOfInputs()) - .WillByDefault(::testing::Return(1)); - ON_CALL(*p_hdmiInputImplMock, isPortConnected(::testing::_)) - .WillByDefault(::testing::Return(true)); - - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onDevicesChanged.onDevicesChanged\",\"params\":{\"devices\":[{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"connected\":\"true\"}]}}"))); - - return Core::ERROR_NONE; - })); - - - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_connect.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_connect.isPortConnected = true; - - EVENT_SUBSCRIBE(0, _T("onDevicesChanged"), _T("client.events.onDevicesChanged"), message); - - dsHdmiEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onDevicesChanged"), _T("client.events.onDevicesChanged"), message); -} - -TEST_F(HdmiInputInitializedEventDsTest, onInputStatusChangeOn) -{ - ASSERT_TRUE(dsHdmiStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onInputStatusChanged.onInputStatusChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"status\":\"started\",\"plane\":0}}"))); - return Core::ERROR_NONE; - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("startHdmiInput"), _T("{\"portId\": \"0\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_status.isPresented = true; - - EVENT_SUBSCRIBE(0, _T("onInputStatusChanged"), _T("client.events.onInputStatusChanged"), message); - - dsHdmiStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onInputStatusChanged"), _T("client.events.onInputStatusChanged"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, onInputStatusChangeOff) -{ - ASSERT_TRUE(dsHdmiStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onInputStatusChanged.onInputStatusChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"status\":\"stopped\",\"plane\":-1}}"))); - return Core::ERROR_NONE; - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("stopHdmiInput"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_status.isPresented = false; - - EVENT_SUBSCRIBE(0, _T("onInputStatusChanged"), _T("client.events.onInputStatusChanged"), message); - - dsHdmiStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onInputStatusChanged"), _T("client.events.onInputStatusChanged"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, onSignalChangedStable) -{ - ASSERT_TRUE(dsHdmiSignalStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onSignalChanged.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"stableSignal\"}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_sig_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_sig_status.status = dsHDMI_IN_SIGNAL_STATUS_STABLE; - - EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); - - dsHdmiSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, onSignalChangedNoSignal) -{ - ASSERT_TRUE(dsHdmiSignalStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onSignalChanged.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"noSignal\"}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_sig_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_sig_status.status = dsHDMI_IN_SIGNAL_STATUS_NOSIGNAL; - - EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); - - dsHdmiSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, onSignalChangedUnstable) -{ - ASSERT_TRUE(dsHdmiSignalStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onSignalChanged.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"unstableSignal\"}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_sig_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_sig_status.status = dsHDMI_IN_SIGNAL_STATUS_UNSTABLE; - - EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); - - dsHdmiSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, onSignalChangedNotSupported) -{ - ASSERT_TRUE(dsHdmiSignalStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onSignalChanged.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"notSupportedSignal\"}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_sig_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_sig_status.status = dsHDMI_IN_SIGNAL_STATUS_NOTSUPPORTED; - - EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); - - dsHdmiSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); - -} -TEST_F(HdmiInputInitializedEventDsTest, onSignalChangedDefault) -{ - ASSERT_TRUE(dsHdmiSignalStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onSignalChanged.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"none\"}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_sig_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_sig_status.status = dsHDMI_IN_SIGNAL_STATUS_MAX; - - EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); - - dsHdmiSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); -} - -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate1) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":1920,\"height\":1080,\"progressive\":false,\"frameRateN\":60000,\"frameRateD\":1001}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_1920x1080; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_59dot94; - - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate2) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":720,\"height\":480,\"progressive\":false,\"frameRateN\":24000,\"frameRateD\":1000}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_720x480; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_24; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate3) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":720,\"height\":576,\"progressive\":false,\"frameRateN\":25000,\"frameRateD\":1000}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_720x576; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_25; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate4) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":3840,\"height\":2160,\"progressive\":false,\"frameRateN\":30000,\"frameRateD\":1000}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_3840x2160; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_30; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate5) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":4096,\"height\":2160,\"progressive\":false,\"frameRateN\":50000,\"frameRateD\":1000}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_4096x2160; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_50; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate6) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":4096,\"height\":2160,\"progressive\":false,\"frameRateN\":60000,\"frameRateD\":1000}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_4096x2160; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_60; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate7) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":4096,\"height\":2160,\"progressive\":false,\"frameRateN\":24000,\"frameRateD\":1001}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_4096x2160; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_23dot98; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate8) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":4096,\"height\":2160,\"progressive\":false,\"frameRateN\":30000,\"frameRateD\":1001}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_4096x2160; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_29dot97; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate9) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":1280,\"height\":720,\"progressive\":false,\"frameRateN\":30000,\"frameRateD\":1001}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_1280x720; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_29dot97; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdateDefault) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":1920,\"height\":1080,\"progressive\":false,\"frameRateN\":60000,\"frameRateD\":1000}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_MAX; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate= dsVIDEO_FRAMERATE_MAX; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, hdmiGameFeatureStatusUpdate) -{ - ASSERT_TRUE(dsHdmiGameFeatureStatusEventHandler != nullptr); - - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.hdmiGameFeatureStatusUpdate.hdmiGameFeatureStatusUpdate\",\"params\":{\"id\":0,\"gameFeature\":\"ALLM\",\"mode\":true}}"))); - - return Core::ERROR_NONE; - })); - - - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_allm_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_allm_mode.allm_mode = true; - EVENT_SUBSCRIBE(0, _T("hdmiGameFeatureStatusUpdate"), _T("client.events.hdmiGameFeatureStatusUpdate"), message); - - dsHdmiGameFeatureStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("hdmiGameFeatureStatusUpdate"), _T("client.events.hdmiGameFeatureStatusUpdate"), message); -} diff --git a/Tests/L1Tests/tests/test_UtilsFile.cpp b/Tests/L1Tests/tests/test_UtilsFile.cpp deleted file mode 100644 index ed41f3ad0..000000000 --- a/Tests/L1Tests/tests/test_UtilsFile.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 - -#include "Module.h" - -#include "UtilsFile.h" - -namespace { -const uint8_t bytes[] = { 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0xFE, 0x03, 0x20, 0x04, 0x00, 0x01 }; -} -#include "ThunderPortability.h" - -using namespace WPEFramework; - -TEST(UtilsFileTest, createFolder_createFile_moveFile_verifyFile) -{ - Core::Directory dir(_T("/tmp/UtilsFileTest")); - -#ifdef USE_THUNDER_R4 - EXPECT_TRUE(dir.Destroy()); -#else - EXPECT_TRUE(dir.Destroy(false)); -#endif /*USE_THUNDER_R4 */ - ASSERT_TRUE(dir.CreatePath()); - - Core::File file(string(_T("/tmp/UtilsFileTest/file"))); - - EXPECT_FALSE(file.Exists()); - EXPECT_TRUE(file.Create()); - EXPECT_EQ(sizeof(bytes), file.Write(bytes, sizeof(bytes))); - - Core::File file2(string(_T("/tmp/UtilsFileTest/destination/for/new/file"))); - - EXPECT_FALSE(file2.Exists()); - EXPECT_TRUE(Utils::MoveFile(file.Name(), file2.Name())); - file.LoadFileInfo(); - file2.LoadFileInfo(); - EXPECT_FALSE(file.Exists()); - EXPECT_TRUE(file2.Exists()); - EXPECT_TRUE(file2.Open(true)); - - uint8_t buffer[2 * sizeof(bytes)]; - - EXPECT_EQ(sizeof(bytes), file2.Read(buffer, 2 * sizeof(bytes))); - EXPECT_EQ(0, memcmp(buffer, bytes, sizeof(bytes))); -} diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/HdmiCecSinkApis.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/HdmiCecSinkApis.py deleted file mode 100644 index 342bb239f..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/HdmiCecSinkApis.py +++ /dev/null @@ -1,356 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Curl command for activating HdmiCecSink plugin -activate_command = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc":"2.0","id":"3" -,"method": "Controller.1.activate", "params":{"callsign":"org.rdk.HdmiCecSource"}}' http://127.0.0.1:55555/jsonrpc''' - -# Curl command for deactivating HdmiCecSink plugin -deactivate_command = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc":"2.0","id":"3" -,"method": "Controller.1.deactivate", "params":{"callsign":"org.rdk.HdmiCecSource"}}' http://127.0.0.1:55555/jsonrpc''' - -# Store the expected output response for activate & deactivate curl command -expected_output_response = '{"jsonrpc":"2.0","id":3,"result":null}' - -###################################################################################### - -# HdmiCecSink Methods : - -#Gets the number of connected source devices and system information for each device -get_device_list = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.getDeviceList"}' http://127.0.0.1:55555/jsonrpc''' - -#Sends a CEC message to the logical address of the device -send_standby_message = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", -"id": 42,"method":"org.rdk.HdmiCecSink.sendStandbyMessage"}' http://127.0.0.1:55555/jsonrpc''' - -#Gets the current vendor ID used by host device -get_vendor_id = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.getVendorId"}' http://127.0.0.1:55555/jsonrpc''' - -#Sets a vendor ID used by host device -set_vendor_id = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setVendorId","params": {"vendorid": "0x4455"}}' http://127.0.0.1:55555/jsonrpc''' - -#Sets an undefined vendor ID(not following the standard data type) used by host device -set_vendor_id_with_undefined_datatype = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setVendorId","params": {"vendorid": "12345"}}' http://127.0.0.1:55555/jsonrpc''' - -#Returns the OSD name used by host device -get_osd_name = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.getOSDName"}' http://127.0.0.1:55555/jsonrpc''' - -#Sets the OSD Name used by host device -set_osd_name = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setOSDName","params": {"name": "Sky TV"}}' http://127.0.0.1:55555/jsonrpc''' - -#Sets the an OSD Name which is not in the correct format used by host device -set_osd_name_with_undefined_datatype = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setOSDName","params": {"name": "ABC TV"}}' http://127.0.0.1:55555/jsonrpc''' - -#Returns whether HDMI-CEC is enabled on platform or not -get_enabled = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.getEnabled"}' http://127.0.0.1:55555/jsonrpc''' - -#Disables HDMI-CEC support in the platform as enabled is FALSE -set_enabled_false = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setEnabled","params": {"enabled": false}}' http://127.0.0.1:55555/jsonrpc''' - -#Enables HDMI-CEC support in the platform -set_enabled_true = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setEnabled","params": {"enabled": true}}' http://127.0.0.1:55555/jsonrpc''' - -#Disables HDMI-CEC support in the platform, by passing a value other than boolean to get an error response -set_enabled_with_undefined_datatype = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setEnabled","params": {"enabled": 1234}}' http://127.0.0.1:55555/jsonrpc''' - -#Gets the current active source -get_active_source_status = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", -"id": 42,"method":"org.rdk.HdmiCecSink.getActiveSourceStatus","params": {"status": true}}' http://127.0.0.1:55555/jsonrpc''' - - -get_otp_enabled = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.getOTPEnabled"}' http://127.0.0.1:55555/jsonrpc''' - -set_otp_enabled_false = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setOTPEnabled","params": {"enabled": false}}' http://127.0.0.1:55555/jsonrpc''' - -set_otp_enabled_true = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setOTPEnabled","params": {"enabled": true}}' http://127.0.0.1:55555/jsonrpc''' - -set_otp_enabled_true_with_undefined_datatype = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setOTPEnabled","params": {"enabled": 1234}}' http://127.0.0.1:55555/jsonrpc''' - -#Sends the CEC message when TV remote key is pressed and all the key events are defined here -send_keypress_VOLUME_UP = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 65}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_VOLUME_DOWN = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 66}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_MUTE = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 67}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_UP = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 1}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_DOWN = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 2}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_LEFT = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 3}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_RIGHT = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 4}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_SELECT = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 0}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_HOME = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 9}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_BACK = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 13}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_0 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 32}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_1 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 33}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_2 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 34}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_3 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 35}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_4 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 36}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_5 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 37}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_6 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 38}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_7 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 39}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_8 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 40}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_9 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 41}}' http://127.0.0.1:55555/jsonrpc''' - - -#Sends the CEC message when TV remote key is pressed -send_keypress_VOLUME_UP_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 65}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_VOLUME_DOWN_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 66}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_MUTE_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 67}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_UP_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 1}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_DOWN_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 2}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_LEFT_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 3}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_RIGHT_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 4}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_SELECT_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 0}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_HOME_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 9}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_BACK_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 13}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_0_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 32}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_1_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 33}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_2_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 34}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_3_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 35}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_4_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 36}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_5_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 37}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_6_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 38}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_7_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 39}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_8_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 40}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_9_USER_Press = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed", "params": {"logicalAddress": 0,"keyCode": 41}}' http://127.0.0.1:55555/jsonrpc''' - - -#Sends the CEC message when TV remote key is released -send_keypress_VOLUME_UP_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 65}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_VOLUME_DOWN_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 66}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_MUTE_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 67}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_UP_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 1}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_DOWN_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 2}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_LEFT_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 3}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_RIGHT_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 4}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_SELECT_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 0}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_HOME_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 9}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_BACK_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 13}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_0_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 32}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_1_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 33}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_2_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 34}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_3_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 35}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_4_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 36}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_5_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 37}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_6_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 38}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_7_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 39}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_8_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 40}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_9_USER_Release = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased", "params": {"logicalAddress": 0,"keyCode": 41}}' http://127.0.0.1:55555/jsonrpc''' - - -#waking up the device from standby -perform_otp_action = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.performOTPAction"}' http://127.0.0.1:55555/jsonrpc''' - -#Sends the CEC Request Short Audio Descriptor (SAD) message as an event -request_short_audio_descriptor = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.requestShortAudioDescriptor"}' http://127.0.0.1:55555/jsonrpc''' - -#This message is used to power on the connected audio device -send_audio_device_power_on_message = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.sendAudioDevicePowerOnMessage"}' http://127.0.0.1:55555/jsonrpc''' - -#Sends the CEC message to request the audio status -get_audio_status_message = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.getAudioStatusMessage"}' http://127.0.0.1:55555/jsonrpc''' - -#Requests the active source in the network -request_active_source = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.requestActiveSource"}' http://127.0.0.1:55555/jsonrpc''' - -#Get status of audio device connection -get_audio_device_connected_status = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.getAudioDeviceConnectedStatus"}' http://127.0.0.1:55555/jsonrpc''' - -#enabling otp with undefined data types -set_otp_enabled_with_undefined_datatype = '''curl --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0","id": 42,"method": "org.rdk.HdmiCecSink.setOTPEnabled","params": {"ennable": true}}' http://127.0.0.1:55555/jsonrpc''' - -set_osd_name_invalid = '''curl --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0","id": 42,"method": "org.rdk.HdmiCecSink.setOSDName","params": {"nnamme": "LG TV"}}' http://127.0.0.1:55555/jsonrpc''' - -set_vendor_id_invalid_1 = '''curl --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0","id": 42,"method": "org.rdk.HdmiCecSink.setVendorId","params": {"vendorid": "]]"}}' http://127.0.0.1:55555/jsonrpc''' - -set_vendor_id_invalid_2 = '''curl --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0","id": 42,"method": "org.rdk.HdmiCecSink.setVendorId","params": {"vllendorid": "]]"}}' http://127.0.0.1:55555/jsonrpc''' - -#Gets details for the current route from the source to sink devices -get_active_route = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.getActiveRoute"}' http://127.0.0.1:55555/jsonrpc''' - -#Sets the source device to active (setStreamPath) -set_active_path = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,"method":"org.rdk.HdmiCecSink.setActivePath", "params": {"activePath": "1.0.0.0"}}' http://127.0.0.1:55555/jsonrpc''' - -#Sets the current active source as TV (physical address 0 -set_active_source = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.setActiveSource"}' http://127.0.0.1:55555/jsonrpc''' - -#Updates the internal data structure with the new menu Language and also broadcasts the CEC message.Events -set_menu_language = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setMenuLanguage","params": {"language": "chi"}}' http://127.0.0.1:55555/jsonrpc''' - -#Updates the internal data structure with the new wrong menu Language and also broadcasts the CEC message.Events -set_menu_language_with_undefined_datatype = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setMenuLanguage","params": {"language": "abc"}}' http://127.0.0.1:55555/jsonrpc''' - -#Sets the Current Latency Values such as Video Latency, Latency Flags,Audio Output Compensated value and Audio Output Delay by sending message for Dynamic Auto LipSync Feature. -set_latency_info ='''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setLatencyInfo","params": {"videoLatency": "2","lowLatencyMode": "1","audioOutputCompensated": "1","audioOutputDelay": "20"}}' http://127.0.0.1:55555/jsonrpc''' - -#Sets the Current Latency Values such as invalid which includes Video Latency, Latency Flags,Audio Output Compensated value and Audio Output Delay by sending message for Dynamic Auto LipSync Feature. -set_latency_info_with_undefinedLatencyMode ='''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setLatencyInfo","params": {"videoLatency": "987666","lowLatencyMode": "888888","audioOutputCompensated": "abc","audioOutputDelay": "invalid"}}' http://127.0.0.1:55555/jsonrpc''' - -#Changes routing while switching between HDMI inputs and TV -set_routing_change = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setRoutingChange","params": {"oldPort": "HDMI0","newPort":"TV"}}' http://127.0.0.1:55555/jsonrpc''' - -#Changes routing while switching between HDMI inputs and TV with new ports -set_routing_change_nav = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setRoutingChange","params": {"oldPort": "HDMI0","newPort":"TV"}}' http://127.0.0.1:55555/jsonrpc''' - -#Changes routing while switching between unknown devices/port -set_routing_change_with_undefined_datatype = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setRoutingChange","params": {"oldPort": "ABCD","newPort":"zxcv"}}' http://127.0.0.1:55555/jsonrpc''' - -#Enable (or disable) HDMI-CEC Audio Return Channel (ARC) routing -set_arc_routing_params_enabled = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setupARCRouting","params":{"enabled":true}' http://127.0.0.1:55555/jsonrpc''' - -set_arc_routing_params_disabled = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setupARCRouting","params":{"enabled":false}' http://127.0.0.1:55555/jsonrpc''' - -#It prints the list of connected devices and properties of connected devices like deviceType, VendorID, CEC version, PowerStatus, OSDName, PhysicalAddress etc. -print_device_list = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.printDeviceList"}' http://127.0.0.1:55555/jsonrpc''' - -#Get status of audio device connection -request_audio_device_power_status = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.requestAudioDevicePowerStatus"}' http://127.0.0.1:55555/jsonrpc''' - -#Gets the current active source -get_Active_Source = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.getActiveSource"}' http://127.0.0.1:55555/jsonrpc''' - -#Sends the CEC message to request the audio status. -sendGetAudioStatusMessage = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendGetAudioStatusMessage"}' http://127.0.0.1:55555/jsonrpc''' - -#Set an invalid/undefined vendor ID in the format of INT instead of hexa -set_vendor_id_invalid_2 = '''curl --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0","id": 42,"method": "org.rdk.HdmiCecSource.setVendorId","params": {"vllendorid": "]]"}}' http://127.0.0.1:55555/jsonrpc''' - -#Routing change api from Hdmi to an undefined device for failing the scenario -set_routing_change_negative = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSink.setRoutingChange","params": {"oldPort": "HDMI0","newPort":"NEW"}}' http://127.0.0.1:55555/jsonrpc''' - -#All set curl command Json RPC request without params for negtaive scenarios -sendKeyPress_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendKeyPressEvent"}' http://127.0.0.1:55555/jsonrpc''' -senduserContolledPress_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlPressed"}' http://127.0.0.1:55555/jsonrpc''' -sendusercontrolledReleased_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.sendUserControlReleased"}' http://127.0.0.1:55555/jsonrpc''' -setActivepath_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.setActivePath"}' http://127.0.0.1:55555/jsonrpc''' -setEnabled_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.setEnabled"}' http://127.0.0.1:55555/jsonrpc''' -setMenuLanguage_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.setMenuLanguage"}' http://127.0.0.1:55555/jsonrpc''' -setOSDName_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.setOSDName"}' http://127.0.0.1:55555/jsonrpc''' -setRoutingChange_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.setRoutingChange"}' http://127.0.0.1:55555/jsonrpc''' -setupARCRouting_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.setupARCRouting"}' http://127.0.0.1:55555/jsonrpc''' -setvendorID_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.setVentorId"}' http://127.0.0.1:55555/jsonrpc''' -setLatencyInfo_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSink.setLatencyInfo"}' http://127.0.0.1:55555/jsonrpc''' diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_001_HDMICECSINK_getEnabled.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_001_HDMICECSINK_getEnabled.py deleted file mode 100644 index 333be0be5..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_001_HDMICECSINK_getEnabled.py +++ /dev/null @@ -1,66 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID001_getEnabled_001 -# Testcase Description : Returns HDMI-CEC driver enabled status - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -print("TC Description - Returns whether HDMI-CEC is enabled on platform or not.") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"enabled":true,"success":true}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_enabled) -if curl_response: - Utils.info_log("curl command to get enabled is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The default driver status ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID001_HdmiCecSink_getEnabled' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_002_HDMICECSINK_setEnabled.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_002_HDMICECSINK_setEnabled.py deleted file mode 100644 index 221a7dc3f..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_002_HDMICECSINK_setEnabled.py +++ /dev/null @@ -1,77 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID002 -# Testcase Description : Set the cec enable status to false and verify that cec enable -# status is false in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -print(" TC Description - Set the cec enable status to false and verify that cec enable status is false in output response") -# send the curl command to set the cec enable status to false -Utils.initialize_flask() -print("---------------------------------------------------------------------------------------------------------------------------") -set_response = Utils.send_curl_command(HdmiCecSinkApis.set_enabled_false) -if set_response: - Utils.warning_log("send the curl command to set the cec enable status to false is success") -else: - Utils.error_log("send the curl command to set the cec enable status to false failed") -print("") -# store the expected output response of testcase -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"enabled":false,"success":true}}' - -# send the curl command to get enable status of cec and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_enabled) -if curl_response: - Utils.info_log("send the curl command to get enable status of cec and fetch the output json response is success") -else: - Utils.error_log("send the curl command to get enable status of cec and fetch the output json response is failed") -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The cec enabled status is obtained ' \ - 'as false in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# set the cec enable status to true as a post condition -Utils.send_curl_command(HdmiCecSinkApis.set_enabled_true) -Utils.info_log("Reset the set enabled to TRUE") - -# generate logs in terminal -tc_id = 'TCID002_HdmiCecSink_setEnabled_CEC_False' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_003_HDMICECSINK_getOSDName.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_003_HDMICECSINK_getOSDName.py deleted file mode 100644 index ed98e2758..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_003_HDMICECSINK_getOSDName.py +++ /dev/null @@ -1,65 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID003 -# Testcase Description : Verify that default OSD Name is obtained in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"name":"TV Box","success":true}}' -Utils.initialize_flask() -print("TC Description - Verify that default OSD Name is obtained in output response") -# send the curl command and fetch the output json response -print("---------------------------------------------------------------------------------------------------------------------------") -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_osd_name) -if curl_response: - Utils.info_log("curl command send for get_osd_name") -else: - Utils.error_log("curl command send for get_osd_name failed") -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The default OSD Name is obtained ' \ - 'in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID004_HdmiCecSink_getOSDName_default' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) -Utils.initialize_flask() diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_004_HDMICECSINK_setOSDName.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_004_HDMICECSINK_setOSDName.py deleted file mode 100644 index 1a374af4a..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_004_HDMICECSINK_setOSDName.py +++ /dev/null @@ -1,88 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID004 -# Testcase Description : Set the OSD Name to new one using curl command and verify that new -# OSD Name set by the test user is obtained in output response -import requests -import Config -import json -import time - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -print("TC Description - Set the OSD Name to new one using curl command and verify that new OSD Name set by the test user is obtained in output response") -Utils.initialize_flask() -print("---------------------------------------------------------------------------------------------------------------------------") -# send the curl command to set the new OSD Name -set_response = Utils.send_curl_command(HdmiCecSinkApis.set_osd_name) -if set_response: - Utils.info_log(" sent the curl command to set the new OSD Name") -else: - Utils.error_log("curl command sent to get the new OSD name failed") -print("") -# store the expected output response of testcase -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"name":"CUSTOM8 TV","success":true}}' - -# send the curl command to get OSD Name and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_osd_name) -if curl_response: - Utils.warning_log("send the curl command to get_osd_name") -else: - Utils.warning_log("curl command send failed to get_osd_name") - -#send messages required for osd string -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_osd_string))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the set_osd_string") -else: - Utils.error_log("sendMessage emulation failed for requesting the set_osd_string") -time.sleep(3) -print("") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The new OSD Name given by user ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' -Utils.initialize_flask() -# generate logs in terminal -tc_id = 'TCID005_HdmiCecSink_setOSDName' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_005_HDMICECSINK_getVendorID.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_005_HDMICECSINK_getVendorID.py deleted file mode 100644 index f34091537..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_005_HDMICECSINK_getVendorID.py +++ /dev/null @@ -1,66 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID005 -# Testcase Description : Verify that default vendor id is obtained in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -print("TC Description - Verify that default vendor id is obtained in output response") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"vendorid":"019fb","success":true}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_vendor_id) -if curl_response: - Utils.info_log("curl command to get vendorID is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The default vendor id ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID005_HdmiCecSink_getVendorId' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_006_HDMICECSINK_setVendorID.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_006_HDMICECSINK_setVendorID.py deleted file mode 100644 index dc9049c7e..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_006_HDMICECSINK_setVendorID.py +++ /dev/null @@ -1,87 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID006 -# Testcase Description : Set the cec enable status to false and verify that cec enable -# status is false in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -import json - -print(" TC Description - Sets a vendor ID used by host device.") -# send the curl command to set the cec enable status to false -Utils.initialize_flask() -print("---------------------------------------------------------------------------------------------------------------------------") -pre_expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"vendorid":"019fb","success":true}}' -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"vendorid":"04455","success":true}}' - -pre_get_response = Utils.send_curl_command(HdmiCecSinkApis.get_vendor_id) -if pre_get_response: - Utils.warning_log("send curl command to get the vendor id is success") -else: - Utils.error_log("send curl command to get the vendor id is false failed") -print("") - -set_response = Utils.send_curl_command(HdmiCecSinkApis.set_vendor_id) -print("---------------------------------------------------------------------------------------------------------------------------") -if set_response: - Utils.warning_log("send the curl command to set the vendor id is success") -else: - Utils.error_log("send the curl command to set the vendor id to false failed") -print("") - -get_response = Utils.send_curl_command(HdmiCecSinkApis.get_vendor_id) -if get_response: - Utils.warning_log("send curl command to get the vendor id is success") -else: - Utils.error_log("send curl command to get the vendor id is false failed") -print("") - -# compare both expected and received output responses -if str(pre_get_response) == str(pre_expected_output_response) or str(get_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The cec enabled status is obtained ' \ - 'as false in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# set the cec enable status to true as a post condition -Utils.send_curl_command(HdmiCecSinkApis.set_enabled_true) -Utils.info_log("Reset the set enabled to TRUE") - -# generate logs in terminal -tc_id = 'TCID006_setVendorid' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + set_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, set_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_007_HDMICECSINK_getActiveRoute.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_007_HDMICECSINK_getActiveRoute.py deleted file mode 100644 index 5818be3f3..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_007_HDMICECSINK_getActiveRoute.py +++ /dev/null @@ -1,101 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID007 -# Testcase Description : Gets details for the current route from the source to sink devices, and bverify the output response -import requests -import Config -import json -import time - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Gets details for the current route from the source to sink devices") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' -expected_output_response_ = '{"jsonrpc":"2.0","id":42,"result":{"available":true,"ActiveRoute":"TV","success":true}}' - - -#send messages required for image and text view in active device making sink device active -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.imageViewON))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the imageViewON") -else: - Utils.error_log("sendMessage emulation failed for requesting the imageViewON") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.textViewON))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the textViewON") -else: - Utils.error_log("sendMessage emulation failed for requesting the textViewON") -time.sleep(3) -print("") - -curl_response1 = Utils.send_curl_command(HdmiCecSinkApis.set_routing_change) -if curl_response1: - Utils.info_log("curl command to set routing change is success") -else: - Utils.error_log("curl command to set routing change is failed") - -# send the curl command and fetch the output json response -curl_response2 = Utils.send_curl_command(HdmiCecSinkApis.get_active_route) -if curl_response2: - Utils.info_log("curl command to get ActiveRoute is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - - - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response1) == str(expected_output_response) and str(curl_response2) == str(expected_output_response_): - status = 'Pass' - message = 'Output response is matching with expected one. The default vendor id ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID007_HdmiCecSink_getActiveRoute' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response2) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response2, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_008_HDMICECSINK_getActiveSource.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_008_HDMICECSINK_getActiveSource.py deleted file mode 100644 index c40891018..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_008_HDMICECSINK_getActiveSource.py +++ /dev/null @@ -1,78 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID008 -# Testcase Description : Hit the curl command for getActiveSourceStatus method and -# verify that status is obtained as false in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"error":{"code":-32601,"message":"Unknown method."}}' - -print("TC Description - Hit the curl command for getActiveSourceStatus method and verify that status is obtained as false in output response") - -print("---------------------------------------------------------------------------------------------------------------------------") -# send the curl command and fetch the output json response -Utils.initialize_flask() -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_routing_change) -if curl_response: - Utils.info_log("curl command send for set routing change") - status = 'Pass' - message = 'Output response is matching with expected one. The set latency info ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_latency_info)) - status = 'False' - message = 'Output response is not matching with expected one' - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_active_source_status) -if curl_response: - Utils.info_log("curl command send for get_active_source") -else: - Utils.error_log("curl command send failed for get_active_source") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID008_getActiveSourceStatus_false' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_009_HDMICECSINK_getAudioDeviceConnectedStatus.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_009_HDMICECSINK_getAudioDeviceConnectedStatus.py deleted file mode 100644 index 8b70f08bf..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_009_HDMICECSINK_getAudioDeviceConnectedStatus.py +++ /dev/null @@ -1,68 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID009 -# Testcase Description : Verify that default vendor id is obtained in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -print("TC Description - Get status of audio device connection.") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"connected":true,"success":true}}' - -#ToDo - Send Message emulation to connect an audio device and send its status message with sink device or give it from device config by specifying the exact logical address required. - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_audio_device_connected_status) -if curl_response: - Utils.info_log("curl command to get audio device connected status is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The default vendor id ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID009_HdmiCecSink_getAudioDeviceConnectedStatus' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_010_HDMICECSINK_getDeviceList.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_010_HDMICECSINK_getDeviceList.py deleted file mode 100644 index 75788072a..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_010_HDMICECSINK_getDeviceList.py +++ /dev/null @@ -1,68 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID010 -# Testcase Description : Gets the number of connected source devices and system information for each device. The information includes device type, physical address, CEC version, vendor ID, power status and OSD name., and verify the output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -import time - -print("TC Description - Gets the number of connected source devices and system information for each device. The information includes device type, physical address, CEC version, vendor ID, power status and OSD name.") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -time.sleep(6) -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"numberofdevices":3,"deviceList":[{"logicalAddress":3,"physicalAddress":"15.15.15.15","deviceType":"Reserved","cecVersion":"Version 1.3a","osdName":"@GStreaming Tw","vendorID":"000","powerStatus":"On","portNumber":-1},{"logicalAddress":5,"physicalAddress":"15.15.15.15","deviceType":"TV","cecVersion":"Unknown","osdName":"","vendorID":"000","powerStatus":"On","portNumber":-1},{"logicalAddress":9,"physicalAddress":"15.15.15.15","deviceType":"TV","cecVersion":"Unknown","osdName":"","vendorID":"000","powerStatus":"On","portNumber":-1}],"success":true}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_device_list) -if curl_response: - Utils.info_log("curl command to get devicelist is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The default vendor id ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID005_HdmiCecSink_getDevicelist' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_011_HDMICECSINK_requestActiveSource.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_011_HDMICECSINK_requestActiveSource.py deleted file mode 100644 index 3f1db7c6e..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_011_HDMICECSINK_requestActiveSource.py +++ /dev/null @@ -1,178 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID011 -# Testcase Description : Requests the active source in the network., verify the output response -import subprocess -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -print("TC Description - Hit the curl command for getActiveSourceStatus method and verify that status is obtained as true in output response") - -print("---------------------------------------------------------------------------------------------------------------------------") -# send the curl command and fetch the output json response -Utils.initialize_flask() -time.sleep(3) -#send messages required for getting inactive source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") - -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.send_standby_message) -if curl_response: - Utils.warning_log("send_standby_message curl command sent from the test runner") -else: - Utils.error_log("send_standby_message curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.perform_otp_action) -if curl_response: - Utils.warning_log("perform_otp_action curl command sent from the test runner") -else: - Utils.error_log("perform_otp_action curl command failed") - -#send messages required for getting inactive source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") - -#send messages required for set stream path -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_stream_path_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for set stream path to hisense") -else: - Utils.error_log("sendMessage emulation failed for set stream path to hisense") -time.sleep(3) -print("") - -#send messages required for routing change -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_change))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for routing change to hisense") -else: - Utils.error_log("sendMessage emulation failed for routing change to hisense") -time.sleep(3) -print("") - -#send messages required for routing information -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_information_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying routing information from hisense") -else: - Utils.error_log("sendMessage emulation failed for querying routing information from hisense") -time.sleep(3) -print("") - -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - -#ToDo - send message emulation for onActiveSourceChange Triggered with the active source device changes. - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.request_active_source) -if curl_response: - Utils.info_log("curl command send for get_active_source") -else: - Utils.error_log("curl command send failed for get_active_source") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID011_requestActiveSource' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_012_HDMICECSINK_requestShortAudioDescriptor.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_012_HDMICECSINK_requestShortAudioDescriptor.py deleted file mode 100644 index 83bfd7645..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_012_HDMICECSINK_requestShortAudioDescriptor.py +++ /dev/null @@ -1,82 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID012_requestShortAudioDescriptor -# Testcase Description : Sends the CEC Request Short Audio Descriptor (SAD) message as an event and verify the output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -import Config -import requests -import json -import time - -print("TC Description - Sends the CEC Request Short Audio Descriptor (SAD) message,and verify the output response") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.request_short_audio_descriptor) -if curl_response: - Utils.info_log("curl command to request short audio descriptor is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -time.sleep(3) -#ToDo - sendMessage emulation for shortAudio descriptor event [Triggered when SAD is received from the connected audio device.] -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportShortAudioDes))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportShortAudioDes") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportShortAudioDes") -time.sleep(3) -print("") - - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The default vendor id ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID012_HDMICECSINK_requestShortAudioDescriptor' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_013_HDMICECSINK_sendAudioDevicePowerOnMessage.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_013_HDMICECSINK_sendAudioDevicePowerOnMessage.py deleted file mode 100644 index 5f9308c30..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_013_HDMICECSINK_sendAudioDevicePowerOnMessage.py +++ /dev/null @@ -1,100 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID013_sendAudioDevicePowerOnMessage -# Testcase Description : This message is used to power on the connected audio device. Usually sent by the TV when it comes out of standby and detects audio device connected in the network. -import requests -import Config -import json -import time - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - This message is used to power on the connected audio device. Usually sent by the TV when it comes out of standby and detects audio device connected in the network.") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.send_standby_message) -if curl_response: - Utils.warning_log("send_standby_message curl command sent from the test runner") -else: - Utils.error_log("send_standby_message curl command failed") - -time.sleep(3) #3 second wait to turn on sink device - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.perform_otp_action) -if curl_response: - Utils.warning_log("perform_otp_action curl command sent from the test runner") -else: - Utils.error_log("perform_otp_action curl command failed") - -time.sleep(3) - -#send messages required for reporting audio power mode -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportAudioMode))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportAudioMode") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportAudioMode") -time.sleep(3) -print("") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.send_audio_device_power_on_message) -if curl_response: - Utils.info_log("curl command to send audio device power on message is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The send audio device power on message' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID013_HdmiCecSink_sendAudioDevicePowerOnMessage' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_014_HDMICECSINK_getAudioStatusMessage.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_014_HDMICECSINK_getAudioStatusMessage.py deleted file mode 100644 index 2a9070de1..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_014_HDMICECSINK_getAudioStatusMessage.py +++ /dev/null @@ -1,96 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID014_getAudioStatusMessage -# Testcase Description : Sends the CEC message to request the audio status., and verify the output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis -import Config -import requests -import json -import time - -print("TC Description - Sends the CEC message to request the audio status.") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - - - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.sendGetAudioStatusMessage) -if curl_response: - Utils.info_log("curl command to send audio status message is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -time.sleep(3) - -#ToDo - send message emulation for report audio status message event[reportAudioStatusEvent Triggered when CEC message of device is received.] -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportShortAudioDes))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportShortAudioDes") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportShortAudioDes") -time.sleep(3) -print("") - -time.sleep(3) - -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportAudioMode))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportAudioMode") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportAudioMode") -time.sleep(3) -print("") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The send audio status message and report audio sytatus event ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID014_HdmiCecSink_getAudioStatusMessage' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_015_HDMICECSINK_sendKeyPressEvent.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_015_HDMICECSINK_sendKeyPressEvent.py deleted file mode 100644 index 8d42655ec..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_015_HDMICECSINK_sendKeyPressEvent.py +++ /dev/null @@ -1,83 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID015 -# Testcase Description : Hit the curl command for sendKeyPressEvent and -# verify that output response is correct - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' -Utils.initialize_flask() - -keypress = [HdmiCecSinkApis.send_keypress_VOLUME_UP, HdmiCecSinkApis.send_keypress_VOLUME_DOWN, - HdmiCecSinkApis.send_keypress_MUTE, - HdmiCecSinkApis.send_keypress_UP, HdmiCecSinkApis.send_keypress_DOWN, - HdmiCecSinkApis.send_keypress_LEFT, - HdmiCecSinkApis.send_keypress_RIGHT, HdmiCecSinkApis.send_keypress_SELECT, - HdmiCecSinkApis.send_keypress_HOME, - HdmiCecSinkApis.send_keypress_BACK, HdmiCecSinkApis.send_keypress_NUMBER_0, - HdmiCecSinkApis.send_keypress_NUMBER_1, - HdmiCecSinkApis.send_keypress_NUMBER_2, HdmiCecSinkApis.send_keypress_NUMBER_3, - HdmiCecSinkApis.send_keypress_NUMBER_4, - HdmiCecSinkApis.send_keypress_NUMBER_5, HdmiCecSinkApis.send_keypress_NUMBER_6, - HdmiCecSinkApis.send_keypress_NUMBER_7, - HdmiCecSinkApis.send_keypress_NUMBER_8, HdmiCecSinkApis.send_keypress_NUMBER_9] -print("TC Description - Hit the curl command for sendKeyPressEvent and verify that output response is correct") -print( - "---------------------------------------------------------------------------------------------------------------------------") -# send the curl command and fetch the output json response -for command in keypress: - curl_response = Utils.send_curl_command(command) - -if curl_response: - Utils.info_log("curl command send for send_keypress_event") -else: - Utils.error_log("curl command send failed") -print("") -# compare both expected and received output responses -print( - "---------------------------------------------------------------------------------------------------------------------------") -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID015_sendKeyPressEvent' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_016_HDMICECSINK_sendUserControlPressed.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_016_HDMICECSINK_sendUserControlPressed.py deleted file mode 100644 index 3497a9d89..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_016_HDMICECSINK_sendUserControlPressed.py +++ /dev/null @@ -1,83 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID016 -# Testcase Description : Hit the curl command for sendUserControlledPressEvent and -# verify that output response is correct - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' -Utils.initialize_flask() - -keypress = [HdmiCecSinkApis.send_keypress_VOLUME_UP_USER_Press, HdmiCecSinkApis.send_keypress_VOLUME_DOWN_USER_Press, - HdmiCecSinkApis.send_keypress_MUTE_USER_Press, - HdmiCecSinkApis.send_keypress_UP_USER_Press, HdmiCecSinkApis.send_keypress_DOWN_USER_Press, - HdmiCecSinkApis.send_keypress_LEFT_USER_Press, - HdmiCecSinkApis.send_keypress_RIGHT_USER_Press, HdmiCecSinkApis.send_keypress_SELECT_USER_Press, - HdmiCecSinkApis.send_keypress_HOME_USER_Press, - HdmiCecSinkApis.send_keypress_BACK_USER_Press, HdmiCecSinkApis.send_keypress_NUMBER_0_USER_Press, - HdmiCecSinkApis.send_keypress_NUMBER_1_USER_Press, - HdmiCecSinkApis.send_keypress_NUMBER_2_USER_Press, HdmiCecSinkApis.send_keypress_NUMBER_3_USER_Press, - HdmiCecSinkApis.send_keypress_NUMBER_4_USER_Press, - HdmiCecSinkApis.send_keypress_NUMBER_5_USER_Press, HdmiCecSinkApis.send_keypress_NUMBER_6_USER_Press, - HdmiCecSinkApis.send_keypress_NUMBER_7_USER_Press, - HdmiCecSinkApis.send_keypress_NUMBER_8_USER_Press, HdmiCecSinkApis.send_keypress_NUMBER_9_USER_Press] -print("TC Description - Hit the curl command for sendUserControlPressed and verify that output response is correct") -print( - "---------------------------------------------------------------------------------------------------------------------------") -# send the curl command and fetch the output json response -for command in keypress: - curl_response = Utils.send_curl_command(command) - -if curl_response: - Utils.info_log("curl command send for send_user_control_pressed") -else: - Utils.error_log("curl command send failed") -print("") -# compare both expected and received output responses -print( - "---------------------------------------------------------------------------------------------------------------------------") -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID016_sendUserControlPressed' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_017_HDMICECSINK_sendUserControlReleased.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_017_HDMICECSINK_sendUserControlReleased.py deleted file mode 100644 index 8688f3c0e..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_017_HDMICECSINK_sendUserControlReleased.py +++ /dev/null @@ -1,83 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID017 -# Testcase Description : Hit the curl command for sendUserControlledReleaseEvent and -# verify that output response is correct - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' -Utils.initialize_flask() - -keypress = [HdmiCecSinkApis.send_keypress_VOLUME_UP_USER_Release, HdmiCecSinkApis.send_keypress_VOLUME_DOWN_USER_Release, - HdmiCecSinkApis.send_keypress_MUTE_USER_Release, - HdmiCecSinkApis.send_keypress_UP_USER_Release, HdmiCecSinkApis.send_keypress_DOWN_USER_Release, - HdmiCecSinkApis.send_keypress_LEFT_USER_Release, - HdmiCecSinkApis.send_keypress_RIGHT_USER_Release, HdmiCecSinkApis.send_keypress_SELECT_USER_Release, - HdmiCecSinkApis.send_keypress_HOME_USER_Release, - HdmiCecSinkApis.send_keypress_BACK_USER_Release, HdmiCecSinkApis.send_keypress_NUMBER_0_USER_Release, - HdmiCecSinkApis.send_keypress_NUMBER_1_USER_Release, - HdmiCecSinkApis.send_keypress_NUMBER_2_USER_Release, HdmiCecSinkApis.send_keypress_NUMBER_3_USER_Release, - HdmiCecSinkApis.send_keypress_NUMBER_4_USER_Release, - HdmiCecSinkApis.send_keypress_NUMBER_5_USER_Release, HdmiCecSinkApis.send_keypress_NUMBER_6_USER_Release, - HdmiCecSinkApis.send_keypress_NUMBER_7_USER_Release, - HdmiCecSinkApis.send_keypress_NUMBER_8_USER_Release, HdmiCecSinkApis.send_keypress_NUMBER_9_USER_Release] -print("TC Description - Hit the curl command for sendUserControlReleased and verify that output response is correct") -print( - "---------------------------------------------------------------------------------------------------------------------------") -# send the curl command and fetch the output json response -for command in keypress: - curl_response = Utils.send_curl_command(command) - -if curl_response: - Utils.info_log("curl command send for send_user_control_released") -else: - Utils.error_log("curl command send failed") -print("") -# compare both expected and received output responses -print( - "---------------------------------------------------------------------------------------------------------------------------") -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID017_sendUserControlReleased' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_018_HDMICECSINK_sendStandbyMessage.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_018_HDMICECSINK_sendStandbyMessage.py deleted file mode 100644 index 183b314b7..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_018_HDMICECSINK_sendStandbyMessage.py +++ /dev/null @@ -1,65 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID018_sendStandbyMessage -# Testcase Description : Sends a CEC message to the logical address of the device. and verify the outpu response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -print("TC Description - Sends a CEC message to the logical address of the device. and verify the outpu response.") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.send_standby_message) -if curl_response: - Utils.info_log("curl command to send standby message is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The default vendor id ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID018_HdmiCecSink_sendStandbyMessage' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_019_HDMICECSINK_setActivePath.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_019_HDMICECSINK_setActivePath.py deleted file mode 100644 index c96c4b6e5..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_019_HDMICECSINK_setActivePath.py +++ /dev/null @@ -1,77 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID019_HDMICECSINK_setActivePath -# Testcase Description : Sets the source device to active (setStreamPath), and verify the outpu response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -print("TC Description - Sets the source device to active (setStreamPath)") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.send_standby_message) -if curl_response: - Utils.info_log("curl command to send standby message is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_routing_change) -if curl_response: - Utils.info_log("Routing change set to active path") -else: - Utils.info_log("Routing change set to active path failed") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_active_path) -if curl_response: - Utils.info_log("curl command sent for set active path") -else: - Utils.error_log("Curl command not send {}" .format(HdmiCecSinkApis.set_active_path)) - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The active path ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID019_HdmiCecSink_setActivePath' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_020_HDMICECSINK_setActiveSource.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_020_HDMICECSINK_setActiveSource.py deleted file mode 100644 index f6b3cd1dc..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_020_HDMICECSINK_setActiveSource.py +++ /dev/null @@ -1,65 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID020_setActiveSource -# Testcase Description : Sets the current active source as TV (physical address 0.0.0.0). This call needs to be made when the TV switches to internal tuner or any apps. and verify the outpu response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -print("TC Description - Sets the current active source as TV (physical address 0.0.0.0). This call needs to be made when the TV switches to internal tuner or any apps. and verify the outpu response") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_active_source) -if curl_response: - Utils.info_log("curl command sent for set active source") -else: - Utils.error_log("Curl command not send {}" .format(HdmiCecSinkApis.set_active_path)) - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The set active source ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID020_HdmiCecSink_setActiveSource' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_021_HDMICECSINK_setmenuLanguage.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_021_HDMICECSINK_setmenuLanguage.py deleted file mode 100644 index 983bc26df..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_021_HDMICECSINK_setmenuLanguage.py +++ /dev/null @@ -1,88 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID021_setMenuLanguage -# Testcase Description : Updates the internal data structure with the new menu Language and also broadcasts the CEC message.and verify the outpu response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -import json -import requests -import time -import Config - -Utils.initialize_flask() -#send messages required for getting physical address -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.give_physical_address_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the physical address") -else: - Utils.error_log("sendMessage emulation failed for querying the physical address") -time.sleep(3) -print("") - -#send messages required for getting menu language -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.get_menu_language_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the menu language") -else: - Utils.error_log("sendMessage emulation failed for querying the menu language") -time.sleep(3) -print("") - -#send messages required for setting menu language -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_menu_language))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for setting the menu language") -else: - Utils.error_log("sendMessage emulation failed for setting the menu language") -time.sleep(3) -print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_menu_language) -if curl_response: - Utils.info_log("curl command send for set menu language") - status = 'Pass' - message = 'Output response is matching with expected one. The set menu language ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_menu_language)) - status = 'False' - message = 'Output response is not matching with expected one' - -# generate logs in terminal -tc_id = 'TCID021_HdmiCecSink_setMenuLanguage' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_022_HDMICECSINK_setLatencyInfo.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_022_HDMICECSINK_setLatencyInfo.py deleted file mode 100644 index e6c6d8219..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_022_HDMICECSINK_setLatencyInfo.py +++ /dev/null @@ -1,90 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID022_setLatencyInfo -# Testcase Description : Sets the Current Latency Values such as Video Latency, Latency Flags,Audio Output Compensated value and Audio Output Delay by sending message for Dynamic Auto LipSync Feature. Verify the output response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -import json -import requests -import time -import Config - -Utils.initialize_flask() -#ToDo - send messages required for reporting current latency info -#send messages required for reporting current latency -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.requestcurrentlatency))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the requestcurrentlatency") -else: - Utils.error_log("sendMessage emulation failed for requesting the requestcurrentlatency") -time.sleep(3) -print("") - - -#send messages required for getting menu language -#message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( -# Config.flask_server_ip, json.dumps(Config.get_menu_language_hisense))) -#if "200" in str(message1_response): -# Utils.info_log("sendMessage emulation success for querying the menu language") -#else: -# Utils.error_log("sendMessage emulation failed for querying the menu language") -#time.sleep(3) -#print("") - -#send messages required for setting menu language -#message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( -# Config.flask_server_ip, json.dumps(Config.set_menu_language))) -#if "200" in str(message1_response): -# Utils.info_log("sendMessage emulation success for setting the menu language") -#else: -# Utils.error_log("sendMessage emulation failed for setting the menu language") -#time.sleep(3) -#print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_latency_info) -if curl_response: - Utils.info_log("curl command send for set latency info") - status = 'Pass' - message = 'Output response is matching with expected one. The set latency info ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_latency_info)) - status = 'False' - message = 'Output response is not matching with expected one' - -# generate logs in terminal -tc_id = 'TCID022_HdmiCecSink_setLatencyInfo' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_023_HDMICECSINK_setRoutingChange.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_023_HDMICECSINK_setRoutingChange.py deleted file mode 100644 index bebdc9a43..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_023_HDMICECSINK_setRoutingChange.py +++ /dev/null @@ -1,186 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID023_setRoutingChange -# Testcase Description : Changes routing while switching between HDMI inputs and TV. Verify the output response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis -import json -import requests -import time -import Config - -Utils.initialize_flask() - -print("TC Description - Changes routing while switching between HDMI inputs and TV. Verify the output response") -#ToDo - send messages required for switching inputs between hdmi and TV, by sending active source message emulation. -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") - -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.send_standby_message) -if curl_response: - Utils.warning_log("send_standby_message curl command sent from the test runner") -else: - Utils.error_log("send_standby_message curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.perform_otp_action) -if curl_response: - Utils.warning_log("perform_otp_action curl command sent from the test runner") -else: - Utils.error_log("perform_otp_action curl command failed") - -#send messages required for getting inactive source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") - -#send messages required for set stream path -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_stream_path_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for set stream path to hisense") -else: - Utils.error_log("sendMessage emulation failed for set stream path to hisense") -time.sleep(3) -print("") - -#send messages required for routing change -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_change))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for routing change to hisense") -else: - Utils.error_log("sendMessage emulation failed for routing change to hisense") -time.sleep(3) -print("") - -#send messages required for routing information -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_information_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying routing information from hisense") -else: - Utils.error_log("sendMessage emulation failed for querying routing information from hisense") -time.sleep(3) -print("") - -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - - -#send messages required for getting menu language -#message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( -# Config.flask_server_ip, json.dumps(Config.get_menu_language_hisense))) -#if "200" in str(message1_response): -# Utils.info_log("sendMessage emulation success for querying the menu language") -#else: -# Utils.error_log("sendMessage emulation failed for querying the menu language") -#time.sleep(3) -#print("") - -#send messages required for setting menu language -#message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( -# Config.flask_server_ip, json.dumps(Config.set_menu_language))) -#if "200" in str(message1_response): -# Utils.info_log("sendMessage emulation success for setting the menu language") -#else: -# Utils.error_log("sendMessage emulation failed for setting the menu language") -#time.sleep(3) -#print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_routing_change) -if curl_response: - Utils.info_log("curl command send for set routing change") - status = 'Pass' - message = 'Output response is matching with expected one. The set latency info ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_latency_info)) - status = 'False' - message = 'Output response is not matching with expected one' - -# generate logs in terminal -tc_id = 'TCID023_HdmiCecSink_setRoutingChange' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_024_HDMICECSINK_setupArcRouting.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_024_HDMICECSINK_setupArcRouting.py deleted file mode 100644 index 753df8762..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_024_HDMICECSINK_setupArcRouting.py +++ /dev/null @@ -1,95 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID024_setupArcRoutingChange -# Testcase Description :Enable (or disable) HDMI-CEC Audio Return Channel (ARC) routing. Upon enabling, triggers arcInitiationEvent and upon disabling, triggers arcTerminationEvent. Verify the output response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -import json -import requests -import time -import Config - -Utils.initialize_flask() -print("TC - Description : Enable (or disable) HDMI-CEC Audio Return Channel (ARC) routing. Upon enabling, triggers arcInitiationEvent and upon disabling, triggers arcTerminationEvent. Verify the output response") -#ToDo - send messages required for arpc routing with different params - - -#ToDo - SendMessage emulation for arcInitiationEvent[[enabled, the CEC and messages are sent]] Triggered when routing though the HDMI ARC port is successfully established. -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.initiateArc))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for initiating arc event") -else: - Utils.error_log("sendMessage emulation failed for initiating arc event") -time.sleep(3) -print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_arc_routing_params_disabled) -if curl_response: - Utils.info_log("curl command send for arc routing") - status = 'Pass' - message = 'Output response is matching with expected one. The arc routing ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_arc_routing_params_disabled)) - status = 'False' - message = 'Output response is not matching with expected one' - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_arc_routing_params_enabled) -if curl_response: - Utils.info_log("curl command send for arc routing") - status = 'Pass' - message = 'Output response is matching with expected one. The arc routing ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_arc_routing_params_enabled)) - status = 'False' - message = 'Output response is not matching with expected one' - - -#ToDo - SendMessage emulation for arcTerminationEvent[[If disabled, the CEC and messages are sent.]].Triggered when routing though the HDMI ARC port terminates. -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.terminateArc))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for terminating Arc Event") -else: - Utils.error_log("sendMessage emulation failed for terminating Arc Event") -time.sleep(3) -print("") - - -# generate logs in terminal -tc_id = 'TCID024_HdmiCecSink_setArcRouting' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_025_HDMICECSINK_printDeviceList.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_025_HDMICECSINK_printDeviceList.py deleted file mode 100644 index e2b4edd83..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_025_HDMICECSINK_printDeviceList.py +++ /dev/null @@ -1,66 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID025 -# Testcase Description : This is a helper debug command for developers. It prints the list of connected devices and properties of connected devices like deviceType, VendorID, CEC version, PowerStatus, OSDName, PhysicalAddress etc and ,verify the output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -print("TC Description - This is a helper debug command for developers. It prints the list of connected devices and properties of connected devices like deviceType, VendorID, CEC version, PowerStatus, OSDName, PhysicalAddress etc.") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"printed":true,"success":true}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.print_device_list) -if curl_response: - Utils.info_log("curl command to print devicelist is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The print device list details ' \ - 'are obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID025_HdmiCecSink_printDevicelist' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_026_HDMICECSINK_requestAudioDevicePowerStatus.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_026_HDMICECSINK_requestAudioDevicePowerStatus.py deleted file mode 100644 index 5cf7bcb80..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_026_HDMICECSINK_requestAudioDevicePowerStatus.py +++ /dev/null @@ -1,119 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID026 -# Testcase Description : requesting the audio device power status -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -import time -import Config -import json -import requests - -print("TC Description - Requesting the audio device power status") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.request_audio_device_power_status) -if curl_response: - Utils.info_log("curl command to request audio device power status is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportShortAudioDes))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportShortAudioDes") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportShortAudioDes") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.setSystemAudioMode))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the setSystemAudioMode") -else: - Utils.error_log("sendMessage emulation failed for requesting the setSystemAudioMode") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportAudioMode))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportAudioMode") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportAudioMode") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.givefeatures))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the givefeatures") -else: - Utils.error_log("sendMessage emulation failed for requesting the givefeatures") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.requestcurrentlatency))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the requestcurrentlatency") -else: - Utils.error_log("sendMessage emulation failed for requesting the requestcurrentlatency") -time.sleep(3) -print("") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The audio power device power status details ' \ - 'are obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID026_HdmiCecSink_requestAudioDevicePowerStatus' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_028_HDMICECSINK_abortCombinationsEmulation.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_028_HDMICECSINK_abortCombinationsEmulation.py deleted file mode 100644 index 04fe6b40a..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_028_HDMICECSINK_abortCombinationsEmulation.py +++ /dev/null @@ -1,186 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID028 -# Testcase Description : Emulating abort feature with several combinations.Here emulating with invalid vendorId -import time -import json -import Config -import requests -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Emulating abort feature with several combinations.Here emulating the feature abort trigger message by giving an invalid vendor ID ,so that system doesnt support") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"vendorid":"019fb","success":true}}' - - -def update_config(data): - time.sleep(10) - Utils.abort_data(data) - -def feature_abort(): - message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.feature_abort))) - if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the feature_abort") - else: - Utils.error_log("sendMessage emulation failed for requesting the feature_abort") - time.sleep(3) - print("") - -#send messages required for requesting active source -def abort_hisense(): - message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.abort_hisense))) - if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the abort_hisense") - else: - Utils.error_log("sendMessage emulation failed for requesting the abort_hisense") - time.sleep(3) - print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_vendor_id_invalid_2) -if curl_response: - Utils.warning_log("set vendor id invalid curl command sent from the test runner") - Utils.info_log("curl command send for arc routing") - status = 'Pass' - message = 'Output response is matching with expected one. The arc routing ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}".format(HdmiCecSinkApis.set_arc_routing_params_enabled)) - status = 'False' - message = 'Output response is not matching with expected one' - - - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_vendor_id) -if curl_response == expected_output_response: - Utils.warning_log("get vendor id curl command sent from the test runner") - Utils.info_log("curl command send for arc routing") - status = 'Pass' - message = 'Output response is matching with expected one. ' -else: - Utils.error_log("get vendor id curl command failed") - status = 'Fail' - message = 'Output response is not matching with expected one. The arc routing ' - - -Utils.initialize_flask() -time.sleep(2) -#calling feature abort with existing config -feature_abort() -time.sleep(3) - -#calling abort hisense with exsiting config -abort_hisense() -time.sleep(2) - -#send the second config data for feature abort - -update_config(Config.abort_data_1) - -time.sleep(2) -feature_abort() -time.sleep(3) - -abort_hisense() -time.sleep(2) - -#send the third config data for feature abort - - -update_config(Config.abort_data_2) - -time.sleep(2) -feature_abort() -time.sleep(3) - -abort_hisense() -time.sleep(2) - -#send the forth config data for feature abort - - -update_config(Config.abort_data_3) - -time.sleep(2) -feature_abort() -time.sleep(3) - -abort_hisense() -time.sleep(2) - -#send the fifth config data for feature abort - -update_config(Config.abort_data_4) - -time.sleep(2) -feature_abort() -time.sleep(3) - -abort_hisense() -time.sleep(2) - -#send the sixth config data for feature abort - - -update_config(Config.abort_data_5) - -time.sleep(2) -feature_abort() -time.sleep(3) - -abort_hisense() -time.sleep(2) - - - -# generate logs in terminal -tc_id = 'TCID_028_HDMICECSINK_abortCombinationsEmulation' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - - - - - - - - - - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_029_HDMICECSINK_getActiveSourcewithroutingChange.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_029_HDMICECSINK_getActiveSourcewithroutingChange.py deleted file mode 100644 index 9ff32609f..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_029_HDMICECSINK_getActiveSourcewithroutingChange.py +++ /dev/null @@ -1,112 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID029 -# Testcase Description : Verify the current active source and its output response -import time -import json -import Config -import requests -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Verify the current active source and its output response") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -#expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"available":true,"logicalAddress":0,"physicalAddress":"0.0.1.0","deviceType":"TV","cecVersion":"Version 1.4","osdName":"TV Box","vendorID":"019fb","powerStatus":"On","port":"TV","success":true}}' -expected_output_response_with_aud_phyAddr = '{"jsonrpc":"2.0","id":42,"result":{"available":true,"logicalAddress":0,"physicalAddress":"0.0.0.0","deviceType":"TV","cecVersion":"Version 1.4","osdName":"TV Box","vendorID":"019fb","powerStatus":"Standby","port":"TV","success":true}}' -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_routing_change) -if curl_response: - Utils.info_log("curl command send for set routing change") - status = 'Pass' - message = 'Output response is matching with expected one. The set latency info ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_routing_change)) - status = 'False' - message = 'Output response is not matching with expected one' -time.sleep(3) - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_Active_Source) -if curl_response: - Utils.info_log("curl command sent for get active source") -else: - Utils.error_log("Curl command not send {}" .format(HdmiCecSinkApis.get_Active_Source)) - -#sendMessage emulations for image view on and text view on -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.imageViewON))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the imageViewON") -else: - Utils.error_log("sendMessage emulation failed for requesting the imageViewON") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.textViewON))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the textViewON") -else: - Utils.error_log("sendMessage emulation failed for requesting the textViewON") -time.sleep(3) -print("") - -#send messages required for osd string -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_osd_string))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the set_osd_string") -else: - Utils.error_log("sendMessage emulation failed for requesting the set_osd_string") -time.sleep(3) -print("") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response_with_aud_phyAddr): - status = 'Pass' - message = 'Output response is matching with expected one. current active source status ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID_029_HDMICECSINK_getActiveSourcewithroutingChange.py' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_030_HDMICECSINK_sendGetAudioStatusMessage.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_030_HDMICECSINK_sendGetAudioStatusMessage.py deleted file mode 100644 index 71f6262e0..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_030_HDMICECSINK_sendGetAudioStatusMessage.py +++ /dev/null @@ -1,84 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID030 -# Testcase Description : Verify the send get audio status message and its output response -import time -import json -import Config -import requests -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Verify the send get audio status message and its output response") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.sendGetAudioStatusMessage) -if curl_response: - Utils.info_log("curl command send for send get audio status message") - status = 'Pass' - message = 'Output response is matching with expected one. The send get audio status message ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.sendGetAudioStatusMessage)) - status = 'False' - message = 'Output response is not matching with expected one' - -#Report SAD (short Audio Descriptor) -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportShortAudioDes))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportShortAudioDes") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportShortAudioDes") -time.sleep(3) -print("") - -#send messages required for setting system audio mode -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.setSystemAudioMode))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the setSystemAudioMode") -else: - Utils.error_log("sendMessage emulation failed for requesting the setSystemAudioMode") -time.sleep(3) -print("") - -# generate logs in terminal -tc_id = 'TCID_030_HDMICECSINK_sendGetAudioStatusMessage' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_031_HDMICECSINK_getEnabled_HAL_False.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_031_HDMICECSINK_getEnabled_HAL_False.py deleted file mode 100644 index c0af14ca3..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_031_HDMICECSINK_getEnabled_HAL_False.py +++ /dev/null @@ -1,124 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID031_getEnabled_HAL_False -# Testcase Description : Verify the driver enabled status, with different enum values for HDMICECGETLOGICALADDRESS HAL API - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import CecUtils,HdmiCecSourceApis -import Config -import time - -print("TC Description - Returns HDMI-CEC enabled status with different enum values for HDMICECGETLOGICALADDRESS HAL API") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -time.sleep(3) - #ToDo- how to dynamically pass the config here find a way config already written in python side , to do changes in hal c side. -def sink_update(data): - CecUtils.cec_sink_tx_fail(data) - Utils.info_log("Updated Outparams result with next enum combination") -#CecUtils.cec_sink_tx_fail(Config.api_data_sink) -#Utils.info_log("Updated HdmiCecOpen HAL API return values to -1") -# store the expected output response -#expected_output_response = '{"jsonrpc":"2.0","id":42,"error":{"code":1,"message":"ERROR_GENERAL"}}' - -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"enabled":true,"success":true}}' - -def main_scenario(): - curl_response1 = Utils.send_curl_command(HdmiCecSinkApis.get_enabled) - if curl_response1: - Utils.info_log("curl command to get enabled is sent from the test runner") - else: - Utils.error_log("curl command invoke failed") - -# send the curl command and fetch the output json response - curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_enabled) - if curl_response: - Utils.info_log("curl command to get enabled is sent from the test runner") - else: - Utils.error_log("curl command invoke failed") - - return curl_response1 -sink_update(Config.api_data_sink_1) -time.sleep(2) -curl_response1 = main_scenario() - - -sink_update(Config.api_data_sink_2) -time.sleep(2) -curl_response1 = main_scenario() - - -sink_update(Config.api_data_sink_3) -time.sleep(2) -curl_response1 = main_scenario() - - -sink_update(Config.api_data_sink_4) -time.sleep(2) -curl_response1 = main_scenario() - - -sink_update(Config.api_data_sink_5) -time.sleep(2) -curl_response1 = main_scenario() - - -sink_update(Config.api_data_sink_6) -time.sleep(2) -curl_response1 = main_scenario() - - -sink_update(Config.api_data_sink_7) -time.sleep(2) -curl_response1 = main_scenario() - - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response1) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The driver enabled status ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -Utils.info_log("Bringing the system state back to normal") -Utils.initialize_flask() -# generate logs in terminal -tc_id = 'TCID031_HdmiCecSink_getEnabled_HAL_False' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response1) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response1, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_032_HDMICECSINK_EmulateTextViewONStandbyBy.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_032_HDMICECSINK_EmulateTextViewONStandbyBy.py deleted file mode 100644 index a7c02df1b..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_032_HDMICECSINK_EmulateTextViewONStandbyBy.py +++ /dev/null @@ -1,91 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID032_EmulateText view On process with sendStandby Message -# Testcase Description : Touch the process text view on on a sink device(as tv views on the text), then Sends a CEC message to the logical address of the device. and verify the outpu response and then trigger the text view on process again -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -import requests -import Config -import json -import time - -print("Testcase Description : Touch the process text view on on a sink device(as tv views on the text), then Sends a CEC message to the logical address of the device. and verify the outpu response and then trigger the text view on process again") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -#Emulate TextViewOn Process -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.textViewON))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the textViewON") -else: - Utils.error_log("sendMessage emulation failed for requesting the textViewON") -time.sleep(3) -print("") - - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.send_standby_message) -if curl_response: - Utils.info_log("curl command to send standby message is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - - -#Emulate textviewON -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.textViewON))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the textViewON") -else: - Utils.error_log("sendMessage emulation failed for requesting the textViewON") -time.sleep(3) -print("") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The default vendor id ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID032_EmulateText_view_on_process_with_sendStandby_Message' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_033_HDMICECSINK_setRoutingChangeNegative.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_033_HDMICECSINK_setRoutingChangeNegative.py deleted file mode 100644 index e0a4aeee5..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_033_HDMICECSINK_setRoutingChangeNegative.py +++ /dev/null @@ -1,170 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID033_setRoutingChange_negative -# Testcase Description : Changes routing while switching between HDMI inputs and TV. Verify the output response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis -import json -import requests -import time -import Config - -Utils.initialize_flask() - -expected_output_response = '{"jsonrpc":"2.0","id":42,"error":{"code":1,"message":"ERROR_GENERAL"}}' - -#ToDo - send messages required for switching inputs between hdmi and TV, by sending active source message emulation. -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") - -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.send_standby_message) -if curl_response: - Utils.warning_log("send_standby_message curl command sent from the test runner") -else: - Utils.error_log("send_standby_message curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.perform_otp_action) -if curl_response: - Utils.warning_log("perform_otp_action curl command sent from the test runner") -else: - Utils.error_log("perform_otp_action curl command failed") - -#send messages required for getting inactive source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") - -#send messages required for set stream path -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_stream_path_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for set stream path to hisense") -else: - Utils.error_log("sendMessage emulation failed for set stream path to hisense") -time.sleep(3) -print("") - -#send messages required for routing change -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_change))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for routing change to hisense") -else: - Utils.error_log("sendMessage emulation failed for routing change to hisense") -time.sleep(3) -print("") - -#send messages required for routing information -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_information_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying routing information from hisense") -else: - Utils.error_log("sendMessage emulation failed for querying routing information from hisense") -time.sleep(3) -print("") - -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_routing_change_negative) -if curl_response: - Utils.info_log("curl command send for set routing change") - status = 'Pass' - message = 'Output response is matching with expected one. The set latency info ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_routing_change_negative)) - status = 'False' - message = 'Output response is not matching with expected one' - -if str(curl_response) == str(expected_output_response): - Utils.info_log("Test Case Passed") -else: - Utils.error_log("Test Case Failed") -# generate logs in terminal -tc_id = 'TCID033_setRoutingChange_negative' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_034_HDMICECSINK_active_source.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_034_HDMICECSINK_active_source.py deleted file mode 100644 index 97dc3ae17..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_034_HDMICECSINK_active_source.py +++ /dev/null @@ -1,74 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID005 -# Testcase Description : Verify that default vendor id is obtained in output response -import time -import json -import Config -import requests -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Verify that getActiveSource is obtained in output response") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -# Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -#send messages required for getting inactive source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_xione_uk))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_active_route) -if curl_response: - Utils.info_log("curl command send for send get audio status message") - status = 'Pass' - message = 'Output response is matching with expected one. The send get audio status message ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.get_active_route)) - status = 'False' - message = 'Output response is not matching with expected one' - -# generate logs in terminal -tc_id = 'TCID_034_HDMICECSINK_active_source' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_035_Arc_start_stop.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_035_Arc_start_stop.py deleted file mode 100644 index dd38b1971..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_035_Arc_start_stop.py +++ /dev/null @@ -1,204 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID035 -# Testcase Description :Emulating osd string, and arc events -import time -import json -import Config -import requests -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Emulating osd string, and arc events") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask_without_audio_device() -time.sleep(3) -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - - -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportPhysicalAdd))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for reporting the physical address") -else: - Utils.error_log("sendMessage emulation failed for reporting the physical address") -time.sleep(3) -print("") -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.imageViewON))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the imageViewON") -else: - Utils.error_log("sendMessage emulation failed for requesting the imageViewON") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.textViewON))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the textViewON") -else: - Utils.error_log("sendMessage emulation failed for requesting the textViewON") -time.sleep(3) -print("") - -Utils.initialize_flask() -time.sleep(3) -#Emulation curl command -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_arc_routing_params_enabled) -if curl_response: - Utils.info_log("curl command send for arc routing") - status = 'Pass' - message = 'Output response is matching with expected one. The arc routing ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_arc_routing_params_enabled)) - status = 'False' - message = 'Output response is not matching with expected one' - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_change))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the routing_change") -else: - Utils.error_log("sendMessage emulation failed for requesting the routing_change") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.feature_abort))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the feature_abort") -else: - Utils.error_log("sendMessage emulation failed for requesting the feature_abort") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.abort_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the abort_hisense") -else: - Utils.error_log("sendMessage emulation failed for requesting the abort_hisense") -time.sleep(3) -print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_routing_change_nav) -if curl_response: - Utils.info_log("curl command send for set routing change") - status = 'Pass' - message = 'Output response is matching with expected one. The set latency info ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_routing_change_nav)) - status = 'False' - message = 'Output response is not matching with expected one' -time.sleep(3) - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.initiateArc))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the initiateArc") -else: - Utils.error_log("sendMessage emulation failed for requesting the initiateArc") -time.sleep(3) -print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_arc_routing_params_disabled) -if curl_response: - Utils.info_log("curl command send for set routing change") - status = 'Pass' - message = 'Output response is matching with expected one. The set latency info ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_arc_routing_params_disabled)) - status = 'False' - message = 'Output response is not matching with expected one' - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.terminateArc))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the terminateArc") -else: - Utils.error_log("sendMessage emulation failed for requesting the terminateArc") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportShortAudioDes))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportShortAudioDes") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportShortAudioDes") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.setSystemAudioMode))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the setSystemAudioMode") -else: - Utils.error_log("sendMessage emulation failed for requesting the setSystemAudioMode") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportAudioMode))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportAudioMode") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportAudioMode") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.givefeatures))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the givefeatures") -else: - Utils.error_log("sendMessage emulation failed for requesting the givefeatures") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.requestcurrentlatency))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the requestcurrentlatency") -else: - Utils.error_log("sendMessage emulation failed for requesting the requestcurrentlatency") -time.sleep(3) -print("") diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_036_HDMICECSINK_OSDStringMenuLanguageEmulation.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_036_HDMICECSINK_OSDStringMenuLanguageEmulation.py deleted file mode 100644 index 8950a9d00..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_036_HDMICECSINK_OSDStringMenuLanguageEmulation.py +++ /dev/null @@ -1,107 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID036 -# Testcase Description : Verify the memu language and OsdString set emulation -import time -import json -import Config -import requests -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Verify the memu language and OsdString set emulation") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportPhysicalAdd))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportPhysicalAdd") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportPhysicalAdd") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.ignore_set_menu_language))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the ignore_set_menu_language") -else: - Utils.error_log("sendMessage emulation failed for requesting the ignore_set_menu_language") -time.sleep(3) -print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_menu_language) -if curl_response: - Utils.info_log("curl command send for set menu language") - status = 'Pass' - message = 'Output response is matching with expected one. The set menu language ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_menu_language)) - status = 'False' - message = 'Output response is not matching with expected one' - - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_osd_string))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the set_osd_string") -else: - Utils.error_log("sendMessage emulation failed for requesting the set_osd_string") -time.sleep(3) -print("") - - - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.get_menu_language_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the get_menu_language_hisense") -else: - Utils.error_log("sendMessage emulation failed for requesting the get_menu_language_hisense") -time.sleep(3) -print("") - -# generate logs in terminal -tc_id = 'TCID036_HdmiCecSink_osdStringMenuLanguage_emulation' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_037_HDMICECSINK_sendEvents.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_037_HDMICECSINK_sendEvents.py deleted file mode 100644 index 7a25c2462..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_037_HDMICECSINK_sendEvents.py +++ /dev/null @@ -1,87 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID037 -# Testcase Description : To verify the emulation of sending of events - -import subprocess -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis -from HdmiCecSink import HdmiCecSinkApis -import time - - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"enabled":true,"success":true}}' - -print("TC Description - To verify the emulation of sending of events.") -Utils.initialize_flask() -time.sleep(3) -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_enabled) -time.sleep(1) -if curl_response: - Utils.warning_log("activate curl command sent from the test runner") -else: - Utils.error_log("activate curl command failed") - -#Define the script to be executed -execute_script = '../../../../../sendEvents.sh' - - -#Execute the script -try: - result = subprocess.run(['/bin/bash', execute_script], check=True, capture_output=True, text=True) - print("sendEvents.sh executed successfully.") - print("Output:\n", result.stdout) - -except subprocess.CalledProcessError as e: - print("Error occured while executing the shell script.") - print("Error message:\n", e.stderr) - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one.' -else: - status = 'Fail' - message = 'Output response is different from expected one.' - -# generate logs in terminal -tc_id = 'TCID025_sending events' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_038_HDMICECSINK_undefinedDatatypesInSetApis.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_038_HDMICECSINK_undefinedDatatypesInSetApis.py deleted file mode 100644 index cfd4b7ef5..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_038_HDMICECSINK_undefinedDatatypesInSetApis.py +++ /dev/null @@ -1,54 +0,0 @@ -# Testcase ID : TCID005 -# Testcase Description : Verify that default vendor id is obtained in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -print("TC Description - Verify that default vendor id AND default OSD name is obtained in output response") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -count = 0 -expected_output_response_vendor_id = '{"jsonrpc":"2.0","id":42,"result":{"vendorid":"019fb","success":true}}' -expected_output_response_osd_name = '{"jsonrpc":"2.0","id":42,"result":{"name":"TV Box","success":true}}' -# send the curl command and fetch the output json response -curl_response_vendor_id = Utils.send_curl_command(HdmiCecSinkApis.set_vendor_id_with_undefined_datatype) -curl_response_vendor_id = Utils.send_curl_command(HdmiCecSinkApis.get_vendor_id) -if curl_response_vendor_id: - Utils.info_log("curl command to get vendorID is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -curl_response_osd_name = Utils.send_curl_command(HdmiCecSinkApis.set_osd_name_with_undefined_datatype) -curl_response_osd_name = Utils.send_curl_command(HdmiCecSinkApis.get_osd_name) -if curl_response_osd_name: - Utils.info_log("curl command to set OSD name is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response_vendor_id) == str(expected_output_response_vendor_id) and (curl_response_osd_name) == str(expected_output_response_osd_name): - count = count+1 - status = 'Pass' - message = 'Output response is matching with expected one. The default vendor id ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID005_HdmiCecSink_getVendorId' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response_osd_name) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response_osd_name, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_039_HDMICECSINK_undefinedBooleanforSetApis.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_039_HDMICECSINK_undefinedBooleanforSetApis.py deleted file mode 100644 index 7043de717..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_039_HDMICECSINK_undefinedBooleanforSetApis.py +++ /dev/null @@ -1,164 +0,0 @@ -# Testcase ID : TCID023_setRoutingChange -# Testcase Description : Changes routing while switching between HDMI inputs and TV. Verify the output response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis -import json -import requests -import time -import Config - -Utils.initialize_flask() - -print("TC Description - Changes routing while switching between HDMI inputs and TV. Verify the output response") -#ToDo - send messages required for switching inputs between hdmi and TV, by sending active source message emulation. -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") - -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.send_standby_message) -if curl_response: - Utils.warning_log("send_standby_message curl command sent from the test runner") -else: - Utils.error_log("send_standby_message curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.perform_otp_action) -if curl_response: - Utils.warning_log("perform_otp_action curl command sent from the test runner") -else: - Utils.error_log("perform_otp_action curl command failed") - -#send messages required for getting inactive source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") - -#send messages required for set stream path -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_stream_path_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for set stream path to hisense") -else: - Utils.error_log("sendMessage emulation failed for set stream path to hisense") -time.sleep(3) -print("") - -#send messages required for routing change -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_change))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for routing change to hisense") -else: - Utils.error_log("sendMessage emulation failed for routing change to hisense") -time.sleep(3) -print("") - -#send messages required for routing information -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_information_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying routing information from hisense") -else: - Utils.error_log("sendMessage emulation failed for querying routing information from hisense") -time.sleep(3) -print("") - -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - - -#send messages required for getting menu language -#message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( -# Config.flask_server_ip, json.dumps(Config.get_menu_language_hisense))) -#if "200" in str(message1_response): -# Utils.info_log("sendMessage emulation success for querying the menu language") -#else: -# Utils.error_log("sendMessage emulation failed for querying the menu language") -#time.sleep(3) -#print("") - -#send messages required for setting menu language -#message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( -# Config.flask_server_ip, json.dumps(Config.set_menu_language))) -#if "200" in str(message1_response): -# Utils.info_log("sendMessage emulation success for setting the menu language") -#else: -# Utils.error_log("sendMessage emulation failed for setting the menu language") -#time.sleep(3) -#print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_routing_change_with_undefined_datatype ) -if curl_response: - Utils.info_log("curl command send for set routing change") - status = 'Pass' - message = 'Output response is matching with expected one. The set latency info ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_routing_change_with_undefined_datatype)) - status = 'False' - message = 'Output response is not matching with expected one' - -# generate logs in terminal -tc_id = 'TCID039_HdmiCecSink_setRoutingChange_with_undefinedDatatypesandRoutingInformation' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_040_HDMICECSINK_undefinedDatatypeForSetLatencyInfo.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_040_HDMICECSINK_undefinedDatatypeForSetLatencyInfo.py deleted file mode 100644 index 23a641044..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_040_HDMICECSINK_undefinedDatatypeForSetLatencyInfo.py +++ /dev/null @@ -1,135 +0,0 @@ -# Testcase ID : TCID022_setLatencyInfo -# Testcase Description : Sets the Current Latency Values such as Video Latency, Latency Flags,Audio Output Compensated value and Audio Output Delay by sending message for Dynamic Auto LipSync Feature. Verify the output response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -import json -import requests -import time -import Config - -Utils.initialize_flask() -#ToDo - send messages required for reporting current latency info -#send messages required for reporting current latency -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.requestcurrentlatency))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the requestcurrentlatency") -else: - Utils.error_log("sendMessage emulation failed for requesting the requestcurrentlatency") -time.sleep(3) -print("") - - -#send messages required for getting menu language -#message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( -# Config.flask_server_ip, json.dumps(Config.get_menu_language_hisense))) -#if "200" in str(message1_response): -# Utils.info_log("sendMessage emulation success for querying the menu language") -#else: -# Utils.error_log("sendMessage emulation failed for querying the menu language") -#time.sleep(3) -#print("") - -#send messages required for setting menu language -#message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( -# Config.flask_server_ip, json.dumps(Config.set_menu_language))) -#if "200" in str(message1_response): -# Utils.info_log("sendMessage emulation success for setting the menu language") -#else: -# Utils.error_log("sendMessage emulation failed for setting the menu language") -#time.sleep(3) -#print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_latency_info) -if curl_response: - Utils.info_log("curl command send for set latency info") - status = 'Pass' - message = 'Output response is matching with expected one. The set latency info ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_latency_info)) - status = 'False' - message = 'Output response is not matching with expected one' - -# generate logs in terminal -tc_id = 'TCID022_HdmiCecSink_setLatencyInfo' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message)# Testcase ID : TCID022_setLatencyInfo -# Testcase Description : Sets the Current Latency Values such as Video Latency, Latency Flags,Audio Output Compensated value and Audio Output Delay by sending message for Dynamic Auto LipSync Feature. Verify the output response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -import json -import requests -import time -import Config - -Utils.initialize_flask() -#ToDo - send messages required for reporting current latency info -#send messages required for reporting current latency -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.requestcurrentlatency))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the requestcurrentlatency") -else: - Utils.error_log("sendMessage emulation failed for requesting the requestcurrentlatency") -time.sleep(3) -print("") - - -#send messages required for getting menu language -#message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( -# Config.flask_server_ip, json.dumps(Config.get_menu_language_hisense))) -#if "200" in str(message1_response): -# Utils.info_log("sendMessage emulation success for querying the menu language") -#else: -# Utils.error_log("sendMessage emulation failed for querying the menu language") -#time.sleep(3) -#print("") - -#send messages required for setting menu language -#message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( -# Config.flask_server_ip, json.dumps(Config.set_menu_language))) -#if "200" in str(message1_response): -# Utils.info_log("sendMessage emulation success for setting the menu language") -#else: -# Utils.error_log("sendMessage emulation failed for setting the menu language") -#time.sleep(3) -#print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_latency_info_with_undefinedLatencyMode) -if curl_response: - Utils.info_log("curl command send for set latency info") - status = 'Pass' - message = 'Output response is matching with expected one. The set latency info ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_latency_info_with_undefinedLatencyMode)) - status = 'False' - message = 'Output response is not matching with expected one' - -# generate logs in terminal -tc_id = 'TCID040_HdmiCecSink_setLatencyInfo_with_erroneousLatencyModes' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_041_HDMICECSINK_setRoutingChange_with_undefinedRoutingParams.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_041_HDMICECSINK_setRoutingChange_with_undefinedRoutingParams.py deleted file mode 100644 index da66e44a5..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_041_HDMICECSINK_setRoutingChange_with_undefinedRoutingParams.py +++ /dev/null @@ -1,164 +0,0 @@ -# Testcase ID : TCID041_setRoutingChange_withUndefinedDatatypes -# Testcase Description : Changes routing while switching between error inputs and TV. Verify the erroneuos output response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis -import json -import requests -import time -import Config - -Utils.initialize_flask() - -print("TC Description - Changes routing while switching between error inputs and TV. Verify the erroneuos output response") -#ToDo - send messages required for switching inputs between hdmi and TV, by sending active source message emulation. -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") - -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.send_standby_message) -if curl_response: - Utils.warning_log("send_standby_message curl command sent from the test runner") -else: - Utils.error_log("send_standby_message curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.perform_otp_action) -if curl_response: - Utils.warning_log("perform_otp_action curl command sent from the test runner") -else: - Utils.error_log("perform_otp_action curl command failed") - -#send messages required for getting inactive source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") - -#send messages required for set stream path -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_stream_path_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for set stream path to hisense") -else: - Utils.error_log("sendMessage emulation failed for set stream path to hisense") -time.sleep(3) -print("") - -#send messages required for routing change -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_change))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for routing change to hisense") -else: - Utils.error_log("sendMessage emulation failed for routing change to hisense") -time.sleep(3) -print("") - -#send messages required for routing information -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_information_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying routing information from hisense") -else: - Utils.error_log("sendMessage emulation failed for querying routing information from hisense") -time.sleep(3) -print("") - -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - - -#send messages required for getting menu language -#message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( -# Config.flask_server_ip, json.dumps(Config.get_menu_language_hisense))) -#if "200" in str(message1_response): -# Utils.info_log("sendMessage emulation success for querying the menu language") -#else: -# Utils.error_log("sendMessage emulation failed for querying the menu language") -#time.sleep(3) -#print("") - -#send messages required for setting menu language -#message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( -# Config.flask_server_ip, json.dumps(Config.set_menu_language))) -#if "200" in str(message1_response): -# Utils.info_log("sendMessage emulation success for setting the menu language") -#else: -# Utils.error_log("sendMessage emulation failed for setting the menu language") -#time.sleep(3) -#print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_routing_change_with_undefined_datatype) -if curl_response: - Utils.info_log("curl command send for set routing change") - status = 'Pass' - message = 'Output response is matching with expected one. The set latency info ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_latency_info)) - status = 'False' - message = 'Output response is not matching with expected one' - -# generate logs in terminal -tc_id = 'TCID041_HdmiCecSink_setRoutingChange_with_erroneousRoutingParams' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_042_HDMICECSINK_PassingNegativeConfigurationsfromHalside.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_042_HDMICECSINK_PassingNegativeConfigurationsfromHalside.py deleted file mode 100644 index 32a3981ac..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_042_HDMICECSINK_PassingNegativeConfigurationsfromHalside.py +++ /dev/null @@ -1,66 +0,0 @@ -# Testcase ID : TCID021_setMenuLanguage -# Testcase Description : Updates the internal data structure with the new menu Language and also broadcasts the CEC message.and verify the outpu response -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -import json -import requests -import time -import Config - -Utils.initialize_flask_with_HalApiNegativeValues() -#send messages required for getting physical address -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.give_physical_address_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the physical address") -else: - Utils.error_log("sendMessage emulation failed for querying the physical address") -time.sleep(3) -print("") - -#send messages required for getting menu language -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.get_menu_language_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the menu language") -else: - Utils.error_log("sendMessage emulation failed for querying the menu language") -time.sleep(3) -print("") - -#send messages required for setting menu language -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_menu_language))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for setting the menu language") -else: - Utils.error_log("sendMessage emulation failed for setting the menu language") -time.sleep(3) -print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.set_menu_language) -if curl_response: - Utils.info_log("curl command send for set menu language") - status = 'Pass' - message = 'Output response is matching with expected one. The set menu language ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.set_menu_language)) - status = 'False' - message = 'Output response is not matching with expected one' - -# generate logs in terminal -tc_id = 'TCID021_HdmiCecSink_setMenuLanguage_withNegativeHapApis' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_043_HDMICECSINK_getDeviceListwithHalApisNegativeReturn.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_043_HDMICECSINK_getDeviceListwithHalApisNegativeReturn.py deleted file mode 100644 index 1ab48d584..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_043_HDMICECSINK_getDeviceListwithHalApisNegativeReturn.py +++ /dev/null @@ -1,47 +0,0 @@ -# Testcase ID : TCID010 -# Testcase Description : Gets the number of connected source devices and system information for each device. The information includes device type, physical address, CEC version, vendor ID, power status and OSD name., and verify the output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -import time - -print("TC Description - Gets the number of connected source devices and system information for each device. The information includes device type, physical address, CEC version, vendor ID, power status and OSD name.Here an error value is passed to all HAL APIs for the system to return erroneous response") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask_with_HalApiNegativeValues() -time.sleep(6) -expected_output_response = '{"jsonrpc":"2.0","id":42,"error":{"code":1,"message":"ERROR_GENERAL"}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_device_list) -if curl_response: - Utils.info_log("curl command to get devicelist is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The default vendor id ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID005_HdmiCecSink_getDevicelist' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -#restoring to working state -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_044_HDMICECSINK_getActiveRouteNegativeHal.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_044_HDMICECSINK_getActiveRouteNegativeHal.py deleted file mode 100644 index 54024114b..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_044_HDMICECSINK_getActiveRouteNegativeHal.py +++ /dev/null @@ -1,52 +0,0 @@ -# Testcase ID : TCID005 -# Testcase Description : Verify that default vendor id is obtained in output response -import time -import json -import Config -import requests -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Verify that getActiveSource error is obtained in output response as HAL Api values has been given erroneous") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask_with_HalApiNegativeValues() -expected_output_response = '{"jsonrpc":"2.0","id":42,"error":{"code":1,"message":"ERROR_GENERAL"}}' - -#send messages required for getting inactive source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_xione_uk))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_active_route) -if curl_response: - Utils.info_log("curl command send for send get audio status message") - status = 'Pass' - message = 'Output response is matching with expected one. The send get audio status message ' \ - 'is obtained in output response' -else: - Utils.error_log("curl command send failed {}" .format(HdmiCecSinkApis.get_active_route)) - status = 'False' - message = 'Output response is not matching with expected one' - -# generate logs in terminal -tc_id = 'TCID_044_HDMICECSINK_active_route_HAL_False' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_045_HDMICECSINK_AudioStatusNegative.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_045_HDMICECSINK_AudioStatusNegative.py deleted file mode 100644 index 78c92eb69..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_045_HDMICECSINK_AudioStatusNegative.py +++ /dev/null @@ -1,74 +0,0 @@ -# Testcase ID : TCID014_getAudioStatusMessage -# Testcase Description : Sends the CEC message to request the audio status., and verify the output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis -import Config -import requests -import json -import time - -print("TC Description - To check if mngr Sends the CEC message to request the audio status if HAL Api values are passed negative") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask_with_HalApiNegativeValues() -expected_output_response = '{"jsonrpc":"2.0","id":42,"error":{"code":1,"message":"ERROR_GENERAL"}}' - - - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.sendGetAudioStatusMessage) -if curl_response: - Utils.info_log("curl command to send audio status message is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -time.sleep(3) - -#ToDo - send message emulation for report audio status message event[reportAudioStatusEvent Triggered when CEC message of device is received.] -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportShortAudioDes))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportShortAudioDes") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportShortAudioDes") -time.sleep(3) -print("") - -time.sleep(3) - -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportAudioMode))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportAudioMode") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportAudioMode") -time.sleep(3) -print("") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The send audio status message and report audio sytatus event ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID045_HdmiCecSink_getAudioStatusMessageNegative' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_046_HDMICECSINK_HALNegativeReturn.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_046_HDMICECSINK_HALNegativeReturn.py deleted file mode 100644 index f2aecd444..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_046_HDMICECSINK_HALNegativeReturn.py +++ /dev/null @@ -1,43 +0,0 @@ -# Testcase ID : TCID046_HalNegative -# Testcase Description : Returns HDMI-CEC driver enabled status - -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -print("TC Description - Returns whether HDMI-CEC is enabled on platform or not.") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_hal_apis_with_negative_values() -expected_output_response = '{"jsonrpc":"2.0","id":42,"error":{"code":1,"message":"ERROR_GENERAL"}}' -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.get_enabled) -if curl_response: - Utils.info_log("curl command to get enabled is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The default driver status ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID046_HdmiCecSink_HAL_ReturnsNegative_and_string' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_047_HDMICECSINK_SetApisWithoutParamsNegative.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_047_HDMICECSINK_SetApisWithoutParamsNegative.py deleted file mode 100644 index 30f945662..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_047_HDMICECSINK_SetApisWithoutParamsNegative.py +++ /dev/null @@ -1,144 +0,0 @@ -# Testcase ID : TCID047_setApisWithoutParams -# Testcase Description : send all set apis with default HAL values and without params in json rpc request -import time -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis - -print("TC Description - send all set apis with default HAL values and without params in json rpc request") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() - -def wait(): - time.sleep(2) - -expected_output_response = '{"jsonrpc":"2.0","id":42,"error":{"code":1,"message":"ERROR_GENERAL"}}' -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSinkApis.sendKeyPress_withoutParams) -if curl_response: - Utils.info_log("curl command to send key press without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -wait() - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.senduserContolledPress_withoutParams ) -if curl_response: - Utils.info_log("curl command to send usercontrol key press without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.sendusercontrolledReleased_withoutParams ) -if curl_response: - Utils.info_log("curl command to send user key release without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -wait() - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.setActivepath_withoutParams ) -if curl_response: - Utils.info_log("curl command to set active path without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -wait() - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.setEnabled_withoutParams ) -if curl_response: - Utils.info_log("curl command to set enable the driver without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -wait() - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.setMenuLanguage_withoutParams ) -if curl_response: - Utils.info_log("curl command to set menu language without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -wait() - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.setMenuLanguage_withoutParams ) -if curl_response: - Utils.info_log("curl command to set menu language without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -wait() - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.setOSDName_withoutParams ) -if curl_response: - Utils.info_log("curl command to set OSD name without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -wait() - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.setRoutingChange_withoutParams ) -if curl_response: - Utils.info_log("curl command to set routing change without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -wait() - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.setupARCRouting_withoutParams ) -if curl_response: - Utils.info_log("curl command to setup ARC routing without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -wait() - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.setvendorID_withoutParams ) -if curl_response: - Utils.info_log("curl command to set vendor id without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -wait() - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.setMenuLanguage_withoutParams ) -if curl_response: - Utils.info_log("curl command to set menu language without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -wait() - -curl_response = Utils.send_curl_command(HdmiCecSinkApis.setLatencyInfo_withoutParams ) -if curl_response: - Utils.info_log("curl command to set latency info without params is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. error value ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID047_HdmiCecSink_setApis_withoutParams_Negative' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -#Reset the state of the mock system to original -Utils.initialize_flask() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_Emulate.py b/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_Emulate.py deleted file mode 100644 index aa1c14b6e..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSink/TCID_Emulate.py +++ /dev/null @@ -1,205 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID005 -# Testcase Description : Verify that default vendor id is obtained in output response -import time -import json -import Config -import requests -from Utilities import Utils, ReportGenerator -from HdmiCecSink import HdmiCecSinkApis -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Verify that default vendor id is obtained in output response") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initialize_flask() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportPhysicalAdd))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for reporting the physical address") -else: - Utils.error_log("sendMessage emulation failed for reporting the physical address") -time.sleep(3) -print("") - -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.DeviceVendorID))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for reporting the DeviceVendorID") -else: - Utils.error_log("sendMessage emulation failed for reporting the DeviceVendorID") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.imageViewON))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the imageViewON") -else: - Utils.error_log("sendMessage emulation failed for requesting the imageViewON") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.textViewON))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the textViewON") -else: - Utils.error_log("sendMessage emulation failed for requesting the textViewON") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_change))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the routing_change") -else: - Utils.error_log("sendMessage emulation failed for requesting the routing_change") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.ignore_set_menu_language))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the ignore_set_menu_language") -else: - Utils.error_log("sendMessage emulation failed for requesting the ignore_set_menu_language") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_osd_string))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the set_osd_string") -else: - Utils.error_log("sendMessage emulation failed for requesting the set_osd_string") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.get_menu_language_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the get_menu_language_hisense") -else: - Utils.error_log("sendMessage emulation failed for requesting the get_menu_language_hisense") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.feature_abort))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the feature_abort") -else: - Utils.error_log("sendMessage emulation failed for requesting the feature_abort") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.abort_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the abort_hisense") -else: - Utils.error_log("sendMessage emulation failed for requesting the abort_hisense") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.initiateArc))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the initiateArc") -else: - Utils.error_log("sendMessage emulation failed for requesting the initiateArc") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.terminateArc))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the terminateArc") -else: - Utils.error_log("sendMessage emulation failed for requesting the terminateArc") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportShortAudioDes))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportShortAudioDes") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportShortAudioDes") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.setSystemAudioMode))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the setSystemAudioMode") -else: - Utils.error_log("sendMessage emulation failed for requesting the setSystemAudioMode") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportAudioMode))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the reportAudioMode") -else: - Utils.error_log("sendMessage emulation failed for requesting the reportAudioMode") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.givefeatures))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the givefeatures") -else: - Utils.error_log("sendMessage emulation failed for requesting the givefeatures") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.requestcurrentlatency))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the requestcurrentlatency") -else: - Utils.error_log("sendMessage emulation failed for requesting the requestcurrentlatency") -time.sleep(3) -print("") diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/CecUtils.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/CecUtils.py deleted file mode 100644 index f6a2322fa..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/CecUtils.py +++ /dev/null @@ -1,117 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# This file contains all the common functions required for test framework - -import requests -import json -import time -import Config -from Utilities import Utils -from HdmiCecSource import HdmiCecSourceApis - - -def cec_update_api_overrides(data): - '''This function is used to update the api overrides data. After updating the data we will - deactivate and then reactivate the HdmiCecSource plugin to reflect pushed changes''' - try: - # Change the values of api overrides for hdmi-cec plugin using updateAPIConfig API - api_overrides_response = requests.get("http://{}/Hdmicec.updateAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(data))) - print("Inside CecUtils.py : " + api_overrides_response.text + " : " + str(data)) - time.sleep(3) - - # Deactivate the plugin using curl command - Utils.send_curl_command(HdmiCecSourceApis.deactivate_command) - - # Activate the plugin using curl command - Utils.send_curl_command(HdmiCecSourceApis.activate_command) - except: - print("Inside CecUtils.py : Exception in cec_update_api_overrides function") - - -def cec_sink_tx_fail(data): - '''This function is used to update the api overrides data. After updating the data we will - deactivate and then reactivate the HdmiCecSource plugin to reflect pushed changes''' - try: - # Change the values of api overrides for hdmi-cec plugin using updateAPIConfig API - api_overrides_response = requests.get("http://{}/Hdmicec.updateAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(data))) - print("Inside CecUtils.py : " + api_overrides_response.text + " : " + str(data)) - time.sleep(3) - - # Deactivate the plugin using curl command - Utils.send_curl_command(HdmiCecSourceApis.deactivate_command) - - # Activate the plugin using curl command - Utils.send_curl_command(HdmiCecSourceApis.activate_command) - time.sleep(5) - except: - print("Inside CecUtils.py : Exception in cec_update_api_overrides function") - - - -def cec_post_condition_for_negative_scenarios(): - '''This function is used to update the api overrides data back to default. After updating the data - we will restart WPEFramework & Websocket services and then activate the HdmiCecSource plugin - again to reflect pushed changes''' - try: - # Change the values of api overrides data for hdmi-cec plugin back to default 0 - api_overrides_response = requests.get("http://{}/Hdmicec.updateAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.api_data))) - print("Inside CecUtils.py : Post-condition : " + api_overrides_response.text + " : " + str(Config.api_data)) - # time.sleep(3) - - # Restart the WPEFramework & Websocket services - Utils.restart_services() - # time.sleep(3) - - # Store the expected output response for activate command - expected_output_response = '{"jsonrpc":"2.0","id":3,"result":null}' - - # Send the controller activate curl command and fetch the output json response - curl_response = Utils.send_curl_command(HdmiCecSourceApis.activate_command) - - # Compare both expected and received output responses - if str(curl_response) == str(expected_output_response): - print("Inside CecUtils.py : Post-condition : Successfully restarted the WPEFramework & " - "Websocket server services. Successfully activated the HdmiCecSource plugin") - else: - print("Inside CecUtils.py : Post-condition : Failed to restart the WPEFramework & " - "Websocket server services. Failed to activate the HdmiCecSource plugin") - except: - print("Inside CecUtils.py : Post-condition : Exception in cec_post_condition_for_negative_scenarios function") - - -def activate_cec(): - '''This function is used to activate the HdmiCecSource plugin''' - try: - # send the controller activate curl command and fetch the output json response - curl_response = Utils.send_curl_command(HdmiCecSourceApis.activate_command) - - # compare both expected and received output responses - if str(curl_response) == str(HdmiCecSourceApis.expected_output_response): - print("Inside CecUtils.py : Successfully activated the HdmiCecSource plugin") - else: - print("Inside CecUtils.py : Failed to activate the HdmiCecSource plugin") - except: - print("Inside CecUtils.py : Exception in activate_cec function") diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/HdmiCecSourceApis.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/HdmiCecSourceApis.py deleted file mode 100644 index 0c51dd6a3..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/HdmiCecSourceApis.py +++ /dev/null @@ -1,129 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Curl command for activating HdmiCecSource plugin -activate_command = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc":"2.0","id":"3" -,"method": "Controller.1.activate", "params":{"callsign":"org.rdk.HdmiCecSource"}}' http://127.0.0.1:55555/jsonrpc''' - -# Curl command for deactivating HdmiCecSource plugin -deactivate_command = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc":"2.0","id":"3" -,"method": "Controller.1.deactivate", "params":{"callsign":"org.rdk.HdmiCecSource"}}' http://127.0.0.1:55555/jsonrpc''' - -# Store the expected output response for activate & deactivate curl command -expected_output_response = '{"jsonrpc":"2.0","id":3,"result":null}' - -###################################################################################### - -# HdmiCecSource Methods : - -get_device_list = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.getDeviceList"}' http://127.0.0.1:55555/jsonrpc''' - -send_standby_message = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", -"id": 42,"method":"org.rdk.HdmiCecSource.sendStandbyMessage"}' http://127.0.0.1:55555/jsonrpc''' - -get_vendor_id = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.getVendorId"}' http://127.0.0.1:55555/jsonrpc''' - -set_vendor_id = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSource.setVendorId","params": {"vendorid": "0x4455"}}' http://127.0.0.1:55555/jsonrpc''' - -get_osd_name = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.getOSDName"}' http://127.0.0.1:55555/jsonrpc''' - -set_osd_name = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSource.setOSDName","params": {"name": "CUSTOM8 TV"}}' http://127.0.0.1:55555/jsonrpc''' - -get_enabled = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.getEnabled"}' http://127.0.0.1:55555/jsonrpc''' - -set_enabled_false = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSource.setEnabled","params": {"enabled": false}}' http://127.0.0.1:55555/jsonrpc''' - -set_enabled_true = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSource.setEnabled","params": {"enabled": true}}' http://127.0.0.1:55555/jsonrpc''' - -get_active_source_status = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", -"id": 42,"method":"org.rdk.HdmiCecSource.getActiveSourceStatus","params": {"status": true}}' http://127.0.0.1:55555/jsonrpc''' - -get_otp_enabled = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.getOTPEnabled"}' http://127.0.0.1:55555/jsonrpc''' - -set_otp_enabled_false = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSource.setOTPEnabled","params": {"enabled": false}}' http://127.0.0.1:55555/jsonrpc''' - -set_otp_enabled_true = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSource.setOTPEnabled","params": {"enabled": true}}' http://127.0.0.1:55555/jsonrpc''' - -send_keypress_VOLUME_UP = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 65}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_VOLUME_DOWN = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 66}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_MUTE = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 67}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_UP = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 1}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_DOWN = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 2}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_LEFT = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 3}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_RIGHT = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 4}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_SELECT = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 0}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_HOME = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 9}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_BACK = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 13}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_0 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 32}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_1 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 33}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_2 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 34}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_3 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 35}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_4 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 36}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_5 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 37}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_6 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 38}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_7 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 39}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_8 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 40}}' http://127.0.0.1:55555/jsonrpc''' -send_keypress_NUMBER_9 = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42, -"method":"org.rdk.HdmiCecSource.sendKeyPressEvent", "params": {"logicalAddress": 0,"keyCode": 41}}' http://127.0.0.1:55555/jsonrpc''' - -perform_otp_action = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42, -"method":"org.rdk.HdmiCecSource.performOTPAction"}' http://127.0.0.1:55555/jsonrpc''' - -set_otp_enabled_invalid = '''curl --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0","id": 42,"method": "org.rdk.HdmiCecSource.setOTPEnabled","params": {"ennable": true}}' http://127.0.0.1:55555/jsonrpc''' - -set_osd_name_invalid = '''curl --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0","id": 42,"method": "org.rdk.HdmiCecSource.setOSDName","params": {"nnamme": "LG TV"}}' http://127.0.0.1:55555/jsonrpc''' - -set_vendor_id_invalid_1 = '''curl --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0","id": 42,"method": "org.rdk.HdmiCecSource.setVendorId","params": {"vendorid": "]]"}}' http://127.0.0.1:55555/jsonrpc''' - -set_vendor_id_invalid_2 = '''curl --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0","id": 42,"method": "org.rdk.HdmiCecSource.setVendorId","params": {"vllendorid": "]]"}}' http://127.0.0.1:55555/jsonrpc''' - - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID001.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID001.py deleted file mode 100644 index c7dab53d0..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID001.py +++ /dev/null @@ -1,146 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID001 -# Testcase Description : To verify that standby message is successfully triggered -# and got proper logs in thunder. Hit the curl command for sendStandbyMessage and send the corresponding -# messages to hal. Verify the output response. Also, wake up the devices by sending cec message as post condition -import subprocess -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -print("TC Description - To verify that standby message is successfully triggered and get proper logs in thunder. Hit the curl command for sendStandbyMessage and send the corresponding messages to hal. Verify the output response. Also, wake up the devices by sending cec message as post condition") -#send messages required for getting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -Utils.initiliaze_flask_for_HdmiCecSource() -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.getPowerStatusMessage))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the powerstatus of TV") -else: - Utils.error_log("sendMessage emulation failed for querying the powerstatus of TV") -time.sleep(3) -print("") - -#send messages required for reporting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportPowerStatusMessage))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for reporting the powerstatus of TV") -else: - Utils.error_log("sendMessage emulation failed for reporting the powerstatus of TV") -time.sleep(3) -print("") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.send_standby_message) -if curl_response: - Utils.warning_log("send_standby_message curl command sent from the test runner") -else: - Utils.error_log("send_standby_message curl command failed") - -# send messages required for getting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.getPowerStatusMessage))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the powerstatus of TV") -else: - Utils.error_log("sendMessage emulation failed for querying the powerstatus of TV") -time.sleep(3) -print("") - -#send messages required for reporting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportPowerStatusMessage))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for reporting the powerstatus of TV") -else: - Utils.error_log("sendMessage emulation failed for reporting the powerstatus of TV") -time.sleep(3) -print("") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. We are expecting opcode : 36 in thunder logs' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID001_sendStandbyMessage' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - -# wake up the device from standby as post condition by sending message -print("---------------------------------------------------------------------------------------------------------------------------") -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.performOTPActionMessage))) -Utils.warning_log("Reset the device state to ON from standby") -time.sleep(3) - -# send messages required for getting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.getPowerStatusMessage))) -time.sleep(3) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the powerstatus of TV") -else: - Utils.error_log("sendMessage emulation failed for querying the powerstatus of TV") -time.sleep(3) -print("") - -#send messages required for reporting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportPowerStatusMessage))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for reporting the powerstatus of TV") -else: - Utils.error_log("sendMessage emulation failed for reporting the powerstatus of TV") -time.sleep(3) -print("") -Utils.initiliaze_flask_for_HdmiCecSource() - - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID002.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID002.py deleted file mode 100644 index 12c601f48..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID002.py +++ /dev/null @@ -1,66 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID002 -# Testcase Description : Verify that default vendor id is obtained in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Verify that default vendor id is obtained in output response") -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -Utils.initiliaze_flask_for_HdmiCecSource() -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"vendorid":"019fb","success":true}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_vendor_id) -if curl_response: - Utils.info_log("curl command to get vendorID is sent from the test runner") -else: - Utils.error_log("curl command invoke failed") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The default vendor id ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID002_getVendorId' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID003.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID003.py deleted file mode 100644 index f4a8c13cb..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID003.py +++ /dev/null @@ -1,75 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID003 -# Testcase Description : Set the vendor id to new one using curl command and verify that new -# vendor id set by the test user is obtained in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Set the vendor id to new one using curl command and verify that new vendor id set by the test user is obtained in output response") -# send the curl command to set the new vendor id -print("---------------------------------------------------------------------------------------------------------------------------") -Utils.initiliaze_flask_for_HdmiCecSource() -set_response = Utils.send_curl_command(HdmiCecSourceApis.set_vendor_id) -if set_response: - Utils.info_log("curl command sent for setting the vendorID") -else: - Utils.error_log("set vendor_id failed") -print("") - -# store the expected output response of testcase -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"vendorid":"04455","success":true}}' - -# send the curl command to get vendor id and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_vendor_id) -if curl_response: - Utils.info_log("curl command send for getting the vendor id") -else: - Utils.error_log("curl command send failed for getting the vendor id") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The new vendor id ' \ - 'given by user is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID003_setVendorId_set_a_vendorID' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID004.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID004.py deleted file mode 100644 index de327e6fd..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID004.py +++ /dev/null @@ -1,65 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID004 -# Testcase Description : Verify that default OSD Name is obtained in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"name":"TV Box","success":true}}' -Utils.initiliaze_flask_for_HdmiCecSource() -print("TC Description - Verify that default OSD Name is obtained in output response") -# send the curl command and fetch the output json response -print("---------------------------------------------------------------------------------------------------------------------------") -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_osd_name) -if curl_response: - Utils.info_log("curl command send for get_osd_name") -else: - Utils.error_log("curl command send for get_osd_name failed") -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The default OSD Name is obtained ' \ - 'in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID004_getOSDName_default' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) -Utils.initiliaze_flask_for_HdmiCecSource() diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID005.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID005.py deleted file mode 100644 index 590a42382..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID005.py +++ /dev/null @@ -1,74 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID005 -# Testcase Description : Set the OSD Name to new one using curl command and verify that new -# OSD Name set by the test user is obtained in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Set the OSD Name to new one using curl command and verify that new OSD Name set by the test user is obtained in output response") -Utils.initiliaze_flask_for_HdmiCecSource() -print("---------------------------------------------------------------------------------------------------------------------------") -# send the curl command to set the new OSD Name -set_response = Utils.send_curl_command(HdmiCecSourceApis.set_osd_name) -if set_response: - Utils.info_log(" sent the curl command to set the new OSD Name") -else: - Utils.error_log("curl command sent to get the new OSD name failed") -print("") -# store the expected output response of testcase -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"name":"CUSTOM8 TV","success":true}}' - -# send the curl command to get OSD Name and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_osd_name) -if curl_response: - Utils.warning_log("send the curl command to get_osd_name") -else: - Utils.warning_log("curl command send failed to get_osd_name") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The new OSD Name given by user ' \ - 'is obtained in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' -Utils.initiliaze_flask_for_HdmiCecSource() -# generate logs in terminal -tc_id = 'TCID005_setOSDName_to_new' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID006.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID006.py deleted file mode 100644 index 8eae87b87..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID006.py +++ /dev/null @@ -1,65 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID006 -# Testcase Description : Verify that cec enable status is true in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"enabled":true,"success":true}}' - -print("TC Description - Verify that cec enable status is true in output response") -print("---------------------------------------------------------------------------------------------------------------------------") -Utils.initiliaze_flask_for_HdmiCecSource() -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_enabled) -if curl_response: - Utils.info_log("curl command send for get_enabled") -else: - Utils.error_log("curl command send failed for get_enabled") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The cec enable status is true' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID006_getEnabled_CEC_enabled' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID007.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID007.py deleted file mode 100644 index 83e9b8d0a..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID007.py +++ /dev/null @@ -1,77 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID007 -# Testcase Description : Set the cec enable status to false and verify that cec enable -# status is false in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -print(" TC Description - Set the cec enable status to false and verify that cec enable status is false in output response") -# send the curl command to set the cec enable status to false -Utils.initiliaze_flask_for_HdmiCecSource() -print("---------------------------------------------------------------------------------------------------------------------------") -set_response = Utils.send_curl_command(HdmiCecSourceApis.set_enabled_false) -if set_response: - Utils.warning_log("send the curl command to set the cec enable status to false is success") -else: - Utils.error_log("send the curl command to set the cec enable status to false failed") -print("") -# store the expected output response of testcase -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"enabled":false,"success":true}}' - -# send the curl command to get enable status of cec and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_enabled) -if curl_response: - Utils.info_log("send the curl command to get enable status of cec and fetch the output json response is success") -else: - Utils.error_log("send the curl command to get enable status of cec and fetch the output json response is failed") -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The cec enabled status is obtained ' \ - 'as false in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# set the cec enable status to true as a post condition -Utils.send_curl_command(HdmiCecSourceApis.set_enabled_true) -Utils.info_log("Reset the set enabled to TRUE") - -# generate logs in terminal -tc_id = 'TCID007_setEnabled_CEC_False' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID008.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID008.py deleted file mode 100644 index 5b7925f13..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID008.py +++ /dev/null @@ -1,67 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID008 -# Testcase Description : Hit the curl command for getActiveSourceStatus method and -# verify that status is obtained as false in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"status":false,"success":true}}' - -print("TC Description - Hit the curl command for getActiveSourceStatus method and verify that status is obtained as false in output response") - -print("---------------------------------------------------------------------------------------------------------------------------") -# send the curl command and fetch the output json response -Utils.initiliaze_flask_for_HdmiCecSource() -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_active_source_status) -if curl_response: - Utils.info_log("curl command send for get_active_source") -else: - Utils.error_log("curl command send failed for get_active_source") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID008_getActiveSourceStatus_false' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID009.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID009.py deleted file mode 100644 index 62ef669e2..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID009.py +++ /dev/null @@ -1,67 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID009 -# Testcase Description : Verify that otp enabled status is true in output response - -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"enabled":true,"success":true}}' - -print("TC Description - Verify that otp enabled status is true in output response") -Utils.initiliaze_flask_for_HdmiCecSource() -print("---------------------------------------------------------------------------------------------------------------------------") -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_otp_enabled) -if curl_response: - Utils.info_log("curl command send for get_otp_enabled") -else: - Utils.error_log("curl command send for get_otp_enabled failed") -print("") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The otp enabled status is true' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID009_getOTPEnabled_true' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID010.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID010.py deleted file mode 100644 index 65e19906e..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID010.py +++ /dev/null @@ -1,76 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID010 -# Testcase Description : Set the OTP enabled status to false and verify that otp enabled -# status is false in output response. Change the OTP enabled status back to true as post condition - -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -print("TC Description - Set the OTP enabled status to false and verify that otp enabled status is false in output response. Change the OTP enabled status back to true as post condition") -print("---------------------------------------------------------------------------------------------------------------------------") -# send the curl command to set the otp enabled status to false -set_response = Utils.send_curl_command(HdmiCecSourceApis.set_otp_enabled_false) -if set_response: - Utils.warning_log("send the curl command to set the otp enabled status to false is success") -else: - Utils.error_log("send the curl command to set the otp enabled status to false is failed") -print("") -# store the expected output response of testcase -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"enabled":false,"success":true}}' - -# send the curl command to get enabled status of otp and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_otp_enabled) -if curl_response: - Utils.info_log("curl command send for get_otp_enabled") -else: - Utils.error_log("curl command send for get_otp_enabled failed") -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The otp enabled status is obtained ' \ - 'as false in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' -print("") -# set the otp enable status to true as a post condition -Utils.send_curl_command(HdmiCecSourceApis.set_otp_enabled_true) -Utils.info_log("Reset OTP to its initial state") - -# generate logs in terminal -tc_id = 'TCID010_setOTPEnabled_false' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID011.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID011.py deleted file mode 100644 index c2ffa8bd5..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID011.py +++ /dev/null @@ -1,75 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID011 -# Testcase Description : Hit the curl command for sendKeyPressEvent and -# verify that output response is correct - -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' -Utils.initiliaze_flask_for_HdmiCecSource() - -keypress = [HdmiCecSourceApis.send_keypress_VOLUME_UP, HdmiCecSourceApis.send_keypress_VOLUME_DOWN, HdmiCecSourceApis.send_keypress_MUTE, - HdmiCecSourceApis.send_keypress_UP, HdmiCecSourceApis.send_keypress_DOWN, HdmiCecSourceApis.send_keypress_LEFT, - HdmiCecSourceApis.send_keypress_RIGHT, HdmiCecSourceApis.send_keypress_SELECT, HdmiCecSourceApis.send_keypress_HOME, - HdmiCecSourceApis.send_keypress_BACK, HdmiCecSourceApis.send_keypress_NUMBER_0, HdmiCecSourceApis.send_keypress_NUMBER_1, - HdmiCecSourceApis.send_keypress_NUMBER_2, HdmiCecSourceApis.send_keypress_NUMBER_3, HdmiCecSourceApis.send_keypress_NUMBER_4, - HdmiCecSourceApis.send_keypress_NUMBER_5, HdmiCecSourceApis.send_keypress_NUMBER_6, HdmiCecSourceApis.send_keypress_NUMBER_7, - HdmiCecSourceApis.send_keypress_NUMBER_8, HdmiCecSourceApis.send_keypress_NUMBER_9] -print("TC Description - Hit the curl command for sendKeyPressEvent and verify that output response is correct") -print("---------------------------------------------------------------------------------------------------------------------------") -# send the curl command and fetch the output json response -for command in keypress: - curl_response = Utils.send_curl_command(command) - -if curl_response: - Utils.info_log("curl command send for send_keypress_event") -else: - Utils.error_log("curl command send failed") -print("") -# compare both expected and received output responses -print("---------------------------------------------------------------------------------------------------------------------------") -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID011_sendKeyPressEvent' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID012.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID012.py deleted file mode 100644 index c51729f25..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID012.py +++ /dev/null @@ -1,150 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID012 -# Testcase Description : Set the devices to standby mode and wake up the remote device using otp feature -# Hit the curl command for sendStandbyMessage and send corresponding cec messages using sendMessage API -# to hal. Then hit the curl command for perform OTP Action and send corresponding cec messages to hal. -# Then hit the curl command for getActiveSourceStatus and verify that status is true in output response. -# Deactivate and reactivate the HdmiCecSource plugin. Then hit the curl command for getActiveSourceStatus -# and verify that status is back to default(false) in output response.Verify the thunder logs for more info. - -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# Utils.restart_services() -print(" TC Description - Set the devices to standby mode and wake up the remote device using otp feature.Hit the curl command for sendStandbyMessage and send corresponding cec messages using sendMessage API to hal. Then hit the curl command for perform OTP Action and send corresponding cec messages to hal.Then hit the curl command for getActiveSourceStatus and verify that status is true in output response.Deactivate and reactivate the HdmiCecSource plugin. Then hit the curl command for getActiveSourceStatus and verify that status is back to default(false) in output response.Verify the thunder logs for more info. send the curl command to send the standby messages to devices") -Utils.initiliaze_flask_for_HdmiCecSource() -print("---------------------------------------------------------------------------------------------------------------------------") -set_response = Utils.send_curl_command(HdmiCecSourceApis.send_standby_message) -if set_response: - Utils.info_log("curl command send for standby_message") -else: - Utils.error_log("curl command send failed for sending standby_message") -print("") - -# send messages required for getting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message2_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.getPowerStatusMessage))) -time.sleep(3) -if "200" in str(message2_response): - Utils.info_log("send the emulated message for get power status success") -else: - Utils.error_log("emulated message for get power status is failed") -print("") - -# send messages required for reporting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message2_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportPowerStatusMessage))) -time.sleep(3) -if "200" in str(message2_response): - Utils.info_log("send the emulated message for report power status success") -else: - Utils.error_log("emulated message for report power status is failed") -print("") - -# send the curl command to perform OTP action -print("---------------------------------------------------------------------------------------------------------------------------") -curl_response = Utils.send_curl_command(HdmiCecSourceApis.perform_otp_action) -if curl_response: - Utils.warning_log("curl command send for perform_otp_action") -else: - Utils.error_log("curl command send failed for perform_otp_action") -print("") - -# send messages required for getting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message4_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.getPowerStatusMessage))) -time.sleep(3) -if "200" in str(message4_response): - Utils.info_log("send emulated message for get power status success") -else: - Utils.error_log("send emulated message for get power status failed") -print("") - -# send messages required for reporting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message4_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportPowerStatusMessage))) -time.sleep(3) -if "200" in str(message2_response): - Utils.info_log("send the emulated message for report power status success") -else: - Utils.error_log("emulated message for report power status is failed") -print("") - -# store the expected output response of testcase before deactivating plugin -expected_output_response1 = '{"jsonrpc":"2.0","id":42,"result":{"status":true,"success":true}}' - -# store the expected output response of testcase after deactivating and reactivating plugin -expected_output_response2 = '{"jsonrpc":"2.0","id":42,"result":{"status":false,"success":true}}' - -# send the curl command for getActiveSourceStatus before deactivating plugin -curl_response1 = Utils.send_curl_command(HdmiCecSourceApis.get_active_source_status) - -if curl_response1: - Utils.info_log("send the curl command for getActiveSourceStatus before deactivating plugin success") -else: - Utils.error_log("send the curl command for getActiveSourceStatus before deactivating plugin failed") -print("") - -Utils.warning_log("deactivate and activate the plugin") -Utils.send_curl_command(HdmiCecSourceApis.deactivate_command) -Utils.send_curl_command(HdmiCecSourceApis.activate_command) - -# send the curl command for getActiveSourceStatus after deactivating and reactivating plugin -curl_response2 = Utils.send_curl_command(HdmiCecSourceApis.get_active_source_status) -if curl_response2: - Utils.info_log("send the curl command for getActiveSourceStatus after deactivating and reactivating plugin success") -else: - Utils.error_log("send the curl command for getActiveSourceStatus after deactivating and reactivating plugin failed") -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response1) == str(expected_output_response1) and str(curl_response2) == str(expected_output_response2): - status = 'Pass' - message = 'Output response is matching with expected one. The active source status is switching properly' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID012_sendStandbyMessage_performOTPAction_getActiveSourceStatus' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response1) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response1, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID013.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID013.py deleted file mode 100644 index da0e4006f..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID013.py +++ /dev/null @@ -1,69 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID013 -# Testcase Description : To verify all remote devices given by test user during hal initialization -# is present in output response with device details - -import time -from HdmiCecSource import HdmiCecSourceApis -from Utilities import Utils, ReportGenerator - -# Utils.restart_services() -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"numberofdevices":3,"deviceList":[{"logicalAddress":0,"osdName":"TV Box","vendorID":"04567"},{"logicalAddress":5,"osdName":"","vendorID":"4567"},{"logicalAddress":9,"osdName":"Streaming One","vendorID":"4567"}],"success":true}}' - -# send the curl command and fetch the output json response -# Utils.send_curl_command(HdmiCecSourceApis.get_device_list) -# time.sleep(10) -# Utils.send_curl_command(HdmiCecSourceApis.get_device_list) -# time.sleep(10) -Utils.send_curl_command(HdmiCecSourceApis.get_device_list) -time.sleep(3) -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_device_list) - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID013_getDeviceList_verify_all_remote_devices' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - - - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID014.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID014.py deleted file mode 100644 index 12ae24622..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID014.py +++ /dev/null @@ -1,76 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID014 -# Testcase Description : Add a new device to cec network and verify that new device data is listing -# in output response - -import requests -import json -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# Utils.restart_services() -# add afs device to network -add_device_response = requests.get("http://{}/Database.updateDeviceConfig/addDevice/{}".format( - Config.flask_server_ip, json.dumps(Config.hisense_device_data))) -print("Inside TCID014 : " + add_device_response.text + " : " + str(Config.hisense_device_data)) -time.sleep(3) - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"numberofdevices":4,"deviceList":[{"logicalAddress":0,"osdName":"TV Box","vendorID":"04567"},{"logicalAddress":5,"osdName":"","vendorID":"4567"},{"logicalAddress":6,"osdName":"TV Box","vendorID":"04567"},{"logicalAddress":9,"osdName":"Streaming One","vendorID":"4567"}],"success":true}}' - -# send the curl command and fetch the output json response -# Utils.send_curl_command(HdmiCecSourceApis.get_device_list) -# time.sleep(10) -# Utils.send_curl_command(HdmiCecSourceApis.get_device_list) -# time.sleep(10) -Utils.send_curl_command(HdmiCecSourceApis.get_device_list) -time.sleep(3) -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_device_list) - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The newly added HiSense device is ' \ - 'listed in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID014_getDeviceList_Add_new_device' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID015.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID015.py deleted file mode 100644 index 5e4933c4c..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID015.py +++ /dev/null @@ -1,83 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID015 -# Testcase Description : Add a new invalid device to cec network and verify that invalid device data -# is ignored in output response - -import requests -import json -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis -from HdmiCecSource import CecUtils - -# store the expected output response before adding invalid device data -expected_output_response = Utils.send_curl_command(HdmiCecSourceApis.get_device_list) - -# add an invalid device to network -add_device_response = requests.get("http://{}/Database.updateDeviceConfig/addDevice/{}".format( - Config.flask_server_ip, json.dumps(Config.invalid_device_data))) -print("Inside TCID015 : " + add_device_response.text + " : " + str(Config.invalid_device_data)) -time.sleep(3) - -# send the curl command after adding invalid device data and fetch the output json response -# Utils.send_curl_command(HdmiCecSourceApis.get_device_list) -# time.sleep(10) -# Utils.send_curl_command(HdmiCecSourceApis.get_device_list) -# time.sleep(10) -Utils.send_curl_command(HdmiCecSourceApis.get_device_list) -time.sleep(3) -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_device_list) - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response) and len(curl_response) > 5: - status = 'Pass' - message = 'Output response is matching with expected one. The newly added invalid device ' \ - 'is not listed in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID015_getDeviceList_Add_an_invalid_device' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - -# post condition - restart thunder & websocket - then activate plugin again -# time.sleep(15) -# Utils.restart_services() -# time.sleep(15) -# CecUtils.activate_cec() -# time.sleep(15) -print("") diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID016.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID016.py deleted file mode 100644 index ac5114ef2..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID016.py +++ /dev/null @@ -1,91 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID016 -# Testcase Description : Verify that cec enable status is true initially. Then we change the return value -# of HdmiCecOpen as -1 using updateAPIConfig. Deactivate and reactivate the HdmiCecSource plugin. -# After that hit the curl command and verify that cec enable status changed to false. Perform the post-condition -# to revert the changes back to default state - -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import CecUtils -from HdmiCecSource import HdmiCecSourceApis - -print("Testcase Description - Verify that cec enable status is true initially. Then we change the return value of HdmiCecOpen as -1 using updateAPIConfig. Deactivate and reactivate the HdmiCecSource plugin. After that hit the curl command and verify that cec enable status changed to false. Perform the post-condition to revert the changes back to default state store the expected output response with HdmiCecOpen return value as 0") -print("---------------------------------------------------------------------------------------------------------------------------") -expected_output_response1 = '{"jsonrpc":"2.0","id":42,"result":{"enabled":true,"success":true}}' - -# store the expected output response with HdmiCecOpen return value as -1 -expected_output_response2 = '{"jsonrpc":"2.0","id":42,"result":{"enabled":false,"success":true}}' -Utils.initiliaze_flask_for_HdmiCecSource() -# send the curl command and fetch the output json response with HdmiCecOpen return value as 0 -curl_response1 = Utils.send_curl_command(HdmiCecSourceApis.get_enabled) -if curl_response1: - Utils.info_log("send the curl command for get_enabled") -else: - Utils.error_log("send curl command for get_enabled failed") -print("") -# change the return value of HdmiCecOpen hal API to -1 using updateAPIConfig API -update_api=CecUtils.cec_update_api_overrides(Config.cec_minus_one) -if update_api: - Utils.info_log("configuring the return value of HdmiCecOpen as -1 using flask api") -else: - Utils.error_log("failed to configure the return value of HdmiCecOpen as -1") -print("") -# send the curl command and fetch the output json response with HdmiCecOpen return value as -1 -curl_response2 = Utils.send_curl_command(HdmiCecSourceApis.get_enabled) -if curl_response2: - Utils.info_log("curl command send for get_enabled") -else: - Utils.error_log("curl command send for get_enabled failed") -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response1) == str(expected_output_response1) and str(curl_response2) == str(expected_output_response2): - status = 'Pass' - message = 'Output response is matching with expected one. The cec enable status is true initially and ' \ - 'after changing the return value, cec enable status changed to false' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID016_getEnabled_False_HAL_value' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response2) -print("Testcase Status : " + status) -print("Testcase Message : " + message) - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response2, status, message) - -# post condition : change the return value of HdmiCecOpen hal API back to 0 -# post = CecUtils.cec_post_condition_for_negative_scenarios() -print("") -Utils.initiliaze_flask_for_HdmiCecSource() -Utils.warning_log("Reset - changed the return value of HdmiCecOpen hal API back to 0") - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID017.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID017.py deleted file mode 100644 index 1b350a1c9..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID017.py +++ /dev/null @@ -1,79 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID017 -# Testcase Description : To verify that standby message is throwing error when return value for -# HdmiCecOpen is changed to -1. Change the return value of HdmiCecOpen as -1 using updateAPIConfig. -# Deactivate and reactivate the HdmiCecSource plugin. After that hit the curl command and verify -# that output is having error message. Perform the post-condition to revert the changes back to default state - -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import CecUtils -from HdmiCecSource import HdmiCecSourceApis - -post = CecUtils.cec_post_condition_for_negative_scenarios() -print("TC Description - To verify that standby message is throwing error when return value for HdmiCecOpen is changed to -1. Change the return value of HdmiCecOpen as -1 using updateAPIConfig. Deactivate and reactivate the HdmiCecSource plugin. After that hit the curl command and verify that output is having error message. Perform the post-condition to revert the changes back to default state change the return value of HdmiCecOpen hal API to -1 using updateAPIConfig API") -print("---------------------------------------------------------------------------------------------------------------------------") -Utils.initiliaze_flask_for_HdmiCecSource() -CecUtils.cec_update_api_overrides(Config.cec_minus_one) -Utils.info_log("Updating HdmiCecOpen HAL API return value to -1") -print("") -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"error":{"code":1,"message":"ERROR_GENERAL"}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.send_standby_message) -if curl_response: - Utils.info_log("curl command sent with return value -1 on HdmiCecOpen HAL api") -else: - Utils.error_log("curl command sent failed with return value -1 on HdmiCecOpen HAL api") -print("") -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. We are getting error in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID017_sendStandbyMessage_HAL_False' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) -Utils.initiliaze_flask_for_HdmiCecSource() - -# post condition : change the return value of HdmiCecOpen hal API back to 0 -# CecUtils.cec_post_condition_for_negative_scenarios() -Utils.warning_log("Reset - change the return value of HdmiCecOpen hal API back to 0") -print("") diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID018.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID018.py deleted file mode 100644 index 5d4ccd383..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID018.py +++ /dev/null @@ -1,77 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID018 -# Testcase Description : To verify that perform OTP Action is throwing error when return value for -# HdmiCecOpen is changed to -1. Change the return value of HdmiCecOpen as -1 using updateAPIConfig. -# Deactivate and reactivate the HdmiCecSource plugin. After that hit the curl command and verify -# that output is having error message. Perform the post-condition to revert the changes back to default state - -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import CecUtils -from HdmiCecSource import HdmiCecSourceApis - -post = CecUtils.cec_post_condition_for_negative_scenarios() -print("TC Description - To verify that perform OTP Action is throwing error when return value for HdmiCecOpen is changed to -1. Change the return value of HdmiCecOpen as -1 using updateAPIConfig. Deactivate and reactivate the HdmiCecSource plugin. After that hit the curl command and verify that output is having error message. Perform the post-condition to revert the changes back to default state change the return value of HdmiCecOpen hal API to -1 using updateAPIConfig API") -print("---------------------------------------------------------------------------------------------------------------------------") -Utils.initiliaze_flask_for_HdmiCecSource() -CecUtils.cec_update_api_overrides(Config.cec_minus_one) -Utils.info_log("Updated HdmiCecOpen HAL API return values to -1") -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"error":{"code":1,"message":"ERROR_GENERAL"}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.perform_otp_action) -if curl_response: - Utils.info_log("sending the curl command for perform_otp_action") -else: - Utils.error_log("curl command send failed for perform_otp_action") -print("") -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. We are getting error in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID018_performOTPAction_HAL_False' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) -Utils.initiliaze_flask_for_HdmiCecSource() -# post condition : change the return value of HdmiCecOpen hal API back to 0 -# CecUtils.cec_post_condition_for_negative_scenarios() -Utils.warning_log("Reset- change the return value of HAL APIs back to 0") -print("") diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID019.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID019.py deleted file mode 100644 index 306dc5d4a..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID019.py +++ /dev/null @@ -1,84 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID019 -# Testcase Description : To verify the device list is empty and number of devices is 0 in output response -# for getDeviceList curl command when return value of HdmiCecOpen is changed to -1. Change the return -# value of HdmiCecOpen as -1 using updateAPIConfig. Deactivate and reactivate the HdmiCecSource plugin. -# After that hit the curl command and verify that the device list is empty. Perform the post-condition -# to revert the changes back to default state - -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import CecUtils -from HdmiCecSource import HdmiCecSourceApis - -post = CecUtils.cec_post_condition_for_negative_scenarios() -# change the return value of HdmiCecOpen hal API to -1 using updateAPIConfig API -print("TC Description - To verify the device list is empty and number of devices is 0 in output response for getDeviceList curl command when return value of HdmiCecOpen is changed to -1. Change the return value of HdmiCecOpen as -1 using updateAPIConfig. Deactivate and reactivate the HdmiCecSource plugin. After that hit the curl command and verify that the device list is empty. Perform the post-condition to revert the changes back to default state") -Utils.initiliaze_flask_for_HdmiCecSource() -CecUtils.cec_update_api_overrides(Config.cec_minus_one) -Utils.info_log("change the return value of HdmiCecOpen hal API to -1 using updateAPIConfig API") -print("") - -print("---------------------------------------------------------------------------------------------------------------------------") -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"numberofdevices":0,"deviceList":[],"success":true}}' - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_device_list) -if curl_response: - Utils.info_log("curl command send for get_device_list") -else: - Utils.error_log("curl command send failed for get_device_list") -print("") -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. The device list is empty and number of devices' \ - 'is 0 in output response' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID019_getDeviceList_HAL_False' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - -# post condition : change the return value of HdmiCecOpen hal API back to 0 -CecUtils.cec_post_condition_for_negative_scenarios() -Utils.initiliaze_flask_for_HdmiCecSource() -Utils.warning_log("Reset - change the return values of HAL APIs back to 0") -print("") - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID020.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID020.py deleted file mode 100644 index 19ffe8e66..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID020.py +++ /dev/null @@ -1,95 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID020 -# Testcase Description : getVendorId - Invalid data - -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"vendorid":"019fb","success":true}}' - -print("TC Description - getVendorId - Invalid data") -Utils.initiliaze_flask_for_HdmiCecSource() -time.sleep(3) -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.set_vendor_id) -if curl_response: - Utils.warning_log("set vendor id curl command sent from the test runner") -else: - Utils.error_log("set vendor id curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_vendor_id) -if curl_response: - Utils.warning_log("get vendor id curl command sent from the test runner") -else: - Utils.error_log("get vendor id curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.set_vendor_id_invalid_1) -if curl_response: - Utils.warning_log("set vendor id invalid curl command sent from the test runner") -else: - Utils.error_log("set vendor id invalid curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_vendor_id) -if curl_response: - Utils.warning_log("get vendor id curl command sent from the test runner") -else: - Utils.error_log("get vendor id curl command failed") - -post_condition = Utils.send_curl_command(HdmiCecSourceApis.set_vendor_id) - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one.' -else: - status = 'Fail' - message = 'Output response is different from expected one.' - -# generate logs in terminal -tc_id = 'TCID020_getVendorId - Invalid data' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) -Utils.initiliaze_flask_for_HdmiCecSource() - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID021.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID021.py deleted file mode 100644 index 2f48bfc62..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID021.py +++ /dev/null @@ -1,107 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID021 -# Testcase Description : Coverage enhancements - -import subprocess -import os -import signal -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - - -process_name_cec ="CecDaemonMain" -output = subprocess.check_output(["ps", "aux"]) - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":3,"result":null}' - -print("TC Description - To verify coverage enhancements") -Utils.initiliaze_flask_for_HdmiCecSource() -time.sleep(3) -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.deactivate_command) -if curl_response: - Utils.warning_log("Deactivate curl command sent from the test runner") -else: - Utils.error_log("Deactivate curl command failed") - -try: - pids = [] - # Parse the output to find the PID - for line in output.decode().splitlines(): - if process_name_cec in line: - pid = int(line.split()[1]) - pids.append(pid) - print("killing CEC Daemon") - else: - pass - - if pids is not None: - for each_pid in pids: - try: - os.system("kill -9 %s" % (each_pid, )) - except: - print("process already killed") - else: - print("They are no services up wrt HAL Mock setup") -except: - pass - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.activate_command) -if curl_response: - Utils.warning_log("activate curl command sent from the test runner") -else: - Utils.error_log("activate curl command failed") - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one. We are expecting opcode : 36 in thunder logs' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID021_coverage enhancements' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID022.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID022.py deleted file mode 100644 index 6e93d8b5a..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID022.py +++ /dev/null @@ -1,230 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID022 -# Testcase Description : To verify the emulation of the processes which are triggered when 3 devices are connected. -# Initially, when all the devices are on,one device will be an inactive source and another will be an active source. -# After that, the devices go into standby and the user sets the the other device into active source. The devices are then woken up using the one-touch play feature. -# After waking up, one device will be an active source, while the other will be an inactive source. -# As the device enters the active state, it may trigger the text view on and image view on processes also as a result. -import subprocess -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -print("TC Description - To verify the emulation of the processes which are triggered when 3 devices are connected. Send the corresponding messages for HAL. Hit the curlcommand for sendStandbyMessage and performOTPAction. Send the corresponding messages to hal. Verify the output response. One source will be active and the other inactive and vice-versa. Verify that the text view on and the image view on processes are also triggered.") - -Utils.initiliaze_flask_for_HdmiCecSource() -time.sleep(3) -#send messages required for getting inactive source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") - -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.send_standby_message) -if curl_response: - Utils.warning_log("send_standby_message curl command sent from the test runner") -else: - Utils.error_log("send_standby_message curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.perform_otp_action) -if curl_response: - Utils.warning_log("perform_otp_action curl command sent from the test runner") -else: - Utils.error_log("perform_otp_action curl command failed") - -#send messages required for getting inactive source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") - -#send messages required for set stream path -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_stream_path_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for set stream path to hisense") -else: - Utils.error_log("sendMessage emulation failed for set stream path to hisense") -time.sleep(3) -print("") - -#send messages required for routing change -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_change))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for routing change to hisense") -else: - Utils.error_log("sendMessage emulation failed for routing change to hisense") -time.sleep(3) -print("") - -#send messages required for routing information -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_information_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying routing information from hisense") -else: - Utils.error_log("sendMessage emulation failed for querying routing information from hisense") -time.sleep(3) -print("") - -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - -#send messages required for image view on -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.image_view_on))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the image view on") -else: - Utils.error_log("sendMessage emulation failed for querying the image view on") -time.sleep(3) -print("") - -#send messages required for getting text view on -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.text_view_on))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the text view on") -else: - Utils.error_log("sendMessage emulation failed for querying the text view on") -time.sleep(3) -print("") - -#send messages required for getting osd string -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_osd_string))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for getting the osd string") -else: - Utils.error_log("sendMessage emulation failed for getting the osd string") -time.sleep(3) -print("") - - -#send messages required for getting device power status -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.give_device_power_status_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the power status") -else: - Utils.error_log("sendMessage emulation failed for querying the power status") -time.sleep(3) -print("") - -#send messages required for getting osd name -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.give_osd_name_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the osd name") -else: - Utils.error_log("sendMessage emulation failed for querying the osd name") -time.sleep(3) -print("") - - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one.' -else: - status = 'Fail' - message = 'Output response is different from expected one.' - -# generate logs in terminal -tc_id = 'TCID022_process emulation' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) -Utils.initiliaze_flask_for_HdmiCecSource() -op=Utils.netstat_output() -print(op) - - - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID023.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID023.py deleted file mode 100644 index 7ff13589f..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID023.py +++ /dev/null @@ -1,135 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID023 -# Testcase Description : To verify the emulation of the processes which are triggered when 3 devices are connected. -# Initially, when all the devices are on,one device will be querying the menu language of another device. The device will be setting the menu language. Also the cec version will be queried. -import subprocess -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":3,"result":null}' - -print("TC Description - To verify the emulation of the processes which are triggered when 3 devices are connected. Send the corresponding messages for HAL. Hit the curlcommand for plugin activation. Verify the output response. The menu language and the cec version will be queried and the messages which are given will be returned.") -Utils.initiliaze_flask_for_HdmiCecSource() -time.sleep(3) -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.activate_command) -if curl_response: - Utils.warning_log("activate curl command sent from the test runner") -else: - Utils.error_log("activate curl command failed") - -#send messages required for getting physical address -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.give_physical_address_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the physical address") -else: - Utils.error_log("sendMessage emulation failed for querying the physical address") -time.sleep(3) -print("") - -#send messages required for getting menu language -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.get_menu_language_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the menu language") -else: - Utils.error_log("sendMessage emulation failed for querying the menu language") -time.sleep(3) -print("") - -#send messages required for setting menu language -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_menu_language))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for setting the menu language") -else: - Utils.error_log("sendMessage emulation failed for setting the menu language") -time.sleep(3) -print("") - -#send messages required for ignoring a menu language of another device -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.ignore_set_menu_language))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for ignoring the menu language") -else: - Utils.error_log("sendMessage emulation failed for ignoring the menu language") -time.sleep(3) -print("") - -#send messages required for getting cec version -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.get_cec_version))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the cec version") -else: - Utils.error_log("sendMessage emulation failed for querying the cec version") -time.sleep(3) -print("") - -#send messages required for returning the cec version -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.cec_version))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for giving the cec version") -else: - Utils.error_log("sendMessage emulation failed for giving the cec version") -time.sleep(3) -print("") - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one.' -else: - status = 'Fail' - message = 'Output response is different from expected one.' - -# generate logs in terminal -tc_id = 'TCID023_process emulation' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) -Utils.initiliaze_flask_for_HdmiCecSource() -op=Utils.netstat_output() -print(op) - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID024.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID024.py deleted file mode 100644 index 814ce87a4..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID024.py +++ /dev/null @@ -1,95 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID024 -# Testcase Description : To verify the emulation processes - abort and feature abort -import subprocess -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":3,"result":null}' - -print("TC Description - To verify the emulation of the processes - abort and feature abort.") -Utils.initiliaze_flask_for_HdmiCecSource() -time.sleep(3) -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.activate_command) -if curl_response: - Utils.warning_log("activate curl command sent from the test runner") -else: - Utils.error_log("activate curl command failed") - -#send messages required for abort -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.abort_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for abort") -else: - Utils.error_log("sendMessage emulation failed for abort") -time.sleep(3) -print("") - -#send messages required for feature abort -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.feature_abort_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the abort reason") -else: - Utils.error_log("sendMessage emulation failed for querying the abort reason") -time.sleep(3) -print("") - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one.' -else: - status = 'Fail' - message = 'Output response is different from expected one.' - -# generate logs in terminal -tc_id = 'TCID024_process emulation' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) - -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) -Utils.initiliaze_flask_for_HdmiCecSource() -op=Utils.netstat_output() -print(op) - - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID025.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID025.py deleted file mode 100644 index 9bb0e616b..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID025.py +++ /dev/null @@ -1,86 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID025 -# Testcase Description : To verify the emulation of sending of events - -import subprocess -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis -import time - - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":3,"result":null}' - -print("TC Description - To verify the emulation of sending of events.") -Utils.initiliaze_flask_for_HdmiCecSource() -time.sleep(3) -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.activate_command) -time.sleep(1) -if curl_response: - Utils.warning_log("activate curl command sent from the test runner") -else: - Utils.error_log("activate curl command failed") - -#Define the script to be executed -execute_script = '../../../../../sendEvents.sh' - - -#Execute the script -try: - result = subprocess.run(['/bin/bash', execute_script], check=True, capture_output=True, text=True) - print("sendEvents.sh executed successfully.") - print("Output:\n", result.stdout) - -except subprocess.CalledProcessError as e: - print("Error occured while executing the shell script.") - print("Error message:\n", e.stderr) - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one.' -else: - status = 'Fail' - message = 'Output response is different from expected one.' - -# generate logs in terminal -tc_id = 'TCID025_sending events' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID026.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID026.py deleted file mode 100644 index 9831b4925..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID026.py +++ /dev/null @@ -1,161 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -#TCID026 - standby scenario. Device already set on standby and again set to standby. - -import subprocess -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -print(" TC Description - Set the devices to standby mode and hit the sendStandbyMessage curl command again. Then wake up the remote device using otp feature.First, set the device to standby mode via emulation. Next, hit the curl command for sendStandbyMessage and send corresponding cec messages using sendMessage API to hal. Then hit the curl command for perform OTP Action and send corresponding cec messages to hal.Verify the thunder logs for more info.") - -Utils.initiliaze_flask_for_HdmiCecSource() -time.sleep(3) -# send messages required for getting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") - -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"success":true}}' - -message2_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.sendStandbyMessage))) -time.sleep(3) -if "200" in str(message2_response): - Utils.info_log("send the emulated message for standby success") -else: - Utils.error_log("emulated message for standby failed") -print("") - - - -# send messages required for getting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message2_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.getPowerStatusMessage))) -time.sleep(3) -if "200" in str(message2_response): - Utils.info_log("send the emulated message for get power status success") -else: - Utils.error_log("emulated message for get power status is failed") -print("") - -# send messages required for reporting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message2_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportPowerStatusMessage))) -time.sleep(3) -if "200" in str(message2_response): - Utils.info_log("send the emulated message for report power status success") -else: - Utils.error_log("emulated message for report power status is failed") -print("") - - -print("---------------------------------------------------------------------------------------------------------------------------") -#curl command for send standby message -set_response = Utils.send_curl_command(HdmiCecSourceApis.send_standby_message) -if set_response: - Utils.info_log("curl command send for standby_message") -else: - Utils.error_log("curl command send failed for sending standby_message") -print("") - -# send messages required for getting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message2_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.getPowerStatusMessage))) -time.sleep(3) -if "200" in str(message2_response): - Utils.info_log("send the emulated message for get power status success") -else: - Utils.error_log("emulated message for get power status is failed") -print("") - -# send messages required for reporting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message2_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportPowerStatusMessage))) -time.sleep(3) -if "200" in str(message2_response): - Utils.info_log("send the emulated message for report power status success") -else: - Utils.error_log("emulated message for report power status is failed") -print("") - -# send the curl command to perform OTP action -print("---------------------------------------------------------------------------------------------------------------------------") -curl_response = Utils.send_curl_command(HdmiCecSourceApis.perform_otp_action) -if curl_response: - Utils.warning_log("curl command send for perform_otp_action") -else: - Utils.error_log("curl command send failed for perform_otp_action") -print("") - -# send messages required for getting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message4_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.getPowerStatusMessage))) -time.sleep(3) -if "200" in str(message4_response): - Utils.info_log("send emulated message for get power status success") -else: - Utils.error_log("send emulated message for get power status failed") -print("") - -# send messages required for reporting power status of device -print("---------------------------------------------------------------------------------------------------------------------------") -message4_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.reportPowerStatusMessage))) -time.sleep(3) -if "200" in str(message2_response): - Utils.info_log("send the emulated message for report power status success") -else: - Utils.error_log("emulated message for report power status is failed") -print("") - -print("---------------------------------------------------------------------------------------------------------------------------") -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID026_sendStandbyMessage_performOTPAction_fromStandby' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID027.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID027.py deleted file mode 100644 index c58277514..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID027.py +++ /dev/null @@ -1,156 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID027 -# Testcase Description : To verify that the getActiveourceStatus scenario is true after set stream path and routing change. -# Initially, the getActiveSourceStatus curl command will return a false status. When all the devices are on,one device will be an inactive source and another will be an active source. -# After that, the stream path and routing is changed. The device which was inactive becomes active and vice-versa. The devices are then woken up using the one-touch play feature. -# After waking up, the getActiveSourceStatus curl command will return a true status. - -import subprocess -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"status":true,"success":true}}' - -print("TC Description - To verify that the getActiveSourceStatus curl command returns a true status after set stream path and routing change.") -Utils.initiliaze_flask_for_HdmiCecSource() -time.sleep(3) -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_active_source_status) -if curl_response: - Utils.info_log("curl command send for get_active_source") -else: - Utils.error_log("curl command send failed for get_active_source") - -#send messages required for getting inactive source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.inactive_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the inactive source") -else: - Utils.error_log("sendMessage emulation failed for querying the inactive source") -time.sleep(3) -print("") - -#send messages required for requesting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.request_active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for requesting the active source") -else: - Utils.error_log("sendMessage emulation failed for requesting the active source") -time.sleep(3) -print("") -#send messages required for getting active source -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_firestick1))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - -#send messages required for set stream path -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.set_stream_path_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for set stream path to hisense") -else: - Utils.error_log("sendMessage emulation failed for set stream path to hisense") -time.sleep(3) -print("") - -#send messages required for routing change -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_change))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for routing change to hisense") -else: - Utils.error_log("sendMessage emulation failed for routing change to hisense") -time.sleep(3) -print("") - -#send messages required for routing information -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.routing_information_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying routing information from hisense") -else: - Utils.error_log("sendMessage emulation failed for querying routing information from hisense") -time.sleep(3) -print("") - - -message1_response = requests.get("http://{}/Hdmicec.sendMessage/{}".format( - Config.flask_server_ip, json.dumps(Config.active_source_hisense))) -if "200" in str(message1_response): - Utils.info_log("sendMessage emulation success for querying the active source") -else: - Utils.error_log("sendMessage emulation failed for querying the active source") -time.sleep(3) -print("") - -curl_response = Utils.send_curl_command(HdmiCecSourceApis.perform_otp_action) -if curl_response: - Utils.info_log("curl command send for perform_otp_action") -else: - Utils.error_log("curl command send failed for perform_otp_action") - - -print("---------------------------------------------------------------------------------------------------------------------------") -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_active_source_status) -if curl_response: - Utils.info_log("curl command send for get_active_source") -else: - Utils.error_log("curl command send failed for get_active_source") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one' -else: - status = 'Fail' - message = 'Output response is different from expected one' - -# generate logs in terminal -tc_id = 'TCID027_getActiveSourceStatus_True' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID028.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID028.py deleted file mode 100644 index a1cf7ce93..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID028.py +++ /dev/null @@ -1,95 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID028 -# Testcase Description : Invalid curl command - getVendorId - -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"vendorid":"04455","success":true}}' - -print("Invalid curl command - getVendorId") -Utils.initiliaze_flask_for_HdmiCecSource() -time.sleep(3) -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.set_vendor_id) -if curl_response: - Utils.warning_log("set vendor id curl command sent from the test runner") -else: - Utils.error_log("set vendor id curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_vendor_id) -if curl_response: - Utils.warning_log("get vendor id curl command sent from the test runner") -else: - Utils.error_log("get vendor id curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.set_vendor_id_invalid_2) -if curl_response: - Utils.warning_log("set vendor id invalid curl command sent from the test runner") -else: - Utils.error_log("set vendor id invalid curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_vendor_id) -if curl_response: - Utils.warning_log("get vendor id curl command sent from the test runner") -else: - Utils.error_log("get vendor id curl command failed") - -post_condition = Utils.send_curl_command(HdmiCecSourceApis.set_vendor_id) - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one.' -else: - status = 'Fail' - message = 'Output response is different from expected one.' - -# generate logs in terminal -tc_id = 'TCID028_getVendorId - Invalid curl command' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID029.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID029.py deleted file mode 100644 index 5dfe8eae7..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID029.py +++ /dev/null @@ -1,95 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID029 -# Testcase Description : getEnabled - CEC Already Disabled - -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"enabled":false,"success":true}}' - -print("getEnabled - CEC Already Disabled") -Utils.initiliaze_flask_for_HdmiCecSource() -time.sleep(3) -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.set_enabled_false) -if curl_response: - Utils.warning_log("set enabled curl command sent from the test runner") -else: - Utils.error_log("set enabled curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_enabled) -if curl_response: - Utils.warning_log("get enabled curl command sent from the test runner") -else: - Utils.error_log("get enabled curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.set_enabled_false) -if curl_response: - Utils.warning_log("set enabled curl command sent from the test runner") -else: - Utils.error_log("set enabled curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_enabled) -if curl_response: - Utils.warning_log("get enabled curl command sent from the test runner") -else: - Utils.error_log("get enabled curl command failed") - -post_condition = Utils.send_curl_command(HdmiCecSourceApis.set_enabled_true) - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one.' -else: - status = 'Fail' - message = 'Output response is different from expected one.' - -# generate logs in terminal -tc_id = 'TCID029_getEnabled - CEC Already Disabled' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID030.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID030.py deleted file mode 100644 index 8be9a58b4..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID030.py +++ /dev/null @@ -1,93 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID030 -# Testcase Description : getEnabled - CEC Already Enabled - -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"enabled":true,"success":true}}' -Utils.initiliaze_flask_for_HdmiCecSource() -time.sleep(3) -print("getEnabled - CEC Already Enabled") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.set_enabled_true) -if curl_response: - Utils.warning_log("set enabled curl command sent from the test runner") -else: - Utils.error_log("set enabled curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_enabled) -if curl_response: - Utils.warning_log("get enabled curl command sent from the test runner") -else: - Utils.error_log("get enabled curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.set_enabled_true) -if curl_response: - Utils.warning_log("set enabled curl command sent from the test runner") -else: - Utils.error_log("set enabled curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_enabled) -if curl_response: - Utils.warning_log("get enabled curl command sent from the test runner") -else: - Utils.error_log("get enabled curl command failed") - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one.' -else: - status = 'Fail' - message = 'Output response is different from expected one.' - -# generate logs in terminal -tc_id = 'TCID030_getEnabled - CEC Already Enabled' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID031.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID031.py deleted file mode 100644 index 7109c6fdf..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID031.py +++ /dev/null @@ -1,92 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID031 -# Testcase Description : getOTPEnabled - Invalid curl command - -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"enabled":true,"success":true}}' - -print("getOTPEnabled - Invalid curl command") -Utils.initiliaze_flask_for_HdmiCecSource() -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.set_otp_enabled_true) -if curl_response: - Utils.warning_log("set otp enabled curl command sent from the test runner") -else: - Utils.error_log("set otp enabled curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_otp_enabled) -if curl_response: - Utils.warning_log("get otp enabled curl command sent from the test runner") -else: - Utils.error_log("get otp enabled curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.set_otp_enabled_invalid) -if curl_response: - Utils.warning_log("set otp enabled curl command sent from the test runner") -else: - Utils.error_log("set otp enabled curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_otp_enabled) -if curl_response: - Utils.warning_log("get otp enabled curl command sent from the test runner") -else: - Utils.error_log("get otp enabled curl command failed") - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one.' -else: - status = 'Fail' - message = 'Output response is different from expected one.' - -# generate logs in terminal -tc_id = 'TCID031_getOTPEnabled - Invalid curl command' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - - diff --git a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID032.py b/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID032.py deleted file mode 100644 index 484ff71b8..000000000 --- a/Tests/L2HALMockTests/TestCases/HdmiCecSource/TCID032.py +++ /dev/null @@ -1,93 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# Testcase ID : TCID032 -# Testcase Description : getOSDName - Invalid curl command - -import json -import requests -import time -import Config -from Utilities import Utils, ReportGenerator -from HdmiCecSource import HdmiCecSourceApis - -# store the expected output response -expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"name":"CUSTOM8 TV","success":true}}' -Utils.initiliaze_flask_for_HdmiCecSource() -print("getOSDName - Invalid curl command") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.set_osd_name) -if curl_response: - Utils.warning_log("set osd name curl command sent from the test runner") -else: - Utils.error_log("set osd name curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_osd_name) -if curl_response: - Utils.warning_log("get osd name curl command sent from the test runner") -else: - Utils.error_log("get osd name curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.set_osd_name_invalid) -if curl_response: - Utils.warning_log("set osd name invalid curl command sent from the test runner") -else: - Utils.error_log("set osd name invalid curl command failed") - -# send the curl command and fetch the output json response -curl_response = Utils.send_curl_command(HdmiCecSourceApis.get_osd_name) -if curl_response: - Utils.warning_log("get osd name curl command sent from the test runner") -else: - Utils.error_log("get osd name curl command failed") - -print("---------------------------------------------------------------------------------------------------------------------------") - -# compare both expected and received output responses -if str(curl_response) == str(expected_output_response): - status = 'Pass' - message = 'Output response is matching with expected one.' -else: - status = 'Fail' - message = 'Output response is different from expected one.' - -# generate logs in terminal -tc_id = 'TCID032_getOSDName - Invalid curl command' -print("Testcase ID : " + tc_id) -print("Testcase Output Response : " + curl_response) -print("Testcase Status : " + status) -print("Testcase Message : " + message) -print("") - -if status == 'Pass': - ReportGenerator.passed_tc_list.append(tc_id) -else: - ReportGenerator.failed_tc_list.append(tc_id) -Utils.initiliaze_flask_for_HdmiCecSource() -post_condition = Utils.send_curl_command(HdmiCecSourceApis.set_osd_name) -# push the testcase execution details to report file -ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message) - - diff --git a/Tests/L2HALMockTests/Test_Framework/Config.py b/Tests/L2HALMockTests/Test_Framework/Config.py deleted file mode 100644 index 026990e45..000000000 --- a/Tests/L2HALMockTests/Test_Framework/Config.py +++ /dev/null @@ -1,2105 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# This config file contains all the configurable parameters required for Test Framework -import os - -# IP & port details of Flask server -flask_server_ip = "127.0.0.1:8000" - -# Define the paths of Websocket server & WPEFramework -# Define the paths of Websocket server & WPEFramework -WPEFramework_restart = os.getcwd() -os.chdir("../Flask") - -directory_websocket = os.getcwd() -os.chdir("../../../../install/etc/WPEFramework") - -directory_thunder = os.getcwd() -os.chdir(WPEFramework_restart) - -# Define the path where WPEFramework logs needs to be stored -file_name = 'log_file.txt' -WPEFramework_logs_path = os.path.abspath(file_name) - -# Data required for setDeviceConfig api -config_data = { - "apiName": "setDeviceConfig", - "arguments": { - "devices": [ - { - "device": [ - {"name": "xione_uk"}, - {"islocal": 1}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "19"}, - {"logicalAddress": "3"}, - {"vendorId": "4567"}, - {"osdName": "404753747265616D696E672054776F"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "04"} - ] - }, - { - "device": [ - {"name": "Audio Device"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "304"}, - {"logicalAddress": "5"}, - {"vendorId": "4567"}, - {"osdName": "0053616d73756e67"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "04"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 1}, - {"physicalAddress": "304"}, - {"logicalAddress": "9"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"osdString": "48656C6C6F"}, - {"cecVersion": "04"}, - {"abortReason": "04"} - ] - }, - { - "device": [ - {"name": "hisense"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 0}, - {"physicalAddress": "0"}, - {"logicalAddress": "0"}, - {"vendorId": "0x4567"}, - {"osdName": "545620426F78"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "04"} - - ] - } - ] - } -} - -config_data_no_audio = { - "apiName": "setDeviceConfig", - "arguments": { - "devices": [ - { - "device": [ - {"name": "xione_uk"}, - {"islocal": 1}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "301"}, - {"logicalAddress": "3"}, - {"vendorId": "4567"}, - {"osdName": "404753747265616D696E672054776F"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "04"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 1}, - {"physicalAddress": "304"}, - {"logicalAddress": "9"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"osdString": "48656C6C6F"}, - {"cecVersion": "04"}, - {"abortReason": "04"} - ] - }, - { - "device": [ - {"name": "hisense"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 0}, - {"physicalAddress": "0"}, - {"logicalAddress": "0"}, - {"vendorId": "0x4567"}, - {"osdName": "545620426F78"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "04"} - - ] - } - ] - } -} - - -# Data required for setAPIConfig api -api_data = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecOpen": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecGetLogicalAddress": [ - {"return": 0}, - {"outParams": [{"logicalAddress": "0x3"}]} - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - {"return": 0}, - {"outParams": [{"physicalAddress": "0x304"}]} - ] - } - ] - } -} - -#Hal Api Data for error scenarios -api_data_negative = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecOpen": [ - {"return": -1}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecGetLogicalAddress": [ - {"return": -1}, - {"outParams": [{"logicalAddress": "0x3"}]} - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - {"return": -1}, - {"outParams": [{"physicalAddress": "0x304"}]} - ] - } - ] - } -} - - -abort_data_1 = { - "apiName": "setDeviceConfig", - "arguments": { - "devices": [ - { - "device": [ - {"name": "xione_uk"}, - {"islocal": 1}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "301"}, - {"logicalAddress": "3"}, - {"vendorId": "4567"}, - {"osdName": "404753747265616D696E672054776F"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "159"} - ] - }, - { - "device": [ - {"name": "Audio Device"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "304"}, - {"logicalAddress": "5"}, - {"vendorId": "4567"}, - {"osdName": "0053616d73756e67"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "159"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 1}, - {"physicalAddress": "304"}, - {"logicalAddress": "9"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"osdString": "48656C6C6F"}, - {"cecVersion": "04"}, - {"abortReason": "159"} - ] - }, - { - "device": [ - {"name": "hisense"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 0}, - {"physicalAddress": "0"}, - {"logicalAddress": "0"}, - {"vendorId": "0x4567"}, - {"osdName": "545620426F78"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "159"} - - ] - } - ] - } -} - -abort_data_2 = { - "apiName": "setDeviceConfig", - "arguments": { - "devices": [ - { - "device": [ - {"name": "xione_uk"}, - {"islocal": 1}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "301"}, - {"logicalAddress": "3"}, - {"vendorId": "4567"}, - {"osdName": "404753747265616D696E672054776F"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "140"} - ] - }, - { - "device": [ - {"name": "Audio Device"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "304"}, - {"logicalAddress": "5"}, - {"vendorId": "4567"}, - {"osdName": "0053616d73756e67"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "140"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 1}, - {"physicalAddress": "304"}, - {"logicalAddress": "9"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"osdString": "48656C6C6F"}, - {"cecVersion": "04"}, - {"abortReason": "140"} - ] - }, - { - "device": [ - {"name": "hisense"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 0}, - {"physicalAddress": "0"}, - {"logicalAddress": "0"}, - {"vendorId": "0x4567"}, - {"osdName": "545620426F78"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "140"} - - ] - } - ] - } -} - -abort_data_3 = { - "apiName": "setDeviceConfig", - "arguments": { - "devices": [ - { - "device": [ - {"name": "xione_uk"}, - {"islocal": 1}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "301"}, - {"logicalAddress": "3"}, - {"vendorId": "4567"}, - {"osdName": "404753747265616D696E672054776F"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "70"} - ] - }, - { - "device": [ - {"name": "Audio Device"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "304"}, - {"logicalAddress": "5"}, - {"vendorId": "4567"}, - {"osdName": "0053616d73756e67"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "70"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 1}, - {"physicalAddress": "304"}, - {"logicalAddress": "9"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"osdString": "48656C6C6F"}, - {"cecVersion": "04"}, - {"abortReason": "70"} - ] - }, - { - "device": [ - {"name": "hisense"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 0}, - {"physicalAddress": "0"}, - {"logicalAddress": "0"}, - {"vendorId": "0x4567"}, - {"osdName": "545620426F78"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "70"} - - ] - } - ] - } -} - -abort_data_4 = { - "apiName": "setDeviceConfig", - "arguments": { - "devices": [ - { - "device": [ - {"name": "xione_uk"}, - {"islocal": 1}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "301"}, - {"logicalAddress": "3"}, - {"vendorId": "4567"}, - {"osdName": "404753747265616D696E672054776F"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "143"} - ] - }, - { - "device": [ - {"name": "Audio Device"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "304"}, - {"logicalAddress": "5"}, - {"vendorId": "4567"}, - {"osdName": "0053616d73756e67"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "143"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 1}, - {"physicalAddress": "304"}, - {"logicalAddress": "9"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"osdString": "48656C6C6F"}, - {"cecVersion": "04"}, - {"abortReason": "143"} - ] - }, - { - "device": [ - {"name": "hisense"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 0}, - {"physicalAddress": "0"}, - {"logicalAddress": "0"}, - {"vendorId": "0x4567"}, - {"osdName": "545620426F78"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "143"} - - ] - } - ] - } -} - -abort_data_5 = { - "apiName": "setDeviceConfig", - "arguments": { - "devices": [ - { - "device": [ - {"name": "xione_uk"}, - {"islocal": 1}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "301"}, - {"logicalAddress": "3"}, - {"vendorId": "4567"}, - {"osdName": "404753747265616D696E672054776F"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "164"} - ] - }, - { - "device": [ - {"name": "Audio Device"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "304"}, - {"logicalAddress": "5"}, - {"vendorId": "4567"}, - {"osdName": "0053616d73756e67"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "164"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 1}, - {"physicalAddress": "304"}, - {"logicalAddress": "9"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"osdString": "48656C6C6F"}, - {"cecVersion": "04"}, - {"abortReason": "164"} - ] - }, - { - "device": [ - {"name": "hisense"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 0}, - {"physicalAddress": "0"}, - {"logicalAddress": "0"}, - {"vendorId": "0x4567"}, - {"osdName": "545620426F78"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "164"} - - ] - } - ] - } -} - - -# Device data for HiSense TV -hisense_device_data = { - "device": [ - {"name": "hisense"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 0}, - {"physicalAddress": "0"}, - {"logicalAddress": "6"}, - {"vendorId": "0x4567"}, - {"osdName": "545620426F78"}, - # {"optionalProperty1": "value1"}, - # {"optionalProperty2": "value2"} - ] -} - -api_data_sink = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecTx": [ - {"return": -1}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecOpen": [ - {"return": -1}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecGetLogicalAddress": [ - {"return": -1}, - {"outParams": [{"logicalAddress": "0x3"}]} - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - {"return": -1}, - {"outParams": [{"physicalAddress": "0x304"}]} - ] - } - ] - } -} - - - -# Invalid device data for Xione US -invalid_device_data = { - "device": [ - {"name": "xione_us"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 0}, - {"physicalAddress": "333"}, - {"logicalAddress": "77"}, - {"vendorId": "4444"}, - {"osdName": "3333"}, - # {"optionalProperty1": "value1"}, - # {"optionalProperty2": "value2"} - ] -} - -# Send message data for sendStandbyMessage -sendStandbyMessage = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x36" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -# message send to know the current power status of device -getPowerStatusMessage = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x03", - "0x8F" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -# message send to know the current power status of device -reportPowerStatusMessage = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x90" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -# message for perform OTP Action -performOTPActionMessage = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x04" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -# api overrides data in which return value for HdmiCecOpen is set to -1 -cec_minus_one = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecOpen": [ - {"return": -1}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecGetLogicalAddress": [ - {"return": 0}, - {"outParams": [{"logicalAddress": "0x3"}]} - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - {"return": 0}, - {"outParams": [{"physicalAddress": "0x304"}]} - ] - } - ] - } -} - -# messages for active source -active_source_firestick1 = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "amazon fire stick", - "messages": [ - { - "message1": { - "buf": [ - "0x34", - "0x82" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -active_source_hisense = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x82" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -active_source_xione_uk = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0xF3", - "0x82" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} -# messages for inactive source -inactive_source_firestick1 = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "amazon fire stick", - "messages": [ - { - "message1": { - "buf": [ - "0x34", - "0x9D" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -inactive_source_hisense = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x9D" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -# messages for request active source -request_active_source_firestick1 = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "amazon fire stick", - "messages": [ - { - "message1": { - "buf": [ - "0x34", - "0x85" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -request_active_source_hisense = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x85" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -image_view_on = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x04" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -text_view_on = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x0D" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -routing_change = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "amazon fire stick", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x80" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -set_stream_path_hisense = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x86" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -routing_information_hisense = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x81" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -give_device_power_status_hisense = { - - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x8F" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -set_menu_language = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x32" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -ignore_set_menu_language = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x34", - "0x32" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -get_menu_language_hisense = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x91" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -get_cec_version = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x9F" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -cec_version = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x9E" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -give_physical_address_hisense = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x83" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -give_osd_name_hisense = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x46" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -set_osd_string = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x64" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -feature_abort = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x00" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -abort_hisense = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0xFF" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -feature_abort_hisense = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x00" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -polling = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x200" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -sinkActiveSource = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x50", - "0x04" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -sinkActiveSource = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x50", - "0x04" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -imageViewON = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x50", - "0x04" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -textViewON = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x30", - "0x0D" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -reportPhysicalAdd = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0xF0", - "0x84" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -DeviceVendorID = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0xF0", - "0x87" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -initiateArc = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x05", - "0xC0" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -terminateArc = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x05", - "0xC5" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -reportShortAudioDes = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x05", - "0xA3" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -setSystemAudioMode = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x50", - "0x72" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -reportAudioMode = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x50", - "0x7A" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -givefeatures = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x50", - "0xA5" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - -requestcurrentlatency = { - "apiName": "sendMessage", - "arguments": { - "remoteDevices": [ - { - "device": { - "name": "hisense", - "messages": [ - { - "message1": { - "buf": [ - "0x50", - "0xA7" - ], - "len": 2, - "repeat": 2, - "delay": 1 - } - } - ] - } - } - ] - } -} - - -api_data_sink_1 = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecTx": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecOpen": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecGetLogicalAddress": [ - {"return": 0}, - {"outParams": [{"logicalAddress": "0x3"},{"result":0}]} - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - {"return": -1}, - {"outParams": [{"physicalAddress": "0x304"}]} - ] - } - ] - } -} - - -api_data_sink_2 = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecTx": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecOpen": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecGetLogicalAddress": [ - {"return": 0}, - {"outParams": [{"logicalAddress": "0x3"},{"result":1}]} - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - {"return": 0}, - {"outParams": [{"physicalAddress": "0x304"}]} - ] - } - ] - } -} - - -api_data_sink_3 = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecTx": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecOpen": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecGetLogicalAddress": [ - {"return": 0}, - {"outParams": [{"logicalAddress": "0x3"},{"result":2}]} - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - {"return": 0}, - {"outParams": [{"physicalAddress": "0x304"}]} - ] - } - ] - } -} - - -api_data_sink_4 = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecTx": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecOpen": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecGetLogicalAddress": [ - {"return": 0}, - {"outParams": [{"logicalAddress": "0x3"},{"result":3}]} - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - {"return": 0}, - {"outParams": [{"physicalAddress": "0x304"}]} - ] - } - ] - } -} - - -api_data_sink_5 = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecTx": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecOpen": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecGetLogicalAddress": [ - {"return": 0}, - {"outParams": [{"logicalAddress": "0x3"},{"result":4}]} - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - {"return": 0}, - {"outParams": [{"physicalAddress": "0x304"}]} - ] - } - ] - } -} - - -api_data_sink_6 = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecTx": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecOpen": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecGetLogicalAddress": [ - {"return": 0}, - {"outParams": [{"logicalAddress": "0x3"},{"result":5}]} - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - {"return": 0}, - {"outParams": [{"physicalAddress": "0x304"}]} - ] - } - ] - } -} - - -api_data_sink_7 = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecTx": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecOpen": [ - {"return": 0}, - {"outParams": [{"handle": 2345678}]} - ] - }, - { - "HdmiCecGetLogicalAddress": [ - {"return": 0}, - {"outParams": [{"logicalAddress": "0x3"},{"result":6}]} - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - {"return": 0}, - {"outParams": [{"physicalAddress": "0x304"}]} - ] - } - ] - } -} - - -# Data required for setDeviceConfig api HdmiCecSource -config_data_hdmicecsource = { - "apiName": "setDeviceConfig", - "arguments": { - "devices": [ - { - "device": [ - {"name": "xione_uk"}, - {"islocal": 1}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "301"}, - {"logicalAddress": "3"}, - {"vendorId": "4567"}, - {"osdName": "404753747265616D696E672054776F"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "04"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 0}, - {"physicalAddress": "304"}, - {"logicalAddress": "4"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "04"} - ] - }, - { - "device": [ - {"name": "amazon fire stick"}, - {"islocal": 0}, - {"type": "source"}, - {"powerState": 1}, - {"physicalAddress": "304"}, - {"logicalAddress": "9"}, - {"vendorId": "4567"}, - {"osdName": "53747265616D696E67204F6E65"}, - {"osdString": "48656C6C6F"}, - {"cecVersion": "04"}, - {"abortReason": "04"} - ] - }, - { - "device": [ - {"name": "hisense"}, - {"islocal": 0}, - {"type": "sink"}, - {"powerState": 0}, - {"physicalAddress": "0"}, - {"logicalAddress": "0"}, - {"vendorId": "0x4567"}, - {"osdName": "545620426F78"}, - {"menuLanguage": "454E47"}, - {"osdString": "484953454E5345"}, - {"cecVersion": "04"}, - {"abortReason": "04"} - - ] - } - ] - } - } - -# Data required for setAPIConfig api HdmiCecSource -api_data_hdmicecsource = { - "apiName": "setAPIConfig", - "arguments": { - "apiOverrides": [ - { - "HdmiCecOpen": [ - { "return": 0 }, - { "outParams": [{"handle": 2345678}] } - ] - }, - { - "HdmiCecGetLogicalAddress": [ - { "return": 0 }, - { "outParams": [{"logicalAddress": "0x3"}] } - ] - }, - { - "HdmiCecGetPhysicalAddress": [ - { "return": 0 }, - { "outParams": [{"physicalAddress": "0x304"}] } - ] - } - ] - } - } diff --git a/Tests/L2HALMockTests/Test_Framework/Test Execution Reports/TestReport_23Q4-HAL-MOCK-TEST_05-02-2024_16h10m12s.html b/Tests/L2HALMockTests/Test_Framework/Test Execution Reports/TestReport_23Q4-HAL-MOCK-TEST_05-02-2024_16h10m12s.html deleted file mode 100644 index 725cb331a..000000000 --- a/Tests/L2HALMockTests/Test_Framework/Test Execution Reports/TestReport_23Q4-HAL-MOCK-TEST_05-02-2024_16h10m12s.html +++ /dev/null @@ -1,63 +0,0 @@ -

- Build Name: 23Q4-HAL-MOCK-TEST -

-

- Date of Execution: 05/02/2024 -

-

- Time of Execution: 16:10:12 -

-

- Number of Testcases Passed: 2 -

-

- Number of Testcases Failed: 0 -

- - - - - - - - - - - - - - - - - - - - - - - -
- TC ID - - Output Response - - TC Status - - TC Message -
- TCID004 - - {"jsonrpc":"2.0","id":42,"result":{"success":true}} - - Pass - - Output response is matching with expected one. We are expecting opcode : 36 in thunder logs -
- TCID016 - - {"jsonrpc":"2.0","id":42,"result":{"enabled":false,"success":true}} - - Pass - - Output response is matching with expected one. The cec enable status is true initially and after changing the return value, cec enable status changed to false -
\ No newline at end of file diff --git a/Tests/L2HALMockTests/Test_Framework/TestManager.py b/Tests/L2HALMockTests/Test_Framework/TestManager.py deleted file mode 100644 index 38b12aed1..000000000 --- a/Tests/L2HALMockTests/Test_Framework/TestManager.py +++ /dev/null @@ -1,748 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -import sys -import datetime -import time -sys.path.append("../TestCases") -from HdmiCecSource import CecUtils -from Utilities import Utils, ReportGenerator - -sys.path.append("Utilities") -sys.path.append("../TestCases/HdmiCecSource") -sys.path.append("../TestCases/HdmiCecSink") -sys.path.append("../TestCases/FrontPanel") -sys.path.append("../TestCases/HDCPProfile") - -# Define the build name of current build being tested -build_name = "23Q4-HAL-MOCK-TEST" - -# Get the date and time of execution -now = datetime.datetime.now() - -# clear the previous test results -ReportGenerator.passed_tc_list.clear() -ReportGenerator.failed_tc_list.clear() - -print("") -print("Inside TestManager.py : Initializing Python Test Framework......................!") -print("") -argument = sys.argv[1:3] -result = ' '.join(argument) -if len(sys.argv) >= 2: - second_argument = sys.argv[1] - print(f"Two plugins are given: {second_argument}") -elif len(sys.argv) >= 3: - third_argument = sys.argv[2] - print(f"three plugins are given: {third_argument}") -elif len(sys.argv) >= 4: - forth_argument = sys.argv[3] - print(f"4 plugins are given: {argument}") -else: - print("No second argument provided.") - -print("GIVEN PLUGIN NAMES/TC NAME {}" .format(argument)) -# Pushing the initial configuration (cec network data & -# Pushing the initial configuration (cec network data & api override data) to Flask -#Utils.initialize_flask() -print("") - -# Activating the HdmiCecSource plugin using controller1.activate curl command -#CecUtils.activate_cec() -#time.sleep(5) - -print("") -print("***** Test Execution Starts *****") -print("") - -tc_name = result -flag = 0 -track = 0 - -list_of_plugins = ['HdmiCecSource','HdmiCecSink','FrontPanel','HdcpProfile'] - -plugin_name = [] - -for each in list_of_plugins: - if each in argument or each in result: - plugin_name.append(each) - track = track + 1 - -if track == 2 or track > 2: - Utils.info_log("Executing Testcases for the given plugins") - if "HdmiCecSource" in plugin_name or "HdmiCecSink" in plugin_name: - Utils.initialize_flask() - print("") - -# Activating the HdmiCecSource plugin using controller1.activate curl command - CecUtils.activate_cec() - time.sleep(5) - else: - print("Plugins changed does not require FLASK HTTP Server for execution and build") - - if "HdmiCecSource" in plugin_name: - # Execute the testcases - import TCID013 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID014 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID015 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID022 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID023 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID024 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID001 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID002 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID003 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID004 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID005 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID006 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID007 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID008 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID009 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID010 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID011 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID012 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID016 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID017 - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID018 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID019 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID020 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID026 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID027 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID032 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID031 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID030 - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID029 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID028 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID025 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID021 - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - else: - print("Skipping HdmiCecSource as no changes are added") - - if "HdmiCecSink" in plugin_name: - import TCID_031_HDMICECSINK_getEnabled_HAL_False - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_Emulate - import TCID_035_Arc_start_stop - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_028_HDMICECSINK_abortCombinationsEmulation - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_036_HDMICECSINK_OSDStringMenuLanguageEmulation - import TCID_037_HDMICECSINK_sendEvents - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_032_HDMICECSINK_EmulateTextViewONStandbyBy - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_001_HDMICECSINK_getEnabled - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_002_HDMICECSINK_setEnabled - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_003_HDMICECSINK_getOSDName - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_005_HDMICECSINK_getVendorID - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_004_HDMICECSINK_setOSDName - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_006_HDMICECSINK_setVendorID - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_008_HDMICECSINK_getActiveSource - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_007_HDMICECSINK_getActiveRoute - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_009_HDMICECSINK_getAudioDeviceConnectedStatus - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_010_HDMICECSINK_getDeviceList - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_011_HDMICECSINK_requestActiveSource - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_012_HDMICECSINK_requestShortAudioDescriptor - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_013_HDMICECSINK_sendAudioDevicePowerOnMessage - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_014_HDMICECSINK_getAudioStatusMessage - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_015_HDMICECSINK_sendKeyPressEvent - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_016_HDMICECSINK_sendUserControlPressed - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_017_HDMICECSINK_sendUserControlReleased - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_018_HDMICECSINK_sendStandbyMessage - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_019_HDMICECSINK_setActivePath - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_020_HDMICECSINK_setActiveSource - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_021_HDMICECSINK_setmenuLanguage - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_022_HDMICECSINK_setLatencyInfo - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_023_HDMICECSINK_setRoutingChange - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_024_HDMICECSINK_setupArcRouting - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_025_HDMICECSINK_printDeviceList - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_026_HDMICECSINK_requestAudioDevicePowerStatus - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_029_HDMICECSINK_getActiveSourcewithroutingChange - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_030_HDMICECSINK_sendGetAudioStatusMessage - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_033_HDMICECSINK_setRoutingChangeNegative - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_034_HDMICECSINK_active_source - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - else: - print("Skipping HDMICECSINK as no changes are added") - - - if "FrontPanel" in plugin_name: - #Utils.initialize_flask() - print("Executing Test Framework without HTTP server and Websocket") - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_001_DS_FrontPanel_getBrightness - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_011_DS_FrontPanel_setPreferences #commented as its descoped in source code - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_002_DS_FrontPanel_getPreferences - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_003_DS_FrontPanel_is24HourClock - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_014_DS_FrontPanel_setClockBrightness #commented as its descoped in source code - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_004_DS_FrontPanel_getClockBrightness #commented as its descoped in source code - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_005_DS_FrontPanel_powerLedOff - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_006_DS_FrontPanel_powerLedOn - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_007_DS_FrontPanel_set24HourClock - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_008_DS_FrontPanel_setBlink - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_009_DS_FrontPanel_setClockTestPattern - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_010_DS_FrontPanel_setLED - print("\033[32m------########################################################################################################################---------.\033[0m") - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_013_DS_FrontPanel_setBrightness - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_015_DS_FrontPanel_getSetbrightnesscombination - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_012_DS_FrontPanel_getFrontPanelLights - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_017_DS_FrontPanel_sendEventsSimulation - import TCID_016_DS_FrontPanel_Deactivate - else: - print("Skipping FrontPanel as no changes are added") - - if "HdcpProfile" in plugin_name: - print("Detected change in HdcpProfile") - import TCID_001_HDCPProfile_getHDCPStatus - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_002_HDCPProfile_getSettopHDCPSupport #commented as its descoped in source code - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_004_HDCPProfile_Events - time.sleep(2) - import TCID_003_HDCPProfile_ActivateDeactivateSimulation - - else: - print("skipping HdcpProfile as no changes are required") -else: - track = 1 -if "HdmiCecSource" in argument or "HdmiCecSource" in result: - if track < 2: - flag = 1 - if flag == 1 or flag == 15: - Utils.initialize_flask() - print("") - -# Activating the HdmiCecSource plugin using controller1.activate curl command - CecUtils.activate_cec() - time.sleep(5) - - # Execute the testcases for HdmiCecSource - Utils.info_log("Executing Testcases for HdmiCecSource") - # Execute the testcases - import TCID013 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID014 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID015 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID022 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID023 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID024 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID001 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID002 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID003 - import TCID004 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID005 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID006 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID007 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID008 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID009 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID010 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID011 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID012 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID016 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID017 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID018 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID019 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID020 - import TCID020 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID026 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID027 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID032 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID031 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID030 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID029 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID028 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID025 - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID021 - print("\033[32m------########################################################################################################################---------.\033[0m") - else: - print("Executed HdmiCecSource TestCases") -if "HdmiCecSink" in argument or "HdmiCecSink" in result: - if track < 2: - flag = 2 - Utils.info_log("Executing HdmiCecSink Test suite") - Utils.initialize_flask() - print("") - -# Activating the HdmiCecSource plugin using controller1.activate curl command - CecUtils.activate_cec() - time.sleep(5) - - import TCID_031_HDMICECSINK_getEnabled_HAL_False - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_Emulate - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_035_Arc_start_stop - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_028_HDMICECSINK_abortCombinationsEmulation - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_036_HDMICECSINK_OSDStringMenuLanguageEmulation - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_037_HDMICECSINK_sendEvents - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_032_HDMICECSINK_EmulateTextViewONStandbyBy - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_001_HDMICECSINK_getEnabled - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_002_HDMICECSINK_setEnabled - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_003_HDMICECSINK_getOSDName - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_005_HDMICECSINK_getVendorID - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_004_HDMICECSINK_setOSDName - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_006_HDMICECSINK_setVendorID - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_008_HDMICECSINK_getActiveSource - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_007_HDMICECSINK_getActiveRoute - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_009_HDMICECSINK_getAudioDeviceConnectedStatus - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_010_HDMICECSINK_getDeviceList - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_011_HDMICECSINK_requestActiveSource - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_012_HDMICECSINK_requestShortAudioDescriptor - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_013_HDMICECSINK_sendAudioDevicePowerOnMessage - import TCID_014_HDMICECSINK_getAudioStatusMessage - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_015_HDMICECSINK_sendKeyPressEvent - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_016_HDMICECSINK_sendUserControlPressed - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_017_HDMICECSINK_sendUserControlReleased - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_018_HDMICECSINK_sendStandbyMessage - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_019_HDMICECSINK_setActivePath - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_020_HDMICECSINK_setActiveSource - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_021_HDMICECSINK_setmenuLanguage - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_022_HDMICECSINK_setLatencyInfo - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_023_HDMICECSINK_setRoutingChange - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_024_HDMICECSINK_setupArcRouting - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_025_HDMICECSINK_printDeviceList - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_026_HDMICECSINK_requestAudioDevicePowerStatus - - print( - "\033[32m------########################################################################################################################---------.\033[0m") - import TCID_029_HDMICECSINK_getActiveSourcewithroutingChange - import TCID_030_HDMICECSINK_sendGetAudioStatusMessage - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_033_HDMICECSINK_setRoutingChangeNegative - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_034_HDMICECSINK_active_source - print("\033[32m------########################################################################################################################---------.\033[0m") - else: - print("Executed HdmiCecSink TestCases") -if "FrontPanel" in argument or "FrontPanel" in result: - if track < 2: - flag = 3 - Utils.info_log("Executing FrontPanel Test suite") - print("\033[32m------########################################################################################################################---------.\033[0m") - - #Utils.initialize_flask() - print("Executing Test Framework without HTTP server and Websocket") - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_001_DS_FrontPanel_getBrightness - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_011_DS_FrontPanel_setPreferences #commented as its descoped in source code - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_002_DS_FrontPanel_getPreferences - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_003_DS_FrontPanel_is24HourClock - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_014_DS_FrontPanel_setClockBrightness #commented as its descoped in source code - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_004_DS_FrontPanel_getClockBrightness #commented as its descoped in source code - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_005_DS_FrontPanel_powerLedOff - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_006_DS_FrontPanel_powerLedOn - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_007_DS_FrontPanel_set24HourClock - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_008_DS_FrontPanel_setBlink - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_009_DS_FrontPanel_setClockTestPattern - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_010_DS_FrontPanel_setLED - print("\033[32m------########################################################################################################################---------.\033[0m") - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_013_DS_FrontPanel_setBrightness - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_015_DS_FrontPanel_getSetbrightnesscombination - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_012_DS_FrontPanel_getFrontPanelLights - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_017_DS_FrontPanel_sendEventsSimulation - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_018_DS_FrontPanel_negative - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_020_DS_FrontPanel_powerLed_invalid - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_021_DS_FrontPanel_LEDBrightnessNegative - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_022_DS_FrontPanel_24HrClock_invalid - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_016_DS_FrontPanel_Deactivate - -# Activating the HdmiCecSource plugin using controller1.activate curl command - #CecUtils.activate_cec() - #time.sleep(5) -if "HdcpProfile" in argument or "HdcpProfile" in result: - if track < 2: - flag = 4 - Utils.info_log("Executing HDCPProfile Test suite") - print("\033[32m------########################################################################################################################---------.\033[0m") - time.sleep(30) - #Utils.initialize_flask() - print("Executing Test Framework without HTTP server and Websocket") - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_001_HDCPProfile_getHDCPStatus - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_002_HDCPProfile_getSettopHDCPSupport #commented as its descoped in source code - print("\033[32m------########################################################################################################################---------.\033[0m") - import TCID_004_HDCPProfile_Events - time.sleep(28) - import TCID_003_HDCPProfile_ActivateDeactivateSimulation - #import TCID_003_HDCPProfile_ActivateDeactivateSimulation - -if argument == "DeviceSettings": - flag = 3 - Utils.highlight_log("Executing DeviceSettings Test suite") -if argument == "Bluetooth": - flag = 4 - Utils.highlight_log("Executing Bluetooth Test Suite") -if argument == "Wifi": - flag = 5 - Utils.highlight_log("Executing Wifi Test Suite") -if argument == "HdmiInput": - flag = 6 -if argument == "all": - flag = 15 - Utils.highlight_log("Executing Complete Test Suite for all plugins") -if "TCID" in result: - flag = 0 - print( - "\033[32m------########################################################################################################################---------.\033[0m") - print("Execution of testcase {}".format(argument)) - __import__(tc_name) - -if argument != "HdmiCecSource" or argument != "HdmiCecSink" or argument != "all": - print("Execution of testcase {}" .format(argument)) -if flag == 2 or flag == 15: - Utils.info_log("Executed HdmiCecSinkTestcases") -if flag == 15: - Utils.info_log("Executed Complete Test suite") -else: - print("Executed TestManager") - -print("***** Test Execution Ends *****") - -# Generate a html report file with all testcase execution details -ReportGenerator.generate_html_report(build_name, now) diff --git a/Tests/L2HALMockTests/Test_Framework/Utilities/ReportGenerator.py b/Tests/L2HALMockTests/Test_Framework/Utilities/ReportGenerator.py deleted file mode 100644 index 4739fb0f1..000000000 --- a/Tests/L2HALMockTests/Test_Framework/Utilities/ReportGenerator.py +++ /dev/null @@ -1,186 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -import csv -import os -import pandas as pd -from bs4 import BeautifulSoup - -passed_tc_list = [] -failed_tc_list = [] - - -def append_test_results_to_csv(tc_id, output, status, message): - - # Assign the headers for report file - headers = ["Curl API/TC Name", "Output Response", " TC Status ", " Remarks "] - - # Open the report file in append mode - with open("TestReport.csv", "a", newline="") as csvfile: - writer = csv.writer(csvfile) - - # Write headers if the headers in report file is empty - if csvfile.tell() == 0: - writer.writerow(headers) - - # Write the testcase details to a new row - writer.writerow([tc_id, output, status, message]) - - - -# Report Generation in .html file format -def generate_html_report(build_name, now): - - # To read csv file named "TestReport" - a = pd.read_csv("TestReport.csv") - - # Format the date and time as strings to generate the test report file - date = now.strftime("%d-%m-%Y") - time = now.strftime("%Hh%Mm%Ss") - - # To save as html file with build name, execution data and time - a.to_html("TestReport_{}_{}_{}.html".format(build_name, date, time), index=False) - # To remove the TestReport.csv file - #os.remove("TestReport.csv") - - # Add custom CSS style for a black background - # Read the HTML file - with open("TestReport_{}_{}_{}.html".format(build_name, date, time), "r") as f: - html = f.read() - - styled_html = f""" - - {html} - """ - - # Parse the HTML using BeautifulSoup - soup = BeautifulSoup(html, "html.parser") - - # Find the table element - table = soup.find("table") - - # Create a list of elements with the data - - # Calculate the length of the failed_tc_list string - failed_tc_length = str(len(failed_tc_list)) - passed_tc_length = str(len(passed_tc_list)) - - # Create a formatted string with the length in red - #formatted_length_failed = f"\033[91m{failed_tc_length}\033[0m" - #formatted_length_passed = f"\033[92m{passed_tc_length}\033[0m" - formatted_length_failed = failed_tc_length - formatted_length_passed = passed_tc_length - - current_date = now.strftime("%d/%m/%Y") - current_time = now.strftime("%H:%M:%S") - data = [soup.new_tag("p")] - # Now you can use the formatted_length wherever you need it - ##data[-1].string = f"Number of Testcases Failed: {str(formatted_length_failed)}" - #data[-1].string = f"Number of Testcases Failed: {str(len(failed_tc_list))}" - ##data.append(soup.new_tag("p")) - #data[-1].string = f"Number of Testcases Passed: {str(len(passed_tc_list))}" - ##data[-1].string = f"Number of Testcases Passed: {str(formatted_length_passed)}" - ##data.append(soup.new_tag("p")) - ##data[-1].string = f"Time of Execution: {current_time}" - ##data.append(soup.new_tag("p")) - ##data[-1].string = f"Date of Execution: {current_date}" - ##data.append(soup.new_tag("p")) - ##data[-1].string = f"Build Name: {build_name}" - - styled_html = f""" - - - - - -

L2 Test Execution Report

- {html} -

Execution Summary

-

Number of Testcases Failed: {str(formatted_length_failed)}

-

Number of Testcases Passed: {str(formatted_length_passed)}

-

Time of Execution: {current_time}

-

Date of Execution: {current_date}

-

Build Name: {build_name}

- - - """ - - - # Insert the data elements before the table element - for element in reversed(data): - table.insert_before(element) - - - # Replace the old html file with new one - with open("TestReport_{}_{}_{}.html".format(build_name, date, time), "w") as f: - f.write(str(soup)) - - # Read the html file - with open("TestReport_{}_{}_{}.html".format(build_name, date, time)) as html_file: - soup = BeautifulSoup(html_file, "html.parser") - - # Find all the elements - headers = soup.find_all("th") - - # Add the style attribute to each element - for header in headers: - header["style"] = "text-align: center" - - - # Write the modified html to a same report file - with open("TestReport_{}_{}_{}.html".format(build_name, date, time), "w") as html_file: - #html_file.write(soup.prettify()) - html_file.write(styled_html) - # Move the html file to the 'Test Execution Reports' Directory - os.rename("TestReport_{}_{}_{}.html".format(build_name, date, time), - "Test Execution Reports/TestReport_{}_{}_{}.html".format( - build_name, date, time)) diff --git a/Tests/L2HALMockTests/Test_Framework/Utilities/Utils.py b/Tests/L2HALMockTests/Test_Framework/Utilities/Utils.py deleted file mode 100644 index 1f521109a..000000000 --- a/Tests/L2HALMockTests/Test_Framework/Utilities/Utils.py +++ /dev/null @@ -1,261 +0,0 @@ -#** ***************************************************************************** -# * -# * If not stated otherwise in this file or this component's LICENSE file the -# * following copyright and licenses apply: -# * -# * Copyright 2024 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. -# * -#* ****************************************************************************** - -# This file contains all the common functions required for test framework - -import subprocess -import os -import json -import requests -import Config -from os import path -import logging -from colorama import Fore, Style -import time - - -def error_log(message): - print(Fore.RED + f"ERROR: {message}" + Style.RESET_ALL) - -def warning_log(message): - print(Fore.YELLOW + f"LOGGER: {message}" + Style.RESET_ALL) - -def info_log(message): - print(Fore.CYAN + f"INFO: {message}" + Style.RESET_ALL) - -def initiliaze_flask_for_HdmiCecSource(): - '''This function is used to push the initial data towards the Flask server''' - try: - # Push the initial cec network data to Flask using http get requests - setDeviceConfig API - create_device_response = requests.get("http://{}/Database.setDeviceConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.config_data_hdmicecsource))) - print("Inside Utils.py : " + create_device_response.text + " : " + str(Config.config_data_hdmicecsource)) - print("configured device data using - http://{}/Database.setDeviceConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.config_data_hdmicecsource))) - print("") - - # Push the api overrides data to Flask using http get requests - setAPIConfig API - create_api_overrides_response = requests.get("http://{}/Hdmicec.setAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.api_data_hdmicecsource))) - print("Inside Utils.py : " + create_api_overrides_response.text + " : " + str(Config.api_data_hdmicecsource)) - print("configured hal api data using - http://{}/Hdmicec.setAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.api_data_hdmicecsource))) - print("") - - # Compare the obtained response with actual response - if "Success" in str(create_device_response.text) and "Success" in str(create_api_overrides_response.text): - print("Inside Utils.py : Successfully pushed the initial data (setDeviceConfig & setAPIConfig) to Flask") - else: - print("Inside Utils.py : Failed to push the initial data (setDeviceConfig & setAPIConfig) to Flask") - - except: - print("Inside Utils.py : Exception in initialize_flask function") - -def initialize_flask(): - '''This function is used to push the initial data towards the Flask server''' - try: - # Push the initial cec network data to Flask using http get requests - setDeviceConfig API - create_device_response = requests.get("http://{}/Database.setDeviceConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.config_data))) - print("Inside Utils.py : " + create_device_response.text + " : " + str(Config.config_data)) - print("configured device data using - http://{}/Database.setDeviceConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.config_data))) - print("") - - # Push the api overrides data to Flask using http get requests - setAPIConfig API - create_api_overrides_response = requests.get("http://{}/Hdmicec.setAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.api_data))) - print("Inside Utils.py : " + create_api_overrides_response.text + " : " + str(Config.api_data)) - print("configured hal api data using - http://{}/Hdmicec.setAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.api_data))) - print("") - - # Compare the obtained response with actual response - if "Success" in str(create_device_response.text) and "Success" in str(create_api_overrides_response.text): - print("Inside Utils.py : Successfully pushed the initial data (setDeviceConfig & setAPIConfig) to Flask") - else: - print("Inside Utils.py : Failed to push the initial data (setDeviceConfig & setAPIConfig) to Flask") - - except: - print("Inside Utils.py : Exception in initialize_flask function") - -def initialize_hal_apis_with_negative_values(): - '''This function is used to push the initial data towards the Flask server''' - try: - # Push the initial cec network data to Flask using http get requests - setDeviceConfig API - create_device_response = requests.get("http://{}/Database.setDeviceConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.config_data))) - print("Inside Utils.py : " + create_device_response.text + " : " + str(Config.config_data)) - print("configured device data using - http://{}/Database.setDeviceConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.config_data))) - print("") - - # Push the api overrides data to Flask using http get requests - setAPIConfig API - create_api_overrides_response = requests.get("http://{}/Hdmicec.setAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.api_data_crash_instance))) - print("Inside Utils.py : " + create_api_overrides_response.text + " : " + str(Config.api_data_crash_instance)) - print("configured hal api data using - http://{}/Hdmicec.setAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.api_data_crash_instance))) - print("") - - # Compare the obtained response with actual response - if "Success" in str(create_device_response.text) and "Success" in str(create_api_overrides_response.text): - print("Inside Utils.py : Successfully pushed the initial data (setDeviceConfig & setAPIConfig) to Flask") - else: - print("Inside Utils.py : Failed to push the initial data (setDeviceConfig & setAPIConfig) to Flask") - - except: - print("Inside Utils.py : Exception in initialize_flask function") - -def send_curl_command(curl_command): - '''This function is used to send the curl commands to get the output response using os module''' - output_response = "" - try: - # Send the curl command using os.system module - response = os.popen(curl_command) - - # Find the line that is a valid JSON for extracting only the json response - for line in response.readlines(): - try: - # Try to parse the current line as JSON - json.loads(line) - output_response = line - # Exit the loop as we found the JSON line - break - except json.JSONDecodeError: - # If current line is not a valid JSON, just pass and continue with the next line - pass - - # Check the output response and add a message if the obtained output response is null - if len(output_response) < 5: - output_response = "< No response from WPEFramework >" - except: - print("Inside Utils.py : Exception in send_curl_command function") - finally: - # Return the output json response of given curl command as a string - return output_response - -#abort Device config with 5 different device configurations. -def abort_data(data): - print("Sending abort configurations") - create_device_response = requests.get("http://{}/Database.setDeviceConfig/{}".format(Config.flask_server_ip, json.dumps(data))) - print("Inside Utils.py : " + create_device_response.text + " : " + str(data)) - print("configured device data using - http://{}/Database.setDeviceConfig/{}".format( - Config.flask_server_ip, json.dumps(data))) - print("") - -def initialize_flask_without_audio_device(): - '''This function is used to push the initial data towards the Flask server''' - try: - # Push the initial cec network data to Flask using http get requests - setDeviceConfig API - create_device_response = requests.get("http://{}/Database.setDeviceConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.config_data_no_audio))) - print("Inside Utils.py : " + create_device_response.text + " : " + str(Config.config_data)) - print("configured device data using - http://{}/Database.setDeviceConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.config_data_no_audio))) - print("") - - # Push the api overrides data to Flask using http get requests - setAPIConfig API - create_api_overrides_response = requests.get("http://{}/Hdmicec.setAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.api_data))) - print("Inside Utils.py : " + create_api_overrides_response.text + " : " + str(Config.api_data)) - print("configured hal api data using - http://{}/Hdmicec.setAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.api_data))) - print("") - - # Compare the obtained response with actual response - if "Success" in str(create_device_response.text) and "Success" in str(create_api_overrides_response.text): - print( - "Inside Utils.py : Successfully pushed the initial data (setDeviceConfig & setAPIConfig) to Flask") - else: - print("Inside Utils.py : Failed to push the initial data (setDeviceConfig & setAPIConfig) to Flask") - - except: - print("Inside Utils.py : Exception in initialize_flask function") - -def restart_services(): - '''This function is used to kill the WPEFramework & Websocket services and to restart those''' - try: - # Kill the port WPEFramework with -QUIT to generate .gcda filek - os.system("killall -QUIT WPEFramework") - - # Kill the port 55555 which runs the WPEFramework - os.system("fuser -k 55555/tcp") - - # Kill the port 9000 which runs the Websocket server - os.system("fuser -k 9000/tcp") - - # Start the websocket server using python subprocess module - subprocess.Popen(["python3", "websocket_server.py"], cwd=Config.directory_websocket) - time.sleep(5) - subprocess.run(["chmod", "+x", "restart.sh"], check=True) - subprocess.Popen(["./restart.sh"], cwd=Config.WPEFramework_restart) - time.sleep(5) - # file_path = path.relpath(Config.WPEFramework_logs_path) - - # Open a file for writing the output and error of WPEFramework process - # with open(file_path, "w") as logfile: - - # Run the command to start the WPEFramework and redirect the output and error to the file - # subprocess.Popen(["WPEFramework", "-f", "-c", "config.json"], - # cwd=Config.directory_thunder, stdout=logfile, stderr=logfile) - # subprocess.Popen(["./restart.sh"], cwd=Config.WPEFramework_restart, stdout=logfile, stderr=logfile) - except: - print("Inside Utils.py : Exception in restart_services function") - -def netstat_output(): - - #Run the netstat -ntlp command - - output = subprocess.run(['netstat','-ntlp'],capture_output=True,text=True) - - #Return the output as a string - - return output.stdout - -def initialize_flask_with_HalApiNegativeValues(): - '''This function is used to push the initial data towards the Flask server''' - try: - # Push the initial cec network data to Flask using http get requests - setDeviceConfig API - create_device_response = requests.get("http://{}/Database.setDeviceConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.config_data))) - print("Inside Utils.py : " + create_device_response.text + " : " + str(Config.config_data)) - print("configured device data using - http://{}/Database.setDeviceConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.config_data))) - print("") - - # Push the api overrides data to Flask using http get requests - setAPIConfig API - create_api_overrides_response = requests.get("http://{}/Hdmicec.setAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.api_data_negative))) - print("Inside Utils.py : " + create_api_overrides_response.text + " : " + str(Config.api_data_negative)) - print("configured hal api data using - http://{}/Hdmicec.setAPIConfig/{}".format( - Config.flask_server_ip, json.dumps(Config.api_data_negative))) - print("") - - # Compare the obtained response with actual response - if "Success" in str(create_device_response.text) and "Success" in str(create_api_overrides_response.text): - print("Inside Utils.py : Successfully pushed the initial data (setDeviceConfig & setAPIConfig) to Flask") - else: - print("Inside Utils.py : Failed to push the initial data (setDeviceConfig & setAPIConfig) to Flask") - - except: - print("Inside Utils.py : Exception in initialize_flask function") diff --git a/Tests/L2HALMockTests/Test_Framework/lcovrc_halmock b/Tests/L2HALMockTests/Test_Framework/lcovrc_halmock deleted file mode 100644 index 879fe2ce5..000000000 --- a/Tests/L2HALMockTests/Test_Framework/lcovrc_halmock +++ /dev/null @@ -1,181 +0,0 @@ -# -# /etc/lcovrc - system-wide defaults for LCOV -# -# To change settings for a single user, place a customized copy of this file -# at location ~/.lcovrc -# - -# Specify an external style sheet file (same as --css-file option of genhtml) -#genhtml_css_file = gcov.css - -# Specify coverage rate limits (in %) for classifying file entries -# HI: hi_limit <= rate <= 100 graph color: green -# MED: med_limit <= rate < hi_limit graph color: orange -# LO: 0 <= rate < med_limit graph color: red -genhtml_hi_limit = 75 -genhtml_med_limit = 50 - -# Width of line coverage field in source code view -genhtml_line_field_width = 12 - -# Width of branch coverage field in source code view -genhtml_branch_field_width = 16 - -# Width of overview image (used by --frames option of genhtml) -genhtml_overview_width = 80 - -# Resolution of overview navigation: this number specifies the maximum -# difference in lines between the position a user selected from the overview -# and the position the source code window is scrolled to (used by --frames -# option of genhtml) -genhtml_nav_resolution = 4 - -# Clicking a line in the overview image should show the source code view at -# a position a bit further up so that the requested line is not the first -# line in the window. This number specifies that offset in lines (used by -# --frames option of genhtml) -genhtml_nav_offset = 10 - -# Do not remove unused test descriptions if non-zero (same as -# --keep-descriptions option of genhtml) -genhtml_keep_descriptions = 0 - -# Do not remove prefix from directory names if non-zero (same as --no-prefix -# option of genhtml) -genhtml_no_prefix = 0 - -# Do not create source code view if non-zero (same as --no-source option of -# genhtml) -genhtml_no_source = 0 - -# Replace tabs with number of spaces in source view (same as --num-spaces -# option of genhtml) -genhtml_num_spaces = 8 - -# Highlight lines with converted-only data if non-zero (same as --highlight -# option of genhtml) -genhtml_highlight = 0 - -# Include color legend in HTML output if non-zero (same as --legend option of -# genhtml) -genhtml_legend = 0 - -# Use FILE as HTML prolog for generated pages (same as --html-prolog option of -# genhtml) -#genhtml_html_prolog = FILE - -# Use FILE as HTML epilog for generated pages (same as --html-epilog option of -# genhtml) -#genhtml_html_epilog = FILE - -# Use custom filename extension for pages (same as --html-extension option of -# genhtml) -#genhtml_html_extension = html - -# Compress all generated html files with gzip. -#genhtml_html_gzip = 1 - -# Include sorted overview pages (can be disabled by the --no-sort option of -# genhtml) -genhtml_sort = 1 - -# Include function coverage data display (can be disabled by the -# --no-func-coverage option of genhtml) -#genhtml_function_coverage = 1 - -# Include branch coverage data display (can be disabled by the -# --no-branch-coverage option of genhtml) -#genhtml_branch_coverage = 1 - -# Specify the character set of all generated HTML pages -genhtml_charset=UTF-8 - -# Allow HTML markup in test case description text if non-zero -genhtml_desc_html=0 - -# Specify the precision for coverage rates -#genhtml_precision=1 - -# Show missed counts instead of hit counts -#genhtml_missed=1 - -# Demangle C++ symbols -#genhtml_demangle_cpp=1 - -# Name of the tool used for demangling C++ function names -#genhtml_demangle_cpp_tool = c++filt - -# Specify extra parameters to be passed to the demangling tool -#genhtml_demangle_cpp_params = "" - -# Location of the gcov tool (same as --gcov-info option of geninfo) -#geninfo_gcov_tool = gcov - -# Adjust test names to include operating system information if non-zero -#geninfo_adjust_testname = 0 - -# Calculate checksum for each source code line if non-zero (same as --checksum -# option of geninfo if non-zero, same as --no-checksum if zero) -#geninfo_checksum = 1 - -# Specify whether to capture coverage data for external source files (can -# be overridden by the --external and --no-external options of geninfo/lcov) -#geninfo_external = 1 - -# Enable libtool compatibility mode if non-zero (same as --compat-libtool option -# of geninfo if non-zero, same as --no-compat-libtool if zero) -#geninfo_compat_libtool = 0 - -# Use gcov's --all-blocks option if non-zero -#geninfo_gcov_all_blocks = 1 - -# Specify compatiblity modes (same as --compat option of geninfo). -#geninfo_compat = libtool=on, hammer=auto, split_crc=auto - -# Adjust path to source files by removing or changing path components that -# match the specified pattern (Perl regular expression format) -#geninfo_adjust_src_path = /tmp/build => /usr/src - -# Specify if geninfo should try to automatically determine the base-directory -# when collecting coverage data. -geninfo_auto_base = 1 - -# Use gcov intermediate format? Valid values are 0, 1, auto -geninfo_intermediate = auto - -# Specify if exception branches should be excluded from branch coverage. -geninfo_no_exception_branch = 0 - -# Directory containing gcov kernel files -# lcov_gcov_dir = /proc/gcov - -# Location of the insmod tool -lcov_insmod_tool = /sbin/insmod - -# Location of the modprobe tool -lcov_modprobe_tool = /sbin/modprobe - -# Location of the rmmod tool -lcov_rmmod_tool = /sbin/rmmod - -# Location for temporary directories -lcov_tmp_dir = /tmp - -# Show full paths during list operation if non-zero (same as --list-full-path -# option of lcov) -lcov_list_full_path = 0 - -# Specify the maximum width for list output. This value is ignored when -# lcov_list_full_path is non-zero. -lcov_list_width = 80 - -# Specify the maximum percentage of file names which may be truncated when -# choosing a directory prefix in list output. This value is ignored when -# lcov_list_full_path is non-zero. -lcov_list_truncate_max = 20 - -# Specify if function coverage data should be collected and processed. -lcov_function_coverage = 1 - -# Specify if branch coverage data should be collected and processed. -lcov_branch_coverage = 0 diff --git a/Tests/L2HALMockTests/Test_Framework/restart.sh b/Tests/L2HALMockTests/Test_Framework/restart.sh deleted file mode 100755 index 42b1ef67c..000000000 --- a/Tests/L2HALMockTests/Test_Framework/restart.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -SCRIPT=$(readlink -f "$0") -SCRIPTS_DIR=`dirname "$SCRIPT"` -WORKSPACE=$SCRIPTS_DIR/../../../.. - -echo -e "${GREEN}========================================Run rdkservices===============================================${NC}" -cd $WORKSPACE -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH/usr/local/lib/:$WORKSPACE/deps/rdk/hdmicec/install/lib:$WORKSPACE/deps/rdk/hdmicec/ccec/drivers/test:$WORKSPACE/deps/rdk/iarmbus/install/:$WORKSPACE/install/usr/lib:$WORKSPACE/deps/rdk/devicesettings/install/lib -$WORKSPACE/install/usr/bin/WPEFramework -f -c $WORKSPACE/install/etc/WPEFramework/config.json & \ No newline at end of file diff --git a/Tests/L2Tests/CMakeLists.txt b/Tests/L2Tests/CMakeLists.txt deleted file mode 100755 index 7e8523300..000000000 --- a/Tests/L2Tests/CMakeLists.txt +++ /dev/null @@ -1,85 +0,0 @@ -# If not stated otherwise in this file or this component's LICENSE file the -# following copyright and licenses apply: -# -# Copyright 2023 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. - - -set(PLUGIN_NAME L2TestsIO) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) -set(THUNDER_PORT 9998) -#set(CMAKE_CXX_STANDARD 11) -find_package(${NAMESPACE}Plugins REQUIRED) - -include(FetchContent) -FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/e39786088138f2749d64e9e90e0f9902daa77c40.zip -) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) -FetchContent_MakeAvailable(googletest) - -if(PLUGIN_AVOUTPUT) - set(SRC_FILES ${SRC_FILES} tests/AVOutputTV_L2Test.cpp) -endif() - -add_library(${MODULE_NAME} SHARED ${SRC_FILES}) - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -target_compile_definitions(${MODULE_NAME} - PRIVATE - MODULE_NAME=Plugin_${PLUGIN_NAME} - THUNDER_PORT="${THUNDER_PORT}") - -target_compile_options(${MODULE_NAME} PRIVATE -Wno-error) -target_link_libraries(${MODULE_NAME} PRIVATE gmock_main ${NAMESPACE}Plugins::${NAMESPACE}Plugins) - -if (NOT L2_TEST_OOP_RPC) - find_library(TESTMOCKLIB_LIBRARIES NAMES TestMocklib) - if (TESTMOCKLIB_LIBRARIES) - message ("Found mock library - ${TESTMOCKLIB_LIBRARIES}") - target_link_libraries(${MODULE_NAME} PRIVATE ${TESTMOCKLIB_LIBRARIES}) - else (TESTMOCKLIB_LIBRARIES) - message ("Require ${TESTMOCKLIB_LIBRARIES} library") - endif (TESTMOCKLIB_LIBRARIES) -endif (NOT L2_TEST_OOP_RPC) - -find_library(MOCKACCESSOR_LIBRARIES NAMES MockAccessor) -if (MOCKACCESSOR_LIBRARIES) - message ("Found MockAccessor library - ${MOCKACCESSOR_LIBRARIES}") - target_link_libraries(${MODULE_NAME} PRIVATE ${MOCKACCESSOR_LIBRARIES}) -else (MOCKACCESSOR_LIBRARIES) - message ("Require ${MOCKACCESSOR_LIBRARIES} library") -endif (MOCKACCESSOR_LIBRARIES) - -target_include_directories( - ${MODULE_NAME} PRIVATE ./ - ../../helpers - ../../../entservices-testframework/Tests/mocks - ../../../entservices-testframework/Tests/mocks/thunder - ../../../entservices-testframework/Tests/mocks/devicesettings - ../../../entservices-testframework/Tests/mocks/MockPlugin - ../../../entservices-testframework/Tests/L2Tests/L2TestsPlugin - ${CMAKE_INSTALL_PREFIX}/include - ) - -install(TARGETS ${MODULE_NAME} DESTINATION lib) - -write_config(${PLUGIN_NAME}) - - - diff --git a/Tests/L2Tests/tests/AVOutputTV_L2Test.cpp b/Tests/L2Tests/tests/AVOutputTV_L2Test.cpp deleted file mode 100755 index e7e3b47d5..000000000 --- a/Tests/L2Tests/tests/AVOutputTV_L2Test.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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 -#include -#include "L2Tests.h" -#include "L2TestsMock.h" -#include -#include -#include - -#define JSON_TIMEOUT (1000) -#define TEST_LOG(x, ...) fprintf(stderr, "\033[1;32m[%s:%d](%s)" x "\n\033[0m", __FILE__, __LINE__, __FUNCTION__, getpid(), gettid(), ##__VA_ARGS__); fflush(stderr); -#define AVOUTPUT_CALLSIGN _T("org.rdk.AVOutput.1") -#define AVOUTPUT_CALLSIGNL2TEST_CALLSIGN _T("L2tests.1") - -using ::testing::NiceMock; -using namespace WPEFramework; -using testing::StrictMock; - -/** -* @brief Internal test mock class -* -* Note that this is for internal test use only and doesn't mock any actual -* concrete interface. -*/ - -/* AVOutput L2 test class declaration */ -class AVOutput_L2test : public L2TestMocks { -protected: - Core::JSONRPC::Message message; - string response; - IARM_EventHandler_t dsHdmiStatusEventHandler; - IARM_EventHandler_t dsHdmiVideoModeEventHandler; - - virtual ~AVOutput_L2test() override; - - public: - AVOutput_L2test(); -}; - -/** -* @brief Constructor for AVOutput L2 test class -*/ -AVOutput_L2test::AVOutput_L2test() - : L2TestMocks() -{ - printf("AVOutput Constructor\n"); - uint32_t status = Core::ERROR_GENERAL; - - std::ofstream devicePropFileStream("/etc/device.properties"); - devicePropFileStream << "RDK_PROFILE=TV"; - devicePropFileStream << "\n"; - devicePropFileStream.close(); - - EXPECT_CALL(*p_rfcApiImplMock, getRFCParameter(::testing::_, ::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [](char* pcCallerID, const char* pcParameterName, RFC_ParamData_t* pstParamData) { - EXPECT_EQ(string(pcCallerID), string("AVOutput")); - EXPECT_EQ(string(pcParameterName), string("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AVOutput.DynamicAutoLatency")); - strncpy(pstParamData->value, "true", sizeof(pstParamData->value)); - return WDMP_SUCCESS; - })); - - ON_CALL(*p_iarmBusImplMock, IARM_Bus_RegisterEventHandler(::testing::_, ::testing::_, ::testing::_)) - .WillByDefault(::testing::Invoke( - [&](const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) { - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiStatusEventHandler = handler; - } - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiVideoModeEventHandler = handler; - } - return IARM_RESULT_SUCCESS; - })); - - ON_CALL(*p_hdmiInputImplMock, getCurrentVideoModeObj(::testing::_)) - .WillByDefault(::testing::Invoke( - [&](dsVideoPortResolution_t& resolution) { - resolution.pixelResolution = dsVIDEO_PIXELRES_1920x1080; - return tvERROR_NONE; - })); - - ON_CALL(*p_tvSettingsImplMock, TvInit()) - .WillByDefault(::testing::Return(tvERROR_NONE)); - - ON_CALL(*p_tvSettingsImplMock, RegisterVideoFormatChangeCB(testing::_)) - .WillByDefault(testing::Return(tvERROR_NONE)); - ON_CALL(*p_tvSettingsImplMock, RegisterVideoContentChangeCB(testing::_)) - .WillByDefault(testing::Return(tvERROR_NONE)); - ON_CALL(*p_tvSettingsImplMock, RegisterVideoResolutionChangeCB(testing::_)) - .WillByDefault(testing::Return(tvERROR_NONE)); - ON_CALL(*p_tvSettingsImplMock, RegisterVideoFrameRateChangeCB(testing::_)) - .WillByDefault(testing::Return(tvERROR_NONE)); - - EXPECT_CALL(*p_tr181ApiImplMock, getLocalParam(::testing::_, ::testing::_, ::testing::_)) - .Times(2) - .WillOnce(::testing::Invoke( - [&](char *pcCallerID, const char* pcParameterName, TR181_ParamData_t *pstParamData) { - EXPECT_EQ(string(pcCallerID), string("AVOutput")); - strncpy(pstParamData->value, "Normal", sizeof(pstParamData->value)); - - return tr181Success; - })) - .WillOnce(::testing::Invoke( - [&](char *pcCallerID, const char* pcParameterName, TR181_ParamData_t *pstParamData) { - EXPECT_EQ(string(pcCallerID), string("AVOutput")); - strncpy(pstParamData->value, "Normal", sizeof(pstParamData->value)); - - return tr181Success; - })); - - ON_CALL(*p_tvSettingsImplMock, SetAspectRatio(testing::_)) - .WillByDefault(testing::Invoke( - [&](tvDisplayMode_t dispMode) { - EXPECT_EQ(dispMode, tvDisplayMode_NORMAL); - return tvERROR_NONE; - })); - - ON_CALL(*p_tvSettingsImplMock, GetCurrentSource(testing::_)) - .WillByDefault(testing::Invoke( - [&](tvVideoSrcType_t *currentSource) { - EXPECT_EQ(*currentSource, VIDEO_SOURCE_IP); - return tvERROR_NONE; - })); - - ON_CALL(*p_tvSettingsImplMock, GetCurrentVideoFormat(testing::_)) - .WillByDefault(testing::Invoke( - [&](tvVideoFormatType_t* videoFormat) { - EXPECT_EQ(*videoFormat, VIDEO_FORMAT_NONE); - return tvERROR_NONE; // Return an appropriate error code - })); - - ON_CALL(*p_tvSettingsImplMock, SetTVPictureMode(testing::_)) - .WillByDefault(testing::Invoke( - [&](const char * pictureMode) { - EXPECT_EQ(string(pictureMode), string("normal")); - return tvERROR_NONE; - })); - - /* Activate plugin in constructor */ - status = ActivateService("org.rdk.AVOutput"); - EXPECT_EQ(Core::ERROR_NONE, status); -} - -/** -* @brief Destructor for AVInput L2 test class -*/ -AVOutput_L2test::~AVOutput_L2test() -{ - printf("AVOutput Destructor\n"); - uint32_t status = Core::ERROR_GENERAL; - - ON_CALL(*p_tvSettingsImplMock, TvTerm()) - .WillByDefault(::testing::Return(tvERROR_NONE)); - - status = DeactivateService("org.rdk.AVOutput"); - EXPECT_EQ(Core::ERROR_NONE, status); -} - -TEST_F(AVOutput_L2test, AVOUTPUT_GETINPUTDEVICE_Test) -{ - JSONRPC::LinkType jsonrpc(AVOUTPUT_CALLSIGN, AVOUTPUT_CALLSIGNL2TEST_CALLSIGN); - uint32_t status = Core::ERROR_GENERAL; - JsonObject result, params; - - ON_CALL(*p_tvSettingsImplMock, ReadCapablitiesFromConfODM(testing::_, testing::_, testing::_, testing::_, testing::_, testing::_, testing::_)) - .WillByDefault([](std::string& rangeInfo, std::string& pqmodeInfo, std::string& formatInfo, std::string& sourceInfo, std::string param, std::string& platformsupport, std::string& index) { - printf("ReadCapablitiesFromConfODM\n"); - rangeInfo = "\"Standard\",\"Vivid\",\"EnergySaving\",\"Custom\",\"Theater\",\"Game\""; - pqmodeInfo = ""; - formatInfo = "\"SDR\""; - sourceInfo = "\"HDMI\",\"HDMI2\""; - platformsupport = ""; - index = "0"; - - return tvERROR_NONE; - }); - - status = InvokeServiceMethod("org.rdk.AVOutput.1", "getPictureModeCaps", params, result); - -} diff --git a/Tests/L2Tests/tests/HdmiCecSource_L2Test.cpp b/Tests/L2Tests/tests/HdmiCecSource_L2Test.cpp new file mode 100644 index 000000000..e9d11c853 --- /dev/null +++ b/Tests/L2Tests/tests/HdmiCecSource_L2Test.cpp @@ -0,0 +1,3124 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2025 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 "L2Tests.h" +#include "L2TestsMock.h" +#include +#include +#include +#include +#include +// Used to change the power state for events +#include + +#define EVNT_TIMEOUT (5000) +#define HDMICECSOURCE_CALLSIGN _T("org.rdk.HdmiCecSource.1") +#define HDMICECSOURCE_L2TEST_CALLSIGN _T("L2tests.1") + +#define TEST_LOG(x, ...) \ + fprintf(stderr, "\033[1;32m[%s:%d](%s)" x "\n\033[0m", __FILE__, __LINE__, __FUNCTION__, getpid(), gettid(), ##__VA_ARGS__); \ + fflush(stderr); + +using ::testing::NiceMock; +using namespace WPEFramework; +using testing::StrictMock; +using HdmiCecSourceSuccess = WPEFramework::Exchange::IHdmiCecSource::HdmiCecSourceSuccess; +using HdmiCecSourceDevice = WPEFramework::Exchange::IHdmiCecSource::HdmiCecSourceDevices; +using IHdmiCecSourceDeviceListIterator = WPEFramework::Exchange::IHdmiCecSource::IHdmiCecSourceDeviceListIterator; +using PowerState = WPEFramework::Exchange::IPowerManager::PowerState; + +namespace { + static void removeFile(const char* fileName) + { + if (std::remove(fileName) != 0) + { + printf("File %s failed to remove\n", fileName); + perror("Error deleting file"); + } + else + { + printf("File %s successfully deleted\n", fileName); + } + } + + static void createFile(const char* fileName, const char* fileContent) + { + removeFile(fileName); + + std::ofstream fileContentStream(fileName); + fileContentStream << fileContent; + fileContentStream << "\n"; + fileContentStream.close(); + } + +class AsyncHandlerMock { +public: + virtual ~AsyncHandlerMock() = default; + virtual void onActiveSourceStatusUpdated(bool status) = 0; + virtual void onDeviceAdded(int logicalAddress) = 0; + virtual void onDeviceRemoved(int logicalAddress) = 0; + virtual void onDeviceInfoUpdated(int logicalAddress) = 0; + virtual void standbyMessageReceived(int logicalAddress) = 0; + virtual void onKeyReleaseEvent(int logicalAddress) = 0; + virtual void onKeyPressEvent(int logicalAddress, int keyCode) = 0; +}; + +class MockAsyncHandler : public AsyncHandlerMock { +public: + MOCK_METHOD(void, onActiveSourceStatusUpdated, (bool status), (override)); + MOCK_METHOD(void, onDeviceAdded, (int logicalAddress), (override)); + MOCK_METHOD(void, onDeviceRemoved, (int logicalAddress), (override)); + MOCK_METHOD(void, onDeviceInfoUpdated, (int logicalAddress), (override)); + MOCK_METHOD(void, standbyMessageReceived, (int logicalAddress), (override)); + MOCK_METHOD(void, onKeyReleaseEvent, (int logicalAddress), (override)); + MOCK_METHOD(void, onKeyPressEvent, (int logicalAddress, int keyCode), (override)); +}; +} + +// Event flags for different CEC events +typedef enum : uint32_t { + ON_ACTIVE_SOURCE_STATUS_UPDATED = 0x00000001, + ON_DEVICE_ADDED = 0x00000002, + ON_DEVICE_REMOVED = 0x00000004, + ON_DEVICE_INFO_UPDATED = 0x00000008, + STANDBY_MESSAGE_RECEIVED = 0x00000010, + ON_KEY_RELEASE_EVENT = 0x00000020, + ON_KEY_PRESS_EVENT = 0x00000040, + HDMICECSOURCE_STATUS_INVALID = 0x00000000 +} HdmiCecSourceL2test_async_events_t; + +// Notification handler for HdmiCecSource events +class HdmiCecSourceNotificationHandler : public Exchange::IHdmiCecSource::INotification { +private: + std::mutex m_mutex; + std::condition_variable m_condition_variable; + uint32_t m_event_signalled; + + BEGIN_INTERFACE_MAP(Notification) + INTERFACE_ENTRY(Exchange::IHdmiCecSource::INotification) + END_INTERFACE_MAP + +public: + HdmiCecSourceNotificationHandler() + : m_event_signalled(HDMICECSOURCE_STATUS_INVALID) + , m_activeSourceStatus(false) + , m_logicalAddress(0) + , m_keyCode(0) + { + } + + ~HdmiCecSourceNotificationHandler() override = default; + + void OnActiveSourceStatusUpdated(const bool status) override + { + TEST_LOG("OnActiveSourceStatusUpdated event received, status: %d", status); + std::unique_lock lock(m_mutex); + m_activeSourceStatus = status; + m_event_signalled |= ON_ACTIVE_SOURCE_STATUS_UPDATED; + m_condition_variable.notify_one(); + } + + void OnDeviceAdded(const int logicalAddress) override + { + TEST_LOG("OnDeviceAdded event received, logicalAddress: %d", logicalAddress); + std::unique_lock lock(m_mutex); + m_logicalAddress = logicalAddress; + m_event_signalled |= ON_DEVICE_ADDED; + m_condition_variable.notify_one(); + } + + void OnDeviceRemoved(const int logicalAddress) override + { + TEST_LOG("OnDeviceRemoved event received, logicalAddress: %d", logicalAddress); + std::unique_lock lock(m_mutex); + m_logicalAddress = logicalAddress; + m_event_signalled |= ON_DEVICE_REMOVED; + m_condition_variable.notify_one(); + } + + void OnDeviceInfoUpdated(const int logicalAddress) override + { + TEST_LOG("OnDeviceInfoUpdated event received, logicalAddress: %d", logicalAddress); + std::unique_lock lock(m_mutex); + m_logicalAddress = logicalAddress; + m_event_signalled |= ON_DEVICE_INFO_UPDATED; + m_condition_variable.notify_one(); + } + + void StandbyMessageReceived(const int logicalAddress) override + { + TEST_LOG("StandbyMessageReceived event received, logicalAddress: %d", logicalAddress); + std::unique_lock lock(m_mutex); + m_logicalAddress = logicalAddress; + m_event_signalled |= STANDBY_MESSAGE_RECEIVED; + m_condition_variable.notify_one(); + } + + void OnKeyReleaseEvent(const int logicalAddress) override + { + TEST_LOG("OnKeyReleaseEvent event received, logicalAddress: %d", logicalAddress); + std::unique_lock lock(m_mutex); + m_logicalAddress = logicalAddress; + m_event_signalled |= ON_KEY_RELEASE_EVENT; + m_condition_variable.notify_one(); + } + + void OnKeyPressEvent(const int logicalAddress, const int keyCode) override + { + TEST_LOG("OnKeyPressEvent event received, logicalAddress: %d, keyCode: %d", logicalAddress, keyCode); + std::unique_lock lock(m_mutex); + m_logicalAddress = logicalAddress; + m_keyCode = keyCode; + m_event_signalled |= ON_KEY_PRESS_EVENT; + m_condition_variable.notify_one(); + } + + uint32_t WaitForEvent(uint32_t timeout_ms, HdmiCecSourceL2test_async_events_t expected_status) + { + std::unique_lock lock(m_mutex); + auto now = std::chrono::system_clock::now(); + auto timeout = now + std::chrono::milliseconds(timeout_ms); + uint32_t signalled = HDMICECSOURCE_STATUS_INVALID; + + while (!(m_event_signalled & expected_status)) { + if (m_condition_variable.wait_until(lock, timeout) == std::cv_status::timeout) { + TEST_LOG("Timeout waiting for event: 0x%08X", expected_status); + return HDMICECSOURCE_STATUS_INVALID; + } + } + + signalled = m_event_signalled & expected_status; + m_event_signalled = HDMICECSOURCE_STATUS_INVALID; + return signalled; + } + + void ResetEvent() + { + std::unique_lock lock(m_mutex); + m_event_signalled = HDMICECSOURCE_STATUS_INVALID; + } + + bool GetActiveSourceStatus() const { return m_activeSourceStatus; } + int GetLogicalAddress() const { return m_logicalAddress; } + int GetKeyCode() const { return m_keyCode; } + +private: + bool m_activeSourceStatus; + int m_logicalAddress; + int m_keyCode; +}; + +class AsyncHandlerMock_HdmiCecSource { +public: + AsyncHandlerMock_HdmiCecSource() + { + m_asyncHandlerMock = new NiceMock; + } + + virtual ~AsyncHandlerMock_HdmiCecSource() + { + delete m_asyncHandlerMock; + } + + MockAsyncHandler& mock() { return *m_asyncHandlerMock; } + +private: + MockAsyncHandler* m_asyncHandlerMock; +}; + +class HdmiCecSource_L2Test : public L2TestMocks { +protected: + HdmiCecSource_L2Test(); + virtual ~HdmiCecSource_L2Test() override; + +public: + uint32_t CreateHdmiCecSourceInterfaceObject(); + uint32_t WaitForRequestStatus(uint32_t timeout_ms, HdmiCecSourceL2test_async_events_t expected_status); + void onActiveSourceStatusUpdated(const JsonObject& message); + void onDeviceAdded(const JsonObject& message); + void onDeviceInfoUpdated(const JsonObject& message); + void onDeviceRemoved(const JsonObject& message); + void standbyMessageReceived(const JsonObject& message); + void onKeyReleaseEvent(const JsonObject& message); + void onKeyPressEvent(const JsonObject& message); + +protected: + Exchange::IHdmiCecSource* m_cecSourcePlugin = nullptr; + PluginHost::IShell* m_controller_cecSource = nullptr; + Core::Sink m_notificationHandler; + IARM_EventHandler_t dsHdmiEventHandler = nullptr; + IARM_EventHandler_t powerEventHandler = nullptr; + FrameListener* registeredListener = nullptr; + std::vector listeners; + + Core::ProxyType> HdmiCecSource_Engine; + Core::ProxyType HdmiCecSource_Client; + +private: + std::mutex m_mutex; + std::condition_variable m_condition_variable; + uint32_t m_event_signalled = HDMICECSOURCE_STATUS_INVALID; +}; + +HdmiCecSource_L2Test::HdmiCecSource_L2Test() + : L2TestMocks() +{ + TEST_LOG("HdmiCecSource_L2Test Constructor"); + + // Setup device.properties file + removeFile("/etc/device.properties"); + createFile("/etc/device.properties", "RDK_PROFILE=STB"); + createFile("/opt/persistent/ds/cecData_2.json", "0"); + createFile("/tmp/pwrmgr_restarted", "2"); + + // Add sleep to ensure file is properly written to disk + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + + // Mock IARM Bus initialization + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_Init(::testing::_)) + .Times(::testing::AnyNumber()) + .WillRepeatedly(::testing::Return(IARM_RESULT_SUCCESS)); + + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_Connect()) + .Times(::testing::AnyNumber()) + .WillRepeatedly(::testing::Return(IARM_RESULT_SUCCESS)); + + // Mock IARM Event Registration to capture event handlers + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_RegisterEventHandler(::testing::_, ::testing::_, ::testing::_)) + .Times(::testing::AnyNumber()) + .WillRepeatedly(::testing::Invoke( + [this](const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) { + if (strcmp(ownerName, IARM_BUS_DSMGR_NAME) == 0) { + if (eventId == IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG) { + dsHdmiEventHandler = handler; + TEST_LOG("Captured HDMI HotPlug Event Handler"); + } + } else if (strcmp(ownerName, IARM_BUS_PWRMGR_NAME) == 0) { + if (eventId == IARM_BUS_PWRMGR_EVENT_MODECHANGED) { + powerEventHandler = handler; + TEST_LOG("Captured Power Manager Event Handler"); + } + } + return IARM_RESULT_SUCCESS; + })); + + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_UnRegisterEventHandler(::testing::_, ::testing::_)) + .Times(::testing::AnyNumber()) + .WillRepeatedly(::testing::Return(IARM_RESULT_SUCCESS)); + + EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_Call) + .Times(::testing::AnyNumber()) + .WillRepeatedly( + [](const char* ownerName, const char* methodName, void* arg, size_t argLen) { + IARM_Result_t result = IARM_RESULT_SUCCESS; + if (strcmp(ownerName, IARM_BUS_PWRMGR_NAME) == 0) { + if (strcmp(methodName, IARM_BUS_PWRMGR_API_GetPowerState) == 0) { + auto* param = static_cast(arg); + param->curState = IARM_BUS_PWRMGR_POWERSTATE_ON; + } + } + return result; + }); + + // Mock device settings Manager + ON_CALL(*p_managerImplMock, Initialize()) + .WillByDefault(::testing::Return()); + + // Mock Host methods + ON_CALL(*p_hostImplMock, getDefaultVideoPortName()) + .WillByDefault(::testing::Return(std::string("HDMI0"))); + + ON_CALL(*p_hostImplMock, getVideoOutputPort(::testing::_)) + .WillByDefault(::testing::ReturnRef(device::VideoOutputPort::getInstance())); + + // Mock VideoOutputPort methods + ON_CALL(*p_videoOutputPortMock, isDisplayConnected()) + .WillByDefault(::testing::Return(true)); + + ON_CALL(*p_videoOutputPortMock, getDisplay()) + .WillByDefault(::testing::ReturnRef(device::Display::getInstance())); + + // Mock Display methods - getEDIDBytes is void and takes a reference parameter + ON_CALL(*p_displayMock, getEDIDBytes(::testing::_)) + .WillByDefault(::testing::Invoke( + [](std::vector& edid) { + edid = { + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, + 0x4C, 0x2D, 0xFE, 0x08, 0x00, 0x00, 0x00, 0x00 + }; + })); + + // Mock HDMI CEC Connection - capture frame listeners for event injection + ON_CALL(*p_connectionMock, addFrameListener(::testing::_)) + .WillByDefault(::testing::Invoke( + [this](FrameListener* listener) { + TEST_LOG("addFrameListener called with address: %p", static_cast(listener)); + if (listener != nullptr) { + registeredListener = listener; + listeners.push_back(listener); + TEST_LOG("Frame listener registered, total listeners: %zu", listeners.size()); + } + })); + + // Mock MessageEncoder - need to mock both overloads explicitly + ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) + .WillByDefault(::testing::Invoke( + [](const DataBlock& m) -> CECFrame& { + static CECFrame frame; + return frame; + })); + + ON_CALL(*p_messageEncoderMock, encode(::testing::Matcher(::testing::_))) + .WillByDefault(::testing::Invoke( + [](const UserControlPressed& m) -> CECFrame& { + static CECFrame frame; + return frame; + })); + + // Mock Wraps + ON_CALL(*p_wrapsImplMock, access(::testing::_, ::testing::_)) + .WillByDefault(::testing::Return(0)); + + // Mock PowerManager HAL for PowerManager plugin initialization + EXPECT_CALL(*p_powerManagerHalMock, PLAT_DS_INIT()) + .WillOnce(::testing::Return(DEEPSLEEPMGR_SUCCESS)); + + EXPECT_CALL(*p_powerManagerHalMock, PLAT_INIT()) + .WillRepeatedly(::testing::Return(PWRMGR_SUCCESS)); + + EXPECT_CALL(*p_powerManagerHalMock, PLAT_API_SetWakeupSrc(::testing::_, ::testing::_)) + .WillRepeatedly(::testing::Return(PWRMGR_SUCCESS)); + + EXPECT_CALL(*p_powerManagerHalMock, PLAT_API_GetPowerState(::testing::_)) + .WillRepeatedly(::testing::Invoke( + [](PWRMgr_PowerState_t* powerState) { + *powerState = PWRMGR_POWERSTATE_ON; + return PWRMGR_SUCCESS; + })); + + ON_CALL(*p_rfcApiImplMock, getRFCParameter(::testing::_, ::testing::_, ::testing::_)) + .WillByDefault(::testing::Invoke( + [](char* pcCallerID, const char* pcParameterName, RFC_ParamData_t* pstParamData) { + if (strcmp("RFC_DATA_ThermalProtection_POLL_INTERVAL", pcParameterName) == 0) { + strcpy(pstParamData->value, "2"); + return WDMP_SUCCESS; + } else if (strcmp("RFC_ENABLE_ThermalProtection", pcParameterName) == 0) { + strcpy(pstParamData->value, "true"); + return WDMP_SUCCESS; + } else if (strcmp("RFC_DATA_ThermalProtection_DEEPSLEEP_GRACE_INTERVAL", pcParameterName) == 0) { + strcpy(pstParamData->value, "6"); + return WDMP_SUCCESS; + } else { + return WDMP_FAILURE; + } + })); + + EXPECT_CALL(*p_mfrMock, mfrSetTempThresholds(::testing::_, ::testing::_)) + .WillRepeatedly(::testing::Invoke( + [](int high, int critical) { + return mfrERR_NONE; + })); + + /* Activate plugin in constructor */ + uint32_t status = ActivateService("org.rdk.PowerManager"); + if (status != Core::ERROR_NONE) { + TEST_LOG("Failed to activate PowerManager, status: %d", status); + } + + status = ActivateService("org.rdk.HdmiCecSource"); + if (status != Core::ERROR_NONE) { + TEST_LOG("Failed to activate HdmiCecSource, status: %d", status); + } +} + +HdmiCecSource_L2Test::~HdmiCecSource_L2Test() +{ + TEST_LOG("HdmiCecSource_L2Test Destructor"); + + ON_CALL(*p_connectionMock, close()) + .WillByDefault(::testing::Return()); + + ON_CALL(*p_powerManagerHalMock, PLAT_TERM()) + .WillByDefault(::testing::Return(PWRMGR_SUCCESS)); + + ON_CALL(*p_powerManagerHalMock, PLAT_DS_TERM()) + .WillByDefault(::testing::Return(DEEPSLEEPMGR_SUCCESS)); + + + DeactivateService("org.rdk.HdmiCecSource"); + + + DeactivateService("org.rdk.PowerManager"); + + + + if (HdmiCecSource_Client.IsValid()) { + HdmiCecSource_Client.Release(); + } + + if (HdmiCecSource_Engine.IsValid()) { + HdmiCecSource_Engine.Release(); + } + + // Cleanup device.properties file + removeFile("/etc/device.properties"); + removeFile("/tmp/pwrmgr_restarted"); + removeFile("/opt/persistent/ds/cecData_2.json"); + removeFile("/opt/uimgr_settings.bin"); + + TEST_LOG("HdmiCecSource_L2Test cleanup complete"); +} + +uint32_t HdmiCecSource_L2Test::CreateHdmiCecSourceInterfaceObject() +{ + uint32_t return_value = Core::ERROR_GENERAL; + + TEST_LOG("Creating HdmiCecSource_Engine"); + HdmiCecSource_Engine = Core::ProxyType>::Create(); + HdmiCecSource_Client = Core::ProxyType::Create( + Core::NodeId("/tmp/communicator"), + Core::ProxyType(HdmiCecSource_Engine)); + + TEST_LOG("Creating HdmiCecSource_Engine Announcements"); +#if ((THUNDER_VERSION == 2) || ((THUNDER_VERSION == 4) && (THUNDER_VERSION_MINOR == 2))) + HdmiCecSource_Engine->Announcements(HdmiCecSource_Client->Announcement()); +#endif + + if (!HdmiCecSource_Client.IsValid()) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + m_controller_cecSource = HdmiCecSource_Client->Open( + _T("org.rdk.HdmiCecSource"), ~0, 3000); + if (m_controller_cecSource) { + m_cecSourcePlugin = m_controller_cecSource->QueryInterface(); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Register(&m_notificationHandler); + return_value = Core::ERROR_NONE; + TEST_LOG("Successfully created HdmiCecSource Plugin Interface"); + } else { + TEST_LOG("Failed to get IHdmiCecSource interface"); + } + } else { + TEST_LOG("Failed to get HdmiCecSource Plugin Interface"); + } + } + return return_value; +} + +uint32_t HdmiCecSource_L2Test::WaitForRequestStatus(uint32_t timeout_ms, HdmiCecSourceL2test_async_events_t expected_status) +{ + return m_notificationHandler.WaitForEvent(timeout_ms, expected_status); +} + +void HdmiCecSource_L2Test::onActiveSourceStatusUpdated(const JsonObject& message) +{ + TEST_LOG("onActiveSourceStatusUpdated JSON-RPC event received"); + std::unique_lock lock(m_mutex); + m_event_signalled |= ON_ACTIVE_SOURCE_STATUS_UPDATED; + m_condition_variable.notify_one(); +} + +void HdmiCecSource_L2Test::onDeviceAdded(const JsonObject& message) +{ + TEST_LOG("onDeviceAdded JSON-RPC event received"); + std::unique_lock lock(m_mutex); + m_event_signalled |= ON_DEVICE_ADDED; + m_condition_variable.notify_one(); +} + +void HdmiCecSource_L2Test::onDeviceInfoUpdated(const JsonObject& message) +{ + TEST_LOG("onDeviceInfoUpdated JSON-RPC event received"); + std::unique_lock lock(m_mutex); + m_event_signalled |= ON_DEVICE_INFO_UPDATED; + m_condition_variable.notify_one(); +} + +void HdmiCecSource_L2Test::onDeviceRemoved(const JsonObject& message) +{ + TEST_LOG("onDeviceRemoved JSON-RPC event received"); + std::unique_lock lock(m_mutex); + m_event_signalled |= ON_DEVICE_REMOVED; + m_condition_variable.notify_one(); +} + +void HdmiCecSource_L2Test::standbyMessageReceived(const JsonObject& message) +{ + TEST_LOG("standbyMessageReceived JSON-RPC event received"); + std::unique_lock lock(m_mutex); + m_event_signalled |= STANDBY_MESSAGE_RECEIVED; + m_condition_variable.notify_one(); +} + +void HdmiCecSource_L2Test::onKeyReleaseEvent(const JsonObject& message) +{ + TEST_LOG("onKeyReleaseEvent JSON-RPC event received"); + std::unique_lock lock(m_mutex); + m_event_signalled |= ON_KEY_RELEASE_EVENT; + m_condition_variable.notify_one(); +} + +void HdmiCecSource_L2Test::onKeyPressEvent(const JsonObject& message) +{ + TEST_LOG("onKeyPressEvent JSON-RPC event received"); + std::unique_lock lock(m_mutex); + m_event_signalled |= ON_KEY_PRESS_EVENT; + m_condition_variable.notify_one(); +} + +/******************************************************************************************************************* + * Test Functions + * *****************************************************************************************************************/ + +/** + * @brief Test GetActiveSourceStatus API via COM-RPC + * + * This test verifies that the GetActiveSourceStatus API returns the correct status + * and success flag using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, GetActiveSourceStatus_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing GetActiveSourceStatus via COM-RPC"); + + // Declare output parameters + bool isActiveSource = false; + bool success = false; + + // Call the API + uint32_t result = m_cecSourcePlugin->GetActiveSourceStatus(isActiveSource, success); + + // Validate result + EXPECT_EQ(result, Core::ERROR_NONE); + if (result != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(result) + " (" + std::string(Core::ErrorToString(result)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(success); + + // Log and validate output + TEST_LOG(" isActiveSource: %d", isActiveSource); + TEST_LOG(" success: %d", success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test GetActiveSourceStatus API via JSON-RPC + * + * This test verifies that the getActiveSourceStatus API returns the correct status + * using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, GetActiveSourceStatus_JSONRPC) +{ + TEST_LOG("Testing getActiveSourceStatus via JSON-RPC"); + + JsonObject params; + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "getActiveSourceStatus", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } + + // Validate status field + EXPECT_TRUE(result.HasLabel("status")); + if (result.HasLabel("status")) { + bool activeSourceStatus = result["status"].Boolean(); + TEST_LOG(" status: %d", activeSourceStatus); + } +} + +/** + * @brief Test SetEnabled API via COM-RPC + * + * This test verifies that the SetEnabled API works correctly using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, SetEnabled_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing SetEnabled via COM-RPC"); + + // Declare output parameters + HdmiCecSourceSuccess setResult; + + // Call the API + uint32_t result = m_cecSourcePlugin->SetEnabled(true, setResult); + + // Validate result + EXPECT_EQ(result, Core::ERROR_NONE); + if (result != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(result) + " (" + std::string(Core::ErrorToString(result)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(setResult.success); + + // Log output + TEST_LOG(" success: %d", setResult.success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test SetEnabled API via JSON-RPC + * + * This test verifies that the setEnabled API works correctly using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, SetEnabled_JSONRPC) +{ + TEST_LOG("Testing setEnabled via JSON-RPC"); + + JsonObject params; + params["enabled"] = true; + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "setEnabled", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } +} + +/** + * @brief Test GetEnabled API via COM-RPC + * + * This test verifies that the GetEnabled API works correctly using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, GetEnabled_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing GetEnabled via COM-RPC"); + + // Declare output parameters + bool enabled = false; + bool success = false; + + // Call the API + uint32_t result = m_cecSourcePlugin->GetEnabled(enabled, success); + + // Validate result + EXPECT_EQ(result, Core::ERROR_NONE); + if (result != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(result) + " (" + std::string(Core::ErrorToString(result)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(success); + + // Log output + TEST_LOG(" enabled: %d", enabled); + TEST_LOG(" success: %d", success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test GetEnabled API via JSON-RPC + * + * This test verifies that the getEnabled API works correctly using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, GetEnabled_JSONRPC) +{ + TEST_LOG("Testing getEnabled via JSON-RPC"); + + JsonObject params; + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "getEnabled", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } + + // Validate enabled field + EXPECT_TRUE(result.HasLabel("enabled")); + if (result.HasLabel("enabled")) { + bool enabled = result["enabled"].Boolean(); + TEST_LOG(" enabled: %d", enabled); + } +} + +/** + * @brief Test SetOSDName API via COM-RPC + * + * This test verifies that the SetOSDName API works correctly using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, SetOSDName_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing SetOSDName via COM-RPC"); + + // Declare output parameters + string testOSDName = "TestSTB"; + HdmiCecSourceSuccess setResult; + + // Call the API + uint32_t result = m_cecSourcePlugin->SetOSDName(testOSDName, setResult); + + // Validate result + EXPECT_EQ(result, Core::ERROR_NONE); + if (result != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(result) + " (" + std::string(Core::ErrorToString(result)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(setResult.success); + + // Log output + TEST_LOG(" osdName set to: %s", testOSDName.c_str()); + TEST_LOG(" success: %d", setResult.success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test SetOSDName API via JSON-RPC + * + * This test verifies that the setOSDName API works correctly using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, SetOSDName_JSONRPC) +{ + TEST_LOG("Testing setOSDName via JSON-RPC"); + + JsonObject params; + params["name"] = "TestSTB"; + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "setOSDName", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } +} + +/** + * @brief Test GetOSDName API via COM-RPC + * + * This test verifies that the GetOSDName API works correctly using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, GetOSDName_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing GetOSDName via COM-RPC"); + + // Declare output parameters + string osdName; + bool success = false; + + // Call the API + uint32_t result = m_cecSourcePlugin->GetOSDName(osdName, success); + + // Validate result + EXPECT_EQ(result, Core::ERROR_NONE); + if (result != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(result) + " (" + std::string(Core::ErrorToString(result)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(success); + + // Log and validate output + TEST_LOG(" osdName: %s", osdName.c_str()); + TEST_LOG(" success: %d", success); + EXPECT_FALSE(osdName.empty()); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test GetOSDName API via JSON-RPC + * + * This test verifies that the getOSDName API works correctly using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, GetOSDName_JSONRPC) +{ + TEST_LOG("Testing getOSDName via JSON-RPC"); + + JsonObject params; + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "getOSDName", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } + + // Validate name field + EXPECT_TRUE(result.HasLabel("name")); + if (result.HasLabel("name")) { + string osdName = result["name"].String(); + TEST_LOG(" name: %s", osdName.c_str()); + EXPECT_FALSE(osdName.empty()); + } +} + +/** + * @brief Test SetVendorId API via COM-RPC + * + * This test verifies that the SetVendorId API works correctly using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, SetVendorId_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing SetVendorId via COM-RPC"); + + // Declare output parameters + string testVendorId = "0019FB"; + HdmiCecSourceSuccess setResult; + + // Call the API + uint32_t result = m_cecSourcePlugin->SetVendorId(testVendorId, setResult); + + // Validate result + EXPECT_EQ(result, Core::ERROR_NONE); + if (result != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(result) + " (" + std::string(Core::ErrorToString(result)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(setResult.success); + + // Log output + TEST_LOG(" vendorId set to: %s", testVendorId.c_str()); + TEST_LOG(" success: %d", setResult.success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test SetVendorId API via JSON-RPC + * + * This test verifies that the setVendorId API works correctly using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, SetVendorId_JSONRPC) +{ + TEST_LOG("Testing setVendorId via JSON-RPC"); + + JsonObject params; + params["vendorid"] = "0019FB"; + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "setVendorId", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } +} + +/** + * @brief Test GetVendorId API via JSON-RPC + * + * This test verifies that the getVendorId API works correctly using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, GetVendorId_JSONRPC) +{ + TEST_LOG("Testing getVendorId via JSON-RPC"); + + JsonObject params; + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "getVendorId", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } + + // Validate vendorid field + EXPECT_TRUE(result.HasLabel("vendorid")); + if (result.HasLabel("vendorid")) { + string vendorId = result["vendorid"].String(); + EXPECT_FALSE(vendorId.empty()); + TEST_LOG(" vendorid: %s", vendorId.c_str()); + } +} + +/** + * @brief Test SetOTPEnabled API via COM-RPC + * + * This test verifies that the SetOTPEnabled API works correctly using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, SetOTPEnabled_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing SetOTPEnabled via COM-RPC"); + + // Declare output parameters + HdmiCecSourceSuccess setResult; + + // Call the API + uint32_t result = m_cecSourcePlugin->SetOTPEnabled(true, setResult); + + // Validate result + EXPECT_EQ(result, Core::ERROR_NONE); + if (result != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(result) + " (" + std::string(Core::ErrorToString(result)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(setResult.success); + + // Log output + TEST_LOG(" success: %d", setResult.success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test SetOTPEnabled API via JSON-RPC + * + * This test verifies that the setOTPEnabled API works correctly using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, SetOTPEnabled_JSONRPC) +{ + TEST_LOG("Testing setOTPEnabled via JSON-RPC"); + + JsonObject params; + params["enabled"] = true; + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "setOTPEnabled", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } +} + +/** + * @brief Test GetOTPEnabled API via COM-RPC + * + * This test verifies that the GetOTPEnabled API works correctly using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, GetOTPEnabled_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing GetOTPEnabled via COM-RPC"); + + // Declare output parameters + bool enabled = false; + bool success = false; + + // Call the API + uint32_t result = m_cecSourcePlugin->GetOTPEnabled(enabled, success); + + // Validate result + EXPECT_EQ(result, Core::ERROR_NONE); + if (result != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(result) + " (" + std::string(Core::ErrorToString(result)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(success); + + // Log and validate output + TEST_LOG(" enabled: %d", enabled); + TEST_LOG(" success: %d", success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test GetOTPEnabled API via JSON-RPC + * + * This test verifies that the getOTPEnabled API works correctly using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, GetOTPEnabled_JSONRPC) +{ + TEST_LOG("Testing getOTPEnabled via JSON-RPC"); + + JsonObject params; + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "getOTPEnabled", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } + + // Validate enabled field + EXPECT_TRUE(result.HasLabel("enabled")); + if (result.HasLabel("enabled")) { + bool enabled = result["enabled"].Boolean(); + TEST_LOG(" enabled: %d", enabled); + } +} + +/** + * @brief Test SendStandbyMessage API via COM-RPC + * + * This test verifies that the SendStandbyMessage API works correctly using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, SendStandbyMessage_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing SendStandbyMessage via COM-RPC"); + + // Declare output parameters + HdmiCecSourceSuccess result; + + // Call the API + uint32_t retval = m_cecSourcePlugin->SendStandbyMessage(result); + + // Validate result + EXPECT_EQ(retval, Core::ERROR_NONE); + if (retval != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(retval) + " (" + std::string(Core::ErrorToString(retval)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(result.success); + + // Log output + TEST_LOG(" success: %d", result.success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test SendStandbyMessage API via JSON-RPC + * + * This test verifies that the sendStandbyMessage API works correctly using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, SendStandbyMessage_JSONRPC) +{ + TEST_LOG("Testing sendStandbyMessage via JSON-RPC"); + + JsonObject params; + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "sendStandbyMessage", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } +} + +/** + * @brief Test SendKeyPressEvent API via COM-RPC + * + * This test verifies that the SendKeyPressEvent API works correctly using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, SendKeyPressEvent_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing SendKeyPressEvent via COM-RPC"); + + // Declare input/output parameters + uint32_t logicalAddress = 0; // TV logical address + uint32_t keyCode = 0x00; // Select key code + HdmiCecSourceSuccess result; + + // Call the API + uint32_t retval = m_cecSourcePlugin->SendKeyPressEvent(logicalAddress, keyCode, result); + + // Validate result + EXPECT_EQ(retval, Core::ERROR_NONE); + if (retval != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(retval) + " (" + std::string(Core::ErrorToString(retval)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(result.success); + + // Log output + TEST_LOG(" logicalAddress: %d", logicalAddress); + TEST_LOG(" keyCode: %d", keyCode); + TEST_LOG(" success: %d", result.success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test SendKeyPressEvent API via JSON-RPC + * + * This test verifies that the sendKeyPressEvent API works correctly using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, SendKeyPressEvent_JSONRPC) +{ + TEST_LOG("Testing sendKeyPressEvent via JSON-RPC"); + + JsonObject params; + params["logicalAddress"] = 0; // TV logical address + params["keyCode"] = 0x00; // Select key code + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "sendKeyPressEvent", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } +} + +/** + * @brief Test GetVendorId API via COM-RPC + * + * This test verifies that the GetVendorId API works correctly using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, GetVendorId_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing GetVendorId via COM-RPC"); + + // Declare output parameters + string vendorId; + bool success = false; + + // Call the API + uint32_t result = m_cecSourcePlugin->GetVendorId(vendorId, success); + + // Validate result + EXPECT_EQ(result, Core::ERROR_NONE); + if (result != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(result) + " (" + std::string(Core::ErrorToString(result)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(success); + EXPECT_FALSE(vendorId.empty()); + + // Log output + TEST_LOG(" vendorId: %s", vendorId.c_str()); + TEST_LOG(" success: %d", success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test GetDeviceList API via COM-RPC + * + * This test verifies that the GetDeviceList API returns the correct device information using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, GetDeviceList_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing GetDeviceList via COM-RPC"); + + // Declare output parameters + uint32_t numberOfDevices = 0; + IHdmiCecSourceDeviceListIterator* deviceList = nullptr; + bool success = false; + + // Call the API + uint32_t result = m_cecSourcePlugin->GetDeviceList(numberOfDevices, deviceList, success); + + // Validate result + EXPECT_EQ(result, Core::ERROR_NONE); + if (result != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(result) + " (" + std::string(Core::ErrorToString(result)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(success); + + // Log and validate output + TEST_LOG(" numberOfDevices: %d", numberOfDevices); + TEST_LOG(" success: %d", success); + + if (deviceList != nullptr) { + HdmiCecSourceDevice device; + uint32_t deviceCount = 0; + while (deviceList->Next(device)) { + TEST_LOG(" Device[%d]: logicalAddress=%d, vendorID=%s, osdName=%s", + deviceCount++, device.logicalAddress, device.vendorID.c_str(), device.osdName.c_str()); + EXPECT_FALSE(device.vendorID.empty()); + EXPECT_FALSE(device.osdName.empty()); + } + EXPECT_EQ(deviceCount, numberOfDevices); + deviceList->Release(); + } + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test GetDeviceList API via JSON-RPC + * + * This test verifies that the getDeviceList API returns the correct device information using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, GetDeviceList_JSONRPC) +{ + TEST_LOG("Testing getDeviceList via JSON-RPC"); + + JsonObject params; + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "getDeviceList", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } + + // Validate numberofdevices field + EXPECT_TRUE(result.HasLabel("numberofdevices")); + if (result.HasLabel("numberofdevices")) { + uint32_t numberOfDevices = result["numberofdevices"].Number(); + TEST_LOG(" numberofdevices: %d", numberOfDevices); + } + + // Validate deviceList array + EXPECT_TRUE(result.HasLabel("deviceList")); + if (result.HasLabel("deviceList")) { + JsonArray deviceList = result["deviceList"].Array(); + TEST_LOG(" deviceList length: %d", deviceList.Length()); + + for (uint32_t i = 0; i < deviceList.Length(); i++) { + JsonObject device = deviceList[i].Object(); + + EXPECT_TRUE(device.HasLabel("logicalAddress")); + if (device.HasLabel("logicalAddress")) { + uint32_t logicalAddress = device["logicalAddress"].Number(); + TEST_LOG(" Device[%d].logicalAddress: %d", i, logicalAddress); + } + + EXPECT_TRUE(device.HasLabel("vendorID")); + if (device.HasLabel("vendorID")) { + string vendorID = device["vendorID"].String(); + TEST_LOG(" Device[%d].vendorID: %s", i, vendorID.c_str()); + EXPECT_FALSE(vendorID.empty()); + } + + EXPECT_TRUE(device.HasLabel("osdName")); + if (device.HasLabel("osdName")) { + string osdName = device["osdName"].String(); + TEST_LOG(" Device[%d].osdName: %s", i, osdName.c_str()); + EXPECT_FALSE(osdName.empty()); + } + } + } +} + +/** + * @brief Test PerformOTPAction API via COM-RPC + * + * This test verifies that the PerformOTPAction API works correctly using COM-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, PerformOTPAction_COMRPC) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + TEST_LOG("Testing PerformOTPAction via COM-RPC"); + + // Declare output parameters + HdmiCecSourceSuccess result; + + // Call the API + uint32_t retval = m_cecSourcePlugin->PerformOTPAction(result); + + // Validate result + EXPECT_EQ(retval, Core::ERROR_NONE); + if (retval != Core::ERROR_NONE) { + std::string errorMsg = "COM-RPC returned error " + std::to_string(retval) + " (" + std::string(Core::ErrorToString(retval)) + ")"; + TEST_LOG("Err: %s", errorMsg.c_str()); + } + EXPECT_TRUE(result.success); + + // Log output + TEST_LOG(" success: %d", result.success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test PerformOTPAction API via JSON-RPC + * + * This test verifies that the performOTPAction API works correctly using JSON-RPC interface. + */ +TEST_F(HdmiCecSource_L2Test, PerformOTPAction_JSONRPC) +{ + TEST_LOG("Testing performOTPAction via JSON-RPC"); + + JsonObject params; + JsonObject result; + + uint32_t status = InvokeServiceMethod("org.rdk.HdmiCecSource.1", "performOTPAction", params, result); + + EXPECT_EQ(status, Core::ERROR_NONE); + + // Validate success field + EXPECT_TRUE(result.HasLabel("success")); + if (result.HasLabel("success")) { + EXPECT_TRUE(result["success"].Boolean()); + TEST_LOG(" success: %d", result["success"].Boolean()); + } +} + +/** + * @brief Test GetOTPEnabled/SetOTPEnabled APIs + * + * This test verifies that the SetOTPEnabled and GetOTPEnabled APIs work correctly. + */ +TEST_F(HdmiCecSource_L2Test, SetGetOTPEnabled) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + // Set OTP enabled to true + HdmiCecSourceSuccess setResult; + uint32_t result = m_cecSourcePlugin->SetOTPEnabled(true, setResult); + EXPECT_EQ(result, Core::ERROR_NONE); + EXPECT_TRUE(setResult.success); + + // Get OTP enabled status + bool enabled = false; + bool success = false; + result = m_cecSourcePlugin->GetOTPEnabled(enabled, success); + EXPECT_EQ(result, Core::ERROR_NONE); + EXPECT_TRUE(success); + EXPECT_TRUE(enabled); + TEST_LOG("GetOTPEnabled: enabled=%d, success=%d", enabled, success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test SendStandbyMessage API + * + * This test verifies that the SendStandbyMessage API works correctly. + */ +TEST_F(HdmiCecSource_L2Test, SendStandbyMessage) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + HdmiCecSourceSuccess result; + uint32_t retval = m_cecSourcePlugin->SendStandbyMessage(result); + + EXPECT_EQ(retval, Core::ERROR_NONE); + EXPECT_TRUE(result.success); + TEST_LOG("SendStandbyMessage: success=%d", result.success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test SendKeyPressEvent API + * + * This test verifies that the SendKeyPressEvent API works correctly. + */ +TEST_F(HdmiCecSource_L2Test, SendKeyPressEvent) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + uint32_t logicalAddress = 0; // TV logical address + uint32_t keyCode = 0x00; // Select key code + HdmiCecSourceSuccess result; + uint32_t retval = m_cecSourcePlugin->SendKeyPressEvent(logicalAddress, keyCode, result); + + EXPECT_EQ(retval, Core::ERROR_NONE); + EXPECT_TRUE(result.success); + TEST_LOG("SendKeyPressEvent: logicalAddress=%d, keyCode=%d, success=%d", + logicalAddress, keyCode, result.success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test GetDeviceList API + * + * This test verifies that the GetDeviceList API returns the correct device information. + */ +TEST_F(HdmiCecSource_L2Test, GetDeviceList) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + uint32_t numberOfDevices = 0; + IHdmiCecSourceDeviceListIterator* deviceList = nullptr; + bool success = false; + + uint32_t result = m_cecSourcePlugin->GetDeviceList(numberOfDevices, deviceList, success); + + EXPECT_EQ(result, Core::ERROR_NONE); + EXPECT_TRUE(success); + TEST_LOG("GetDeviceList: numberOfDevices=%d, success=%d", numberOfDevices, success); + + if (deviceList != nullptr) { + HdmiCecSourceDevice device; + while (deviceList->Next(device)) { + TEST_LOG("Device: logicalAddress=%d, vendorID=%s, osdName=%s", + device.logicalAddress, device.vendorID.c_str(), device.osdName.c_str()); + } + deviceList->Release(); + } + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test PerformOTPAction API + * + * This test verifies that the PerformOTPAction API works correctly. + */ +TEST_F(HdmiCecSource_L2Test, PerformOTPAction) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + HdmiCecSourceSuccess result; + uint32_t retval = m_cecSourcePlugin->PerformOTPAction(result); + + EXPECT_EQ(retval, Core::ERROR_NONE); + EXPECT_TRUE(result.success); + TEST_LOG("PerformOTPAction: success=%d", result.success); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test OnActiveSourceStatusUpdated event + * + * This test verifies that the OnActiveSourceStatusUpdated event is received correctly. + */ +TEST_F(HdmiCecSource_L2Test, OnActiveSourceStatusUpdatedEvent) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + // Simulate active source status change + m_notificationHandler.OnActiveSourceStatusUpdated(true); + + uint32_t status = WaitForRequestStatus(EVNT_TIMEOUT, ON_ACTIVE_SOURCE_STATUS_UPDATED); + EXPECT_EQ(status, ON_ACTIVE_SOURCE_STATUS_UPDATED); + EXPECT_TRUE(m_notificationHandler.GetActiveSourceStatus()); + TEST_LOG("OnActiveSourceStatusUpdated event verified"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +/** + * @brief Test OnDeviceAdded event + * + * This test verifies that the OnDeviceAdded event is received correctly. + */ +TEST_F(HdmiCecSource_L2Test, OnDeviceAddedEvent) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + } else { + EXPECT_TRUE(m_controller_cecSource != nullptr); + if (m_controller_cecSource) { + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + if (m_cecSourcePlugin) { + // Simulate device added event + int testLogicalAddress = 4; + m_notificationHandler.OnDeviceAdded(testLogicalAddress); + + uint32_t status = WaitForRequestStatus(EVNT_TIMEOUT, ON_DEVICE_ADDED); + EXPECT_EQ(status, ON_DEVICE_ADDED); + EXPECT_EQ(m_notificationHandler.GetLogicalAddress(), testLogicalAddress); + TEST_LOG("OnDeviceAdded event verified"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } else { + TEST_LOG("m_cecSourcePlugin is NULL"); + } + m_controller_cecSource->Release(); + } else { + TEST_LOG("m_controller_cecSource is NULL"); + } + } +} + +//======================================== Frame Injection Tests ======================================== + +/** + * @brief Test Standby frame injection and verify standbyMessageReceived event + * + * This test injects a Standby CEC frame and verifies that the standbyMessageReceived event is triggered. + */ +TEST_F(HdmiCecSource_L2Test, InjectStandbyFrameAndVerifyEvent) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject Standby frame (Opcode 0x36) + // From TV (0) to device (4) + uint8_t buffer[] = { 0x04, 0x36 }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting Standby CEC frame"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Wait for standbyMessageReceived event + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, STANDBY_MESSAGE_RECEIVED); + EXPECT_TRUE(signalled & STANDBY_MESSAGE_RECEIVED); + EXPECT_EQ(m_notificationHandler.GetLogicalAddress(), 0); + TEST_LOG("Standby event verified"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test UserControlPressed frame injection and verify onKeyPressEvent event + * + * This test injects a UserControlPressed CEC frame and verifies that the onKeyPressEvent is triggered. + */ +TEST_F(HdmiCecSource_L2Test, InjectUserControlPressedFrameAndVerifyEvent) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject UserControlPressed frame (Opcode 0x44) with keycode for Volume Up (0x41) + // From TV (0) to device (4) + uint8_t buffer[] = { 0x04, 0x44, 0x41 }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting UserControlPressed CEC frame with Volume Up key"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Wait for onKeyPressEvent + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_KEY_PRESS_EVENT); + EXPECT_TRUE(signalled & ON_KEY_PRESS_EVENT); + EXPECT_EQ(m_notificationHandler.GetLogicalAddress(), 0); + EXPECT_EQ(m_notificationHandler.GetKeyCode(), 0x41); + TEST_LOG("UserControlPressed event verified"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test UserControlReleased frame injection and verify onKeyReleaseEvent event + * + * This test injects a UserControlReleased CEC frame and verifies that the onKeyReleaseEvent is triggered. + */ +TEST_F(HdmiCecSource_L2Test, InjectUserControlReleasedFrameAndVerifyEvent) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject UserControlReleased frame (Opcode 0x45) + // From TV (0) to device (4) + uint8_t buffer[] = { 0x04, 0x45 }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting UserControlReleased CEC frame"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Wait for onKeyReleaseEvent + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_KEY_RELEASE_EVENT); + EXPECT_TRUE(signalled & ON_KEY_RELEASE_EVENT); + EXPECT_EQ(m_notificationHandler.GetLogicalAddress(), 0); + TEST_LOG("UserControlReleased event verified"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test ActiveSource frame injection and verify OnActiveSourceStatusUpdated event + * + * This test injects an ActiveSource CEC frame with our physical address + * and verifies that the OnActiveSourceStatusUpdated event is triggered with true status. + */ +TEST_F(HdmiCecSource_L2Test, InjectActiveSourceFrameAndVerifyEvent) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject ActiveSource frame (Opcode 0x82) with physical address matching ours + // Physical address: 0x0F0F (15.15.15.15 in 2-byte CEC format) + // From device (4) to all (broadcast) + uint8_t buffer[] = { 0x4F, 0x82, 0x0F, 0x0F }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting ActiveSource CEC frame with our physical address"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Give the system time to process the frame and trigger events + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + + // Wait for OnActiveSourceStatusUpdated event + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_ACTIVE_SOURCE_STATUS_UPDATED); + EXPECT_TRUE(signalled & ON_ACTIVE_SOURCE_STATUS_UPDATED); + //EXPECT_TRUE(m_notificationHandler.GetActiveSourceStatus()); + TEST_LOG("ActiveSource event verified with status=true"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test DeviceVendorID frame injection and verify OnDeviceInfoUpdated event + * + * This test injects a DeviceVendorID CEC frame and verifies that the OnDeviceInfoUpdated event is triggered. + */ +TEST_F(HdmiCecSource_L2Test, InjectDeviceVendorIDFrameAndVerifyEvent) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // First add the device by injecting ReportPhysicalAddress + uint8_t setupBuffer[] = { 0x4F, 0x84, 0x20, 0x00, 0x04 }; + CECFrame setupFrame(setupBuffer, sizeof(setupBuffer)); + + TEST_LOG("Setting up: Injecting ReportPhysicalAddress CEC frame"); + for (auto* listener : listeners) { + if (listener) + listener->notify(setupFrame); + } + + // Give time to process + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + + // Wait for device to be added + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_DEVICE_ADDED); + //EXPECT_TRUE(signalled & ON_DEVICE_ADDED); + m_notificationHandler.ResetEvent(); + + // Now inject DeviceVendorID frame (Opcode 0x87) + // From device 4 to all (broadcast), Vendor ID: LG (0x00E091) + uint8_t buffer[] = { 0x4F, 0x87, 0x00, 0xE0, 0x91 }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting DeviceVendorID CEC frame with LG vendor ID"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Wait for OnDeviceInfoUpdated event + signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_DEVICE_INFO_UPDATED); + EXPECT_TRUE(signalled & ON_DEVICE_INFO_UPDATED); + EXPECT_EQ(m_notificationHandler.GetLogicalAddress(), 4); + TEST_LOG("OnDeviceInfoUpdated event verified after DeviceVendorID"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test SetOSDName frame injection and verify OnDeviceInfoUpdated event + * + * This test injects a SetOSDName CEC frame and verifies that the OnDeviceInfoUpdated event is triggered. + */ +TEST_F(HdmiCecSource_L2Test, InjectSetOSDNameFrameAndVerifyEvent) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // First add the device by injecting ReportPhysicalAddress + uint8_t setupBuffer[] = { 0x4F, 0x84, 0x20, 0x00, 0x04 }; + CECFrame setupFrame(setupBuffer, sizeof(setupBuffer)); + + TEST_LOG("Setting up: Injecting ReportPhysicalAddress CEC frame"); + for (auto* listener : listeners) { + if (listener) + listener->notify(setupFrame); + } + + // Give time to process + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + + // Wait for device to be added + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_DEVICE_ADDED); + //EXPECT_TRUE(signalled & ON_DEVICE_ADDED); + m_notificationHandler.ResetEvent(); + + // Now inject SetOSDName frame (Opcode 0x47) + // From device 4 to us (device 3 or 0), OSD Name: "TestDev" + uint8_t buffer[] = { 0x40, 0x47, 'T', 'e', 's', 't', 'D', 'e', 'v' }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting SetOSDName CEC frame with name 'TestDev'"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Wait for OnDeviceInfoUpdated event + signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_DEVICE_INFO_UPDATED); + EXPECT_TRUE(signalled & ON_DEVICE_INFO_UPDATED); + EXPECT_EQ(m_notificationHandler.GetLogicalAddress(), 4); + TEST_LOG("OnDeviceInfoUpdated event verified after SetOSDName"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test RequestActiveSource frame injection + * + * This test injects a RequestActiveSource CEC frame. If the device is active source, + * it should respond with an ActiveSource message. + */ +TEST_F(HdmiCecSource_L2Test, InjectRequestActiveSourceFrameAndVerify) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject RequestActiveSource frame (Opcode 0x85) + // From TV (0) to all (broadcast) + uint8_t buffer[] = { 0x0F, 0x85 }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting RequestActiveSource CEC frame"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Note: This will only send ActiveSource if isDeviceActiveSource is true + // The test verifies the frame is processed without errors + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + TEST_LOG("RequestActiveSource frame processed"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test GetCECVersion frame injection + * + * This test injects a GetCECVersion CEC frame and verifies that the device + * responds with a CECVersion message. + */ +TEST_F(HdmiCecSource_L2Test, InjectGetCECVersionFrameAndVerify) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject GetCECVersion frame (Opcode 0x9F) + // From TV (0) to device (4) + uint8_t buffer[] = { 0x04, 0x9F }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting GetCECVersion CEC frame"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // The device should respond with CECVersion (V_1_4) + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + TEST_LOG("GetCECVersion frame processed - device should send CECVersion response"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test CECVersion frame injection and verify device added + * + * This test injects a CECVersion CEC frame and verifies that the device + * is added to the device list. + */ +TEST_F(HdmiCecSource_L2Test, InjectCECVersionFrameAndVerifyDeviceAdded) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject CECVersion frame (Opcode 0x9E) + // From device 5 to us (device 4), Version 1.4 + uint8_t buffer[] = { 0x54, 0x9E, 0x05 }; // 0x05 = Version 1.4 + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting CECVersion CEC frame from device 5"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Wait for OnDeviceAdded event + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_DEVICE_ADDED); + //EXPECT_TRUE(signalled & ON_DEVICE_ADDED); + //EXPECT_EQ(m_notificationHandler.GetLogicalAddress(), 5); + TEST_LOG("CECVersion frame processed - device 5 added"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test GiveOSDName frame injection + * + * This test injects a GiveOSDName CEC frame and verifies that the device + * responds with a SetOSDName message. + */ +TEST_F(HdmiCecSource_L2Test, InjectGiveOSDNameFrameAndVerify) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject GiveOSDName frame (Opcode 0x46) + // From TV (0) to device (4) + uint8_t buffer[] = { 0x04, 0x46 }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting GiveOSDName CEC frame"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // The device should respond with SetOSDName + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + TEST_LOG("GiveOSDName frame processed - device should send SetOSDName response"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test GivePhysicalAddress frame injection + * + * This test injects a GivePhysicalAddress CEC frame and verifies that the device + * responds with a ReportPhysicalAddress message. + */ +TEST_F(HdmiCecSource_L2Test, InjectGivePhysicalAddressFrameAndVerify) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject GivePhysicalAddress frame (Opcode 0x83) + // From TV (0) to device (4) + uint8_t buffer[] = { 0x04, 0x83 }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting GivePhysicalAddress CEC frame"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // The device should respond with ReportPhysicalAddress + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + TEST_LOG("GivePhysicalAddress frame processed - device should send ReportPhysicalAddress response"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test GiveDeviceVendorID frame injection + * + * This test injects a GiveDeviceVendorID CEC frame and verifies that the device + * responds with a DeviceVendorID message. + */ +TEST_F(HdmiCecSource_L2Test, InjectGiveDeviceVendorIDFrameAndVerify) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject GiveDeviceVendorID frame (Opcode 0x8C) + // From TV (0) to device (4) + uint8_t buffer[] = { 0x04, 0x8C }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting GiveDeviceVendorID CEC frame"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // The device should respond with DeviceVendorID + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + TEST_LOG("GiveDeviceVendorID frame processed - device should send DeviceVendorID response"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test RoutingChange frame injection and verify active source event + * + * This test injects a RoutingChange CEC frame with our physical address as destination + * and verifies that the OnActiveSourceStatusUpdated event is triggered. + */ +TEST_F(HdmiCecSource_L2Test, InjectRoutingChangeFrameAndVerifyActiveSource) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject RoutingChange frame (Opcode 0x80) + // From TV (0) to all (broadcast), changing route to our physical address (0x0F0F) + uint8_t buffer[] = { 0x0F, 0x80, 0x00, 0x00, 0x0F, 0x0F }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting RoutingChange CEC frame routing to our address"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Give time for processing and event propagation + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + + // Wait for OnActiveSourceStatusUpdated event + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_ACTIVE_SOURCE_STATUS_UPDATED); + EXPECT_TRUE(signalled & ON_ACTIVE_SOURCE_STATUS_UPDATED); + //EXPECT_TRUE(m_notificationHandler.GetActiveSourceStatus()); + TEST_LOG("RoutingChange frame processed - active source status updated to true"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test RoutingInformation frame injection and verify active source event + * + * This test injects a RoutingInformation CEC frame with our physical address + * and verifies that the OnActiveSourceStatusUpdated event is triggered. + */ +TEST_F(HdmiCecSource_L2Test, InjectRoutingInformationFrameAndVerifyActiveSource) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject RoutingInformation frame (Opcode 0x81) + // From TV (0) to all (broadcast), routing to our physical address (0x0F0F) + uint8_t buffer[] = { 0x0F, 0x81, 0x0F, 0x0F }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting RoutingInformation CEC frame routing to our address"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Give time for processing and event propagation + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + + // Wait for OnActiveSourceStatusUpdated event + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_ACTIVE_SOURCE_STATUS_UPDATED); + EXPECT_TRUE(signalled & ON_ACTIVE_SOURCE_STATUS_UPDATED); + //EXPECT_TRUE(m_notificationHandler.GetActiveSourceStatus()); + TEST_LOG("RoutingInformation frame processed - active source status updated to true"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test SetStreamPath frame injection and verify active source event + * + * This test injects a SetStreamPath CEC frame with our physical address + * and verifies that the OnActiveSourceStatusUpdated event is triggered. + */ +TEST_F(HdmiCecSource_L2Test, InjectSetStreamPathFrameAndVerifyActiveSource) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject SetStreamPath frame (Opcode 0x86) + // From TV (0) to all (broadcast), setting stream path to our physical address (0x0F0F) + uint8_t buffer[] = { 0x0F, 0x86, 0x0F, 0x0F }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting SetStreamPath CEC frame to our address"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Give time for processing and event propagation + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + + // Wait for OnActiveSourceStatusUpdated event + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_ACTIVE_SOURCE_STATUS_UPDATED); + EXPECT_TRUE(signalled & ON_ACTIVE_SOURCE_STATUS_UPDATED); + //EXPECT_TRUE(m_notificationHandler.GetActiveSourceStatus()); + TEST_LOG("SetStreamPath frame processed - active source status updated to true"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test GiveDevicePowerStatus frame injection + * + * This test injects a GiveDevicePowerStatus CEC frame and verifies that the device + * responds with a ReportPowerStatus message. + */ +TEST_F(HdmiCecSource_L2Test, InjectGiveDevicePowerStatusFrameAndVerify) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject GiveDevicePowerStatus frame (Opcode 0x8F) + // From TV (0) to device (4) + uint8_t buffer[] = { 0x04, 0x8F }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting GiveDevicePowerStatus CEC frame"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // The device should respond with ReportPowerStatus + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + TEST_LOG("GiveDevicePowerStatus frame processed - device should send ReportPowerStatus response"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test ReportPowerStatus frame injection and verify device added + * + * This test injects a ReportPowerStatus CEC frame from TV and verifies that the device + * is added to the device list. + */ +TEST_F(HdmiCecSource_L2Test, InjectReportPowerStatusFrameAndVerifyDeviceAdded) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject ReportPowerStatus frame (Opcode 0x90) + // From TV (0) to device (4), Power status: ON (0x00) + uint8_t buffer[] = { 0x04, 0x90, 0x00 }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting ReportPowerStatus CEC frame from TV"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Wait for OnDeviceAdded event + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_DEVICE_ADDED); + EXPECT_TRUE(signalled & ON_DEVICE_ADDED); + EXPECT_EQ(m_notificationHandler.GetLogicalAddress(), 0); + TEST_LOG("ReportPowerStatus frame processed - TV device added"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test FeatureAbort frame injection + * + * This test injects a FeatureAbort CEC frame and verifies that the device + * processes it without errors. + */ +TEST_F(HdmiCecSource_L2Test, InjectFeatureAbortFrameAndVerify) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject FeatureAbort frame (Opcode 0x00) + // From TV (0) to device (4), Feature Opcode: 0x44 (User Control Pressed), Abort Reason: 0x04 (Refused) + uint8_t buffer[] = { 0x04, 0x00, 0x44, 0x04 }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting FeatureAbort CEC frame"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // The frame should be processed without errors + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + TEST_LOG("FeatureAbort frame processed"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test Abort frame injection + * + * This test injects an Abort CEC frame (unrecognized opcode) and verifies that the device + * responds with a FeatureAbort message. + */ +TEST_F(HdmiCecSource_L2Test, InjectAbortFrameAndVerify) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject an unrecognized opcode frame that will trigger Abort processing + // From TV (0) to device (4), Invalid Opcode: 0xFF + uint8_t buffer[] = { 0x04, 0xFF }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting frame with unrecognized opcode (Abort)"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // The device should respond with FeatureAbort + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + TEST_LOG("Abort frame processed - device should send FeatureAbort response"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test Polling frame injection + * + * This test injects a Polling CEC frame and verifies that the device + * processes it without errors. + */ +TEST_F(HdmiCecSource_L2Test, InjectPollingFrameAndVerify) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject Polling frame (same source and destination) + // From device (4) to device (4) - this is a polling message + uint8_t buffer[] = { 0x44 }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting Polling CEC frame"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // The frame should be processed without errors + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + TEST_LOG("Polling frame processed"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test ActiveSource frame with matching physical address to set device as active source + * + * This test injects an ActiveSource CEC frame with our own physical address (0x0F0F) + * to test the path where isDeviceActiveSource becomes true. + */ +TEST_F(HdmiCecSource_L2Test, InjectActiveSourceFrameWithMatchingAddressAndVerify) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // First, inject ActiveSource frame with OUR physical address (0x0F0F) to make device active + // From device 4 (us) to all (broadcast) + uint8_t buffer1[] = { 0x4F, 0x82, 0x0F, 0x0F }; + CECFrame frame1(buffer1, sizeof(buffer1)); + + TEST_LOG("Injecting ActiveSource CEC frame with our physical address to set as active source"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame1); + } + + // Give time for processing + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + + // Wait for OnActiveSourceStatusUpdated event - device should now be active source + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_ACTIVE_SOURCE_STATUS_UPDATED); + EXPECT_TRUE(signalled & ON_ACTIVE_SOURCE_STATUS_UPDATED); + TEST_LOG("Device is now active source after ActiveSource with matching address"); + + // Now inject RequestActiveSource to test the path where device responds + // From TV (0) to all (broadcast) + uint8_t buffer2[] = { 0x0F, 0x85 }; + CECFrame frame2(buffer2, sizeof(buffer2)); + + TEST_LOG("Injecting RequestActiveSource - device should respond with ActiveSource"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame2); + } + + // The device should respond with ActiveSource since it's now the active source + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TEST_LOG("RequestActiveSource processed - device sent ActiveSource response"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test RoutingChange frame with matching destination address + * + * This test injects a RoutingChange CEC frame where the destination matches our physical address + * to test the path where isDeviceActiveSource becomes true. + */ +TEST_F(HdmiCecSource_L2Test, InjectRoutingChangeFrameWithMatchingDestination) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject RoutingChange frame where destination MATCHES our physical address + // From TV (0) to all (broadcast), routing FROM 0x0000 TO our address 0x0F0F + uint8_t buffer[] = { 0x0F, 0x80, 0x00, 0x00, 0x0F, 0x0F }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting RoutingChange with destination matching our address"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Give time for processing and event propagation + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + + // Wait for OnActiveSourceStatusUpdated event with true status + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_ACTIVE_SOURCE_STATUS_UPDATED); + EXPECT_TRUE(signalled & ON_ACTIVE_SOURCE_STATUS_UPDATED); + TEST_LOG("RoutingChange processed - device is now active source"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test RoutingInformation frame with matching destination address + * + * This test injects a RoutingInformation CEC frame where the destination matches our physical address + * to test the path where isDeviceActiveSource becomes true. + */ +TEST_F(HdmiCecSource_L2Test, InjectRoutingInformationFrameWithMatchingDestination) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + if (!m_cecSourcePlugin || listeners.empty()) { + TEST_LOG("Test prerequisites not met"); + if (m_cecSourcePlugin) { + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + } + if (m_controller_cecSource) { + m_controller_cecSource->Release(); + } + return; + } + + // Inject RoutingInformation frame where destination MATCHES our physical address + // From TV (0) to all (broadcast), routing TO our address 0x0F0F + uint8_t buffer[] = { 0x0F, 0x81, 0x0F, 0x0F }; + CECFrame frame(buffer, sizeof(buffer)); + + TEST_LOG("Injecting RoutingInformation with destination matching our address"); + for (auto* listener : listeners) { + if (listener) + listener->notify(frame); + } + + // Give time for processing and event propagation + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + + // Wait for OnActiveSourceStatusUpdated event with true status + uint32_t signalled = WaitForRequestStatus(EVNT_TIMEOUT, ON_ACTIVE_SOURCE_STATUS_UPDATED); + EXPECT_TRUE(signalled & ON_ACTIVE_SOURCE_STATUS_UPDATED); + TEST_LOG("RoutingInformation processed - device is now active source"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test SendKeyPressEvent with invalid logical address + * + * This test verifies error handling when SendKeyPressEvent is called with an invalid logical address. + */ +TEST_F(HdmiCecSource_L2Test, SendKeyPressEventWithInvalidLogicalAddress) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + HdmiCecSourceSuccess success; + success.success = false; + + // Test with invalid logical address (0xFF is invalid) + uint32_t result = m_cecSourcePlugin->SendKeyPressEvent(0xFF, 0x41, success); + + // Should return error + EXPECT_NE(result, Core::ERROR_NONE); + EXPECT_FALSE(success.success); + TEST_LOG("SendKeyPressEvent correctly rejected invalid logical address"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} + +/** + * @brief Test SendKeyPressEvent with invalid key code + * + * This test verifies error handling when SendKeyPressEvent is called with an unsupported key code. + */ +TEST_F(HdmiCecSource_L2Test, SendKeyPressEventWithInvalidKeyCode) +{ + if (CreateHdmiCecSourceInterfaceObject() != Core::ERROR_NONE) { + TEST_LOG("Invalid HdmiCecSource_Client"); + return; + } + + EXPECT_TRUE(m_controller_cecSource != nullptr); + EXPECT_TRUE(m_cecSourcePlugin != nullptr); + + HdmiCecSourceSuccess success; + success.success = false; + + // Test with valid logical address but invalid/unsupported key code (0xFF) + uint32_t result = m_cecSourcePlugin->SendKeyPressEvent(0, 0xFF, success); + + // Should return NOT_SUPPORTED error + EXPECT_EQ(result, Core::ERROR_NOT_SUPPORTED); + EXPECT_FALSE(success.success); + TEST_LOG("SendKeyPressEvent correctly rejected unsupported key code"); + + m_cecSourcePlugin->Unregister(&m_notificationHandler); + m_cecSourcePlugin->Release(); + m_controller_cecSource->Release(); +} diff --git a/Tests/README.md b/Tests/README.md deleted file mode 100644 index 4b6eb4ac2..000000000 --- a/Tests/README.md +++ /dev/null @@ -1,54 +0,0 @@ -As part of rdkservices open source activity and logical grouping of services into various entservices-* repos, the below listed change to L1 and L2 Test are effective hence forth. - -# Changes Done: -Since the mock part is common across various plugins/repos and common for L1, L2 & etc, the gtest and gmock related stubs (including platform interface mocks) are moved to a new repo called "entservices-testframework" and L1 & L2 test files of each plugin moved to corresponding repos, you can find them inside Tests directory of each entservices-*. -Hence, any modifications/additions related to mocks should be commited to entservices-testframework repo @ rdkcentral and any modifications/additions related to test case should be commited to Test directory of corresponding entservices repo. - -# Individual Repo Handling -Each individual entservices-* repo was added with a .yml file to trigger L1, L2, L2-OOP test job in github workflow. This yml file triggers below mentioned build jobs in addition to regular build jobs (thunder, thunder tools & etc,). - -a/ Build mocks => To create TestMock Lib from all required mock relates stubs and copy to install/usr/lib path. -b/ Build entservices- => To create Test Lib of .so type from all applicable test files which are enabled for plugin test. -c/ Build entservices-testframework => To create L1/L2 executable by linking the plugins/test .so files. - -This ensures everything in-tact in repo level across multiple related plugins when there is a new change comes in. - -# testframework Repo Handling -The entservices-testframework repo contains yml files corresponds to L1, L2 & L2-OOP to trigger test job in github workflow. - -This yml file triggers below mentioned build jobs in addition to regular build jobs (thunder, thunder tools & etc,). - -a/ Build mocks => To create TestMock Lib from all required mock relates stubs and copy to install/usr/lib path. -b/ Build entservices-* => Jobs to checkout/build all individual repo's plugin & test files which are enabled for plugin test and copy all required libs to install/usr/lib path. -c/ Build entservices-testframework => To create L1/L2 executable by linking the plugins/test .so files. - -This ensures everything in-tact across multiple repos when there is a new change comes either in mocks or test case or plugins. - -##### Steps to run L1, L2, L2-OOP test locally ##### -1. checkout the entservices- to your working directory in your build machine. -example: git clone https://github.com/rdkcentral/entservices-testframework.git - -2. switch to entservices- directory -example: cd entservices-testframework - -3. check and ensure current working branch points to develop -example: git branch - -4. Run below curl command to download act executable to your repo. -example: curl -SL https://raw.githubusercontent.com/nektos/act/master/install.sh | bash - -5. 5a/to run L1 test -example: ./bin/act -W .github/workflows/L1-tests.yml -s GITHUB_TOKEN= - -5. 5b/to run L2 test -example: ./bin/act -W .github/workflows/L2-tests.yml -s GITHUB_TOKEN= - -5. 5c/to run L2 test OOP -example: ./bin/act -W .github/workflows/L2-tests-oop.yml -s GITHUB_TOKEN= - -NOTES: -a/ If you face any secret token related error while run your yml, pls comment the below mentioned line -#token: ${{ secrets.RDKE_GITHUB_TOKEN }} -b/ Coverage Report of both L1 and L2 test are uploaded to artifacts server. -c/ For the case, which has modification in plugin and/or test files as well in entservices-testframework mock files, change the ref key of checkout job to point your own branch instead of develop, in both entservices-testframework and entservices-* repo and ensure L1, L2, L2-OOP test jobs are passing for your PR. -example: ref: feature/L1-test diff --git a/Tests/clang.cmake b/Tests/clang.cmake deleted file mode 100755 index e4d5ac4ae..000000000 --- a/Tests/clang.cmake +++ /dev/null @@ -1,31 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 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. -### - -set(CMAKE_C_COMPILER "/usr/bin/clang") -set(CMAKE_CXX_COMPILER "/usr/bin/clang++") - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-command-line-argument") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=missing-braces") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=dangling-gsl") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-const-variable") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=inconsistent-missing-override") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-parameter") - -# clang Valgrind: debuginfo reader: ensure_valid failed -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gdwarf-4") diff --git a/Tests/gcc-with-coverage.cmake b/Tests/gcc-with-coverage.cmake deleted file mode 100755 index 6a2b449ac..000000000 --- a/Tests/gcc-with-coverage.cmake +++ /dev/null @@ -1,20 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 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. -### - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") diff --git a/build_dependencies.sh b/build_dependencies.sh index 92d10f7f2..21afdd159 100644 --- a/build_dependencies.sh +++ b/build_dependencies.sh @@ -31,7 +31,7 @@ git clone --branch R4.4.3 https://github.com/rdkcentral/ThunderTools.git git clone --branch R4.4.1 https://github.com/rdkcentral/Thunder.git -git clone --branch main https://github.com/rdkcentral/entservices-apis.git +git clone --branch develop https://github.com/rdkcentral/entservices-apis.git git clone https://$GITHUB_TOKEN@github.com/rdkcentral/entservices-testframework.git @@ -121,6 +121,7 @@ touch audiocapturemgr/audiocapturemgr_iarm.h touch ccec/drivers/CecIARMBusMgr.h touch ccec/FrameListener.hpp touch ccec/Connection.hpp +touch ccec/CCEC.hpp touch ccec/Assert.hpp touch ccec/Messages.hpp touch ccec/MessageDecoder.hpp @@ -162,6 +163,7 @@ touch rbus.h touch telemetry_busmessage_sender.h touch maintenanceMGR.h touch pkg.h +touch edid-parser.hpp touch secure_wrapper.h touch wpa_ctrl.h touch btmgr.h diff --git a/cmake/FindAC.cmake b/cmake/FindAC.cmake deleted file mode 100644 index a250eda02..000000000 --- a/cmake/FindAC.cmake +++ /dev/null @@ -1,43 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find Audio Capture Mgr -# Once done this will define -# AC_FOUND - System has audiocapturemgr -# AC_INCLUDE_DIRS - The audiocapturemgr include directories -# AC_LIBRARIES - The libraries needed to use audiocapturemgr -# AC_FLAGS - The flags needed to use audiocapturemgr -# - -find_package(PkgConfig) - -find_library(AC_LIBRARIES NAMES audiocapturemgr) -find_path(AC_INCLUDE_DIRS NAMES audiocapturemgr_iarm.h PATH_SUFFIXES audiocapturemgr) - -set(AC_LIBRARIES ${AC_LIBRARIES} CACHE PATH "Path to audiocapturemgr library") -set(AC_INCLUDE_DIRS ${AC_INCLUDE_DIRS} ) -set(AC_INCLUDE_DIRS ${AC_INCLUDE_DIRS} CACHE PATH "Path to audiocapturemgr include") - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(AC DEFAULT_MSG AC_INCLUDE_DIRS AC_LIBRARIES) - -mark_as_advanced( - AC_FOUND - AC_INCLUDE_DIRS - AC_LIBRARIES - AC_LIBRARY_DIRS - AC_FLAGS) diff --git a/cmake/FindAamp.cmake b/cmake/FindAamp.cmake deleted file mode 100644 index d8a160cbb..000000000 --- a/cmake/FindAamp.cmake +++ /dev/null @@ -1,51 +0,0 @@ -# - Try to find Aamp streamer. -# Once done this will define -# AAMP_FOUND - System has a Aamp streamer -# AAMP::AAMP - The Aamp streamer 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(AAMP_INCLUDE priv_aamp.h - PATHS /usr/include/) - -find_library(AAMP_LIBRARY aamp) - -if(EXISTS "${AAMP_LIBRARY}") - include(FindPackageHandleStandardArgs) - - set(AAMP_FOUND TRUE) - - find_package_handle_standard_args(AAMP DEFAULT_MSG AAMP_FOUND AAMP_INCLUDE AAMP_LIBRARY) - mark_as_advanced(AAMP_INCLUDE AAMP_LIBRARY) - - if(NOT TARGET AAMP::AAMP) - add_library(AAMP::AAMP UNKNOWN IMPORTED) - - set_target_properties(AAMP::AAMP PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${AAMP_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${AAMP_INCLUDE}" - ) - endif() -endif() diff --git a/cmake/FindBCM_HOST.cmake b/cmake/FindBCM_HOST.cmake deleted file mode 100644 index 81fbf495c..000000000 --- a/cmake/FindBCM_HOST.cmake +++ /dev/null @@ -1,58 +0,0 @@ -# - Try to find bcm_host. -# Once done, this will define -# -# BCM_HOST_FOUND - the bcm_host is available -# BCM_HOST::BCM_HOST - The bcm_host library and all its dependecies -# -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 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. -### - -if(BCM_HOST_FIND_QUIETLY) - set(_BCM_HOST_MODE QUIET) -elseif(BCM_HOST_FIND_REQUIRED) - set(_BCM_HOST_MODE REQUIRED) -endif() - -find_package(PkgConfig) -pkg_check_modules(PC_BCM_HOST ${_BCM_HOST_MODE} bcm_host) - -if(${PC_BCM_HOST_FOUND}) - find_library(BCM_HOST_LIBRARY bcm_host - HINTS ${PC_BCM_LIBDIR} ${PC_BCM_LIBRARY_DIRS} - ) - set(BCM_LIBRARIES ${PC_BCM_HOST_LIBRARIES}) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(BCM_HOST DEFAULT_MSG PC_BCM_HOST_FOUND PC_BCM_HOST_INCLUDE_DIRS BCM_HOST_LIBRARY PC_BCM_HOST_LIBRARIES) - mark_as_advanced(PC_BCM_HOST_INCLUDE_DIRS PC_BCM_HOST_LIBRARIES) - - if(BCM_HOST_FOUND AND NOT TARGET BCM_HOST::BCM_HOST) - add_library(BCM_HOST::BCM_HOST UNKNOWN IMPORTED) - - set_target_properties(BCM_HOST::BCM_HOST - PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${BCM_HOST_LIBRARY}" - INTERFACE_COMPILE_DEFINITIONS "PLATFORM_RPI" - INTERFACE_COMPILE_OPTIONS "${PC_BCM_HOST_CFLAGS_OTHER}" - INTERFACE_INCLUDE_DIRECTORIES "${PC_BCM_HOST_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${PC_BCM_HOST_LIBRARIES}" - ) - endif() -endif() diff --git a/cmake/FindCEC.cmake b/cmake/FindCEC.cmake deleted file mode 100644 index 442174f96..000000000 --- a/cmake/FindCEC.cmake +++ /dev/null @@ -1,50 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find IARMBus -# Once done this will define -# IARMBUS_FOUND - System has IARMBus -# IARMBUS_INCLUDE_DIRS - The IARMBus include directories -# IARMBUS_LIBRARIES - The libraries needed to use IARMBus -# IARMBUS_FLAGS - The flags needed to use IARMBus -# - -find_package(PkgConfig) - -find_library(CEC_LIBRARIES NAMES RCEC) -find_library(CEC_HAL_LIBRARIES NAMES RCECHal) -find_library(OSAL_LIBRARIES NAMES RCECOSHal) - -find_path(CEC_INCLUDE_DIRS NAMES ccec/Connection.hpp PATH_SUFFIXES ccec/include) -find_path(OSAL_INCLUDE_DIRS NAMES osal/Mutex.hpp PATH_SUFFIXES osal/include) - -set(CEC_LIBRARIES "-Wl,--no-as-needed" ${CEC_LIBRARIES} ${CEC_HAL_LIBRARIES} ${OSAL_LIBRARIES} "-Wl,--as-needed") - -set(CEC_LIBRARIES ${CEC_LIBRARIES} CACHE PATH "Path to CEC library") - -set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} ${OSAL_INCLUDE_DIRS}) -set(CEC_INCLUDE_DIRS ${CEC_INCLUDE_DIRS} CACHE PATH "Path to CEC include") - -include(FindPackageHandleStandardArgs) -#FIND_PACKAGE_HANDLE_STANDARD_ARGS(IARMBUS DEFAULT_MSG IARMBUS_INCLUDE_DIRS IARMBUS_LIBRARIES) - -mark_as_advanced( - CEC_FOUND - CEC_INCLUDE_DIRS - CEC_LIBRARIES - CEC_LIBRARY_DIRS - CEC_FLAGS) diff --git a/cmake/FindCTRLM.cmake b/cmake/FindCTRLM.cmake deleted file mode 100644 index 2071c7c16..000000000 --- a/cmake/FindCTRLM.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find ControlManager -# Once done this will define -# CTRLM_FOUND - System has ControlManager -# CTRLM_INCLUDE_DIRS - The ControlManager include directories -# - -find_package(PkgConfig) - -find_path(CTRLM_INCLUDE_DIRS NAMES ctrlm_ipc.h) - -set(CTRLM_INCLUDE_DIRS ${CTRLM_INCLUDE_DIRS}) -set(CTRLM_INCLUDE_DIRS ${CTRLM_INCLUDE_DIRS} CACHE PATH "Path to ControlManager include") - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(CTRLM DEFAULT_MSG CTRLM_INCLUDE_DIRS) - -mark_as_advanced( - CTRLM_FOUND - CTRLM_INCLUDE_DIRS) diff --git a/cmake/FindCurl.cmake b/cmake/FindCurl.cmake deleted file mode 100644 index 9b1eafc10..000000000 --- a/cmake/FindCurl.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find curl - -find_package(PkgConfig) - -find_library(CURL_LIBRARY NAMES curl) - -set(CURL_LIBRARY ${CURL_LIBRARY} CACHE PATH "Path to curl library") - -include(FindPackageHandleStandardArgs) - -mark_as_advanced( - CURL_FOUND - CURL_INCLUDE_DIRS - CURL_LIBRARIES - CURL_LIBRARY_DIRS - CURL_FLAGS) diff --git a/cmake/FindDL.cmake b/cmake/FindDL.cmake deleted file mode 100644 index bc6e78eb6..000000000 --- a/cmake/FindDL.cmake +++ /dev/null @@ -1,24 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 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. -### - -find_package(PkgConfig) - -find_library(DL_LIBRARIES NAMES dl) - -mark_as_advanced(DL_LIBRARIES) diff --git a/cmake/FindDS.cmake b/cmake/FindDS.cmake deleted file mode 100644 index af2a7a1c9..000000000 --- a/cmake/FindDS.cmake +++ /dev/null @@ -1,51 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find Display Settings library -# Once done this will define -# DS_FOUND - System has DS -# DS_INCLUDE_DIRS - The DS include directories -# DS_LIBRARIES - The libraries needed to use DS -# DS_FLAGS - The flags needed to use DS -# - -find_package(PkgConfig) - -find_library(DS_LIBRARIES NAMES ds) -find_library(DSHAL_LIBRARIES NAMES dshalcli) -find_library(OEMHAL_LIBRARIES NAMES ds-hal) -find_library(IARMBUS_LIBRARIES NAMES IARMBus) -find_path(DS_INCLUDE_DIRS NAMES manager.hpp PATH_SUFFIXES rdk/ds) -find_path(DSHAL_INCLUDE_DIRS NAMES dsTypes.h PATH_SUFFIXES rdk/halif/ds-hal) -find_path(DSRPC_INCLUDE_DIRS NAMES dsMgr.h PATH_SUFFIXES rdk/ds-rpc) - -set(DS_LIBRARIES ${DS_LIBRARIES} ${DSHAL_LIBRARIES}) -set(DS_LIBRARIES ${DS_LIBRARIES} CACHE PATH "Path to DS library") -set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} ${DSHAL_INCLUDE_DIRS} ${DSRPC_INCLUDE_DIRS}) -set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} CACHE PATH "Path to DS include") - - - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(DS DEFAULT_MSG DS_INCLUDE_DIRS DS_LIBRARIES) - -mark_as_advanced( - DS_FOUND - DS_INCLUDE_DIRS - DS_LIBRARIES - DS_LIBRARY_DIRS - DS_FLAGS) diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake deleted file mode 100644 index 93d3ec547..000000000 --- a/cmake/FindGLIB.cmake +++ /dev/null @@ -1,122 +0,0 @@ -# - Try to find Glib and its components (gio, gobject etc) -# Once done, this will define -# -# GLIB_FOUND - system has Glib -# GLIB_INCLUDE_DIRS - the Glib include directories -# GLIB_LIBRARIES - link these to use Glib -# -# Optionally, the COMPONENTS keyword can be passed to find_package() -# and Glib components can be looked for. Currently, the following -# components can be used, and they define the following variables if -# found: -# -# gio: GLIB_GIO_LIBRARIES -# gobject: GLIB_GOBJECT_LIBRARIES -# gmodule: GLIB_GMODULE_LIBRARIES -# gthread: GLIB_GTHREAD_LIBRARIES -# -# Note that the respective _INCLUDE_DIR variables are not set, since -# all headers are in the same directory as GLIB_INCLUDE_DIRS. -# -# Copyright (C) 2012 Raphael Kubo da Costa -# -# 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_package(PkgConfig) -pkg_check_modules(PC_GLIB QUIET glib-2.0) - -find_library(GLIB_LIBRARIES - NAMES glib-2.0 - HINTS ${PC_GLIB_LIBDIR} - ${PC_GLIB_LIBRARY_DIRS} -) - -# Files in glib's main include path may include glibconfig.h, which, -# for some odd reason, is normally in $LIBDIR/glib-2.0/include. -get_filename_component(_GLIB_LIBRARY_DIR ${GLIB_LIBRARIES} PATH) -find_path(GLIBCONFIG_INCLUDE_DIR - NAMES glibconfig.h - HINTS ${PC_LIBDIR} ${PC_LIBRARY_DIRS} ${_GLIB_LIBRARY_DIR} - ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} - PATH_SUFFIXES glib-2.0/include -) - -find_path(GLIB_INCLUDE_DIR - NAMES glib.h - HINTS ${PC_GLIB_INCLUDEDIR} - ${PC_GLIB_INCLUDE_DIRS} - PATH_SUFFIXES glib-2.0 -) - -set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIBCONFIG_INCLUDE_DIR}) - -# Version detection -if (EXISTS "${GLIBCONFIG_INCLUDE_DIR}/glibconfig.h") - file(READ "${GLIBCONFIG_INCLUDE_DIR}/glibconfig.h" GLIBCONFIG_H_CONTENTS) - string(REGEX MATCH "#define GLIB_MAJOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}") - set(GLIB_VERSION_MAJOR "${CMAKE_MATCH_1}") - string(REGEX MATCH "#define GLIB_MINOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}") - set(GLIB_VERSION_MINOR "${CMAKE_MATCH_1}") - string(REGEX MATCH "#define GLIB_MICRO_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}") - set(GLIB_VERSION_MICRO "${CMAKE_MATCH_1}") - set(GLIB_VERSION "${GLIB_VERSION_MAJOR}.${GLIB_VERSION_MINOR}.${GLIB_VERSION_MICRO}") -endif () - -# Additional Glib components. We only look for libraries, as not all of them -# have corresponding headers and all headers are installed alongside the main -# glib ones. -foreach (_component ${GLIB_FIND_COMPONENTS}) - if (${_component} STREQUAL "gio") - find_library(GLIB_GIO_LIBRARIES NAMES gio-2.0 HINTS ${_GLIB_LIBRARY_DIR}) - set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GIO_LIBRARIES) - elseif (${_component} STREQUAL "gobject") - find_library(GLIB_GOBJECT_LIBRARIES NAMES gobject-2.0 HINTS ${_GLIB_LIBRARY_DIR}) - set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GOBJECT_LIBRARIES) - elseif (${_component} STREQUAL "gmodule") - find_library(GLIB_GMODULE_LIBRARIES NAMES gmodule-2.0 HINTS ${_GLIB_LIBRARY_DIR}) - set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GMODULE_LIBRARIES) - elseif (${_component} STREQUAL "gthread") - find_library(GLIB_GTHREAD_LIBRARIES NAMES gthread-2.0 HINTS ${_GLIB_LIBRARY_DIR}) - set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GTHREAD_LIBRARIES) - elseif (${_component} STREQUAL "gio-unix") - # gio-unix is compiled as part of the gio library, but the include paths - # are separate from the shared glib ones. Since this is currently only used - # by WebKitGTK+ we don't go to extraordinary measures beyond pkg-config. - pkg_check_modules(GIO_UNIX QUIET gio-unix-2.0) - endif () -endforeach () - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLIB REQUIRED_VARS GLIB_INCLUDE_DIRS GLIB_LIBRARIES ${ADDITIONAL_REQUIRED_VARS} - VERSION_VAR GLIB_VERSION) - -mark_as_advanced( - GLIBCONFIG_INCLUDE_DIR - GLIB_GIO_LIBRARIES - GLIB_GIO_UNIX_LIBRARIES - GLIB_GMODULE_LIBRARIES - GLIB_GOBJECT_LIBRARIES - GLIB_GTHREAD_LIBRARIES - GLIB_INCLUDE_DIR - GLIB_INCLUDE_DIRS - GLIB_LIBRARIES -) diff --git a/cmake/FindGStreamer.cmake b/cmake/FindGStreamer.cmake deleted file mode 100644 index 90dd7d0a2..000000000 --- a/cmake/FindGStreamer.cmake +++ /dev/null @@ -1,60 +0,0 @@ -# - Try to find gstreamer-1.0. -# Once done, this will define -# -# GSTREAMER_FOUND - the gstreamer-1.0 is available -# GStreamer::GStreamer - The gstreamer-1.0 library and all its dependecies -# -# 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_package(PkgConfig) -pkg_check_modules(PC_GSTREAMER gstreamer-1.0) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PC_GSTREAMER DEFAULT_MSG PC_GSTREAMER_FOUND) - -mark_as_advanced(PC_GSTREAMER_INCLUDE_DIRS PC_GSTREAMER_LIBRARIES PC_GSTREAMER_LIBRARY_DIRS) - -if(${PC_GSTREAMER_FOUND}) - find_library(GSTREAMER_LIBRARY gstreamer-1.0 - HINTS ${PC_GSTREAMER_LIBRARY_DIRS} - ) - - set(GSTREAMER_LIBRARIES ${PC_GSTREAMER_LIBRARIES}) - set(GSTREAMER_INCLUDES ${PC_GSTREAMER_INCLUDE_DIRS}) - set(GSTREAMER_FOUND ${PC_GSTREAMER_FOUND}) - - if(NOT TARGET GStreamer::GStreamer) - add_library(GStreamer::GStreamer UNKNOWN IMPORTED) - - set_target_properties(GStreamer::GStreamer - PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${GSTREAMER_LIBRARY}" - INTERFACE_COMPILE_DEFINITIONS "GSTREAMER" - INTERFACE_COMPILE_OPTIONS "${PC_GSTREAMER_CFLAGS_OTHER}" - INTERFACE_INCLUDE_DIRECTORIES "${PC_GSTREAMER_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${PC_GSTREAMER_LIBRARIES}" - ) - endif() -endif() diff --git a/cmake/FindGStreamerVideo.cmake b/cmake/FindGStreamerVideo.cmake deleted file mode 100644 index 153bfa466..000000000 --- a/cmake/FindGStreamerVideo.cmake +++ /dev/null @@ -1,60 +0,0 @@ -# - Try to find gstreamer-video-1.0. -# Once done, this will define -# -# GSTREAMER_VIDEO_FOUND - the gstreamer-video-1.0 is available -# GStreamerVideo::GStreamerVideo - The gstreamer-video-1.0 library and all its dependecies -# -# 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_package(PkgConfig) -pkg_check_modules(PC_GSTREAMER_VIDEO gstreamer-video-1.0) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PC_GSTREAMER_VIDEO DEFAULT_MSG PC_GSTREAMER_VIDEO_FOUND) - -mark_as_advanced(PC_GSTREAMER_VIDEO_INCLUDE_DIRS PC_GSTREAMER_VIDEO_LIBRARIES PC_GSTREAMER_VIDEO_LIBRARY_DIRS) - -if(${PC_GSTREAMER_VIDEO_FOUND}) - find_library(GSTREAMER_VIDEO_LIBRARY gstvideo-1.0 - HINTS ${PC_GSTREAMER_VIDEO_LIBRARY_DIRS} - ) - - set(GSTREAMER_VIDEO_LIBRARIES ${PC_GSTREAMER_VIDEO_LIBRARIES}) - set(GSTREAMER_VIDEO_INCLUDES ${PC_GSTREAMER_VIDEO_INCLUDE_DIRS}) - set(GSTREAMER_VIDEO_FOUND ${PC_GSTREAMER_VIDEO_FOUND}) - - if(NOT TARGET GStreamerVideo::GStreamerVideo) - add_library(GStreamerVideo::GStreamerVideo UNKNOWN IMPORTED) - - set_target_properties(GStreamerVideo::GStreamerVideo - PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${GSTREAMER_VIDEO_LIBRARY}" - INTERFACE_COMPILE_DEFINITIONS "GSTREAMER_VIDEO" - INTERFACE_COMPILE_OPTIONS "${PC_GSTREAMER_VIDEO_CFLAGS_OTHER}" - INTERFACE_INCLUDE_DIRECTORIES "${PC_GSTREAMER_VIDEO_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${PC_GSTREAMER_VIDEO_LIBRARIES}" - ) - endif() -endif() diff --git a/cmake/FindIARMBus.cmake b/cmake/FindIARMBus.cmake deleted file mode 100644 index da1d58778..000000000 --- a/cmake/FindIARMBus.cmake +++ /dev/null @@ -1,44 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find IARMBus -# Once done this will define -# IARMBUS_FOUND - System has IARMBus -# IARMBUS_INCLUDE_DIRS - The IARMBus include directories -# IARMBUS_LIBRARIES - The libraries needed to use IARMBus -# IARMBUS_FLAGS - The flags needed to use IARMBus -# - -find_package(PkgConfig) - -find_library(IARMBUS_LIBRARIES NAMES IARMBus) -find_path(IARMBUS_INCLUDE_DIRS NAMES libIARM.h PATH_SUFFIXES rdk/iarmbus) -find_path(IARMRECEIVER_INCLUDE_DIRS NAMES receiverMgr.h PATH_SUFFIXES rdk/iarmmgrs/receiver) - -set(IARMBUS_LIBRARIES ${IARMBUS_LIBRARIES} CACHE PATH "Path to IARMBus library") -set(IARMBUS_INCLUDE_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMRECEIVER_INCLUDE_DIRS}) -set(IARMBUS_INCLUDE_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMRECEIVER_INCLUDE_DIRS} CACHE PATH "Path to IARMBus include") - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(IARMBUS DEFAULT_MSG IARMBUS_INCLUDE_DIRS IARMBUS_LIBRARIES) - -mark_as_advanced( - IARMBUS_FOUND - IARMBUS_INCLUDE_DIRS - IARMBUS_LIBRARIES - IARMBUS_LIBRARY_DIRS - IARMBUS_FLAGS) diff --git a/cmake/FindLMPLAYER.cmake b/cmake/FindLMPLAYER.cmake deleted file mode 100644 index 369aa1a0b..000000000 --- a/cmake/FindLMPLAYER.cmake +++ /dev/null @@ -1,47 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find Audio Capture Mgr -# Once done this will define -# LMPLAYER_FOUND - System has audiocapturemgr -# LMPLAYER_INCLUDE_DIRS - The audiocapturemgr include directories -# LMPLAYER_LIBRARIES - The libraries needed to use audiocapturemgr -# LMPLAYER_FLAGS - The flags needed to use audiocapturemgr -# - -find_package(PkgConfig) - -find_library(LMPLAYER_LIBRARIES NAMES mediaplayer) -find_path(LMPLAYER_INCLUDE_DIRS NAMES libmediaplayer.h) -#find_library(LMPLAYER_LIBRARIES NAMES ds) -#find_path(LMPLAYER_INCLUDE_DIRS NAMES dsTypes.h PATH_SUFFIXES rdk/halif/ds-hal) -message(STATUS "LMPLAYER_LIBRARIES is ${LMPLAYER_LIBRARIES}") -message(STATUS "LMPLAYER_INCLUDE_DIRS is ${LMPLAYER_INCLUDE_DIRS}") - -set(LMPLAYER_LIBRARIES ${LMPLAYER_LIBRARIES} CACHE PATH "Path to libmediaplayer library") -set(LMPLAYER_INCLUDE_DIRS ${LMPLAYER_INCLUDE_DIRS} ) -set(LMPLAYER_INCLUDE_DIRS ${LMPLAYER_INCLUDE_DIRS} CACHE PATH "Path to libmediaplayer include") - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LMPLAYER DEFAULT_MSG LMPLAYER_INCLUDE_DIRS LMPLAYER_LIBRARIES) - -mark_as_advanced( - LMPLAYER_FOUND - LMPLAYER_INCLUDE_DIRS - LMPLAYER_LIBRARIES - LMPLAYER_LIBRARY_DIRS - LMPLAYER_FLAGS) diff --git a/cmake/FindLibSoup.cmake b/cmake/FindLibSoup.cmake deleted file mode 100644 index fc2472938..000000000 --- a/cmake/FindLibSoup.cmake +++ /dev/null @@ -1,40 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find libsoup -# Once done this will define -# LIBSOUP_FOUND - System has libsoup -# LIBSOUP_INCLUDE_DIRS - The libsoup include directories -# LIBSOUP_LIBRARIES - The libraries needed to use libsoup - -find_package(PkgConfig) -pkg_check_modules(PC_LIBSOUP QUIET libsoup-2.4) - -find_path(LIBSOUP_INCLUDE_DIRS - NAMES libsoup/soup.h - HINTS ${PC_LIBSOUP_INCLUDEDIR} ${PC_LIBSOUP_INCLUDE_DIRS} -) - -find_library(LIBSOUP_LIBRARIES - NAMES soup-2.4 - HINTS ${PC_LIBSOUP_LIBDIR} ${PC_LIBSOUP_LIBRARY_DIRS} -) - -mark_as_advanced(LIBSOUP_INCLUDE_DIRS LIBSOUP_LIBRARIES) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(LIBSOUP REQUIRED_VARS LIBSOUP_INCLUDE_DIRS LIBSOUP_LIBRARIES) diff --git a/cmake/FindNEXUS.cmake b/cmake/FindNEXUS.cmake deleted file mode 100644 index ea7c9553d..000000000 --- a/cmake/FindNEXUS.cmake +++ /dev/null @@ -1,79 +0,0 @@ -# - Try to find Nexus. -# Once done this will define -# NEXUS_FOUND - System has Nexus -# NEXUS::NEXUS - The Nexus library -# -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 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. -### - -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() diff --git a/cmake/FindNXCLIENT.cmake b/cmake/FindNXCLIENT.cmake deleted file mode 100644 index dc2a165bb..000000000 --- a/cmake/FindNXCLIENT.cmake +++ /dev/null @@ -1,49 +0,0 @@ -# - Try to find Nexus client. -# Once done this will define -# NXCLIENT_FOUND - System has a Nexus client -# NXCLIENT::NXCLIENT - The Nexus client library -# -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 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. -### - -find_path(LIBNXCLIENT_INCLUDE nexus_config.h - PATH_SUFFIXES refsw) - -find_library(LIBNXCLIENT_LIBRARY nxclient) - -if(EXISTS "${LIBNXCLIENT_LIBRARY}") - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(NXCLIENT DEFAULT_MSG LIBNXCLIENT_INCLUDE LIBNXCLIENT_LIBRARY) - mark_as_advanced(LIBNXCLIENT_LIBRARY) - - if(NXCLIENT_FOUND AND NOT TARGET NXCLIENT::NXCLIENT) - add_library(NXCLIENT::NXCLIENT UNKNOWN IMPORTED) - set_target_properties(NXCLIENT::NXCLIENT PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${LIBNXCLIENT_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${LIBNXCLIENT_INCLUDE}" - ) - endif() -else() - if(NXCLIENT_FIND_REQUIRED) - message(FATAL_ERROR "LIBNXCLIENT_LIBRARY not available") - elseif(NOT NXCLIENT_FIND_QUIETLY) - message(STATUS "LIBNXCLIENT_LIBRARY not available") - endif() -endif() diff --git a/cmake/FindNopoll.cmake b/cmake/FindNopoll.cmake deleted file mode 100644 index 0565c096b..000000000 --- a/cmake/FindNopoll.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find RDK Storage Manager library -# Once done this will define -# NOPOLL_FOUND - System has Nopoll -# NOPOLL_LIBRARIES - The libraries needed to use Nopoll - -find_package(PkgConfig) - -find_path(NOPOLL_INCLUDE_DIRS NAMES nopoll.h PATH_SUFFIXES nopoll) -#find_path(NOPOLL_INCLUDE_DIRS NAMES libIARM.h PATH_SUFFIXES rdk/iarmbus) - -find_library(NOPOLL_LIBRARIES NAMES nopoll) - -mark_as_advanced( - NOPOLL_FOUND - NOPOLL_INCLUDE_DIRS - NOPOLL_LIBRARIES) diff --git a/cmake/FindPlabels.cmake b/cmake/FindPlabels.cmake deleted file mode 100644 index cb1f3f9ca..000000000 --- a/cmake/FindPlabels.cmake +++ /dev/null @@ -1,31 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 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. -### - -find_package(PkgConfig) - -find_path(PLABELS_INCLUDE_DIRS NAMES pbnj_utils.hpp PATH_SUFFIXES pbnj_utils) - -find_library(PLABELS_LIBRARIES NAMES plabels) - -set(PLABELS_FLAGS -DUSE_PLABELS=1 -DRDKLOG_ERROR= -DRDKLOG_INFO= CACHE PATH "Flags for pbnj_utils") - -mark_as_advanced( - PLABELS_FLAGS - PLABELS_INCLUDE_DIRS - PLABELS_LIBRARIES) diff --git a/cmake/FindRDKStorageManager.cmake b/cmake/FindRDKStorageManager.cmake deleted file mode 100644 index be40ab22e..000000000 --- a/cmake/FindRDKStorageManager.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find RDK Storage Manager library -# Once done this will define -# RDK_SM_FOUND - System has DS -# RDK_SM_LIBRARIES - The libraries needed to use DS - -find_package(PkgConfig) - -find_library(RDK_SM_LIBRARIES NAMES rdkstmgr) - -mark_as_advanced( - RDK_SM_FOUND - RDK_SM_LIBRARIES) diff --git a/cmake/FindSqlite.cmake b/cmake/FindSqlite.cmake deleted file mode 100644 index 465672ff1..000000000 --- a/cmake/FindSqlite.cmake +++ /dev/null @@ -1,22 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 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. -### - -find_package(PkgConfig) - -pkg_search_module(SQLITE REQUIRED sqlite3) diff --git a/cmake/FindSqliteSee.cmake b/cmake/FindSqliteSee.cmake deleted file mode 100644 index 5db645a6c..000000000 --- a/cmake/FindSqliteSee.cmake +++ /dev/null @@ -1,22 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 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. -### - -find_package(PkgConfig) - -pkg_search_module(SQLITE REQUIRED sqlite3see) diff --git a/cmake/FindTTS.cmake b/cmake/FindTTS.cmake deleted file mode 100644 index 97c3c8e6a..000000000 --- a/cmake/FindTTS.cmake +++ /dev/null @@ -1,40 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find Display Settings library -# Once done this will define -# TTS_INCLUDE_DIRS - The TTS include directories -# TTS_LIBRARIES - The libraries needed to use TTS -# - -find_package(PkgConfig) -find_library(TTS_LIBRARIES NAMES TTSClient) -find_path(TTS_INCLUDE_DIRS NAMES TTSCommon.h) -find_path(TTSC_INCLUDE_DIRS NAMES TTSClient.h) - -set(TTS_LIBRARIES ${TTS_LIBRARIES} CACHE PATH "Path to TTSClient") -set(TTS_INCLUDE_DIRS ${TTS_INCLUDE_DIRS} CACHE PATH "Path to TTS include") -set(TTSC_INCLUDE_DIRS ${TTSC_INCLUDE_DIRS} CACHE PATH "Path to TTSClient include") - - - -include(FindPackageHandleStandardArgs) - -mark_as_advanced( - TTS_INCLUDE_DIRS - TTSC_INCLUDE_DIRS - TTS_LIBRARIES) diff --git a/cmake/FindUdev.cmake b/cmake/FindUdev.cmake deleted file mode 100644 index 31e9e9f6a..000000000 --- a/cmake/FindUdev.cmake +++ /dev/null @@ -1,22 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 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. -### - -find_package(PkgConfig) - -pkg_search_module(UDEV REQUIRED libudev) diff --git a/cmake/Findjsoncpp.cmake b/cmake/Findjsoncpp.cmake deleted file mode 100644 index 31161c296..000000000 --- a/cmake/Findjsoncpp.cmake +++ /dev/null @@ -1,51 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 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. - -# - Try to find the JSONCPP library. -# -# The following are set after configuration is done: -# JSONCPP_FOUND -# JSONCPP_INCLUDE_DIRS -# JSONCPP_LIBRARY_DIRS -# JSONCPP_LIBRARIES - -find_path( JSONCPP_INCLUDE_DIR NAMES json.h PREFIX json ) -find_library( JSONCPP_LIBRARY NAMES libjsoncpp.so jsoncpp ) - -#message( "JSONCPP_INCLUDE_DIR include dir = ${JSONCPP_INCLUDE_DIR}" ) -#message( "JSONCPP_LIBRARY lib = ${JSONCPP_LIBRARY}" ) - -include( FindPackageHandleStandardArgs ) - -# Handle the QUIETLY and REQUIRED arguments and set the JSONCPP_FOUND to TRUE -# if all listed variables are TRUE -find_package_handle_standard_args( JSONCPP DEFAULT_MSG - JSONCPP_LIBRARY JSONCPP_INCLUDE_DIR ) - -mark_as_advanced( JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY ) - -if( JSONCPP_FOUND ) - set( JSONCPP_LIBRARIES ${JSONCPP_LIBRARY} ) - set( JSONCPP_INCLUDE_DIRS ${JSONCPP_INCLUDE_DIR} ) -endif() - -if( JSONCPP_FOUND AND NOT TARGET JsonCpp::JsonCpp ) - add_library( JsonCpp::JsonCpp SHARED IMPORTED ) - set_target_properties( JsonCpp::JsonCpp PROPERTIES - IMPORTED_LOCATION "${JSONCPP_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${JSONCPP_INCLUDE_DIRS}" ) -endif() \ No newline at end of file diff --git a/cov_build.sh b/cov_build.sh index bde2bce84..906183e11 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -23,9 +23,6 @@ cmake -G Ninja -S "$GITHUB_WORKSPACE" -B build/entservices-inputoutput \ -DRDK_SERVICES_COVERITY=ON \ -DRDK_SERVICES_L1_TEST=ON \ -DDS_FOUND=ON \ --DPLUGIN_HDMICECSOURCE=ON \ --DPLUGIN_HDCPPROFILE=ON \ --DPLUGIN_HDMICECSINK=ON \ -DCMAKE_CXX_FLAGS="-DEXCEPTIONS_ENABLE=ON \ -I ${GITHUB_WORKSPACE}/entservices-testframework/Tests/headers \ -I ${GITHUB_WORKSPACE}/entservices-testframework/Tests/headers/audiocapturemgr \ @@ -37,6 +34,7 @@ cmake -G Ninja -S "$GITHUB_WORKSPACE" -B build/entservices-inputoutput \ -I ${GITHUB_WORKSPACE}/entservices-testframework/Tests/mocks \ -I ${GITHUB_WORKSPACE}/entservices-testframework/Tests/mocks/thunder \ -I ${GITHUB_WORKSPACE}/entservices-testframework/Tests/mocks/devicesettings \ +-I /usr/include/libdrm \ -include ${GITHUB_WORKSPACE}/entservices-testframework/Tests/mocks/devicesettings.h \ -include ${GITHUB_WORKSPACE}/entservices-testframework/Tests/mocks/Iarm.h \ -include ${GITHUB_WORKSPACE}/entservices-testframework/Tests/mocks/Rfc.h \ diff --git a/helpers/PluginInterfaceBuilder.h b/helpers/PluginInterfaceBuilder.h deleted file mode 100755 index a10ad6a69..000000000 --- a/helpers/PluginInterfaceBuilder.h +++ /dev/null @@ -1,225 +0,0 @@ -/** - * If not stated otherwise in this file or this component's LICENSE - * file the following copyright and licenses apply: - * - * Copyright 2024 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. - **/ -#pragma once - -#include -#include -#include - -#include "UtilsLogging.h" - -namespace WPEFramework { -namespace PluginHost { - class IShell; -} - -namespace Plugin { - - template - class PluginInterfaceRef { - INTERFACE* _interface; - PluginHost::IShell* _service; - - public: - PluginInterfaceRef() - : _interface(nullptr) - { - } - - PluginInterfaceRef(INTERFACE* interface, PluginHost::IShell* controller) - : _interface(interface) - { - } - - ~PluginInterfaceRef() - { - Reset(); - } - - // avoid copies - PluginInterfaceRef(const PluginInterfaceRef&) = delete; - PluginInterfaceRef& operator=(const PluginInterfaceRef&) = delete; - - // use move - PluginInterfaceRef(PluginInterfaceRef&& other) - : _interface(other._interface) - { - other._interface = nullptr; - } - - PluginInterfaceRef& operator=(PluginInterfaceRef&& other) - { - if (this != &other) { - _interface = other._interface; - other._interface = nullptr; - } - return *this; - } - - operator bool() const - { - return _interface != nullptr; - } - - INTERFACE* operator->() const - { - return _interface; - } - - void Reset() - { - if (_interface) { - _interface->Release(); - _interface = nullptr; - } - } - }; - - template - class PluginInterfaceBuilder; - - // default impl - template - INTERFACE* createInterface(PluginInterfaceBuilder& builder) - { - WPEFramework::PluginHost::IShell* controller = builder.controller(); - const std::string& callsign = builder.callSign(); - const int retry_count = builder.retryCount(); - const uint32_t retry_interval = builder.retryInterval(); - int count = 0; - - if (!controller) { - LOGERR("Invalid controller"); - return nullptr; - } - - do { - auto pluginInterface = controller->QueryInterfaceByCallsign(callsign.c_str()); - - if (pluginInterface) { - pluginInterface->AddRef(); - LOGINFO("plugin interface succeed and retry count: %d",count); - return pluginInterface; - } - else - { - count++; - LOGERR("plugin interface failed and retry: %d",count); - usleep(retry_interval*1000); - } - }while(count < retry_count); - - return nullptr; - } - - template - std::unique_ptr make_unique(Args&&... args) - { - return std::unique_ptr(new T(std::forward(args)...)); - } - - template - class PluginInterfaceBuilder { - - const std::string _callsign; - PluginHost::IShell* _service; - uint32_t _version; - uint32_t _timeout; - int _retry_count; - uint32_t _retry_interval; - - public: - PluginInterfaceBuilder(const char* callsign) - : _callsign(callsign) - , _service(nullptr) - , _version(static_cast(~0)) - , _timeout(3000) - ,_retry_count(0) - ,_retry_interval(0) - { - } - - // won't take ownership of ref members - ~PluginInterfaceBuilder() = default; - - inline PluginInterfaceBuilder& withVersion(uint32_t version) - { - _version = version; - return *this; - } - - inline PluginInterfaceBuilder& withTimeout(uint32_t timeoutMs) - { - _timeout = timeoutMs; - return *this; - } - - inline PluginInterfaceBuilder& withIShell(PluginHost::IShell * service) - { - _service = service; - return *this; - } - - inline PluginInterfaceBuilder& withRetryIntervalMS(int retryInterval) - { - _retry_interval = retryInterval; - return *this; - } - - inline PluginInterfaceBuilder& withRetryCount(int retryCount) - { - _retry_count = retryCount; - return *this; - } - - PluginInterfaceRef createInterface() - { - auto* interface = ::WPEFramework::Plugin::createInterface(*this); - - if (!interface) { - LOGERR("Failed to create plugin interface for %s", _callsign.c_str()); - } - - // pass on the ownership of controller to interfaceRef - return std::move(PluginInterfaceRef(interface, _service)); - } - - const uint32_t retryInterval() const - { - return _retry_interval; - } - - const int retryCount() const - { - return _retry_count; - } - - const std::string& callSign() const - { - return _callsign; - } - - WPEFramework::PluginHost::IShell* controller() - { - return _service; - } - }; - -} // Plugin -} // WPEFramework diff --git a/helpers/PowerManagerInterface.h b/helpers/PowerManagerInterface.h deleted file mode 100644 index 1486299f8..000000000 --- a/helpers/PowerManagerInterface.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - * If not stated otherwise in this file or this component's LICENSE - * file the following copyright and licenses apply: - * - * Copyright 2024 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. - **/ -#pragma once - -#include "PluginInterfaceBuilder.h" - -using PowerManagerInterfaceBuilder = WPEFramework::Plugin::PluginInterfaceBuilder; -using PowerManagerInterfaceRef = WPEFramework::Plugin::PluginInterfaceRef; diff --git a/helpers/UtilsBIT.h b/helpers/UtilsBIT.h deleted file mode 100644 index ab6d5f115..000000000 --- a/helpers/UtilsBIT.h +++ /dev/null @@ -1,36 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include - -/* a=target variable, b=bit number to act upon 0-n */ -#define BIT_SET(a,b) ((a) |= (1ULL<<(b))) -#define BIT_CLEAR(a,b) ((a) &= ~(1ULL<<(b))) -#define BIT_FLIP(a,b) ((a) ^= (1ULL<<(b))) -#define BIT_CHECK(a,b) (!!((a) & (1ULL<<(b)))) // '!!' to make sure this returns 0 or 1 - -#define BITMASK_SET(x, mask) ((x) |= (mask)) -#define BITMASK_CLEAR(x, mask) ((x) &= (~(mask))) -#define BITMASK_FLIP(x, mask) ((x) ^= (mask)) -#define BITMASK_CHECK_ALL(x, mask) (!(~(x) & (mask))) -#define BITMASK_CHECK_ANY(x, mask) ((x) & (mask)) - -#define GET_BITMASK(a) (((short)pow(2,a))&0xFFFF) diff --git a/helpers/UtilsCStr.h b/helpers/UtilsCStr.h deleted file mode 100644 index 0d1bbab26..000000000 --- a/helpers/UtilsCStr.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#define C_STR(x) (x).c_str() diff --git a/helpers/UtilsController.h b/helpers/UtilsController.h deleted file mode 100644 index f3729bb69..000000000 --- a/helpers/UtilsController.h +++ /dev/null @@ -1,227 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include -#include - -#ifndef DISABLE_SECURITY_TOKEN -#include -#endif - -// std -#include - -#define MAX_STRING_LENGTH 2048 - -#define SERVER_DETAILS "127.0.0.1:9998" - -using namespace WPEFramework; -using namespace std; - -namespace Utils -{ - struct SecurityToken - { - static void getSecurityToken(std::string &token) - { - static std::string sToken = ""; - static bool sThunderSecurityChecked = false; - - static std::mutex mtx; - std::unique_lock lock(mtx); - - if (sThunderSecurityChecked) - { - token = sToken; - return; - } - - sThunderSecurityChecked = true; - -#ifdef DISABLE_SECURITY_TOKEN - token = sToken; -#else - if (!isThunderSecurityConfigured()) - { - LOGINFO("Thunder Security is not enabled. Not getting token"); - token = sToken; - return; - } - - unsigned char buffer[MAX_STRING_LENGTH] = {0}; - int ret = GetSecurityToken(MAX_STRING_LENGTH, buffer); - if (ret < 0) - { - LOGERR("Error in getting token"); - } - else - { - LOGINFO("Retrieved token successfully"); - token = (char *)buffer; - sToken = token; - } -#endif - } - -#ifndef DISABLE_SECURITY_TOKEN - static size_t writeCurlResponse(void *ptr, size_t size, size_t nmemb, string stream) - { - size_t realsize = size * nmemb; - string temp(static_cast(ptr), realsize); - stream.append(temp); - return realsize; - } - - static bool isThunderSecurityConfigured() - { - bool configured = false; - long http_code = 0; - std::string jsonResp; - CURL *curl_handle = NULL; - CURLcode res = CURLE_OK; - curl_handle = curl_easy_init(); - string serialNumber = ""; - string url = "http://127.0.0.1:9998/Service/Controller/Configuration/Controller"; - if (curl_handle && - !curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str()) && - !curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1) && - !curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1) && // when redirected, follow the redirections - !curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writeCurlResponse) && - !curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &jsonResp)) - { - - res = curl_easy_perform(curl_handle); - if (curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &http_code) != CURLE_OK) - { - std::cout << "curl_easy_getinfo failed\n"; - } - std::cout << "Thunder Controller Configuration ret: " << res << " http response code: " << http_code << std::endl; - curl_easy_cleanup(curl_handle); - } - else - { - std::cout << "Could not perform curl to read Thunder Controller Configuration\n"; - } - if ((res == CURLE_OK) && (http_code == 200)) - { - // check for "Security" in response - JsonObject responseJson = JsonObject(jsonResp); - if (responseJson.HasLabel("subsystems")) - { - const JsonArray subsystemList = responseJson["subsystems"].Array(); - for (int i = 0; i < subsystemList.Length(); i++) - { - string subsystem = subsystemList[i].String(); - if (subsystem == "Security") - { - configured = true; - break; - } - } - } - } - return configured; - } -#endif - - }; - - // Thunder Plugin Communication - std::shared_ptr> getThunderControllerClient(std::string callsign="") - { - - string token; - Utils::SecurityToken::getSecurityToken(token); - string query = "token=" + token; - - Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T(SERVER_DETAILS))); - std::shared_ptr> thunderClient = make_shared>(callsign.c_str(), "", false, query); - - return thunderClient; - } - -#ifndef USE_THUNDER_R4 - class Job : public Core::IDispatchType -#else - class Job : public Core::IDispatch -#endif /* USE_THUNDER_R4 */ - { - public: - Job(std::function work) - : _work(work) - { - } - void Dispatch() override - { - _work(); - } - - private: - std::function _work; - }; - - uint32_t getServiceState(PluginHost::IShell *shell, const string &callsign, PluginHost::IShell::state &state) - { - uint32_t result; - auto interface = shell->QueryInterfaceByCallsign(callsign); - if (interface == nullptr) - { - result = Core::ERROR_UNAVAILABLE; - std::cout << "no IShell for " << callsign << std::endl; - } - else - { - result = Core::ERROR_NONE; - state = interface->State(); - std::cout << "IShell state " << state << " for " << callsign << std::endl; - interface->Release(); - } - return result; - } - - uint32_t activatePlugin(PluginHost::IShell *shell, const string &callsign) - { - uint32_t result = Core::ERROR_ASYNC_FAILED; - Core::Event event(false, true); - -#ifndef USE_THUNDER_R4 - Core::IWorkerPool::Instance().Submit(Core::ProxyType>(Core::ProxyType::Create([&]() - { -#else - Core::IWorkerPool::Instance().Submit(Core::ProxyType(Core::ProxyType::Create([&]() - { -#endif /* USE_THUNDER_R4 */ - auto interface = shell->QueryInterfaceByCallsign(callsign); - if (interface == nullptr) { - result = Core::ERROR_UNAVAILABLE; - std::cout << "no IShell for " << callsign << std::endl; - } else { - result = interface->Activate(PluginHost::IShell::reason::REQUESTED); - std::cout << "IShell activate status " << result << " for " << callsign << std::endl; - interface->Release(); - } - event.SetEvent(); }))); - - event.Lock(); - return result; - } - -} diff --git a/helpers/UtilsFile.h b/helpers/UtilsFile.h deleted file mode 100644 index 5d34c2a95..000000000 --- a/helpers/UtilsFile.h +++ /dev/null @@ -1,112 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include -#include -#include -#include - -using namespace std; - -namespace Utils -{ -auto MoveFile( - const string &from, - const string &to) -> bool -{ - using namespace WPEFramework::Core; - - File fileFrom(from); - File fileTo(to); - - Directory(fileTo.PathName().c_str()).CreatePath(); - - bool result = - fileFrom.Exists() && - !fileTo.Exists() && - fileFrom.Open(true) && - fileTo.Create(); - - if (result) { - const uint32_t bufLen = 1024; - - uint8_t buffer[bufLen]; - - do { - auto len = fileFrom.Read(buffer, bufLen); - if (len <= 0) { - break; - } - - auto ptr = buffer; - - do { - auto count = fileTo.Write(ptr, len); - if (count <= 0) { - result = false; - break; - } - - len -= count; - ptr += count; - } - while (len > 0); - } - while (result); - - if (result) { - fileFrom.Destroy(); - } - else { - fileTo.Destroy(); - } - } - - return result; -} - -/** -* @brief Get the last non empty line from the input string, equivalent to "tr -s '\r' '\n' | tail -n 1" -* @param[in] input - The input string -* @param[out] res_str - The last non empty line from the input string -* @return whether or not a non empty line was found -*/ -bool getLastLine(const std::string& input, std::string& res_str) -{ - string read_line = ""; - bool ret_value = false; - - if (!input.empty()) - { - stringstream read_str(input); - while (getline(read_str, read_line, '\n')) - { - if (!read_line.empty()) - { - res_str = read_line; - ret_value = true; - } - } - } - return ret_value; -} - -} diff --git a/helpers/UtilsIarm.h b/helpers/UtilsIarm.h deleted file mode 100644 index c9e61167c..000000000 --- a/helpers/UtilsIarm.h +++ /dev/null @@ -1,90 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include "UtilsLogging.h" - -#include "libIBus.h" -#include - -#define IARM_CHECK(FUNC) { \ - if ((res = FUNC) != IARM_RESULT_SUCCESS) { \ - LOGINFO("IARM %s: %s", #FUNC, \ - res == IARM_RESULT_INVALID_PARAM ? "invalid param" : ( \ - res == IARM_RESULT_INVALID_STATE ? "invalid state" : ( \ - res == IARM_RESULT_IPCCORE_FAIL ? "ipcore fail" : ( \ - res == IARM_RESULT_OOM ? "oom" : "unknown")))); \ - } \ - else \ - { \ - LOGINFO("IARM %s: success", #FUNC); \ - } \ -} - -namespace Utils { -struct IARM { - static bool init() - { - IARM_Result_t res; - bool result = false; - - if (isConnected()) { - LOGINFO("IARM already connected"); - result = true; - } else { - unsigned int retryCount = 0; - do - { - res = IARM_Bus_Init(NAME); - LOGINFO("IARM_Bus_Init: %d", res); - if (res == IARM_RESULT_SUCCESS || res == IARM_RESULT_INVALID_STATE /* already inited or connected */) { - res = IARM_Bus_Connect(); - LOGINFO("IARM_Bus_Connect: %d", res); - if (res == IARM_RESULT_SUCCESS || res == IARM_RESULT_INVALID_STATE /* already connected or not inited */) { - result = isConnected(); - LOGERR("ARM_Bus_Connect result: %d res: %d retryCount :%d ",result, res, retryCount); - } else { - LOGERR("IARM_Bus_Connect failure:result :%d res: %d retryCount :%d ",result, res, retryCount); - } - } else { - LOGERR("IARM_Bus_Init failure: result :%d res: %d retryCount :%d",result, res,retryCount); - } - - if(result == false) usleep(100000); - - }while((result == false) && (retryCount++ < 20)); - } - - return result; - } - - static bool isConnected() - { - IARM_Result_t res; - int isRegistered = 0; - res = IARM_Bus_IsConnected(NAME, &isRegistered); - LOGINFO("IARM_Bus_IsConnected: res:%d isRegistered (%d)", res, isRegistered); - - return (isRegistered == 1); - } - - static constexpr const char* NAME = "Thunder_Plugins"; -}; -} diff --git a/helpers/UtilsInputValidator.h b/helpers/UtilsInputValidator.h deleted file mode 100644 index 49049423c..000000000 --- a/helpers/UtilsInputValidator.h +++ /dev/null @@ -1,351 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2023 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. -**/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Utils { - -#define NON_COPYABLE(Type) \ - Type(Type &) = delete; \ - Type& operator=(Type &) = delete;\ - -#define NON_MOVABLE(Type) \ - Type(Type &&) = delete; \ - Type& operator=(Type &&) = delete;\ - -template -class ExpectedValues -{ -private: - enum Type - { - None, - Discrete, - Range, - RegExp - }; - -public: - ExpectedValues() = default; - - ExpectedValues &operator=(const ExpectedValues ©) - { - m_type = copy.m_type; - switch (m_type) - { - case Type::Discrete: - for (auto &value : copy.m_values) - m_values.emplace(value); - break; - case Type::Range: - m_range = copy.m_range; - break; - case Type::RegExp: - m_regex = copy.m_regex; - break; - case None: - default: - break; - } - - return *this; - }; - ExpectedValues(const ExpectedValues ©) - { - operator=(copy); - } - - ExpectedValues &operator=(ExpectedValues &©) - { - std::swap(m_type, copy.m_type); - switch (m_type) - { - case Type::Discrete: - m_values = std::move(copy.m_values); - break; - case Type::Range: - m_range = copy.m_range; - break; - case Type::RegExp: - m_regex = std::move(copy.m_regex); - break; - case None: - default: - break; - } - - return *this; - }; - ExpectedValues(ExpectedValues &©) - { - operator=(std::forward>(copy)); - }; - - virtual ~ExpectedValues(){}; - - ExpectedValues(T min, T max) : m_type(Range), m_range({min, max}) {} - ExpectedValues(std::string regexStr) : m_type(RegExp), m_regex(std::regex(std::move(regexStr))) {} - ExpectedValues(std::regex regex) : m_type(RegExp), m_regex(std::move(regex)) {} - ExpectedValues(std::set values) : m_type(Discrete), m_values(std::move(values)) {} - - ExpectedValues(std::initializer_list values) : m_type(Discrete), m_values(std::move(values)) {} - ExpectedValues(std::initializer_list values) : m_type(Discrete) - { - for (auto *value : values) { - if (!value) - continue; - m_values.emplace(std::string(value)); - } - } - - ExpectedValues(std::vector values) : m_type(Discrete), m_values(std::move(values)) {} - ExpectedValues(std::vector values) : m_type(Discrete) - { - for (auto *value : values) { - if (!value) - continue; - m_values.emplace(std::string(value)); - } - } - - inline bool validate(const T &value) const - { - switch (m_type) - { - case Type::Discrete: - return std::find(m_values.begin(), m_values.end(), value) != m_values.end(); - case Type::Range: - return value >= m_range.m_min && value <= m_range.m_max; - case Type::RegExp: - return regexMatch(value); - case None: - default: - return true; - } - } - - inline bool validate(const char *value) - { - return value ? validate(std::string(value)) : false; - } - -private: - inline bool regexMatch(const std::string &value) const - { - return std::regex_match(value, m_regex); - } - - template - inline bool regexMatch(const U &value) const - { - return regexMatch(std::to_string(value)); - } - -private: - Type m_type{None}; - - struct - { - T m_min; - T m_max; - } m_range; - std::set m_values; - std::regex m_regex; -}; - -struct ValidatorBase -{ - virtual ~ValidatorBase(){}; -}; - -template -class Validator : public ValidatorBase -{ - using FunctionType = std::function; - - enum Type - { - None, - UseExpectedValues, - CustomValidation - }; - -public: - NON_COPYABLE(Validator); - NON_MOVABLE(Validator); - virtual ~Validator(){}; - - inline static std::shared_ptr create(ExpectedValues &&expectedValues) - { - return std::shared_ptr(static_cast(new Validator(std::forward>(expectedValues)))); - } - - inline static std::shared_ptr create(FunctionType &&func) - { - return std::shared_ptr(static_cast(new Validator(std::forward(func)))); - } - -public: - inline virtual bool validate(const T &value) - { - switch (m_type) - { - case Type::CustomValidation: - return m_func(value); - break; - case Type::UseExpectedValues: - return m_expectedValues.validate(value); - break; - case None: - default: - return false; - } - } - -protected: - Validator() : m_type(Type::None) {} - -private: - Validator(ExpectedValues expectedValues) : m_type(UseExpectedValues), m_expectedValues(std::move(expectedValues)) {} - Validator(std::function func) : m_type(CustomValidation), m_func(std::move(func)) {} - -private: - Type m_type; - - union - { - ExpectedValues m_expectedValues; - std::function m_func; - }; -}; - -class ValidationManager -{ -public: - using ValidatorMap = std::map>>; - using LoggerFunction = void(*)(const char *log); - -public: - inline void addValidator(std::string name, std::shared_ptr validator) - { - m_validators[name].emplace_back(std::move(validator)); - } - - template - inline void addValidator(std::string name, ExpectedValues &&expectedValues) - { - addValidator(name, Validator::create(std::forward>(expectedValues))); - } - - template > - inline void addValidator(std::string name, FunctionType &&func) - { - addValidator(name, Validator::create(std::forward(func))); - } - - template - inline bool validate(std::string name, const T &value) - { - auto it = m_validators.find(name); - if (it != m_validators.end()) - { - for (auto &strValidatorBase : it->second) - { - auto *validator = dynamic_cast *>(strValidatorBase.get()); - if (validator == nullptr || !validator->validate(value)) - { - std::stringstream ss; - if (!validator) - ss << "Validator not found for key \"" << name << "\" with type \"" << typeid(T).name() << "\"" << std::endl; - ss << "Validation failed for key \"" << name << "\" with type \"" << typeid(T).name() << "\" & value \"" << value << "\"" << std::endl; - - if (m_logger) - m_logger(ss.str().c_str()); - else - std::cout << ss.str(); - - return false; - } - } - - return true; - } - - return false; - } - - inline bool validate(std::string name, const char *value) - { - return value ? validate(name, std::string(value)) : false; - } - - void setLogger(LoggerFunction logger) - { - m_logger = logger; - } - -private: - ValidatorMap m_validators; - LoggerFunction m_logger { nullptr }; -}; - -} // namespace Utils - -#if 0 -namespace { - using namespace Utils; - - template - class MyCustomValidator : public Validator - { - public: - NON_COPYABLE(MyCustomValidator); - NON_MOVABLE(MyCustomValidator); - virtual ~MyCustomValidator(){}; - - inline static std::shared_ptr create() - { - return std::shared_ptr(static_cast(new MyCustomValidator())); - } - - public: - inline virtual bool validate(const T &value) override - { - return true; - } - - private: - MyCustomValidator() : Validator() {} - }; - - ValidationManager validator; - validator.addValidator("key", MyCustomValidator::create()); -} -#endif - diff --git a/helpers/UtilsJsonRpc.h b/helpers/UtilsJsonRpc.h deleted file mode 100644 index bff772aa0..000000000 --- a/helpers/UtilsJsonRpc.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include "UtilsLogging.h" - -#define LOGINFOMETHOD() { std::string json; parameters.ToString(json); LOGINFO( "params=%s", json.c_str() ); } -#define LOGTRACEMETHODFIN() { std::string json; response.ToString(json); LOGINFO( "response=%s", json.c_str() ); } - -/** - * DO NOT USE THIS. - * - * "success" parameter was added for legacy reasons. - * Newer APIs should return only error code to match the spec - */ - -#define returnResponse(expression) \ - { \ - bool successBoolean = expression; \ - response["success"] = successBoolean; \ - LOGTRACEMETHODFIN(); \ - return (successBoolean ? WPEFramework::Core::ERROR_NONE : WPEFramework::Core::ERROR_GENERAL); \ - } -#define returnIfParamNotFound(param, name) \ - if (!param.HasLabel(name)) \ - { \ - LOGERR("No argument '%s'", name); \ - returnResponse(false); \ - } -#define returnIfStringParamNotFound(param, name) \ - if (!param.HasLabel(name) || param[name].Content() != WPEFramework::Core::JSON::Variant::type::STRING) \ - {\ - LOGERR("No argument '%s' or it has incorrect type", name); \ - returnResponse(false); \ - } -#define returnIfBooleanParamNotFound(param, name) \ - if (!param.HasLabel(name) || param[name].Content() != WPEFramework::Core::JSON::Variant::type::BOOLEAN) \ - { \ - LOGERR("No argument '%s' or it has incorrect type", name); \ - returnResponse(false); \ - } -#define returnIfNumberParamNotFound(param, name) \ - if (!param.HasLabel(name) || param[name].Content() != WPEFramework::Core::JSON::Variant::type::NUMBER) \ - { \ - LOGERR("No argument '%s' or it has incorrect type", name); \ - returnResponse(false); \ - } - -/** - * DO NOT USE THIS. - * - * You should be capable of just using "Notify". - */ - -#if ((THUNDER_VERSION >= 4) && (THUNDER_VERSION_MINOR == 4)) - -#define sendNotify(event,params) { \ - std::string json; \ - params.ToString(json); \ - LOGINFO("Notify %s %s", event, json.c_str()); \ - Notify(event,params); \ -} - -#define sendNotifyMaskParameters(event,params) { \ - std::string json; \ - params.ToString(json); \ - LOGINFO("Notify %s <***>", event); \ - Notify(event,params); \ -} - -#else - -#define sendNotify(event,params) { \ - std::string json; \ - params.ToString(json); \ - LOGINFO("Notify %s %s", event, json.c_str()); \ - for (uint8_t i = 1; GetHandler(i); i++) GetHandler(i)->Notify(event,params); \ -} -#define sendNotifyMaskParameters(event,params) { \ - std::string json; \ - params.ToString(json); \ - LOGINFO("Notify %s <***>", event); \ - for (uint8_t i = 1; GetHandler(i); i++) GetHandler(i)->Notify(event,params); \ -} - -#endif -/** - * DO NOT USE THIS. - * - * Instead, add YOURPLUGINNAME.json to https://github.com/rdkcentral/ThunderInterfaces - * and use the generated classes from - */ - -#define getNumberParameter(paramName, param) { \ - if (WPEFramework::Core::JSON::Variant::type::NUMBER == parameters[paramName].Content()) \ - param = parameters[paramName].Number(); \ - else \ - try { param = std::stoi( parameters[paramName].String()); } \ - catch (...) { param = 0; } \ -} -#define getNumberParameterObject(parameters, paramName, param) { \ - if (WPEFramework::Core::JSON::Variant::type::NUMBER == parameters[paramName].Content()) \ - param = parameters[paramName].Number(); \ - else \ - try {param = std::stoi( parameters[paramName].String());} \ - catch (...) { param = 0; } \ -} -#define getBoolParameter(paramName, param) { \ - if (WPEFramework::Core::JSON::Variant::type::BOOLEAN == parameters[paramName].Content()) \ - param = parameters[paramName].Boolean(); \ - else \ - param = parameters[paramName].String() == "true" || parameters[paramName].String() == "1"; \ -} -#define getStringParameter(paramName, param) { \ - if (WPEFramework::Core::JSON::Variant::type::STRING == parameters[paramName].Content()) \ - param = parameters[paramName].String(); \ -} -#define getFloatParameter(paramName, param) { \ - if (Core::JSON::Variant::type::FLOAT == parameters[paramName].Content()) \ - param = parameters[paramName].Float(); \ - else \ - try { param = std::stof( parameters[paramName].String()); } \ - catch (...) { param = 0; } \ -} -#define vectorSet(v,s) \ - if (find(begin(v), end(v), s) == end(v)) \ - v.emplace_back(s); -#define getDefaultNumberParameter(paramName, param, default) { \ - if (parameters.HasLabel(paramName)) { \ - if (WPEFramework::Core::JSON::Variant::type::NUMBER == parameters[paramName].Content()) \ - param = parameters[paramName].Number(); \ - else \ - try { param = std::stoi( parameters[paramName].String()); } \ - catch (...) { param = default; } \ - } else param = default; \ -} -#define getDefaultStringParameter(paramName, param, default) { \ - if (parameters.HasLabel(paramName)) { \ - if (WPEFramework::Core::JSON::Variant::type::STRING == parameters[paramName].Content()) \ - param = parameters[paramName].String(); \ - else \ - param = default; \ - } else param = default; \ -} -#define getDefaultBoolParameter(paramName, param, default) { \ - if (parameters.HasLabel(paramName)) { \ - if (WPEFramework::Core::JSON::Variant::type::BOOLEAN == parameters[paramName].Content()) \ - param = parameters[paramName].Boolean(); \ - else \ - param = parameters[paramName].String() == "true" || parameters[paramName].String() == "1"; \ - } else param = default; \ -} diff --git a/helpers/UtilsLOG_MILESTONE.h b/helpers/UtilsLOG_MILESTONE.h deleted file mode 100644 index 45ef5f81c..000000000 --- a/helpers/UtilsLOG_MILESTONE.h +++ /dev/null @@ -1,24 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include "rdk_logger_milestone.h" - -#define LOG_MILESTONE(milestone) logMilestone(milestone); diff --git a/helpers/UtilsLogging.h b/helpers/UtilsLogging.h deleted file mode 100644 index 2fd3d7bfe..000000000 --- a/helpers/UtilsLogging.h +++ /dev/null @@ -1,30 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include - -#define LOGINFO(fmt, ...) do { fprintf(stderr, "[%d] INFO [%s:%d] %s: " fmt "\n", (int)syscall(SYS_gettid), WPEFramework::Core::FileNameOnly(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__); fflush(stderr); } while (0) -#define LOGWARN(fmt, ...) do { fprintf(stderr, "[%d] WARN [%s:%d] %s: " fmt "\n", (int)syscall(SYS_gettid), WPEFramework::Core::FileNameOnly(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__); fflush(stderr); } while (0) -#define LOGERR(fmt, ...) do { fprintf(stderr, "[%d] ERROR [%s:%d] %s: " fmt "\n", (int)syscall(SYS_gettid), WPEFramework::Core::FileNameOnly(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__); fflush(stderr); } while (0) - -#define LOG_DEVICE_EXCEPTION0() LOGWARN("Exception caught: code=%d message=%s", err.getCode(), err.what()); -#define LOG_DEVICE_EXCEPTION1(param1) LOGWARN("Exception caught" #param1 "=%s code=%d message=%s", param1.c_str(), err.getCode(), err.what()); -#define LOG_DEVICE_EXCEPTION2(param1, param2) LOGWARN("Exception caught " #param1 "=%s " #param2 "=%s code=%d message=%s", param1.c_str(), param2.c_str(), err.getCode(), err.what()); diff --git a/helpers/UtilsProcess.h b/helpers/UtilsProcess.h deleted file mode 100644 index 3cad6e8c5..000000000 --- a/helpers/UtilsProcess.h +++ /dev/null @@ -1,92 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace Utils -{ -/** -* @brief Kill all the processes with the given process name -* @param[in] input_pname - The given process name -* @return true if any process with the given name was killed, otherwise false is returned -*/ -bool killProcess(string& input_pname) -{ - PROCTAB* proc = openproc(PROC_FILLMEM | PROC_FILLSTAT | PROC_FILLSTATUS); - proc_t proc_info = {0}; - bool ret_value = false; - - if (proc != NULL) - { - memset(&proc_info, 0, sizeof(proc_info)); - while (readproc(proc, &proc_info) != NULL) - { - if (proc_info.cmd == input_pname) - { - if (0 == kill(proc_info.tid, SIGTERM)) - { - ret_value = true; - LOGINFO("Killed the process [%d] process name [%s]", proc_info.tid, proc_info.cmd); - } - } - } - closeproc(proc); - } - return ret_value; -} - -/** -* @brief Get list of child processes with the given parent process ID, equivalent to "pgrep -P " -* @param[in] input_ppid - The given parent process ID -* @param[out] processIds - The list of child process IDs -* @return true if there are any child processes of the given parent process ID, otherwise false is returned -*/ -bool getChildProcessIDs(int input_ppid, vector& processIds) -{ - PROCTAB* proc = openproc(PROC_FILLMEM | PROC_FILLSTAT | PROC_FILLSTATUS); - proc_t proc_info = {0}; - bool ret_value = false; - - if (proc != NULL) - { - memset(&proc_info, 0, sizeof(proc_info)); - while (readproc(proc, &proc_info) != NULL) - { - if (proc_info.ppid == input_ppid) - { - processIds.push_back(proc_info.tid); - ret_value = true; - } - } - closeproc(proc); - } - return ret_value; -} - -} diff --git a/helpers/UtilsSearchRDKProfile.h b/helpers/UtilsSearchRDKProfile.h deleted file mode 100644 index ce4ddeb58..000000000 --- a/helpers/UtilsSearchRDKProfile.h +++ /dev/null @@ -1,75 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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. -**/ -#pragma once - -#include -#include -#include -#include -#include -using namespace std; - -#define RDK_PROFILE "RDK_PROFILE=" -#define PROFILE_TV "TV" -#define PROFILE_STB "STB" - -typedef enum profile { - NOT_FOUND = -1, - STB = 0, - TV, - MAX -} profile_t; - -profile_t profileType = NOT_FOUND; - -profile_t searchRdkProfile(void) { - - const char* devPropPath = "/etc/device.properties"; - char line[256], *rdkProfile = NULL; - profile_t ret = NOT_FOUND; - FILE* file; - - file = fopen(devPropPath, "r"); - if (file == NULL) { - printf("File not found issue \n"); - return NOT_FOUND; - } - - while (fgets(line, sizeof(line), file)) { - rdkProfile = strstr(line, RDK_PROFILE); - if (rdkProfile != NULL) { - rdkProfile += strlen(RDK_PROFILE); // Move past the 'RDK_PROFILE=' - printf("Found RDK_PROFILE: %s \n", rdkProfile); - break; - } - } - - if (rdkProfile != NULL) { - if (strncmp(rdkProfile, PROFILE_TV, strlen(PROFILE_TV)) == 0) { - ret = TV; - } else if (strncmp(rdkProfile, PROFILE_STB, strlen(PROFILE_STB)) == 0) { - ret = STB; - } - } else { - printf("Found RDK_PROFILE: NOT_FOUND \n"); - ret = NOT_FOUND; - } - fclose(file); - return ret; -} diff --git a/helpers/UtilsString.h b/helpers/UtilsString.h deleted file mode 100644 index 8091719c0..000000000 --- a/helpers/UtilsString.h +++ /dev/null @@ -1,228 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -namespace Utils { -namespace String { - // locale-wise comparison - template - struct loc_equal { - explicit loc_equal(const std::locale& loc) - : loc_(loc) - { - } - bool operator()(charT ch1, charT ch2) - { - return std::toupper(ch1, loc_) == std::toupper(ch2, loc_); - } - - private: - const std::locale& loc_; - }; - - // Case-insensitive substring lookup. - // Returns the substring position or -1 - // Example: int pos = find_substr_ci(string, substring, std::locale()); - template - int find_substr_ci(const T& string, const T& substring, const std::locale& loc = std::locale()) - { - typename T::const_iterator it = std::search(string.begin(), string.end(), - substring.begin(), substring.end(), loc_equal(loc)); - if (it != string.end()) - return it - string.begin(); - else - return -1; // not found - } - - // Case-insensitive substring inclusion lookup. - // Example: if (Utils::String::contains(result, processName)) {..} - template - bool contains(const T& string, const T& substring, const std::locale& loc = std::locale()) - { - int pos = find_substr_ci(string, substring, loc); - return pos != -1; - } - - // Case-insensitive substring inclusion lookup. - // Example: if(Utils::String::contains(tmp, "grep -i")) {..} - template - bool contains(const T& string, const char* c_substring, const std::locale& loc = std::locale()) - { - std::string substring(c_substring); - int pos = find_substr_ci(string, substring, loc); - return pos != -1; - } - - // Case-insensitive string comparison - // returns true if the strings are equal, otherwise returns false - // Example: if (Utils::String::equal(line, provisionType)) {..} - template - bool equal(const T& string, const T& string2, const std::locale& loc = std::locale()) - { - int pos = find_substr_ci(string, string2, loc); - bool res = (pos == 0) && (string.length() == string2.length()); - return res; - } - - // Case-insensitive string comparison - // returns true if the strings are equal, otherwise returns false - // Example: if(Utils::String::equal(line,"CRYPTANIUM")) {..} - template - bool equal(const T& string, const char* c_string2, const std::locale& loc = std::locale()) - { - std::string string2(c_string2); - int pos = find_substr_ci(string, string2, loc); - bool res = (pos == 0) && (string.length() == string2.length()); - return res; - } - - // Trim space characters (' ', '\n', '\v', '\f', \r') on the left side of string - inline void ltrim(std::string& s) - { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { - return !std::isspace(ch); - })); - } - - // Trim space characters (' ', '\n', '\v', '\f', \r') on the right side of string - inline void rtrim(std::string& s) - { - s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { - return !std::isspace(ch); - }).base(), - s.end()); - } - - // Trim space characters (' ', '\n', '\v', '\f', \r') on both sides of string - inline void trim(std::string& s) - { - ltrim(s); - rtrim(s); - } - - inline void toUpper(std::string& s) - { - std::transform(s.begin(), s.end(), s.begin(), ::toupper); - } - - inline void toLower(std::string& s) - { - std::transform(s.begin(), s.end(), s.begin(), ::tolower); - } - - // case insensitive comparison of strings - inline bool stringContains(const std::string& s1, const std::string& s2) - { - return search(s1.begin(), s1.end(), s2.begin(), s2.end(), [](char c1, char c2) { return toupper(c1) == toupper(c2); }) != s1.end(); - } - - // case insensitive comparison of strings - inline bool stringContains(const std::string& s1, const char* s2) - { - return stringContains(s1, std::string(s2)); - } - - // Split string s into a vector of strings using the supplied delimiter - inline void split(std::vector &stringList, std::string &s, std::string delimiters) - { - size_t current; - size_t next = -1; - do - { - current = next + 1; - next = s.find_first_of( delimiters, current ); - - stringList.push_back(s.substr( current, next - current )); - } - while (next != string::npos); - } - - static const TCHAR base64_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - - - inline void imageEncoder(const uint8_t object[], const uint32_t length, const bool padding, string& result) - { - uint8_t state = 0; - uint32_t index = 0; - uint8_t lastStuff = 0; - - while (index < length) { - if (state == 0) { - result += base64_chars[((object[index] & 0xFC) >> 2)]; - lastStuff = ((object[index] & 0x03) << 4); - state = 1; - } else if (state == 1) { - result += base64_chars[(((object[index] & 0xF0) >> 4) | lastStuff)]; - lastStuff = ((object[index] & 0x0F) << 2); - state = 2; - } else if (state == 2) { - result += base64_chars[(((object[index] & 0xC0) >> 6) | lastStuff)]; - result += base64_chars[(object[index] & 0x3F)]; - state = 0; - } - index++; - } - if (state != 0) { - result += base64_chars[lastStuff]; - - if (padding == true) { - if (state == 1) { - result += _T("=="); - } else { - result += _T("="); - } - } - } - - } - -/** -* @brief Remove extra spaces from the given input string -* @param[in] in_str - The input string -* @param[out] out_str - The output string (equals input_string with extra spaces removed) -* @return true if the input string is a valid string -*/ - inline bool removeExtraWhitespaces(string& in_str, string& out_str) - { - bool ret_status = false; - int idx = 0; - if (!in_str.empty()) - { - while (in_str[idx] != '\0') - { - out_str += in_str[idx]; - if (in_str[idx] == ' ') - { - while (in_str[idx+1] == ' ') - { - idx++; - } - } - idx++; - } - ret_status = true; - } - return ret_status; - } - -} -} diff --git a/helpers/UtilsSynchro.hpp b/helpers/UtilsSynchro.hpp deleted file mode 100644 index 0039fd2ef..000000000 --- a/helpers/UtilsSynchro.hpp +++ /dev/null @@ -1,117 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include -#include -#include -#include "UtilsLogging.h" - -using namespace WPEFramework; - -namespace Utils { - namespace Synchro { - - namespace { - // set when inside of getFunctionToCall wrapper (or locked IARM handler - see UtilsSynchroIarm.hpp) - thread_local bool isThreadUsingLockedApi = false; - } - - // keeps API locks, one per specific class - template - struct ApiLocks { - static std::recursive_mutex mtx; - }; - - template std::recursive_mutex ApiLocks::mtx; - - template - std::function - getFunctionToCall(const std::string& debugname, const METHOD& method, REALOBJECT* objectPtr) { - return [debugname, method](REALOBJECT *obj, const WPEFramework::Core::JSON::VariantContainer& in, WPEFramework::Core::JSON::VariantContainer& out) -> uint32_t { - isThreadUsingLockedApi = true; - // printf("METHOD CALL, GETTING LOCK: REALOBJECT '%s', method: '%s' MUTEX:%p\n",typeid(REALOBJECT).name(), debugname.c_str(), &ApiLocks::mtx); fflush(stdout); - std::lock_guard lock(ApiLocks::mtx); - LOGINFO("calling %s with lock: %p\n", debugname.c_str(), &ApiLocks::mtx); - uint32_t ret; - try { - ret = (obj->*method)(in, out); - } catch (...) { - isThreadUsingLockedApi = false; - throw; - } - isThreadUsingLockedApi = false; - return ret; - }; - } - - template - void RegisterLockedApi(const string& methodName, const METHOD& method, REALOBJECT* objectPtr) - { - using MethodType = decltype(getFunctionToCall(methodName, method, objectPtr)); - objectPtr->PluginHost::JSONRPC::Register(methodName, getFunctionToCall(methodName, method, objectPtr), objectPtr); - } - - template - void RegisterLockedApiForVersions(const string& methodName, const METHOD& method, REALOBJECT* objectPtr, const std::vector versions) - { - objectPtr->PluginHost::JSONRPC::Register(methodName, getFunctionToCall(methodName, method, objectPtr), objectPtr, versions); - } - - template - void RegisterLockedApiForHandler(Core::JSONRPC::Handler* handler, const string& methodName, const METHOD& method, REALOBJECT* objectPtr) - { - handler->Register(methodName, getFunctionToCall(methodName, method, objectPtr), objectPtr); - } - - /* - This guard can unlock & re-lock api mutex to prevent deadlock possible when calling other plugins via Invoke - (could deadlock in case when that other plugin called Invoke on this plugin at the same time, or tried to call - this plugin recursively, from the Invoke'd call). - */ - template - struct UnlockApiGuard { - UnlockApiGuard() { - if (isThreadUsingLockedApi) { - ApiLocks::mtx.unlock(); - } - } - ~UnlockApiGuard() { - if (isThreadUsingLockedApi) { - ApiLocks::mtx.lock(); - } - } - }; - - template - struct LockApiGuard { - std::unique_lock _lock; - LockApiGuard() : _lock(ApiLocks::mtx) {} - void unlock() { - _lock.unlock(); - } - void lock() { - _lock.lock(); - } - }; - - - } // Utils -} // Synchro \ No newline at end of file diff --git a/helpers/UtilsSynchroIarm.hpp b/helpers/UtilsSynchroIarm.hpp deleted file mode 100644 index 8e5a8df6d..000000000 --- a/helpers/UtilsSynchroIarm.hpp +++ /dev/null @@ -1,87 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include -#include -#include -#include -#include -#include "UtilsLogging.h" - -using namespace WPEFramework; - -namespace Utils { - - namespace Synchro { - - // owner -> map( eventId -> real handler) - using HandlerMapType = std::map>; - - // maps evnt types to handlers, one per specific class - template - struct IarmHandlers { - static HandlerMapType _registered_iarm_handlers; - }; - - template - HandlerMapType IarmHandlers::_registered_iarm_handlers; - - // we need separate handler per class, so that when we call IARM_Bus_RemoveEventHandler, we will not - // remove _generic_iarm_handler registered by other classes/in-process plugins - template - static void _generic_iarm_handler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) { - auto& handlers_map = IarmHandlers::_registered_iarm_handlers; - isThreadUsingLockedApi = true; - std::lock_guard lock(ApiLocks::mtx); - LOGINFO("calling handler %s/%d with lock: %p\n", owner, eventId, &ApiLocks::mtx); - try { - handlers_map[owner][eventId](owner, eventId, data, len); - } catch (...) { - isThreadUsingLockedApi = false; - throw; - } - isThreadUsingLockedApi = false; - } - - template - static IARM_Result_t RegisterLockedIarmEventHandler(const char *ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) { - auto generic_handler = _generic_iarm_handler; - auto& handlers_map = IarmHandlers::_registered_iarm_handlers; - - std::lock_guard lock(ApiLocks::mtx); - handlers_map[ownerName][eventId] = handler; - return ::IARM_Bus_RegisterEventHandler(ownerName, eventId, generic_handler); - } - - template - static IARM_Result_t RemoveLockedEventHandler(const char *ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) { - auto& handlers_map = IarmHandlers::_registered_iarm_handlers; - - std::lock_guard lock(ApiLocks::mtx); - if (handler != handlers_map[ownerName][eventId]) { - LOGERR("class %s RemoveLockedEventHandler for ownerName: %s, event: %d passed handler: %p different than registered: %p\n", typeid(UsingClass).name(), ownerName, eventId, handler, handlers_map[ownerName][eventId]); fflush(stdout); - } - // still erase the event in any case - handlers_map[ownerName].erase(eventId); - return ::IARM_Bus_RemoveEventHandler(ownerName, eventId, _generic_iarm_handler); - } - } // Synchro -} // Utils diff --git a/helpers/UtilsTelemetry.h b/helpers/UtilsTelemetry.h deleted file mode 100644 index 0d564c246..000000000 --- a/helpers/UtilsTelemetry.h +++ /dev/null @@ -1,71 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -// telemetry -#ifdef ENABLE_TELEMETRY_LOGGING -#include -#endif - -namespace Utils -{ - struct Telemetry - { - static void init() - { -#ifdef ENABLE_TELEMETRY_LOGGING - t2_init((char *) "Thunder_Plugins"); -#endif - }; - - static void sendMessage(char* message) - { -#ifdef ENABLE_TELEMETRY_LOGGING - t2_event_s((char *)"THUNDER_MESSAGE", message); -#endif - }; - - static void sendMessage(char *marker, char* message) - { -#ifdef ENABLE_TELEMETRY_LOGGING - t2_event_s(marker, message); -#endif - }; - - static void sendError(const char* format, ...) - { -#ifdef ENABLE_TELEMETRY_LOGGING - va_list parameters; - va_start(parameters, format); - std::string message; - WPEFramework::Trace::Format(message, format, parameters); - va_end(parameters); - - // get rid of const for t2_event_s - char* error = strdup(message.c_str()); - t2_event_s((char *)"THUNDER_ERROR", error); - if (error) - { - free(error); - } -#endif - }; - }; -} diff --git a/helpers/UtilsThreadRAII.h b/helpers/UtilsThreadRAII.h deleted file mode 100644 index 995a066bb..000000000 --- a/helpers/UtilsThreadRAII.h +++ /dev/null @@ -1,55 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include "UtilsLogging.h" - -namespace Utils { - -class ThreadRAII { -public: - ThreadRAII() {} - ThreadRAII(std::thread&& t) - : t(std::move(t)) - { - } - ~ThreadRAII() - { - try { - if (t.joinable()) { - t.join(); - } - } catch (const std::system_error& e) { - LOGERR("system_error exception in thread join %s", e.what()); - } catch (const std::exception& e) { - LOGERR("exception in thread join %s", e.what()); - } - } - - //support moving - ThreadRAII(ThreadRAII&&) = default; - ThreadRAII& operator=(ThreadRAII&&) = default; - - std::thread& get() { return t; } - -private: - std::thread t; -}; -} diff --git a/helpers/UtilsUnused.h b/helpers/UtilsUnused.h deleted file mode 100644 index 786a6e8f2..000000000 --- a/helpers/UtilsUnused.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#define UNUSED(expr)(void)(expr) diff --git a/helpers/UtilsfileExists.h b/helpers/UtilsfileExists.h deleted file mode 100644 index 6ddffb43b..000000000 --- a/helpers/UtilsfileExists.h +++ /dev/null @@ -1,30 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include - -namespace Utils { -inline bool fileExists(const char* pFileName) -{ - struct stat fileStat; - return 0 == stat(pFileName, &fileStat); -} -} diff --git a/helpers/UtilsgetFileContent.h b/helpers/UtilsgetFileContent.h deleted file mode 100644 index 366813888..000000000 --- a/helpers/UtilsgetFileContent.h +++ /dev/null @@ -1,324 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include -#include -#include - -#include "UtilsString.h" -#define READ_BUFFER_SIZE 1024 -namespace Utils { - -/** - * @brief Read the property value from the given file based on the provided property name. - * @param[in] filename - The name of the file from which to read the properties. - * @param[in] property - The name of the property to search for in the file. - * @param[out] propertyValue - The value of the property will be stored in this string. - * @return bool True if the property is found and successfully read, false otherwise. - */ -inline bool readPropertyFromFile(const char* filename, const string& property, string& propertyValue) -{ - string line = ""; - bool found = false; - std::ifstream file(filename); - propertyValue = ""; - if (file.is_open()) - { - while (std::getline(file, line)) - { - // Skip lines that start with '#' (single-line comments) - if (!line.empty() && line[0] == '#') - { - continue; - } - if (line.find(property + " ") == 0 || line.find(property + "=") == 0) - { - string propertyContent = line.substr(line.find("=") + 1); - - // If the property value starts with '$',recursively expand it - if (!propertyContent.empty() && propertyContent[0] == '$') - { - string expandedProperty = propertyContent.substr(1); - if (readPropertyFromFile(filename, expandedProperty, propertyValue)) - { - found = true; - break; - } - else - { - LOGERR("Failed to find expanded property: %s", expandedProperty.c_str()); - } - } - else - { - // If it does not start with '$', set propertyValue directly - propertyValue = propertyContent; - if (!propertyValue.empty()) - { - // Remove new line character from end of the string if it exists - if ((propertyValue.back() == '\r') || (propertyValue.back() == '\n')) - { - propertyValue.pop_back(); - } - } - found = true; - break; - } - } - } - } - else - { - LOGERR("File is not open"); - } - - // If the property was not found, set the propertyValue to an empty string - if (!found) - { - LOGERR("Variable value is empty"); - } - - return found; -} - -/** - * @brief Read the content of a file and store it in the provided string. - * @param[in] filename - The name of the file to read. - * @param[out] content - The content of the file will be stored in this string. - * @return bool True if the file is successfully read and its content is stored in 'content', false otherwise. - */ -inline bool readFileContent(const char* filename, string& content) -{ - char buffer[READ_BUFFER_SIZE]; - FILE* file = fopen(filename, "r"); - bool found = false; - - if (file) - { - while (fgets(buffer, sizeof(buffer), file) != NULL) - { - content += buffer; - found = true; - } - fclose(file); - - } - else - { - LOGERR("Failed to open the file"); - } - - return found; -} - - -/** - * @brief Check if a given path corresponds to a regular file. - * @param[in] path - The path to check. - * @return bool - True if the path corresponds to a regular file, false otherwise. - */ -inline bool isRegularFile(const string& path) -{ - struct stat st; - if (stat(path.c_str(), &st) == 0) - { - return S_ISREG(st.st_mode); - } - return false; -} - - -inline bool searchFilesRec(std::vector &pathList, unsigned int currentDepth, const std::list& exclusions, string& result) -{ - int count = 0; - - if (pathList.size() == 0) - { - LOGERR("Empty path"); - return false; - } - - std::string inputPath = "/"; - for (unsigned int n = 0; n < currentDepth; n++) - { - inputPath += pathList[n]; - inputPath += "/"; - } - - std::string currentPath = pathList[currentDepth]; - - if (currentPath.find('*') != std::string::npos || currentPath.find('?') != std::string::npos) - { - // Process files and directories in the current directory - DIR *dir = opendir(inputPath.c_str()); - if (!dir) - { - LOGERR("Failed to open the directory '%s'", inputPath.c_str()); - return false; - } - - std::string pattern_s = currentPath; - size_t pos = 0; - while ((pos = pattern_s.find('*', pos)) != std::string::npos) - { - pattern_s.replace(pos, 1, "[^\\n]*"); - pos += 6; - } - - pos = 0; - while ((pos = pattern_s.find('?', pos)) != std::string::npos) - { - pattern_s.replace(pos, 1, "[^\\n]{1}"); - pos += 8; - } - - std::regex pattern(pattern_s.c_str()); - std::smatch matches; - - struct dirent *entry; - while ((entry = readdir(dir))) - { - string fileName = entry->d_name; - - if (fileName == "." || fileName == "..") - { - continue; - } - - if (std::regex_search(fileName, matches, pattern)) - { - if (std::find(exclusions.begin(), exclusions.end(), fileName) == exclusions.end()) - { - if (currentDepth >= pathList.size() - 1) - { - inputPath += fileName; - if (access(inputPath.c_str(), F_OK) == 0) - { - result += inputPath + "\n"; - - count++; - if (count >= 10) - break; // Stop when count reaches 10 - } - } - else - { - pathList[currentDepth] = fileName; - searchFilesRec(pathList, currentDepth + 1, exclusions, result); - } - } - } - } - closedir(dir); - } - else - { - if (currentDepth >= pathList.size() - 1 ) - { - inputPath += currentPath; - if (access(inputPath.c_str(), F_OK) == 0) - { - result += inputPath + "\n"; - return true; - } - } - else - { - searchFilesRec(pathList, currentDepth + 1, exclusions, result); - } - } - - return true; -} - -/** - * @brief Recursively search for files and directories in a given directory path, with depth limits and exclusions. - * @param[in] inputPath - The directory path to start the search from. - * @param[in] maxDepth - The maximum depth of subdirectories to search (0 for no limit). - * @param[in] minDepth - The minimum depth of subdirectories to start searching from (0 to start from inputPath). - * @param[in] exclusions - A list of paths to exclude from the search. - * @param[out] result - The search results will be stored in this string.Results are capped at 10. - * @return bool - True if the search operation is successful, false otherwise. - */ -inline bool searchFiles(string& inputPath, int maxDepth, int minDepth, const std::list& exclusions, string& result) -{ - std::vector pathList; - Utils::String::split(pathList, inputPath, "/"); - pathList.erase(pathList.begin(), pathList.begin() + 1); - - return searchFilesRec(pathList, 0, exclusions,result); -} - -/** - * @brief Process a string containing variables and replace them with corresponding values. - * - * @param[in] input - The input string containing variables; delimited by ' ' or '/' - * @param[in] filePath - The path to the file containing property values. - * @param[out] expandedString - The string with variables replaced by values. - * @return bool - True if the processing and replacement are successful, false otherwise. - */ -inline bool ExpandPropertiesInString(const char* input, const char* filePath, string & expandedString) -{ - const char* variablePos = strchr(input, '$'); - while (variablePos) - { - expandedString.assign(input, variablePos - input); - const char* endPos = strpbrk(variablePos, " /"); - if (endPos) - { - size_t variableLength = endPos - variablePos - 1; - char variable[variableLength + 1]; - strncpy(variable, variablePos + 1, variableLength); - variable[variableLength] = '\0'; - - string tempPropertyValue; - if (readPropertyFromFile(filePath, variable, tempPropertyValue)) - { - const char* propertyValue = tempPropertyValue.c_str(); - expandedString += tempPropertyValue; - variablePos += strlen(propertyValue); - } - else - { - LOGERR("Variable '%s' not found or error reading value.\n", variable); - return false; - } - } - - else - { - endPos = variablePos + 1; - } - variablePos = strchr(endPos, '$'); - if (variablePos) - { - expandedString.append(endPos, variablePos - endPos); - } - else - { - expandedString += endPos; - } - } - - return true; -} - -} diff --git a/helpers/UtilsgetRFCConfig.h b/helpers/UtilsgetRFCConfig.h deleted file mode 100644 index 769e0d5af..000000000 --- a/helpers/UtilsgetRFCConfig.h +++ /dev/null @@ -1,33 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include "rfcapi.h" - -namespace Utils { -inline bool getRFCConfig(const char* paramName, RFC_ParamData_t& paramOutput) -{ - WDMP_STATUS wdmpStatus = getRFCParameter(nullptr, paramName, ¶mOutput); - if (wdmpStatus == WDMP_SUCCESS || wdmpStatus == WDMP_ERR_DEFAULT_VALUE) { - return true; - } - return false; -} -} diff --git a/helpers/UtilsisValidInt.h b/helpers/UtilsisValidInt.h deleted file mode 100644 index c90ebbdfa..000000000 --- a/helpers/UtilsisValidInt.h +++ /dev/null @@ -1,70 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include - -namespace Utils { -inline bool isValidInt(char* x) -{ - bool Checked = true; - int i = 0; - - if (x[0] == '-') { - i = 1; - } - - do { - //valid digit? - if (isdigit(x[i])) { - //to the next character - i++; - Checked = true; - } else { - //to the next character - i++; - Checked = false; - break; - } - } while (x[i] != '\0'); - return Checked; -} - -inline bool isValidUnsignedInt(char* x) -{ - bool Checked = true; - int i = 0; - - do { - //valid digit? - if (isdigit(x[i])) { - //to the next character - i++; - Checked = true; - } else { - //to the next character - i++; - Checked = false; - break; - } - } while (x[i] != '\0'); - return Checked; -} -} diff --git a/helpers/UtilssyncPersistFile.h b/helpers/UtilssyncPersistFile.h deleted file mode 100644 index 0ba672066..000000000 --- a/helpers/UtilssyncPersistFile.h +++ /dev/null @@ -1,63 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 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. -**/ - -#pragma once - -#include - -#include - -namespace Utils { -inline void syncPersistFile(const string file) -{ - FILE* fp = NULL; - fp = fopen(file.c_str(), "r"); - if (fp == NULL) { - printf("fopen NULL\n"); - return; - } - fflush(fp); - fsync(fileno(fp)); - fclose(fp); -} - -inline void persistJsonSettings(const string strFile, const string strKey, const JsonValue& jsValue) -{ - WPEFramework::Core::File file; - file = strFile.c_str(); - - file.Open(false); - if (!file.IsOpen()) - file.Create(); - - JsonObject cecSetting; - cecSetting.IElement::FromFile(file); - file.Destroy(); - file.Create(); - cecSetting[strKey.c_str()] = jsValue; - cecSetting.IElement::ToFile(file); - - file.Close(); - - //Sync the settings - Utils::syncPersistFile(strFile); - - return; -} -} diff --git a/helpers/WebSockets/CommunicationInterface/BinaryInterface.h b/helpers/WebSockets/CommunicationInterface/BinaryInterface.h deleted file mode 100644 index d93be5510..000000000 --- a/helpers/WebSockets/CommunicationInterface/BinaryInterface.h +++ /dev/null @@ -1,59 +0,0 @@ -/** -* 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. -**/ - -#pragma once -#include -#include -#include - -#include "Module.h" -#include "UtilsLogging.h" - -namespace WebSockets { - -template -class BinaryInterface -{ -public: - BinaryInterface() = default; - - bool sendMessage(const std::string& message) - { - Derived& derived = static_cast(*this); - return derived.send(message); - } - - void setOnMessageHandler(const std::function& handler) - { - LOGINFO("Setting onMessage handler."); - onMessage = handler; - } - -protected: - ~BinaryInterface() = default; - - std::function onMessage{[](const std::string& message) { LOGWARN("Default onMessage."); }}; - websocketpp::frame::opcode::value opcode_{websocketpp::frame::opcode::binary}; - -private: - BinaryInterface(const BinaryInterface&) = delete; - BinaryInterface& operator=(const BinaryInterface&) = delete; -}; - -} // namespace WebSockets diff --git a/helpers/WebSockets/CommunicationInterface/CommandInterface.h b/helpers/WebSockets/CommunicationInterface/CommandInterface.h deleted file mode 100644 index b5082c355..000000000 --- a/helpers/WebSockets/CommunicationInterface/CommandInterface.h +++ /dev/null @@ -1,76 +0,0 @@ -/** -* 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. -**/ - -#pragma once -#include -#include -#include -#include -#include -#include - -#include "Module.h" -#include "UtilsLogging.h" - -namespace WebSockets { - -template -class CommandInterface -{ -public: - CommandInterface() = default; - - bool sendCommand(std::string command, std::string& response) - { - LOGINFO("Send command: %s", command.c_str()); - Derived& derived = static_cast(*this); - if (derived.send(command)) - { - std::unique_lock lock(responseMutex_); - responseCondition_.wait_for(lock, std::chrono::seconds(5)); - response = lastResponse_; - return true; - } - - return false; - } - -protected: - ~CommandInterface() = default; - - void onMessage(const std::string& message) - { - LOGINFO("On message: %s", message.c_str()); - std::lock_guard lock(responseMutex_); - lastResponse_ = message; - responseCondition_.notify_one(); - } - - websocketpp::frame::opcode::value opcode_{websocketpp::frame::opcode::text}; - -private: - CommandInterface(const CommandInterface&) = delete; - CommandInterface& operator=(const CommandInterface&) = delete; - - std::string lastResponse_; - std::mutex responseMutex_; - std::condition_variable responseCondition_; -}; - -} // namespace WebSockets diff --git a/helpers/WebSockets/CommunicationInterface/JsonRpcInterface.h b/helpers/WebSockets/CommunicationInterface/JsonRpcInterface.h deleted file mode 100644 index 68d01b3f2..000000000 --- a/helpers/WebSockets/CommunicationInterface/JsonRpcInterface.h +++ /dev/null @@ -1,266 +0,0 @@ -/** -* 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. -**/ - -#pragma once -#include -#include -#include -#include -#include -#include -#include - -#include "../JsonRpc/Request.h" -#include "../JsonRpc/Response.h" -#include "../JsonRpc/Notification.h" - -#include "Module.h" -#include "UtilsJsonRpc.h" -#include "UtilsLogging.h" - -namespace WebSockets { - -template -class JsonRpcInterface -{ -public: - JsonRpcInterface() = default; - - // Note: return value: sending result && receiving result && json-rpc's response field "success" value - bool sendRequest(const JsonRpc::Request& request, JsonRpc::Response& response); - void setNotificationHandler(std::function notificationHandler); - -protected: - ~JsonRpcInterface() = default; - void onMessage(const std::string& message); - - websocketpp::frame::opcode::value opcode_{websocketpp::frame::opcode::text}; - -private: - JsonRpcInterface(const JsonRpcInterface&) = delete; - JsonRpcInterface& operator=(const JsonRpcInterface&) = delete; - - bool getAsyncResponse(uint32_t id, std::future& futureReponse, JsonRpc::Response& response); - boost::optional > createFutureResponse(uint32_t id); - void removePromise(uint32_t id); - bool isRequestProcessingOngoing(uint32_t id); - void handleNotification(const std::string& message); - void handleResponse(uint32_t id, const std::string& message); - bool processResponse(uint32_t id, const std::string &responseString, JsonRpc::Response &deviceResponse) const; - - std::mutex responseMutex_; - std::map > responseToPromise_; - std::function notificationHandler_; -}; - -template -bool JsonRpcInterface::sendRequest(const JsonRpc::Request& request, JsonRpc::Response& response) -{ - if (isRequestProcessingOngoing(request.getId())) - { - LOGERR("Processing of request with ID:%d is already ongoing. Dropping new one:%s", - request.getId(), request.toString().c_str()); - return false; - } - - auto futureReponse = createFutureResponse(request.getId()); - if (!futureReponse) - { - LOGERR("Can't create future response."); - return false; - } - - LOGINFO("Sending json-rpc request: %s", request.toString().c_str()); - Derived& derived = static_cast(*this); - if (derived.send(request.toString())) - { - // Using futureResponse in addition to request.getId() to not lock mutex and search again. - return getAsyncResponse(request.getId(), *futureReponse, response); - } - else - { - LOGERR("Sending request with ID:%d failed. Cleaning internal state.", request.getId()); - removePromise(request.getId()); - return false; - } - return false; -} - -template -void JsonRpcInterface::setNotificationHandler(std::function notificationHandler) -{ - notificationHandler_ = notificationHandler; -} - -template -void JsonRpcInterface::onMessage(const std::string& message) -{ - LOGINFO("On message: %s", message.c_str()); - - JsonObject json; - if (!json.FromString(message)) - { - LOGERR("Discarding message. Message contains malformed JSON: %s", message.c_str()); - return; - } - if (json.HasLabel("id")) - { - LOGINFO("Message contains id field"); - if (json.HasLabel("method")) - { - // TO DO: Implement when there will be use case for client receiving request - // or when JsonRpcInterace will be used for SingleClientServer - } - else - { - if (json["id"].Content() != WPEFramework::Core::JSON::Variant::type::NUMBER) - { - LOGERR("Received message contains ID field which is not a number. Dropping."); - return; - } - handleResponse(json["id"].Number(), message); - return; - } - } - else - { - LOGINFO("Message doesn't contains id field"); - handleNotification(message); - } -} - -template -bool JsonRpcInterface::getAsyncResponse(uint32_t id, std::future& futureReponse, JsonRpc::Response& response) -{ - switch (futureReponse.wait_for(std::chrono::seconds(5))) - { - case std::future_status::ready: - removePromise(id); - return processResponse(id, futureReponse.get(), response); - case std::future_status::timeout: - LOGERR("Timeout for request/response ID:%d", id); - removePromise(id); - return false; - case std::future_status::deferred: - LOGERR("Execution for request/response ID:%d deferred. Internal error.", id); // "should not happen" - removePromise(id); - return false; - } - return false; -} - -template -boost::optional > JsonRpcInterface::createFutureResponse(uint32_t id) -{ - std::lock_guard lock(responseMutex_); - auto insertionResult = responseToPromise_.emplace(std::make_pair(id, std::promise{} )); - if (!insertionResult.second) - { - LOGERR("Request with the same ID:%d already saved.", id); - return boost::none; - } - return insertionResult.first->second.get_future(); -} - -template -void JsonRpcInterface::removePromise(uint32_t id) -{ - std::lock_guard lock(responseMutex_); - responseToPromise_.erase(id); -} - -template -bool JsonRpcInterface::isRequestProcessingOngoing(uint32_t id) -{ - std::lock_guard lock(responseMutex_); - return responseToPromise_.count(id) != 0; -} - -template -void JsonRpcInterface::handleNotification(const std::string& message) -{ - LOGINFO(); - JsonRpc::Notification notif; - notif.FromString(message); - if (!notif.isValid()) - { - LOGERR("Malformed jsonrpc notification. Dropping."); - return; - } - if (!notificationHandler_) - { - LOGINFO("No handler for notifications set. Dropping notification."); - return; - } - notificationHandler_(notif); -} - -template -void JsonRpcInterface::handleResponse(uint32_t id, const std::string& message) -{ - std::lock_guard lock(responseMutex_); - const auto& idToPromise = responseToPromise_.find(id); - if (idToPromise == responseToPromise_.end()) - { - LOGERR("Can't find request with id:%d. Dropping response.", id); - return; - }; - idToPromise->second.set_value(message); -} - -template -bool JsonRpcInterface::processResponse(uint32_t id, const std::string &responseString, JsonRpc::Response &deviceResponse) const -{ - bool success = false; - - deviceResponse.FromString(responseString); - - if (deviceResponse.isValid() && (deviceResponse.getId() == id)) - { - JsonObject parameters; - - if (deviceResponse.isResult()) - { - deviceResponse.getResult(parameters); - if (parameters.HasLabel("success")) - { - getBoolParameter("success", success); - LOGINFO("Result success: %u", success); - } - } - - if (deviceResponse.isError()) - { - deviceResponse.getError(parameters); - int error; - std::string message; - getNumberParameter("code", error); - getStringParameter("message", message); - LOGERR("Error code:message: %i:%s", error, message.c_str()); - } - } - else - { - LOGERR("Invalid response request_id:response_id %u:%u", id, deviceResponse.getId()); - } - - return success; -} - -} // namespace WebSockets diff --git a/helpers/WebSockets/ConnectionInitializationResult.h b/helpers/WebSockets/ConnectionInitializationResult.h deleted file mode 100644 index 65699ac6d..000000000 --- a/helpers/WebSockets/ConnectionInitializationResult.h +++ /dev/null @@ -1,54 +0,0 @@ -/** -* 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. -**/ - -#pragma once -#include - -namespace WebSockets { - -class ConnectionInitializationResult -{ -public: - ConnectionInitializationResult(bool success) : - success_(success), - authenticationSuccess_(true) - { - } - - operator bool() const - { - return success_; - } - - bool authenticationSuccess() const - { - return authenticationSuccess_; - } - - void setAuthenticationSuccess(bool authenticationSuccess) - { - authenticationSuccess_ = authenticationSuccess; - } - -private: - bool success_; - bool authenticationSuccess_; -}; - -} // namespace WebSockets diff --git a/helpers/WebSockets/Encryption/NoEncryption.h b/helpers/WebSockets/Encryption/NoEncryption.h deleted file mode 100644 index b7f641f4e..000000000 --- a/helpers/WebSockets/Encryption/NoEncryption.h +++ /dev/null @@ -1,63 +0,0 @@ -/** -* 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. -**/ - -#pragma once - -#include - -#include "websocketpp/config/asio_no_tls_client.hpp" -#include "websocketpp/client.hpp" - -#include "Module.h" -#include "UtilsLogging.h" - -namespace WebSockets { - -template -class NoEncryption -{ -public: - NoEncryption() - { - LOGINFO("Creating not encrypted websocket.\n"); - } - -protected: - using EndpointType = typename Role::NotEncryptedEndpointType; - - ~NoEncryption() - { - LOGINFO("Destroying not encrypted websocket.\n"); - } - void setup() - { - LOGINFO("Encryption will not be set for this connection.\n"); - } - std::string addProtocolToAddress(const std::string& address) - { - return std::string("ws://") + address; - } - - void setAuthenticationState(ConnectionInitializationResult& result, websocketpp::connection_hdl handler) - { - result.setAuthenticationSuccess(true); - } -}; - -} // namespace WebSockets diff --git a/helpers/WebSockets/Encryption/TlsEnabled.h b/helpers/WebSockets/Encryption/TlsEnabled.h deleted file mode 100644 index 135190ea3..000000000 --- a/helpers/WebSockets/Encryption/TlsEnabled.h +++ /dev/null @@ -1,228 +0,0 @@ -/** -* 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. -**/ - -#pragma once - -#include -#include -#include -#include - -#include "websocketpp/config/asio_client.hpp" -#include "websocketpp/client.hpp" - -#include "Module.h" -#include "UtilsLogging.h" - -namespace WebSockets { - -template -class TlsEnabled -{ -public: - TlsEnabled(); - void setCertFileName(const std::string& certFileName); - void setKeyFileName(const std::string& keyFileName); - void setCAFileNames(const std::vector& CAFileNames); - -protected: - using EndpointType = typename Role::EncryptedEndpointType; - using WebsocketppContextPtr = websocketpp::lib::shared_ptr; - - ~TlsEnabled(); - void setup(); - std::string addProtocolToAddress(const std::string& address); - void setAuthenticationState(ConnectionInitializationResult& result, websocketpp::connection_hdl hdl); - -private: - WebsocketppContextPtr onTlsInit(websocketpp::connection_hdl); - bool logIfCertFailure(bool preverified, boost::asio::ssl::verify_context& verify_ctx) const; - void loadCertificateAuthorities(const WebsocketppContextPtr& ctx) const; - - std::vector CAFileNames_; - std::string certFileName_; - std::string keyFileName_; -}; - -template -TlsEnabled::TlsEnabled() -{ - LOGINFO("Creating TLS enabled websocket."); -} - -template -void TlsEnabled::setCertFileName(const std::string& certFileName) -{ - LOGINFO("Setting cert file name to: %s", certFileName.c_str()); - certFileName_ = certFileName; -} - -template -void TlsEnabled::setKeyFileName(const std::string& keyFileName) -{ - LOGINFO("Setting key file name to: %s", keyFileName.c_str()); - keyFileName_ = keyFileName; -} - -template -void TlsEnabled::setCAFileNames(const std::vector& CAFileNames) -{ - LOGINFO("Setting CA files names with %i files.", CAFileNames.size()); - CAFileNames_ = CAFileNames; -} - -template -TlsEnabled::~TlsEnabled() -{ - LOGINFO("Destroying TLS enabled websocket."); -} - -template -void TlsEnabled::setup() -{ - LOGINFO("Setting up TLS handler."); - Derived& derived = static_cast(*this); - derived.endpointImpl_.set_tls_init_handler(std::bind(&TlsEnabled::onTlsInit, this, std::placeholders::_1)); -} - -template -std::string TlsEnabled::addProtocolToAddress(const std::string& address) -{ - return std::string("wss://") + address; -} - -template -void TlsEnabled::setAuthenticationState(ConnectionInitializationResult& result, websocketpp::connection_hdl handler) -{ - Derived& derived = static_cast(*this); - const auto& connection = derived.getConnection(handler); - - const auto& errorCategory = websocketpp::transport::asio::socket::get_socket_category(); - if (errorCategory == connection->get_ec().category()) - { - using namespace websocketpp::transport::asio::socket; - switch (connection->get_ec().value()) - { - case error::value::security: - case error::value::invalid_tls_context: - case error::value::tls_handshake_timeout: - case error::value::missing_tls_init_handler: - case error::value::tls_handshake_failed: - case error::value::tls_failed_sni_hostname: - LOGINFO("TLS connection not established."); - result.setAuthenticationSuccess(false); - return; - break; - default: - break; - } - } - result.setAuthenticationSuccess(true); -} - -template -typename TlsEnabled::WebsocketppContextPtr TlsEnabled::onTlsInit(websocketpp::connection_hdl) -{ - LOGINFO("Establishing TLS context."); - WebsocketppContextPtr ctx = std::make_shared(boost::asio::ssl::context::sslv23); - - try { - LOGINFO("Setting support for TLS1.2 only."); - ctx->set_options(boost::asio::ssl::context::default_workarounds | - boost::asio::ssl::context::no_sslv2 | - boost::asio::ssl::context::no_sslv3 | - boost::asio::ssl::context::no_tlsv1 | - boost::asio::ssl::context::no_tlsv1_1 | - boost::asio::ssl::context::single_dh_use); - - LOGINFO("Setting verify mode to verify peer."); - ctx->set_verify_mode(boost::asio::ssl::verify_peer | boost::asio::ssl::context::verify_fail_if_no_peer_cert); - ctx->set_verify_callback( - std::bind(&TlsEnabled::logIfCertFailure, this, std::placeholders::_1, std::placeholders::_2)); - - loadCertificateAuthorities(ctx); - - LOGINFO("Enabling advanced cipher negotiation."); - SSL_CTX_set_ecdh_auto(ctx->native_handle(), 1); - - LOGINFO("Loading certificates to context."); - if (!boost::filesystem::exists(certFileName_)) - { - LOGWARN("Cert file not found."); - return ctx; - } - LOGINFO("Loading certificate chain from: %s", certFileName_.c_str()); - ctx->use_certificate_chain_file(certFileName_); - - if (!boost::filesystem::exists(keyFileName_)) - { - LOGERR("Key file not found."); - return ctx; - } - LOGINFO("Loading private key from: %s", keyFileName_.c_str()); - ctx->use_private_key_file(keyFileName_, boost::asio::ssl::context::pem); - - } catch (const std::exception& e) { - LOGERR("Error in context pointer: %s", e.what()); - } - - return ctx; -}; - -template -bool TlsEnabled::logIfCertFailure(bool preverified, boost::asio::ssl::verify_context& verify_ctx) const -{ - if (!preverified) - { - std::string errstr(X509_verify_cert_error_string(X509_STORE_CTX_get_error(verify_ctx.native_handle()))); - LOGERR("Certificate verification failed: %s", errstr.c_str()); - } - return preverified; -} - -template -void TlsEnabled::loadCertificateAuthorities(const WebsocketppContextPtr& ctx) const -{ - if (CAFileNames_.empty()) - { - LOGINFO("No CA file paths defined, trying to use default system path."); - try { - ctx->set_default_verify_paths(); - } catch (const std::exception& e) { - LOGERR("Error while setting default CA paths: %s", e.what()); - } - return; - } - for (const auto& certificateAuthority : CAFileNames_) - { - LOGINFO("Loading Certificate Authority from: %s", certificateAuthority.c_str()); - if (!boost::filesystem::exists(certificateAuthority)) - { - LOGWARN("Certificate: %s doesn't exist.\n", certificateAuthority.c_str()); - continue; - } - try { - ctx->load_verify_file(certificateAuthority); - } catch (const std::exception& e) { - LOGERR("Error while loading certificate: %s, message: %s", certificateAuthority.c_str(), e.what()); - } - } -} - -} // namespace WebSockets diff --git a/helpers/WebSockets/JsonRpc/Notification.cpp b/helpers/WebSockets/JsonRpc/Notification.cpp deleted file mode 100644 index ad37a3f14..000000000 --- a/helpers/WebSockets/JsonRpc/Notification.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/** -* 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 "Notification.h" - -#include "UtilsLogging.h" - -namespace WebSockets { -namespace JsonRpc { - -Notification::Notification() : WPEFramework::Core::JSONRPC::Message() -{ -} - -bool Notification::isValid() const -{ - if (!JSONRPC.IsSet() || JSONRPC.Value().compare(WPEFramework::Core::JSONRPC::Message::DefaultVersion)) - { - LOGERR("Failed JSONRPC2 version check"); - return false; - } - - if (Method().empty()) - { - LOGERR("Method shouldn't be empty"); - return false; - } - - if (Id.IsSet()) - { - LOGERR("Notification shouln't have jsonrpc id"); - return false; - } - - return true; -} - -std::string Notification::toString() const -{ - std::string request; - ToString(request); - return request; -} - -} // namespace JsonRpc -} // namespace WebSockets diff --git a/helpers/WebSockets/JsonRpc/Notification.h b/helpers/WebSockets/JsonRpc/Notification.h deleted file mode 100644 index afd6a8607..000000000 --- a/helpers/WebSockets/JsonRpc/Notification.h +++ /dev/null @@ -1,41 +0,0 @@ -/** -* 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. -**/ - -#pragma once - -#include "Module.h" - -namespace WebSockets { -namespace JsonRpc { - -class Notification : public WPEFramework::Core::JSONRPC::Message -{ -public: - Notification(); - virtual ~Notification() = default; - - std::string toString() const; - bool isValid() const; -private: - Notification(const Notification&) = delete; - Notification& operator=(const Notification&) = delete; -}; - -} // namespace JsonRpc -} // namespace WebSockets diff --git a/helpers/WebSockets/JsonRpc/Request.cpp b/helpers/WebSockets/JsonRpc/Request.cpp deleted file mode 100644 index 4242647fe..000000000 --- a/helpers/WebSockets/JsonRpc/Request.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/** -* 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 "Request.h" - -#include "UtilsLogging.h" - -namespace WebSockets { -namespace JsonRpc { - -std::atomic Request::idSequence(0); - -Request::Request() : WPEFramework::Core::JSONRPC::Message() -{ -} - -uint32_t Request::getId() const -{ - return Id.Value(); -} - -uint32_t Request::generateId() -{ - return (++idSequence); -} - -bool Request::create(std::string method, const JsonObject ¶meters) -{ - if (!JSONRPC.IsSet() || JSONRPC.Value().compare(WPEFramework::Core::JSONRPC::Message::DefaultVersion)) - { - LOGERR("Failed JSONRPC2 version check"); - return false; - } - - if (method.empty()) - { - LOGERR("Provided method is empty"); - return false; - } - Designator = method; - - std::string paramsString; - parameters.ToString(paramsString); - if (!paramsString.empty()) { - Parameters = paramsString; - } - - Id = generateId(); - return true; -} - -std::string Request::toString() const -{ - std::string request; - ToString(request); - return request; -} - -} // namespace JsonRpc -} // namespace WebSockets diff --git a/helpers/WebSockets/JsonRpc/Request.h b/helpers/WebSockets/JsonRpc/Request.h deleted file mode 100644 index 472b98afa..000000000 --- a/helpers/WebSockets/JsonRpc/Request.h +++ /dev/null @@ -1,47 +0,0 @@ -/** -* 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. -**/ - -#pragma once - -#include -#include "Module.h" - -namespace WebSockets { -namespace JsonRpc { - -class Request : public WPEFramework::Core::JSONRPC::Message -{ -public: - Request(); - virtual ~Request() = default; - - bool create(std::string method, const JsonObject ¶meters); - uint32_t getId() const; - std::string toString() const; - -private: - Request(const Request&) = delete; - Request& operator=(const Request&) = delete; - uint32_t generateId(); - - static std::atomic idSequence; -}; - -} // namespace JsonRpc -} // namespace WebSockets diff --git a/helpers/WebSockets/JsonRpc/Response.cpp b/helpers/WebSockets/JsonRpc/Response.cpp deleted file mode 100644 index 0573d3a47..000000000 --- a/helpers/WebSockets/JsonRpc/Response.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/** -* 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 "Response.h" - -#include "UtilsLogging.h" - -namespace WebSockets { -namespace JsonRpc { - -Response::Response() : WPEFramework::Core::JSONRPC::Message() -{ -} - -uint32_t Response::getId() const -{ - return Id.Value(); -} - -bool Response::isResult() const -{ - return Result.IsSet(); -} - -bool Response::getResult(JsonObject& jsonObject) const -{ - bool result = false; - - if (isResult()) - { - jsonObject.FromString(Result.Value()); - result = true; - } - - return result; -} - -bool Response::isError() const -{ - return Error.IsSet(); -} - -bool Response::getError(JsonObject& jsonObject) const -{ - bool result = false; - - if (isError()) - { - std::string errorString; - Error.ToString(errorString); - jsonObject.FromString(errorString); - result = true; - } - - return result; -} - -bool Response::isValid() const -{ - if (!JSONRPC.IsSet() || JSONRPC.Value().compare(WPEFramework::Core::JSONRPC::Message::DefaultVersion)) - { - LOGERR("Failed jsonrpc version check"); - return false; - } - - if (!Id.IsSet()) - { - LOGERR("Failed jsonrpc id check"); - return false; - } - - if (!Result.IsSet() && !Error.IsSet()) - { - LOGERR("Failed jsonrpc result/error check - both missing"); - return false; - } - - if (Result.IsSet() && Error.IsSet()) - { - LOGERR("Failed jsonrpc result/error check - both set"); - return false; - } - - if (Error.IsSet()) - { - if (!Error.Code.IsSet() || !Error.Text.IsSet()) - { - LOGERR("Failed jsonrpc error code/message check"); - return false; - } - } - - return true; -} - -} // namespace JsonRpc -} // namespace WebSockets diff --git a/helpers/WebSockets/JsonRpc/Response.h b/helpers/WebSockets/JsonRpc/Response.h deleted file mode 100644 index 521c0cf7d..000000000 --- a/helpers/WebSockets/JsonRpc/Response.h +++ /dev/null @@ -1,46 +0,0 @@ -/** -* 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. -**/ - -#pragma once - -#include "Module.h" - -namespace WebSockets { -namespace JsonRpc { - -class Response : public WPEFramework::Core::JSONRPC::Message -{ -public: - Response(); - virtual ~Response() = default; - - uint32_t getId() const; - bool isResult() const; - bool getResult(JsonObject& jsonObject) const; - bool isError() const; - bool getError(JsonObject& jsonObject) const; - bool isValid() const; - -private: - Response(const Response&) = delete; - Response& operator=(const Response&) = delete; -}; - -} // namespace JsonRpc -} // namespace WebSockets diff --git a/helpers/WebSockets/PingPong/PingPongDisabled.h b/helpers/WebSockets/PingPong/PingPongDisabled.h deleted file mode 100644 index 0aa8c1cf3..000000000 --- a/helpers/WebSockets/PingPong/PingPongDisabled.h +++ /dev/null @@ -1,47 +0,0 @@ -/** -* 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. -**/ - -#pragma once -#include "websocketpp/common/connection_hdl.hpp" - -namespace WebSockets { - -template -class PingPongDisabled -{ -public: - PingPongDisabled() = default; - -protected: - ~PingPongDisabled() = default; - - typedef typename websocketpp::connection_hdl ConnectionHandler; - - void startPing(ConnectionHandler handler) - { - } - -private: - PingPongDisabled(const PingPongDisabled&) = delete; - PingPongDisabled& operator=(const PingPongDisabled&) = delete; - - -}; - -} // namespace WebSockets diff --git a/helpers/WebSockets/PingPong/PingPongEnabled.h b/helpers/WebSockets/PingPong/PingPongEnabled.h deleted file mode 100644 index 741f4028d..000000000 --- a/helpers/WebSockets/PingPong/PingPongEnabled.h +++ /dev/null @@ -1,143 +0,0 @@ -/** -* 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. -**/ - -#pragma once -#include -#include - -#include "websocketpp/common/connection_hdl.hpp" -#include "websocketpp/common/functional.hpp" -#include "websocketpp/error.hpp" - -#include "Module.h" -#include "UtilsLogging.h" - -namespace WebSockets { - -template -class PingPongEnabled -{ -public: - typedef typename websocketpp::connection_hdl ConnectionHandler; - PingPongEnabled() = default; - -protected: - ~PingPongEnabled() = default; - void startPing(ConnectionHandler handler); - -private: - void schedule(uint interval, const std::function& cb); - void ping(websocketpp::lib::error_code ecc); - void onPong(ConnectionHandler hdl, std::string); - void onPongTimeout(ConnectionHandler hdl, std::string); - void printConnectionState(const websocketpp::session::state::value& state) const; - - const uint pingInterval_{5000}; - PingPongEnabled(const PingPongEnabled&) = delete; - PingPongEnabled& operator=(const PingPongEnabled&) = delete; -}; - -template -void PingPongEnabled::startPing(ConnectionHandler handler) -{ - LOGINFO(); - Derived& derived = static_cast(*this); - auto connection = derived.getConnection(handler); - if (!connection) - { - LOGERR("Cant get connection."); - return; - } - printConnectionState(connection->get_state()); - connection->set_pong_handler(std::bind(&PingPongEnabled::onPong, this, - websocketpp::lib::placeholders::_1, websocketpp::lib::placeholders::_2)); - connection->set_pong_timeout_handler(std::bind(&PingPongEnabled::onPongTimeout, this, - websocketpp::lib::placeholders::_1, websocketpp::lib::placeholders::_2)); - - schedule(pingInterval_, std::bind(&PingPongEnabled::ping, this, websocketpp::lib::placeholders::_1)); -} - -template -void PingPongEnabled::schedule(uint interval, const std::function& cb) -{ - Derived& derived = static_cast(*this); - derived.endpointImpl_.set_timer( - interval, - websocketpp::lib::bind( - cb, - websocketpp::lib::placeholders::_1 - ) - ); -} - -template -void PingPongEnabled::ping(websocketpp::lib::error_code ecc) -{ - LOGINFO(); - Derived& derived = static_cast(*this); - auto connection = derived.getConnection(derived.connectionHandler_); - if (!connection) - { - // Probably connection closed and cleaned up. - LOGINFO("Cant get connection. Not sending ping."); - return; - } - if (connection->get_state() != websocketpp::session::state::open) - { - // Connection will be/was closed internaly and onClose will be/has been launched - printConnectionState(connection->get_state()); - LOGINFO("Connection state is not open/working. Not sending ping."); - return; - } - websocketpp::lib::error_code ec; - connection->ping("",ec); - if (ec) - { - LOGERR("Sending ping failed, reason: %s", ec.message().c_str()); - return; - } -} - -template -void PingPongEnabled::onPong(ConnectionHandler hdl, std::string) -{ - LOGINFO("Pong received"); - schedule(pingInterval_, std::bind(&PingPongEnabled::ping, this, websocketpp::lib::placeholders::_1)); -} - -template -void PingPongEnabled::onPongTimeout(ConnectionHandler hdl, std::string) -{ - LOGINFO("Pong timeout. Closing connection."); - Derived& derived = static_cast(*this); - derived.closeConnection(); -} - -template -void PingPongEnabled::printConnectionState(const websocketpp::session::state::value& state) const -{ - static std::map m = { - {websocketpp::session::state::connecting, "connecting"}, - {websocketpp::session::state::open, "open"}, - {websocketpp::session::state::closing, "closing"}, - {websocketpp::session::state::closed, "closed"}}; - LOGINFO("Connection state is: %s", m[state].c_str()); -} - -} // namespace WebSockets diff --git a/helpers/WebSockets/Roles/Client.h b/helpers/WebSockets/Roles/Client.h deleted file mode 100644 index 2a1de0939..000000000 --- a/helpers/WebSockets/Roles/Client.h +++ /dev/null @@ -1,88 +0,0 @@ -/** -* 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. -**/ - -#pragma once -#include -#include - -#include "websocketpp/config/asio_no_tls_client.hpp" -#include "websocketpp/config/asio_client.hpp" -#include "websocketpp/client.hpp" - -#include "Module.h" -#include "UtilsLogging.h" - -namespace WebSockets { - -template -class Client -{ -public: - using NotEncryptedEndpointType = websocketpp::client; - using EncryptedEndpointType = websocketpp::client; - - Client() = default; - - bool connect(std::string address, std::function connectionInitializationCallback, - std::function connectionClosedCallback); - void disconnect(); - -protected: - ~Client() = default; - -private: - Client(const Client&) = delete; - Client& operator=(const Client&) = delete; -}; - -template -bool Client::connect(std::string address, std::function connectionInitializationCallback, - std::function connectionClosedCallback) -{ - Derived& derived = static_cast(*this); - const std::string uri = derived.addProtocolToAddress(address); - - LOGINFO("Connecting, uri: %s", uri.c_str()); - - derived.connectionInitializationCallback_ = connectionInitializationCallback; - derived.connectionClosedCallback_ = connectionClosedCallback; - - websocketpp::lib::error_code ec; - auto connection = derived.endpointImpl_.get_connection(uri, ec); - if (ec) { - LOGERR("Can't prepare connection to connect with: %s, reason: %s", uri.c_str(), ec.message().c_str()); - return false; - } - - derived.startEventLoop(); - LOGINFO("Calling connect on: %s\n", uri.c_str()); - derived.endpointImpl_.connect(connection); - return true; -} - -template -void Client::disconnect() -{ - LOGINFO(); - Derived& derived = static_cast(*this); - derived.closeConnection(); - LOGINFO("Disconnection successfull"); -} - -} // namespace WebSockets diff --git a/helpers/WebSockets/Roles/SingleClientServer.h b/helpers/WebSockets/Roles/SingleClientServer.h deleted file mode 100644 index 991606e80..000000000 --- a/helpers/WebSockets/Roles/SingleClientServer.h +++ /dev/null @@ -1,98 +0,0 @@ -/** -* 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. -**/ - -#pragma once -#include -#include -#include - -#include "websocketpp/config/asio_no_tls.hpp" -#include "websocketpp/config/asio.hpp" -#include "websocketpp/server.hpp" - -#include "Module.h" -#include "UtilsLogging.h" - -namespace WebSockets { - -template -class SingleClientServer -{ -public: - using NotEncryptedEndpointType = websocketpp::server; - using EncryptedEndpointType = websocketpp::server; - - SingleClientServer() = default; - - bool start(int port, std::function connectionInitializationCallback, - std::function connectionClosedCallback); - void stop(); - -protected: - ~SingleClientServer() = default; - -private: - SingleClientServer(const SingleClientServer&) = delete; - SingleClientServer& operator=(const SingleClientServer&) = delete; -}; - -template -bool SingleClientServer::start(int port, std::function connectionInitializationCallback, - std::function connectionClosedCallback) -{ - LOGINFO("Starting websocket server on port: %d", port); - - Derived& derived = static_cast(*this); - derived.connectionInitializationCallback_ = connectionInitializationCallback; - derived.connectionClosedCallback_ = connectionClosedCallback; - - websocketpp::lib::error_code ec; - derived.endpointImpl_.listen(port, ec); - if (ec) { - LOGERR("Failed to start listening, reason: %s", ec.message().c_str()); - return false; - } - - derived.endpointImpl_.start_accept(ec); - if (ec) { - LOGERR("Failed to start server, reason: %s", ec.message().c_str()); - return false; - } - - derived.startEventLoop(); - return true; -} - -template -void SingleClientServer::stop() -{ - LOGINFO(); - Derived& derived = static_cast(*this); - websocketpp::lib::error_code ec; - derived.endpointImpl_.stop_listening(ec); - if (ec) - { - LOGERR("Ordering server to stop listening failed, reason: %s", ec.message().c_str()); - return; - } - derived.closeConnection(); - LOGINFO("Connection ordered to stop and server ordered to stop listening. Server will fully close when 'run' method ends."); -} - -} // namespace WebSockets diff --git a/helpers/WebSockets/WSEndpoint.cpp b/helpers/WebSockets/WSEndpoint.cpp deleted file mode 100644 index 895c1d728..000000000 --- a/helpers/WebSockets/WSEndpoint.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/** -* 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 "WSEndpoint.h" -#include "CommunicationInterface/BinaryInterface.h" -#include "CommunicationInterface/CommandInterface.h" -#include "CommunicationInterface/JsonRpcInterface.h" - -#include "Roles/SingleClientServer.h" -#include "Roles/Client.h" -#include "PingPong/PingPongEnabled.h" -#include "PingPong/PingPongDisabled.h" -#include "Encryption/TlsEnabled.h" -#include "Encryption/NoEncryption.h" - -#include "UtilsLogging.h" - -namespace WebSockets { - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -WSEndpoint::WSEndpoint() -{ - LOGINFO(); - // Uncomment for connection details - // endpointImpl_.set_access_channels(websocketpp::log::alevel::all); - // endpointImpl_.set_error_channels(websocketpp::log::elevel::all); - endpointImpl_.clear_access_channels(websocketpp::log::alevel::all); - endpointImpl_.clear_error_channels(websocketpp::log::elevel::all); - - registerHandlers(); - - endpointImpl_.init_asio(); - Encryption >::setup(); - endpointImpl_.start_perpetual(); -} - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -WSEndpoint::~WSEndpoint() -{ - LOGINFO(); - endpointImpl_.stop_perpetual(); - closeConnection(); - stopEventLoop(); -} - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -void WSEndpoint::closeConnection() -{ - LOGINFO(); - auto conn = getConnection(connectionHandler_); - if (!conn) - { - LOGINFO("Cant get connection (Probably connection already closed)."); - return; - } - if (conn->get_state() != websocketpp::session::state::open) - { - LOGINFO("Can't close connection which is not open."); - return; - } - - websocketpp::lib::error_code ec; - endpointImpl_.close(connectionHandler_, websocketpp::close::status::going_away, "", ec); - if (ec) { - LOGERR("Closing connection failed, reason: %s", ec.message().c_str()); - } -} - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -void WSEndpoint::startEventLoop() -{ - LOGINFO(); - if (!eventLoopThread_) - { - LOGINFO("Starting new event loop thread"); - eventLoopThread_ = std::thread([this]() { - LOGINFO("Starting websocket communication on new thread"); - endpointImpl_.run(); - LOGINFO("Event loop thread finished"); - }); - } -} - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -void WSEndpoint::stopEventLoop() -{ - LOGINFO(); - if (eventLoopThread_ && eventLoopThread_->joinable()) - { - LOGINFO("Event loop thread is joinable. Waiting for join."); - eventLoopThread_->join(); - eventLoopThread_ = boost::none; - } -} - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -void WSEndpoint::registerHandlers() -{ - LOGINFO(); - endpointImpl_.set_message_handler(std::bind(&WSEndpoint::onMessage, this, websocketpp::lib::placeholders::_1, websocketpp::lib::placeholders::_2)); - endpointImpl_.set_open_handler(std::bind(&WSEndpoint::onOpen, this, websocketpp::lib::placeholders::_1)); - endpointImpl_.set_close_handler(std::bind(&WSEndpoint::onClose, this, websocketpp::lib::placeholders::_1)); - endpointImpl_.set_fail_handler(std::bind(&WSEndpoint::onFail, this, websocketpp::lib::placeholders::_1)); - endpointImpl_.set_open_handshake_timeout(5000); - endpointImpl_.set_close_handshake_timeout(5000); -} - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -bool WSEndpoint::send(const std::string& message) -{ - if (message.empty()) - { - LOGERR("Can't send empty message"); - return false; - } - - websocketpp::lib::error_code ec; - endpointImpl_.send(connectionHandler_, message, MessagingInterface::opcode_, ec); - if (ec) - { - LOGERR("Sending failed, reason: %s", ec.message().c_str()); - return false; - } - - return true; -} - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -void WSEndpoint::onMessage(ConnectionHandler, typename WebsocketppEndpoint::message_ptr msg) -{ - if (msg->get_opcode() != MessagingInterface::opcode_) - { - LOGERR("Received message is not tagged with text opcode, droping."); - return; - } - MessagingInterface::onMessage(msg->get_payload()); -} - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -void WSEndpoint::onOpen(ConnectionHandler handler) -{ - LOGINFO("New connection opened."); - connectionHandler_ = handler; - connectionInitializationCallback_(ConnectionInitializationResult(true)); - PingPong::startPing(handler); -} - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -void WSEndpoint::onFail(ConnectionHandler handler) -{ - LOGINFO("Connection attempt failure."); - - const auto& connection = getConnection(handler); - const auto& connectionEc = connection->get_ec(); - if (connectionEc) - { - LOGINFO("Connection error: %s. Category: %s. Value: %d", connectionEc.message().c_str(), - connectionEc.category().name(), connectionEc.value()); - } - - ConnectionInitializationResult result(false); - Encryption >::setAuthenticationState(result, handler); - - connectionInitializationCallback_(result); -} - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -void WSEndpoint::onClose(ConnectionHandler) -{ - LOGINFO("Connection closed."); - connectionClosedCallback_(); -} - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -typename WSEndpoint::ConnectionPtr -WSEndpoint::getConnection(ConnectionHandler handler) -{ - websocketpp::lib::error_code handlerToConnectionEc; - auto connection = endpointImpl_.get_con_from_hdl(handler, handlerToConnectionEc); - if (handlerToConnectionEc) - { - LOGERR("Can't get connection from handler, reason: %s", handlerToConnectionEc.message().c_str()); - return {}; - } - return connection; -} - -// All used configurations need to be listed here to generate needed symbols. -// Without those symbols there is a runtime crash. - -template class WSEndpoint; -template class WSEndpoint; -template class WSEndpoint; -template class WSEndpoint; -template class WSEndpoint; -template class WSEndpoint; -template class WSEndpoint; -template class WSEndpoint; -template class WSEndpoint; - -} // namespace WebSockets diff --git a/helpers/WebSockets/WSEndpoint.h b/helpers/WebSockets/WSEndpoint.h deleted file mode 100644 index af1140ccc..000000000 --- a/helpers/WebSockets/WSEndpoint.h +++ /dev/null @@ -1,79 +0,0 @@ -/** -* 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. -**/ - -#pragma once -#include -#include -#include -#include -#include - -#include "ConnectionInitializationResult.h" -#include "websocketpp/server.hpp" - -namespace WebSockets { - -template< - template typename Role, - template typename MessagingInterface, - template typename PingPong, - template typename Encryption -> -class WSEndpoint : public Role >, - public MessagingInterface >, - private PingPong >, - public Encryption, Role > > -{ -public: - WSEndpoint(); - ~WSEndpoint(); - -private: - WSEndpoint(const WSEndpoint&) = delete; - WSEndpoint& operator=(const WSEndpoint&) = delete; - - friend Role; - friend MessagingInterface; - friend PingPong; - friend Encryption >; - - using WebsocketppEndpoint = typename Encryption >::EndpointType; - using ConnectionPtr = typename WebsocketppEndpoint::connection_ptr; - using ConnectionHandler = websocketpp::connection_hdl; - - bool send(const std::string& message); - void closeConnection(); - void startEventLoop(); - void stopEventLoop(); - WSEndpoint::ConnectionPtr getConnection(ConnectionHandler handler); - - void registerHandlers(); - void onMessage(ConnectionHandler, typename WebsocketppEndpoint::message_ptr msg); - void onOpen(ConnectionHandler); - void onFail(ConnectionHandler); - void onClose(ConnectionHandler); - - WebsocketppEndpoint endpointImpl_; - ConnectionHandler connectionHandler_; - boost::optional eventLoopThread_; - std::function connectionInitializationCallback_; - std::function connectionClosedCallback_; -}; - -} // namespace WebSockets diff --git a/helpers/cSettings.h b/helpers/cSettings.h deleted file mode 100644 index d6590e16b..000000000 --- a/helpers/cSettings.h +++ /dev/null @@ -1,211 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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. -**/ - -#pragma once - -#include -#include -#include -#include -#include - -#include "UtilsfileExists.h" - -using namespace std; - -class cSettings { - std::string filename; - JsonObject data; - -public: - /*** - * @brief : Constructor. - * @return : nil. - */ - cSettings(std::string file) - { - filename = file; - if (!readFromFile()) { - /* File not present; create a new one assuming a fresh partition. */ - std::fstream fs; - fs.open(filename.c_str(), std::fstream::in | std::fstream::out | std::fstream::app); - if (!fs.is_open()) { - std::cout << "Error:[ctor cSettings] unable to open configuration file." << std::endl; - } else { - fs << flush; - fs.close(); - } - } - } - - /*** - * @brief : Destructor. - * @return : nil. - */ - ~cSettings() = default; - - /*** - * @brief : Get value of given key. - * @param1[in] : key - * @return : the value to the corresponding key - */ - JsonValue getValue(std::string key) - { - return data.Get(key.c_str()); - } - - /*** - * @brief : Set value of given key. - * @param1[in] : key - * @param2[in] : value - * @return : True if setvalue successfull, else False - */ - bool setValue(std::string key, std::string value) - { - data[key.c_str()] = value; - return writeToFile(); - } - - /*** - * @brief : Set value of given key. - * @param1[in] : key - * @param2[in] : value - * @return : True if setvalue successfull, else False - */ - bool setValue(std::string key, int value) - { - data[key.c_str()] = value; - return writeToFile(); - } - - /*** - * @brief : Set value of given key. - * @param1[in] : key - * @param2[in] : value - * @return : True if setvalue successfull, else False - */ - bool setValue(std::string key, bool value) - { - data[key.c_str()] = value; - return writeToFile(); - } - - /*** - * @brief : Check if a particular key is set. - * @param1[in] : key - * @return : True if key is already set, else False - */ - bool contains(std::string key) - { - bool resp = false; - if (data.HasLabel(key.c_str())) { - if (data[key.c_str()].String().empty()) { - resp = false; - } else { - resp = true; - } - } else { - resp = false; - } - return resp; - } - - /*** - * @brief : Remove a particular key-value pair. - * @param1[in] : key - * @return : True if key is key-value pair removed, else False - */ - bool remove(std::string key) - { - bool status = false; - /* - * Noticed that there is an error with the Remove function. - * work around is to assign a null value to the key and handle it - * accordingly. - */ - data[key.c_str()] = ""; - data.Remove(key.c_str()); - if (!contains(key)) { - if (writeToFile()) { - status = true; - } else { - status = false; - } - } else { - status = false; - } - return status; - } - - /*** - * @brief : Update new inserts into the json object onto file. - * @return : False if timer thread couldn't be started. - */ - bool writeToFile() - { - bool status = false; - - if (Utils::fileExists(filename.c_str())) { - ofstream ofile; - ofile.open(filename.c_str(), ios::out); - if (ofile) { - JsonObject::Iterator iterator = data.Variants(); - while (iterator.Next()) { - if (!data[iterator.Label()].String().empty()) { - ofile << iterator.Label() << "=" << data[iterator.Label()].String() << endl; - } else { - continue; - } - } - status = true; - ofile.close(); - } else { - status = false; - } - } - return status; - } - - /*** - * @brief : Initialise the jsonobject from a given conf file. - * @return : False if file couldn't be accessed, else True. - */ - bool readFromFile() - { - bool retStatus = false; - std::string content; - if (!Utils::fileExists(filename.c_str())) { - return retStatus; - } - fstream ifile(filename, ios::in); - if (ifile) { - while (!ifile.eof()) { - std::getline(ifile, content); - size_t pos = content.find_last_of("="); - if (std::string::npos != pos) { - data[(content.substr(0, pos).c_str())] = content.substr(pos + 1, std::string::npos); - } - retStatus = true; - } - } else { - //Do nothing. - } - return retStatus; - } -}; diff --git a/helpers/frontpanel.cpp b/helpers/frontpanel.cpp deleted file mode 100644 index a6020463b..000000000 --- a/helpers/frontpanel.cpp +++ /dev/null @@ -1,713 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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. -**/ - -/** -* @defgroup servicemanager -* @{ -* @defgroup src -* @{ -**/ - -//#define USE_DS //TODO - this was defined in servicemanager.pro for all STB builds. Not sure where to put it except here for now -//#define HAS_API_POWERSTATE - -#include "frontpanel.h" -#ifdef USE_DS - #include "frontPanelConfig.hpp" - #include "frontPanelTextDisplay.hpp" - #include "manager.hpp" -#endif - -#include -#include -#include -#include - -#if defined(HAS_API_POWERSTATE) -#include "libIBus.h" -#include - -using namespace WPEFramework; -using PowerState = WPEFramework::Exchange::IPowerManager::PowerState; -#endif - -#include "UtilsJsonRpc.h" -#include "UtilsLogging.h" -#include "UtilssyncPersistFile.h" -#include "PowerManagerInterface.h" - -#define FP_SETTINGS_FILE_JSON "/opt/fp_service_preferences.json" - -/* -Requirement now - Ability to get/set Led brightness - Ability to power off/on a led - -*/ - -namespace WPEFramework -{ - - namespace Plugin - { - CFrontPanel* CFrontPanel::s_instance = NULL; - static int globalLedBrightness = 100; -#ifdef CLOCK_BRIGHTNESS_ENABLED - static int clockBrightness = 100; -#endif - int CFrontPanel::initDone = 0; - static bool isMessageLedOn = false; - static bool isRecordLedOn = false; -#ifdef CLOCK_BRIGHTNESS_ENABLED - static bool isClockOn; -#endif - static bool powerStatus = false; //Check how this works on xi3 and rng's - static bool started = false; - static int m_numberOfBlinks = 0; - static int m_maxNumberOfBlinkRepeats = 0; - static int m_currentBlinkListIndex = 0; - static std::vector m_lights; - static device::List fpIndicators; - static PowerManagerInterfaceRef _powerManagerPlugin; - - static Core::TimerType blinkTimer(64 * 1024, "BlinkTimer"); - - namespace - { - - struct Mapping - { - const char *IArmBusName; - const char *SvcManagerName; - }; - - static struct Mapping name_mappings[] = { - { "Record" , "record_led"}, - { "Message" , "data_led"}, - { "Power" , "power_led"}, - // TODO: add your mappings here - // { , }, - { 0, 0} - }; - - std::string svc2iarm(const std::string &name) - { - const char *s = name.c_str(); - - int i = 0; - while (name_mappings[i].SvcManagerName) - { - if (strcmp(s, name_mappings[i].SvcManagerName) == 0) - return name_mappings[i].IArmBusName; - i++; - } - return name; - } - } - - CFrontPanel::CFrontPanel() - : m_blinkTimer(this) - , m_isBlinking(false) - { - } - - CFrontPanel* CFrontPanel::instance(PluginHost::IShell *service) - { - if (!initDone) - { - if (nullptr != service) - { - _powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager")) - .withIShell(service) - .withRetryIntervalMS(200) - .withRetryCount(25) - .createInterface(); - } - if (!s_instance) - s_instance = new CFrontPanel; -#ifdef USE_DS - try - { - LOGINFO("Front panel init"); - fpIndicators = device::FrontPanelConfig::getInstance().getIndicators(); - - for (uint i = 0; i < fpIndicators.size(); i++) - { - std::string IndicatorNameIarm = fpIndicators.at(i).getName(); - - auto it = std::find(m_lights.begin(), m_lights.end(), IndicatorNameIarm); - if (m_lights.end() == it) - { - m_lights.push_back(IndicatorNameIarm); - } - } - -#if defined(HAS_API_POWERSTATE) - { - Core::hresult res = Core::ERROR_GENERAL; - PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; - PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; - ASSERT (_powerManagerPlugin); - if (_powerManagerPlugin) { - res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev); - if (Core::ERROR_NONE == res) - { - if (pwrStateCur == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON) - powerStatus = true; - } - } - } -#endif -#ifdef CLOCK_BRIGHTNESS_ENABLED - clockBrightness = device::FrontPanelTextDisplay::getInstance("Text").getTextBrightness(); - device::FrontPanelTextDisplay::getInstance("Text").setTextBrightness(clockBrightness); -#endif - globalLedBrightness = device::FrontPanelIndicator::getInstance("Power").getBrightness(); - LOGINFO("Power light brightness, %d, power status %d", globalLedBrightness, powerStatus); - - for (uint i = 0; i < fpIndicators.size(); i++) - { - LOGWARN("Initializing light %s", fpIndicators.at(i).getName().c_str()); - if (powerStatus) - device::FrontPanelIndicator::getInstance(fpIndicators.at(i).getName()).setBrightness(globalLedBrightness); - - device::FrontPanelIndicator::getInstance(fpIndicators.at(i).getName()).setState(false); - } - - if (powerStatus) - device::FrontPanelIndicator::getInstance("Power").setState(true); - - } - catch (...) - { - LOGERR("Exception Caught during [CFrontPanel::instance]\r\n"); - } - initDone=1; -#endif - } - - return s_instance; - } - - bool CFrontPanel::start() - { - LOGWARN("Front panel start"); - try - { - if (powerStatus) - device::FrontPanelIndicator::getInstance("Power").setState(true); - - device::List fpIndicators = device::FrontPanelConfig::getInstance().getIndicators(); - for (uint i = 0; i < fpIndicators.size(); i++) - { - std::string IndicatorNameIarm = fpIndicators.at(i).getName(); - - auto it = std::find(m_lights.begin(), m_lights.end(), IndicatorNameIarm); - if (m_lights.end() == it) - m_lights.push_back(IndicatorNameIarm); - } - } - catch (...) - { - LOGERR("Frontpanel Exception Caught during [%s]\r\n", __func__); - } - if (!started) - { - m_numberOfBlinks = 0; - m_maxNumberOfBlinkRepeats = 0; - m_currentBlinkListIndex = 0; - started = true; - } - return true; - } - - bool CFrontPanel::stop() - { - stopBlinkTimer(); - return true; - } - - void CFrontPanel::setPowerStatus(bool bPowerStatus) - { - powerStatus = bPowerStatus; - } - - std::string CFrontPanel::getLastError() - { - return lastError_; - } - - void CFrontPanel::addEventObserver(FrontPanel* o) - { - - auto it = std::find(observers_.begin(), observers_.end(), o); - - if (observers_.end() == it) - observers_.push_back(o); - } - - void CFrontPanel::removeEventObserver(FrontPanel* o) - { - observers_.remove(o); - } - - bool CFrontPanel::setBrightness(int fp_brightness) - { - stopBlinkTimer(); - globalLedBrightness = fp_brightness; - - try - { - for (uint i = 0; i < fpIndicators.size(); i++) - { - device::FrontPanelIndicator::getInstance(fpIndicators.at(i).getName()).setBrightness(globalLedBrightness); - } - } - catch (...) - { - LOGERR("Frontpanel Exception Caught during [%s]\r\n",__func__); - } - - powerOnLed(FRONT_PANEL_INDICATOR_ALL); - return true; - } - - int CFrontPanel::getBrightness() - { - try - { - globalLedBrightness = device::FrontPanelIndicator::getInstance("Power").getBrightness(); - LOGWARN("Power light brightness, %d\n", globalLedBrightness); - } - catch (...) - { - LOGERR("Frontpanel Exception Caught during [%s]\r\n", __func__); - } - - return globalLedBrightness; - } - -#ifdef CLOCK_BRIGHTNESS_ENABLED - bool CFrontPanel::setClockBrightness(int brightness) - { - clockBrightness = brightness; - powerOnLed(FRONT_PANEL_INDICATOR_CLOCK); - return true; - } - - int CFrontPanel::getClockBrightness() - { - try - { - clockBrightness = device::FrontPanelTextDisplay::getInstance("Text").getTextBrightness(); - } - catch (...) - { - LOGERR("FrontPanel Exception Caught during [%s]\r\n", __func__); - } - - return clockBrightness; - } -#endif - - bool CFrontPanel::powerOnLed(frontPanelIndicator fp_indicator) - { - stopBlinkTimer(); - try - { - if (powerStatus) - { - switch (fp_indicator) - { - case FRONT_PANEL_INDICATOR_CLOCK: -#ifdef CLOCK_BRIGHTNESS_ENABLED - isClockOn = true; - device::FrontPanelTextDisplay::getInstance("Text").setTextBrightness(clockBrightness); -#endif - break; - case FRONT_PANEL_INDICATOR_MESSAGE: - isMessageLedOn = true; - device::FrontPanelIndicator::getInstance("Message").setState(true); - break; - case FRONT_PANEL_INDICATOR_RECORD: - isRecordLedOn = true; - device::FrontPanelIndicator::getInstance("Record").setState(true); - break; - case FRONT_PANEL_INDICATOR_REMOTE: - device::FrontPanelIndicator::getInstance("Remote").setState(true); - break; - case FRONT_PANEL_INDICATOR_RFBYPASS: - device::FrontPanelIndicator::getInstance("RfByPass").setState(true); - break; - case FRONT_PANEL_INDICATOR_ALL: - if (isMessageLedOn) - device::FrontPanelIndicator::getInstance("Message").setState(true); - if (isRecordLedOn) - device::FrontPanelIndicator::getInstance("Record").setState(true); - device::FrontPanelIndicator::getInstance("Power").setState(true); - break; - case FRONT_PANEL_INDICATOR_POWER: - //LOGWARN("CFrontPanel::powerOnLed() - FRONT_PANEL_INDICATOR_POWER not handled"); - device::FrontPanelIndicator::getInstance("Power").setState(true); - break; - } - } - } - catch (...) - { - LOGERR("FrontPanel Exception Caught during [%s]\r\n", __func__); - return false; - } - return true; - } - - bool CFrontPanel::powerOffLed(frontPanelIndicator fp_indicator) - { - stopBlinkTimer(); - try - { - switch (fp_indicator) - { - case FRONT_PANEL_INDICATOR_CLOCK: -#ifdef CLOCK_BRIGHTNESS_ENABLED - isClockOn = false; - device::FrontPanelTextDisplay::getInstance("Text").setTextBrightness(0); -#endif - break; - case FRONT_PANEL_INDICATOR_MESSAGE: - isMessageLedOn = false; - device::FrontPanelIndicator::getInstance("Message").setState(false); - break; - case FRONT_PANEL_INDICATOR_RECORD: - isRecordLedOn = false; - device::FrontPanelIndicator::getInstance("Record").setState(false); - break; - case FRONT_PANEL_INDICATOR_REMOTE: - device::FrontPanelIndicator::getInstance("Remote").setState(false); - break; - case FRONT_PANEL_INDICATOR_RFBYPASS: - device::FrontPanelIndicator::getInstance("RfByPass").setState(false); - break; - case FRONT_PANEL_INDICATOR_ALL: - for (uint i = 0; i < fpIndicators.size(); i++) - { - //LOGWARN("powerOffLed for Indicator %s", QString::fromStdString(fpIndicators.at(i).getName()).toUtf8().constData()); - LOGWARN("powerOffLed for Indicator %s", fpIndicators.at(i).getName().c_str()); - device::FrontPanelIndicator::getInstance(fpIndicators.at(i).getName()).setState(false); - } - break; - case FRONT_PANEL_INDICATOR_POWER: - //LOGWARN("CFrontPanel::powerOffLed() - FRONT_PANEL_INDICATOR_POWER not handled"); - device::FrontPanelIndicator::getInstance("Power").setState(false); - break; - } - } - catch (...) - { - LOGERR("FrontPanel Exception Caught during [%s]\r\n", __func__); - return false; - } - return true; - } - - - bool CFrontPanel::powerOffAllLed() - { - powerOffLed(FRONT_PANEL_INDICATOR_ALL); - return true; - } - - bool CFrontPanel::powerOnAllLed() - { - powerOnLed(FRONT_PANEL_INDICATOR_ALL); - return true; - } - - bool CFrontPanel::setLED(const JsonObject& parameters) - { - stopBlinkTimer(); - bool success = false; - string ledIndicator = svc2iarm(parameters["ledIndicator"].String()); - int brightness = -1; - - if (parameters.HasLabel("brightness")) - //brightness = properties["brightness"].Number(); - getNumberParameter("brightness", brightness); - - unsigned int color = 0; - if (parameters.HasLabel("color")) //color mode 2 - { - string colorString = parameters["color"].String(); - try - { - device::FrontPanelIndicator::getInstance(ledIndicator.c_str()).setColor(device::FrontPanelIndicator::Color::getInstance(colorString.c_str()), false); - success = true; - } - catch (...) - { - success = false; - } - } - else if (parameters.HasLabel("red")) //color mode 1 - { - unsigned int red,green,blue; - - getNumberParameter("red", red); - getNumberParameter("green", green); - getNumberParameter("blue", blue); - - color = (red << 16) | (green << 8) | blue; - try - { - device::FrontPanelIndicator::getInstance(ledIndicator.c_str()).setColor(color); - success = true; - } - catch (...) - { - success = false; - } - } - - LOGWARN("setLed ledIndicator: %s brightness: %d", parameters["ledIndicator"].String().c_str(), brightness); - try - { - if (brightness == -1) - brightness = device::FrontPanelIndicator::getInstance(ledIndicator.c_str()).getBrightness(); - - device::FrontPanelIndicator::getInstance(ledIndicator.c_str()).setBrightness(brightness, false); - success = true; - } - catch (...) - { - success = false; - } - return success; - } - - void CFrontPanel::setBlink(const JsonObject& blinkInfo) - { - stopBlinkTimer(); - m_blinkList.clear(); - string ledIndicator = svc2iarm(blinkInfo["ledIndicator"].String()); - int iterations; - getNumberParameterObject(blinkInfo, "iterations", iterations); - JsonArray patternList = blinkInfo["pattern"].Array(); - for (int i = 0; i < patternList.Length(); i++) - { - JsonObject frontPanelBlinkHash = patternList[i].Object(); - FrontPanelBlinkInfo frontPanelBlinkInfo; - frontPanelBlinkInfo.ledIndicator = ledIndicator; - int brightness = -1; - if (frontPanelBlinkHash.HasLabel("brightness")) - getNumberParameterObject(frontPanelBlinkHash, "brightness", brightness); - - int duration; - getNumberParameterObject(frontPanelBlinkHash, "duration", duration); - LOGWARN("setBlink ledIndicator: %s iterations: %d brightness: %d duration: %d", ledIndicator.c_str(), iterations, brightness, duration); - frontPanelBlinkInfo.brightness = brightness; - frontPanelBlinkInfo.durationInMs = duration; - frontPanelBlinkInfo.colorValue = 0; - if (frontPanelBlinkHash.HasLabel("color")) //color mode 2 - { - string color = frontPanelBlinkHash["color"].String(); - frontPanelBlinkInfo.colorName = color; - frontPanelBlinkInfo.colorMode = 2; - } - else if (frontPanelBlinkHash.HasLabel("red")) //color mode 1 - { - unsigned int red,green,blue; - - getNumberParameterObject(frontPanelBlinkHash, "red", red); - getNumberParameterObject(frontPanelBlinkHash, "green", green); - getNumberParameterObject(frontPanelBlinkHash, "blue", blue); - - frontPanelBlinkInfo.colorValue = (red << 16) | (green << 8) | blue; - frontPanelBlinkInfo.colorMode = 1; - } - else - { - frontPanelBlinkInfo.colorMode = 0; - } - m_blinkList.push_back(frontPanelBlinkInfo); - } - startBlinkTimer(iterations); - } - - JsonObject CFrontPanel::getPreferences() - { - return m_preferencesHash; - } - - void CFrontPanel::setPreferences(const JsonObject& preferences) - { - m_preferencesHash = preferences; - - Core::File file; - file = FP_SETTINGS_FILE_JSON; - - file.Open(false); - if (!file.IsOpen()) - file.Create(); - - m_preferencesHash.IElement::ToFile(file); - - file.Close(); - Utils::syncPersistFile (FP_SETTINGS_FILE_JSON); - } - - void CFrontPanel::loadPreferences() - { - m_preferencesHash.Clear(); - - Core::File file; - file = FP_SETTINGS_FILE_JSON; - - file.Open(); - m_preferencesHash.IElement::FromFile(file); - - file.Close(); - } - - void CFrontPanel::startBlinkTimer(int numberOfBlinkRepeats) - { - LOGWARN("startBlinkTimer numberOfBlinkRepeats: %d m_blinkList.length : %zu", numberOfBlinkRepeats, m_blinkList.size()); - stopBlinkTimer(); - m_numberOfBlinks = 0; - m_isBlinking = true; - m_maxNumberOfBlinkRepeats = numberOfBlinkRepeats; - m_currentBlinkListIndex = 0; - if (m_blinkList.size() > 0) - { - FrontPanelBlinkInfo blinkInfo = m_blinkList.at(0); - setBlinkLed(blinkInfo); - if (m_isBlinking) - blinkTimer.Schedule(Core::Time::Now().Add(blinkInfo.durationInMs), m_blinkTimer); - } - } - - void CFrontPanel::stopBlinkTimer() - { - m_isBlinking = false; - blinkTimer.Revoke(m_blinkTimer); - } - - void CFrontPanel::setBlinkLed(FrontPanelBlinkInfo blinkInfo) - { - std::string ledIndicator = blinkInfo.ledIndicator; - int brightness = blinkInfo.brightness; - try - { - if (blinkInfo.colorMode == 1) - { - device::FrontPanelIndicator::getInstance(ledIndicator.c_str()).setColor(blinkInfo.colorValue, false); - } - else if (blinkInfo.colorMode == 2) - { - device::FrontPanelIndicator::getInstance(ledIndicator.c_str()).setColor(device::FrontPanelIndicator::Color::getInstance(blinkInfo.colorName.c_str()), false); - } - - } - catch (...) - {} - try - { - if (brightness == -1) - brightness = device::FrontPanelIndicator::getInstance(ledIndicator.c_str()).getBrightness(); - - device::FrontPanelIndicator::getInstance(ledIndicator.c_str()).setBrightness(brightness, false); - } - catch (...) - { - LOGWARN("Exception caught in setBlinkLed for setBrightness "); - } - } - - void CFrontPanel::onBlinkTimer() - { - m_currentBlinkListIndex++; - bool blinkAgain = true; - if ((size_t)m_currentBlinkListIndex >= m_blinkList.size()) - { - blinkAgain = false; - m_currentBlinkListIndex = 0; - m_numberOfBlinks++; - if (m_maxNumberOfBlinkRepeats < 0 || m_numberOfBlinks <= m_maxNumberOfBlinkRepeats) - { - blinkAgain = true; - } - } - if (blinkAgain) - { - FrontPanelBlinkInfo blinkInfo = m_blinkList.at(m_currentBlinkListIndex); - setBlinkLed(blinkInfo); - if (m_isBlinking) - blinkTimer.Schedule(Core::Time::Now().Add(blinkInfo.durationInMs), m_blinkTimer); - } - - //if not blink again then the led color should stay on the LAST element in the array as stated in the spec - } - - void CFrontPanel::set24HourClock(bool is24Hour) - { - try - { - int newFormat = is24Hour ? device::FrontPanelTextDisplay::kModeClock24Hr : device::FrontPanelTextDisplay::kModeClock12Hr; - device::FrontPanelTextDisplay &textDisplay = device::FrontPanelConfig::getInstance().getTextDisplay("Text"); - int currentFormat = textDisplay.getCurrentTimeFormat(); - LOGINFO("set24HourClock - Before setting %d - Time zone read from DS is %d", newFormat, currentFormat); - textDisplay.setTimeFormat(newFormat); - currentFormat = textDisplay.getCurrentTimeFormat(); - LOGINFO("set24HourClock - After setting %d - Time zone read from DS is %d", newFormat, currentFormat); - } - catch (...) - { - LOGERR("Exception Caught during set24HourClock"); - } - } - - bool CFrontPanel::is24HourClock() - { - bool is24Hour = false; - try - { - device::FrontPanelTextDisplay &textDisplay = device::FrontPanelConfig::getInstance().getTextDisplay("Text"); - int currentFormat = textDisplay.getCurrentTimeFormat(); - LOGINFO("is24HourClock - Time zone read from DS is %d", currentFormat); - is24Hour = currentFormat == device::FrontPanelTextDisplay::kModeClock24Hr; - } - catch (...) - { - LOGERR("Exception Caught during is24HourClock"); - } - return is24Hour; - } - - uint64_t BlinkInfo::Timed(const uint64_t scheduledTime) - { - - uint64_t result = 0; - m_frontPanel->onBlinkTimer(); - return(result); - } - - } -} - -/** @} */ -/** @} */ diff --git a/helpers/frontpanel.h b/helpers/frontpanel.h deleted file mode 100644 index d9b441caf..000000000 --- a/helpers/frontpanel.h +++ /dev/null @@ -1,151 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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. -**/ - -/** -* @defgroup servicemanager -* @{ -* @defgroup include -* @{ -**/ - - -#ifndef FRONTPANEL_H -#define FRONTPANEL_H - -#include -#include -#include - -#include - -namespace WPEFramework -{ - - namespace Plugin - { - - class FrontPanel; - class CFrontPanel; - - class BlinkInfo - { - private: - BlinkInfo() = delete; - BlinkInfo& operator=(const BlinkInfo& RHS) = delete; - - public: - BlinkInfo(CFrontPanel* fp) - : m_frontPanel(fp) - { - } - BlinkInfo(const BlinkInfo& copy) - : m_frontPanel(copy.m_frontPanel) - { - } - ~BlinkInfo() {} - - inline bool operator==(const BlinkInfo& RHS) const - { - return(m_frontPanel == RHS.m_frontPanel); - } - - public: - uint64_t Timed(const uint64_t scheduledTime); - - private: - CFrontPanel* m_frontPanel; - }; - - - typedef struct _FrontPanelBlinkInfo - { - std::string ledIndicator; - std::string colorName; - unsigned int colorValue; - int brightness; - int durationInMs; - int colorMode; - } FrontPanelBlinkInfo; - - typedef enum _frontPanelIndicator - { - FRONT_PANEL_INDICATOR_CLOCK, - FRONT_PANEL_INDICATOR_MESSAGE, - FRONT_PANEL_INDICATOR_POWER, - FRONT_PANEL_INDICATOR_RECORD, - FRONT_PANEL_INDICATOR_REMOTE, - FRONT_PANEL_INDICATOR_RFBYPASS, - FRONT_PANEL_INDICATOR_ALL - } frontPanelIndicator; - - class CFrontPanel - { - public: - static CFrontPanel* instance(PluginHost::IShell *service = nullptr); - bool start(); - bool stop(); - std::string getLastError(); - void addEventObserver(FrontPanel* o); - void removeEventObserver(FrontPanel* o); - bool setBrightness(int fp_brighness); - int getBrightness(); -#ifdef CLOCK_BRIGHTNESS_ENABLED - bool setClockBrightness(int brightness); - int getClockBrightness(); -#endif - bool powerOffLed(frontPanelIndicator fp_indicator); - bool powerOnLed(frontPanelIndicator fp_indicator); - bool powerOffAllLed(); - bool powerOnAllLed(); - void setPowerStatus(bool powerStatus); - JsonObject getPreferences(); - void setPreferences(const JsonObject& preferences); - bool setLED(const JsonObject& blinkInfo); - void setBlink(const JsonObject& blinkInfo); - void loadPreferences(); - void stopBlinkTimer(); - void set24HourClock(bool is24Hour); - bool is24HourClock(); - - void onBlinkTimer(); - static int initDone; - - private: - CFrontPanel(); - static CFrontPanel* s_instance; - void startBlinkTimer(int numberOfBlinkRepeats); - void setBlinkLed(FrontPanelBlinkInfo blinkInfo); - JsonObject m_preferencesHash; // is this needed - - BlinkInfo m_blinkTimer; - bool m_isBlinking; - std::vector m_blinkList; - std::list observers_; - - std::string lastError_; - }; - } // namespace Plugin -} // namespace WPEFramework - - -#endif - - -/** @} */ -/** @} */ diff --git a/helpers/tptimer.h b/helpers/tptimer.h deleted file mode 100644 index 25b43eebf..000000000 --- a/helpers/tptimer.h +++ /dev/null @@ -1,140 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 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. -**/ - -#ifndef TTIMER_H -#define TTIMER_H - -//#include -#include - -namespace WPEFramework { - -namespace Plugin { - class TpTimer { - private: - class TpTimerJob { - private: - TpTimerJob() = delete; - TpTimerJob& operator=(const TpTimerJob& RHS) = delete; - - public: - TpTimerJob(TpTimer* tpt) - : m_tptimer(tpt) - { - } - TpTimerJob(const TpTimerJob& copy) - : m_tptimer(copy.m_tptimer) - { - } - ~TpTimerJob() {} - - inline bool operator==(const TpTimerJob& RHS) const - { - return (m_tptimer == RHS.m_tptimer); - } - - public: - uint64_t Timed(const uint64_t scheduledTime) - { - if (m_tptimer) { - m_tptimer->Timed(); - } - return 0; - } - - private: - TpTimer* m_tptimer; - }; - - public: - TpTimer() - : baseTimer(64 * 1024, "ThunderPluginBaseTimer") - , m_timerJob(this) - , m_isActive(false) - , m_isSingleShot(false) - , m_intervalInMs(-1) - { - } - ~TpTimer() - { - stop(); - } - - bool isActive() - { - return m_isActive; - } - void stop() - { - baseTimer.Revoke(m_timerJob); - m_isActive = false; - } - void start() - { - baseTimer.Revoke(m_timerJob); - baseTimer.Schedule(Core::Time::Now().Add(m_intervalInMs), m_timerJob); - m_isActive = true; - } - void start(int msec) - { - setInterval(msec); - start(); - } - void setSingleShot(bool val) - { - m_isSingleShot = val; - } - void setInterval(int msec) - { - m_intervalInMs = msec; - } - - void connect(std::function callback) - { - onTimeoutCallback = callback; - } - - private: - void Timed() - { - if (onTimeoutCallback != nullptr) { - onTimeoutCallback(); - } - - if (m_isActive) { - if (m_isSingleShot) { - stop(); - } else { - start(); - } - } - } - - WPEFramework::Core::TimerType baseTimer; - TpTimerJob m_timerJob; - bool m_isActive; - bool m_isSingleShot; - int m_intervalInMs; - - std::function onTimeoutCallback; - }; -} -} - -#endif diff --git a/services.cmake b/services.cmake deleted file mode 100644 index 660c98918..000000000 --- a/services.cmake +++ /dev/null @@ -1,160 +0,0 @@ -# If not stated otherwise in this file or this component's Licenses.txt file the -# following copyright and licenses apply: -# -# Copyright 2016 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. - -# -# features -# - -add_definitions (-DUSE_SOUND_PLAYER) - -add_definitions (-DUSE_IARM) -option(USE_IARM "USE_IARM" ON) - -add_definitions (-DUSE_IARM_BUS) -option(USE_IARM_BUS "USE_IARM_BUS" ON) - -add_definitions (-DUSE_IARMBUS) - -add_definitions (-DUSE_TR_69) - -add_definitions (-DHAS_API_SYSTEM) -add_definitions (-DHAS_API_POWERSTATE) -add_definitions(-DRDK_LOG_MILESTONE) - -add_definitions (-DUSE_DS) - -option(PLUGIN_WAREHOUSE "PLUGIN_WAREHOUSE" ON) -option(HAS_API_HDMI_INPUT "HAS_API_HDMI_INPUT" ON) -option(PLUGIN_COPILOT "PLUGIN_COPILOT" OFF) -option(PLUGIN_FRAMERATE "PLUGIN_FRAMERATE" ON) -option(PLUGIN_STORAGE_MANAGER "PLUGIN_STORAGE_MANAGER" OFF) -option(PLUGIN_DEVICEDIAGNOSTICS "PLUGIN_DEVICEDIAGNOSTICS" ON) -option(PLUGIN_SOUNDPLAYER "PLUGIN_SOUNDPLAYER" OFF) -option(PLUGIN_TELEMETRY "PLUGIN_TELEMETRY" ON) -option(PLUGIN_LEDCONTROL "PLUGIN_LEDCONTROL" ON) -option(PLUGIN_CONTINUEWATCHING "PLUGIN_CONTINUEWATCHING" ON) - - -#add_definitions (-DCLIENT_VERSION_STRING)=\\\"$(VERSION_FULL_VALUE)\\\" -#add_definitions (-DSTB_VERSION_STRING)=\\\"$(FULL_VERSION_NAME_VALUE)\\\" -#add_definitions (-DSTB_TIMESTAMP_STRING)=\\\"$(STB_TIMESTAMP_VALUE)\\\" - -#add_definitions (-DHAS_API_TTSSETTINGSSERVICE) -#add_definitions (-DHAS_API_TTSSESSIONSERVICE) -#add_definitions (-DHAS_API_TTSRESOURCESERVICE) -add_definitions (-DPLUGIN_CONTINUEWATCHING) -option(PLUGIN_CONTINUEWATCHING "PLUGIN_CONTINUEWATCHING" ON) - -if(PLUGIN_CONTINUEWATCHING) - if(CONTINUEWATCHING_DISABLE_SECAPI) - add_definitions (-DDISABLE_SECAPI) - endif() -endif() - - -if(PLUGIN_CONTINUEWATCHING) - if(CONTINUEWATCHING_DISABLE_SECAPI) - add_definitions (-DDISABLE_SECAPI) - endif() -endif() - -if (DISABLE_GEOGRAPHY_TIMEZONE) - add_definitions (-DDISABLE_GEOGRAPHY_TIMEZONE) -endif() - -if (BUILD_ENABLE_SYSTIMEMGR_SUPPORT) - message("Building with SYSTIMEMGR_SUPPORT enabled") - add_definitions (-DENABLE_SYSTIMEMGR_SUPPORT) -endif() - -if (BUILD_DBUS) - message("Building for DBUS") - - add_definitions (-DBUILD_DBUS) - option(BUILD_DBUS "BUILD_DBUS" ON) - add_definitions (-DIARM_USE_DBUS) - option(IARM_USE_DBUS "IARM_USE_DBUS" ON) -endif() - -if (BUILD_ENABLE_THERMAL_PROTECTION) - add_definitions (-DBUILD_ENABLE_THERMAL_PROTECTION) - add_definitions (-DENABLE_THERMAL_PROTECTION) -endif() - -if (BUILD_ENABLE_DEVICE_MANUFACTURER_INFO) - message("Building with device manufacturer info") - add_definitions (-DENABLE_DEVICE_MANUFACTURER_INFO) -endif() - -if (SUPPRESS_MAINTENANCE) - message("Enable SUPPRESS_MAINTENANCE") - add_definitions (-DSUPPRESS_MAINTENANCE) -endif() - -if (BUILD_ENABLE_CLOCK) - message("Building with clock support") - add_definitions (-DCLOCK_BRIGHTNESS_ENABLED) -endif() - -if (BUILD_ENABLE_EXTENDED_ALL_SEGMENTS_TEXT_PATTERN) - add_definitions (-DUSE_EXTENDED_ALL_SEGMENTS_TEXT_PATTERN) -endif() - -if(ENABLE_SYSTEM_GET_STORE_DEMO_LINK) - message("Building with System Service getStoreDemoLink") - add_definitions (-DENABLE_SYSTEM_GET_STORE_DEMO_LINK) -endif() - -if (BUILD_ENABLE_TELEMETRY_LOGGING) - message("Building with telemetry logging") - add_definitions (-DENABLE_TELEMETRY_LOGGING) -endif() - -if (BUILD_ENABLE_LINK_LOCALTIME) - message("Building with link localtime") - add_definitions (-DENABLE_LINK_LOCALTIME) -endif() - -add_definitions (-DENABLE_DEEP_SLEEP) - -# only on LLama -if(BUILD_ENABLE_APP_CONTROL_AUDIOPORT_INIT) - add_definitions (-DAPP_CONTROL_AUDIOPORT_INIT) -endif() - -if(NET_DISABLE_NETSRVMGR_CHECK) - add_definitions (-DNET_DISABLE_NETSRVMGR_CHECK) -endif() - -if (ENABLE_WHOAMI) - message("Enable WHOAMI") - add_definitions (-DENABLE_WHOAMI=ON) -endif() - -if (ENABLE_RFC_MANAGER) - message("Using binary for RFC Maintenance task") - add_definitions (-DENABLE_RFC_MANAGER=ON) -endif() - -if (DISABLE_DCM_TASK) - message("Disabling DCM Maintenance task") - add_definitions (-DDISABLE_DCM_TASK=ON) -endif() - -if(BUILD_ENABLE_ERM) - add_definitions(-DENABLE_ERM) -endif()