diff --git a/.github/workflows/L1-tests.yml b/.github/workflows/L1-tests.yml index 259d11b7..cc031231 100755 --- a/.github/workflows/L1-tests.yml +++ b/.github/workflows/L1-tests.yml @@ -1,10 +1,15 @@ name: L1-tests on: - push: - branches: [ main, develop, 'sprint/**', 'release/**', 'topic/RDK*' ] - pull_request: - branches: [ main, develop, 'sprint/**', 'release/**', 'topic/RDK*' ] + workflow_call: + inputs: + caller_source: + description: "Specifies the source type (e.g., local or test framework) for the workflow." + required: true + type: string + secrets: + RDKCM_RDKE: + required: true env: BUILD_TYPE: Debug @@ -66,6 +71,11 @@ jobs: python-version: '3.x' - run: pip install jsonref + - name: ACK External Trigger + run: | + echo "Message: External Trigger Received for L1 Tests" + echo "Trigger Source: ${{ inputs.caller_source }}" + - name: Set up CMake uses: jwlawson/actions-setup-cmake@v1.13 with: @@ -117,9 +127,26 @@ jobs: token: ${{ secrets.RDKCM_RDKE }} - name: Checkout entservices-inputoutput + if: ${{ inputs.caller_source == 'local' }} + uses: actions/checkout@v3 + with: + path: entservices-inputoutput + + - name: Checkout entservices-inputoutput-testframework + if: ${{ inputs.caller_source == 'testframework' }} uses: actions/checkout@v3 with: + repository: rdkcentral/entservices-inputoutput path: entservices-inputoutput + ref: develop + + - name: Checkout googletest + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/checkout@v3 + with: + repository: google/googletest + path: googletest + ref: v1.15.0 - name: Apply patches ThunderTools run: | @@ -247,6 +274,9 @@ jobs: rdk/ds/frontPanelIndicator.hpp rdk/ds/frontPanelConfig.hpp rdk/ds/frontPanelTextDisplay.hpp + rdk/ds/audioOutputPortType.hpp + rdk/ds/audioOutputPortConfig.hpp + rdk/ds/pixelResolution.hpp rdk/iarmbus/libIARM.h rdk/iarmbus/libIBus.h rdk/iarmbus/libIBusDaemon.h @@ -263,6 +293,7 @@ jobs: telemetry_busmessage_sender.h maintenanceMGR.h pkg.h + edid-parser.hpp secure_wrapper.h wpa_ctrl.h proc/readproc.h @@ -270,7 +301,7 @@ jobs: 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 . + 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 /usr/include/libdrm/drm.h /usr/include/libdrm/drm_mode.h /usr/include/xf86drm.h . - name: Set clang toolchain if: ${{ matrix.compiler == 'clang' }} @@ -280,6 +311,24 @@ jobs: 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 googletest + if: steps.cache.outputs.cache-hit != 'true' + run: > + cmake -G Ninja + -S "$GITHUB_WORKSPACE/googletest" + -B build/googletest + -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 + -DBUILD_GMOCK=ON + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + && + cmake --build build/googletest -j8 + && + cmake --install build/googletest + - name: Build mocks run: > cmake @@ -309,8 +358,11 @@ jobs: -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/entservices-inputoutput/helpers -I $GITHUB_WORKSPACE/Thunder/Source -I $GITHUB_WORKSPACE/Thunder/Source/core + -I $GITHUB_WORKSPACE/install/usr/include + -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 @@ -368,6 +420,8 @@ jobs: -I $GITHUB_WORKSPACE/entservices-testframework/Tests -I $GITHUB_WORKSPACE/Thunder/Source -I $GITHUB_WORKSPACE/Thunder/Source/core + -I $GITHUB_WORKSPACE/install/usr/include + -I $GITHUB_WORKSPACE/install/usr/include/WPEFramework -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 @@ -406,6 +460,7 @@ jobs: -DDS_FOUND=ON -DHAS_FRONT_PANEL=ON -DRDK_SERVICES_L1_TEST=ON + -DPLUGIN_AVINPUT=ON -DPLUGIN_HDCPPROFILE=ON -DPLUGIN_HDMICECSOURCE=ON -DPLUGIN_HDMICECSINK=ON @@ -443,6 +498,9 @@ jobs: -I $GITHUB_WORKSPACE/entservices-testframework/Tests -I $GITHUB_WORKSPACE/Thunder/Source -I $GITHUB_WORKSPACE/Thunder/Source/core + -I $GITHUB_WORKSPACE/install/usr/include + -I $GITHUB_WORKSPACE/install/usr/include/WPEFramework + -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 @@ -459,7 +517,7 @@ jobs: -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 + -Wl,-wrap,system -Wl,-wrap,popen -Wl,-wrap,syslog -Wl,--no-as-needed -DENABLE_TELEMETRY_LOGGING -DUSE_IARMBUS -DENABLE_SYSTEM_GET_STORE_DEMO_LINK @@ -480,6 +538,7 @@ jobs: -DCMAKE_DISABLE_FIND_PACKAGE_CEC=ON -DCMAKE_BUILD_TYPE=Debug -DDS_FOUND=ON + -DPLUGIN_AVINPUT=ON -DPLUGIN_HDCPPROFILE=ON -DPLUGIN_HDMICECSOURCE=ON -DPLUGIN_HDMICECSINK=ON @@ -631,7 +690,7 @@ jobs: if: ${{ !env.ACT }} uses: actions/upload-artifact@v4 with: - name: artifacts + name: artifacts-L1-inputoutput path: | coverage/ valgrind_log diff --git a/.github/workflows/L2-tests.yml b/.github/workflows/L2-tests.yml index 7224e70b..34cdc6d6 100755 --- a/.github/workflows/L2-tests.yml +++ b/.github/workflows/L2-tests.yml @@ -1,9 +1,15 @@ 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: + workflow_call: + inputs: + caller_source: + description: "Specifies the source type (e.g., local or test framework) for the workflow." + required: true + type: string + secrets: + RDKCM_RDKE: + required: true env: BUILD_TYPE: Debug @@ -35,6 +41,11 @@ jobs: python-version: '3.x' - run: pip install jsonref + - name: ACK External Trigger + run: | + echo "Message: External Trigger Received for L2 Tests" + echo "Trigger Source: ${{ inputs.caller_source }}" + - name: Set up CMake uses: jwlawson/actions-setup-cmake@v1.13 with: @@ -78,9 +89,18 @@ jobs: ref: R4.4.3 - name: Checkout entservices-inputoutput + if: ${{ inputs.caller_source == 'local' }} + uses: actions/checkout@v3 + with: + path: entservices-inputoutput + + - name: Checkout entservices-inputoutput-testframework + if: ${{ inputs.caller_source == 'testframework' }} uses: actions/checkout@v3 with: + repository: rdkcentral/entservices-inputoutput path: entservices-inputoutput + ref: develop - name: Checkout entservices-testframework uses: actions/checkout@v3 @@ -90,6 +110,14 @@ jobs: ref: develop token: ${{ secrets.RDKCM_RDKE }} + - name: Checkout googletest + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/checkout@v3 + with: + repository: google/googletest + path: googletest + ref: v1.15.0 + - name: Apply patches ThunderTools run: | cd $GITHUB_WORKSPACE/ThunderTools @@ -192,6 +220,9 @@ jobs: rdk/ds/manager.hpp rdk/ds/dsTypes.h rdk/ds/dsUtl.h + rdk/ds/audioOutputPortType.hpp + rdk/ds/audioOutputPortConfig.hpp + rdk/ds/pixelResolution.hpp rdk/iarmbus/libIARM.h rdk/iarmbus/libIBus.h rdk/iarmbus/libIBusDaemon.h @@ -206,6 +237,7 @@ jobs: systemaudioplatform.h maintenanceMGR.h pkg.h + edid-parser.hpp btmgr.h tvError.h tvTypes.h @@ -221,7 +253,7 @@ jobs: 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 . + 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 /usr/include/libdrm/drm.h /usr/include/libdrm/drm_mode.h /usr/include/xf86drm.h . - name: Set clang toolchain if: ${{ matrix.compiler == 'clang' }} @@ -231,6 +263,24 @@ jobs: 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 googletest + if: steps.cache.outputs.cache-hit != 'true' + run: > + cmake -G Ninja + -S "$GITHUB_WORKSPACE/googletest" + -B build/googletest + -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 + -DBUILD_GMOCK=ON + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + && + cmake --build build/googletest -j8 + && + cmake --install build/googletest + - name: Build mocks run: > cmake @@ -242,7 +292,8 @@ jobs: -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_FLAGS=" - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers" + -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers + -I $GITHUB_WORKSPACE/install/usr/include" && cmake --build build/mocks -j8 && @@ -274,6 +325,8 @@ jobs: -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/install/usr/include + -I $GITHUB_WORKSPACE/install/usr/include/WPEFramework -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 @@ -292,26 +345,7 @@ jobs: -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 + -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/essos-resmgr.h -Werror -Wall -Wno-unused-result -Wno-deprecated-declarations -Wno-error=format= -DUSE_IARMBUS -DRDK_SERVICE_L2_TEST @@ -364,7 +398,10 @@ jobs: -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 + -I $GITHUB_WORKSPACE/entservices-inputoutput/helpers + -I $GITHUB_WORKSPACE/install/usr/include + -I $GITHUB_WORKSPACE/install/usr/include/WPEFramework + -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 @@ -384,6 +421,7 @@ jobs: -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= + -Wl,--no-as-needed -DUSE_IARMBUS -DRDK_SERVICE_L2_TEST -DDISABLE_SECURITY_TOKEN @@ -567,7 +605,7 @@ jobs: if: ${{ !env.ACT }} uses: actions/upload-artifact@v4 with: - name: artifacts + name: artifacts-L2-inputoutput path: | coverage/ valgrind_log diff --git a/.github/workflows/component-release.yml b/.github/workflows/component-release.yml new file mode 100644 index 00000000..4a26990e --- /dev/null +++ b/.github/workflows/component-release.yml @@ -0,0 +1,111 @@ +name: Component Release + +permissions: + contents: write + +on: + pull_request: + types: [closed] + branches: + - develop + +jobs: + release: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Git + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "actions@github.com" + + - name: Install git-flow and auto-changelog + run: | + sudo apt-get update + sudo apt-get install -y git-flow + npm install -g auto-changelog + + - name: Clone the project and start release + run: | + set -e + git clone https://x-access-token:${{ secrets.RDKCM_RDKE }}@github.com/${{ github.repository }} project + cd project + git fetch --all + git checkout main || git checkout -b main origin/main + git checkout develop || git checkout -b develop origin/develop + + git config gitflow.branch.master main + git config gitflow.branch.develop develop + git config gitflow.prefix.feature feature/ + git config gitflow.prefix.bugfix bugfix/ + git config gitflow.prefix.release release/ + git config gitflow.prefix.hotfix hotfix/ + git config gitflow.prefix.support support/ + git config gitflow.prefix.versiontag '' + + echo "git config completed" + # Extract version from PR description + PR_DESC="${{ github.event.pull_request.body }}" + # Get top tag from CHANGELOG.md + TOP_TAG=$(grep -m 1 -oP '^#### \[\K[^\]]+' CHANGELOG.md) + if [[ -z "$TOP_TAG" ]]; then + echo "No version found in CHANGELOG.md!" + exit 1 + fi + # Validate TOP_TAG format (semantic versioning: major.minor.patch) + if [[ ! "$TOP_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Invalid version format in CHANGELOG.md: $TOP_TAG. Expected format: major.minor.patch" + exit 1 + fi + IFS='.' read -r major minor patch <<< "$TOP_TAG" + VERSION_TYPE=$(echo "$PR_DESC" | grep -oiP 'version\s*:\s*\K(major|minor|patch)' | tr '[:upper:]' '[:lower:]') + if [[ -z "$VERSION_TYPE" ]]; then + echo "No version type found in PR description, defaulting to PATCH increment." + patch=$((patch + 1)) + elif [[ "$VERSION_TYPE" == "major" ]]; then + major=$((major + 1)) + minor=0 + patch=0 + elif [[ "$VERSION_TYPE" == "minor" ]]; then + minor=$((minor + 1)) + patch=0 + elif [[ "$VERSION_TYPE" == "patch" ]]; then + patch=$((patch + 1)) + else + echo "Invalid version type in PR description: $VERSION_TYPE" + exit 1 + fi + RELEASE_VERSION="$major.$minor.$patch" + echo "Using calculated version: $RELEASE_VERSION" + echo "RELEASE_VERSION=$RELEASE_VERSION" + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV + # Check if tag already exists + if git rev-parse "refs/tags/$RELEASE_VERSION" >/dev/null 2>&1; then + echo "Tag $RELEASE_VERSION already exists. Skipping release." + exit 0 + fi + git flow release start $RELEASE_VERSION + auto-changelog -v $RELEASE_VERSION + git add CHANGELOG.md + git commit -m "$RELEASE_VERSION release changelog updates" + git flow release publish + + - name: Finish release and push (default git-flow messages) + run: | + set -e + cd project + git flow release finish -m "$RELEASE_VERSION release" $RELEASE_VERSION + git push origin main + git push origin --tags + git push origin develop + + - name: Cleanup tag if workflow fails + if: failure() + run: | + cd project + git tag -d $RELEASE_VERSION || true + git push origin :refs/tags/$RELEASE_VERSION || true diff --git a/.github/workflows/tests-trigger.yml b/.github/workflows/tests-trigger.yml new file mode 100755 index 00000000..bb3de6af --- /dev/null +++ b/.github/workflows/tests-trigger.yml @@ -0,0 +1,24 @@ +permissions: + contents: read +name: main-workflow + +on: + push: + branches: [ main, develop, 'sprint/**', 'release/**' ] + pull_request: + branches: [ main, develop, 'sprint/**', 'release/**' ] + +jobs: + trigger-L1: + uses: ./.github/workflows/L1-tests.yml + with: + caller_source: local + secrets: + RDKCM_RDKE: ${{ secrets.RDKCM_RDKE }} + + trigger-L2: + uses: ./.github/workflows/L2-tests.yml + with: + caller_source: local + secrets: + RDKCM_RDKE: ${{ secrets.RDKCM_RDKE }} diff --git a/AVInput/AVInput.cpp b/AVInput/AVInput.cpp index 8c71c7a6..c7586702 100644 --- a/AVInput/AVInput.cpp +++ b/AVInput/AVInput.cpp @@ -48,6 +48,9 @@ #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_SET_VRR_SUPPORT "setVRRSupport" +#define AVINPUT_METHOD_GET_VRR_SUPPORT "getVRRSupport" +#define AVINPUT_METHOD_GET_VRR_FRAME_RATE "getVRRFrameRate" #define AVINPUT_METHOD_GET_HDMI_COMPATIBILITY_VERSION "getHdmiVersion" #define AVINPUT_METHOD_SET_MIXER_LEVELS "setMixerLevels" #define AVINPUT_METHOD_START_INPUT "startInput" @@ -65,6 +68,12 @@ #define AVINPUT_EVENT_ON_GAME_FEATURE_STATUS_CHANGED "gameFeatureStatusUpdate" #define AVINPUT_EVENT_ON_AVI_CONTENT_TYPE_CHANGED "aviContentTypeUpdate" +#define STR_ALLM "ALLM" +#define VRR_TYPE_HDMI "VRR-HDMI" +#define VRR_TYPE_FREESYNC "VRR-FREESYNC" +#define VRR_TYPE_FREESYNC_PREMIUM "VRR-FREESYNC-PREMIUM" +#define VRR_TYPE_FREESYNC_PREMIUM_PRO "VRR-FREESYNC-PREMIUM-PRO" + static bool isAudioBalanceSet = false; static int planeType = 0; @@ -156,7 +165,11 @@ void AVInput::InitializeIARM() IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, dsAVGameFeatureStatusEventHandler)); - IARM_CHECK(IARM_Bus_RegisterEventHandler( + IARM_CHECK(IARM_Bus_RegisterEventHandler( + IARM_BUS_DSMGR_NAME, + IARM_BUS_DSMGR_EVENT_HDMI_IN_VRR_STATUS, + dsAVGameFeatureStatusEventHandler)); + IARM_CHECK(IARM_Bus_RegisterEventHandler( IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG, dsAVEventHandler)); @@ -198,6 +211,9 @@ void AVInput::DeinitializeIARM() 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_HDMI_IN_VRR_STATUS, dsAVGameFeatureStatusEventHandler)); IARM_CHECK(IARM_Bus_RemoveEventHandler( IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG, dsAVEventHandler)); @@ -231,6 +247,9 @@ void AVInput::RegisterAll() 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_SET_VRR_SUPPORT), &AVInput::setVRRSupportWrapper, this); + Register(_T(AVINPUT_METHOD_GET_VRR_SUPPORT), &AVInput::getVRRSupportWrapper, this); + Register(_T(AVINPUT_METHOD_GET_VRR_FRAME_RATE), &AVInput::getVRRFrameRateWrapper, 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); @@ -239,6 +258,7 @@ void AVInput::RegisterAll() Register(_T(AVINPUT_METHOD_GAME_FEATURE_STATUS), &AVInput::getGameFeatureStatusWrapper, this); m_primVolume = DEFAULT_PRIM_VOL_LEVEL; m_inputVolume = DEFAULT_INPUT_VOL_LEVEL; + m_currentVrrType = dsVRR_NONE; } void AVInput::UnregisterAll() @@ -251,6 +271,9 @@ void AVInput::UnregisterAll() Unregister(_T(AVINPUT_METHOD_READ_EDID)); Unregister(_T(AVINPUT_METHOD_READ_RAWSPD)); Unregister(_T(AVINPUT_METHOD_READ_SPD)); + Unregister(_T(AVINPUT_METHOD_SET_VRR_SUPPORT)); + Unregister(_T(AVINPUT_METHOD_GET_VRR_SUPPORT)); + Unregister(_T(AVINPUT_METHOD_GET_VRR_FRAME_RATE)); Unregister(_T(AVINPUT_METHOD_SET_EDID_VERSION)); Unregister(_T(AVINPUT_METHOD_GET_EDID_VERSION)); Unregister(_T(AVINPUT_METHOD_START_INPUT)); @@ -868,7 +891,30 @@ void AVInput::AVInputVideoModeUpdate( int port , dsVideoPortResolution_t resolut params["frameRateN"] = 60000; params["frameRateD"] = 1001; break; - + case dsVIDEO_FRAMERATE_100: + params["frameRateN"] = 100000; + params["frameRateD"] = 1000; + break; + case dsVIDEO_FRAMERATE_119dot88: + params["frameRateN"] = 120000; + params["frameRateD"] = 1001; + break; + case dsVIDEO_FRAMERATE_120: + params["frameRateN"] = 120000; + params["frameRateD"] = 1000; + break; + case dsVIDEO_FRAMERATE_200: + params["frameRateN"] = 200000; + params["frameRateD"] = 1000; + break; + case dsVIDEO_FRAMERATE_239dot76: + params["frameRateN"] = 240000; + params["frameRateD"] = 1001; + break; + case dsVIDEO_FRAMERATE_240: + params["frameRateN"] = 240000; + params["frameRateD"] = 100; + break; default: params["frameRateN"] = 60000; params["frameRateD"] = 1000; @@ -1001,18 +1047,71 @@ void AVInput::dsAVGameFeatureStatusEventHandler(const char *owner, IARM_EventId_ AVInput::_instance->AVInputALLMChange(hdmi_in_port, allm_mode); } + if (IARM_BUS_DSMGR_EVENT_HDMI_IN_VRR_STATUS == eventId) + { + IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; + int hdmi_in_port = eventData->data.hdmi_in_vrr_mode.port; + dsVRRType_t new_vrrType = eventData->data.hdmi_in_vrr_mode.vrr_type; + LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_VRR_STATUS event port: %d, VRR Type: %d", hdmi_in_port,new_vrrType); + + if(new_vrrType == dsVRR_NONE) + { + if(AVInput::_instance->m_currentVrrType != dsVRR_NONE){ + AVInput::_instance->AVInputVRRChange(hdmi_in_port, AVInput::_instance->m_currentVrrType, false); + } + } + else + { + if(AVInput::_instance->m_currentVrrType != dsVRR_NONE){ + AVInput::_instance->AVInputVRRChange(hdmi_in_port, AVInput::_instance->m_currentVrrType, false); + } + AVInput::_instance->AVInputVRRChange(hdmi_in_port, new_vrrType, true); + } + AVInput::_instance->m_currentVrrType = new_vrrType; + } } void AVInput::AVInputALLMChange( int port , bool allm_mode) { JsonObject params; params["id"] = port; - params["gameFeature"] = "ALLM"; + params["gameFeature"] = STR_ALLM; params["mode"] = allm_mode; sendNotify(AVINPUT_EVENT_ON_GAME_FEATURE_STATUS_CHANGED, params); } +void AVInput::AVInputVRRChange( int port , dsVRRType_t vrr_type, bool vrr_mode) +{ + JsonObject params; + switch(vrr_type) + { + case dsVRR_HDMI_VRR: + params["id"] = port; + params["gameFeature"] = VRR_TYPE_HDMI; + params["mode"] = vrr_mode; + break; + case dsVRR_AMD_FREESYNC: + params["id"] = port; + params["gameFeature"] = VRR_TYPE_FREESYNC; + params["mode"] = vrr_mode; + break; + case dsVRR_AMD_FREESYNC_PREMIUM: + params["id"] = port; + params["gameFeature"] = VRR_TYPE_FREESYNC_PREMIUM; + params["mode"] = vrr_mode; + break; + case dsVRR_AMD_FREESYNC_PREMIUM_PRO: + params["id"] = port; + params["gameFeature"] = VRR_TYPE_FREESYNC_PREMIUM_PRO; + params["mode"] = vrr_mode; + break; + default: + break; + } + sendNotify(AVINPUT_EVENT_ON_GAME_FEATURE_STATUS_CHANGED, params); +} + uint32_t AVInput::getSupportedGameFeatures(const JsonObject& parameters, JsonObject& response) { LOGINFOMETHOD(); @@ -1061,15 +1160,55 @@ uint32_t AVInput::getGameFeatureStatusWrapper(const JsonObject& parameters, Json returnResponse(false); } - if (strcmp (sGameFeature.c_str(), "ALLM") == 0) + if (strcmp (sGameFeature.c_str(), STR_ALLM) == 0) { bool allm = getALLMStatus(portId); LOGWARN("AVInput::getGameFeatureStatusWrapper ALLM MODE:%d", allm); response["mode"] = allm; } + else if(strcmp (sGameFeature.c_str(), VRR_TYPE_HDMI) == 0) + { + bool hdmi_vrr = false; + dsHdmiInVrrStatus_t vrrStatus; + getVRRStatus(portId, &vrrStatus); + if(vrrStatus.vrrType == dsVRR_HDMI_VRR) + hdmi_vrr = true; + LOGWARN("AVInput::getGameFeatureStatusWrapper HDMI VRR MODE:%d", hdmi_vrr); + response["mode"] = hdmi_vrr; + } + else if(strcmp (sGameFeature.c_str(), VRR_TYPE_FREESYNC) == 0) + { + bool freesync = false; + dsHdmiInVrrStatus_t vrrStatus; + getVRRStatus(portId, &vrrStatus); + if(vrrStatus.vrrType == dsVRR_AMD_FREESYNC) + freesync = true; + LOGWARN("AVInput::getGameFeatureStatusWrapper FREESYNC MODE:%d", freesync); + response["mode"] = freesync; + } + else if(strcmp (sGameFeature.c_str(), VRR_TYPE_FREESYNC_PREMIUM) == 0) + { + bool freesync_premium = false; + dsHdmiInVrrStatus_t vrrStatus; + getVRRStatus(portId, &vrrStatus); + if(vrrStatus.vrrType == dsVRR_AMD_FREESYNC_PREMIUM) + freesync_premium = true; + LOGWARN("AVInput::getGameFeatureStatusWrapper FREESYNC PREMIUM MODE:%d", freesync_premium); + response["mode"] = freesync_premium; + } + else if(strcmp (sGameFeature.c_str(), VRR_TYPE_FREESYNC_PREMIUM_PRO) == 0) + { + bool freesync_premium_pro = false; + dsHdmiInVrrStatus_t vrrStatus; + getVRRStatus(portId, &vrrStatus); + if(vrrStatus.vrrType == dsVRR_AMD_FREESYNC_PREMIUM_PRO) + freesync_premium_pro = true; + LOGWARN("AVInput::getGameFeatureStatusWrapper FREESYNC PREMIUM PRO MODE:%d", freesync_premium_pro); + response["mode"] = freesync_premium_pro; + } else { - LOGWARN("AVInput::getGameFeatureStatusWrapper Mode is not supported. Supported mode: ALLM"); + LOGWARN("AVInput::getGameFeatureStatusWrapper Mode is not supported. Supported mode: ALLM, VRR-HDMI, VRR-FREESYNC-PREMIUM"); returnResponse(false); } returnResponse(true); @@ -1091,6 +1230,22 @@ bool AVInput::getALLMStatus(int iPort) return allm; } +bool AVInput::getVRRStatus(int iPort, dsHdmiInVrrStatus_t *vrrStatus) +{ + bool ret = true; + try + { + device::HdmiInput::getInstance().getVRRStatus (iPort, vrrStatus); + LOGWARN("AVInput::getVRRStatus VRR TYPE: %d, VRR FRAMERATE: %f", vrrStatus->vrrType,vrrStatus->vrrAmdfreesyncFramerate_Hz); + } + catch (const device::Exception& err) + { + LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); + ret = false; + } + return ret; +} + uint32_t AVInput::getRawSPDWrapper(const JsonObject& parameters, JsonObject& response) { LOGINFOMETHOD(); @@ -1363,6 +1518,125 @@ uint32_t AVInput::getEdid2AllmSupportWrapper(const JsonObject& parameters, JsonO } } +bool AVInput::getVRRSupport(int portId,bool *vrrSupportValue) +{ + bool ret = true; + try + { + device::HdmiInput::getInstance().getVRRSupport (portId, vrrSupportValue); + LOGINFO("AVInput - getVRRSupport:%d", *vrrSupportValue); + } + catch (const device::Exception& err) + { + LOG_DEVICE_EXCEPTION1(std::to_string(portId)); + ret = false; + } + return ret; +} + +uint32_t AVInput::getVRRSupportWrapper(const JsonObject& parameters, JsonObject& response) +{ + LOGINFOMETHOD(); + returnIfParamNotFound(parameters, "portId"); + string sPortId = parameters["portId"].String(); + + int portId = 0; + bool vrrSupport = true; + + try { + portId = stoi(sPortId); + }catch (const std::exception& err) { + LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); + returnResponse(false); + } + + bool result = getVRRSupport(portId, &vrrSupport); + if(result == true) + { + response["vrrSupport"] = vrrSupport; + returnResponse(true); + } + else + { + returnResponse(false); + } +} + +bool AVInput::setVRRSupport(int portId, bool vrrSupport) +{ + bool ret = true; + try + { + device::HdmiInput::getInstance().setVRRSupport (portId, vrrSupport); + LOGWARN("AVInput - vrrSupport:%d", vrrSupport); + } + catch (const device::Exception& err) + { + LOG_DEVICE_EXCEPTION1(std::to_string(portId)); + ret = false; + } + return ret; + +} + +uint32_t AVInput::setVRRSupportWrapper(const JsonObject& parameters, JsonObject& response) +{ + LOGINFOMETHOD(); + + returnIfParamNotFound(parameters, "portId"); + returnIfParamNotFound(parameters, "vrrSupport"); + + int portId = 0; + string sPortId = parameters["portId"].String(); + bool vrrSupport = parameters["vrrSupport"].Boolean(); + + try { + portId = stoi(sPortId); + }catch (const std::exception& err) { + LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); + returnResponse(false); + } + + bool result = setVRRSupport(portId, vrrSupport); + if(result == true) + { + returnResponse(true); + } + else + { + returnResponse(false); + } +} + +uint32_t AVInput::getVRRFrameRateWrapper(const JsonObject& parameters, JsonObject& response) +{ + LOGINFOMETHOD(); + returnIfParamNotFound(parameters, "portId"); + string sPortId = parameters["portId"].String(); + + int portId = 0; + dsHdmiInVrrStatus_t vrrStatus; + vrrStatus.vrrAmdfreesyncFramerate_Hz = 0; + + try { + portId = stoi(sPortId); + }catch (const std::exception& err) { + LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); + returnResponse(false); + } + + bool result = getVRRStatus(portId, &vrrStatus); + if(result == true) + { + response["currentVRRVideoFrameRate"] = vrrStatus.vrrAmdfreesyncFramerate_Hz; + returnResponse(true); + } + else + { + returnResponse(false); + } +} + uint32_t AVInput::setEdidVersionWrapper(const JsonObject& parameters, JsonObject& response) { LOGINFOMETHOD(); diff --git a/AVInput/AVInput.h b/AVInput/AVInput.h index 22b61827..b6c86142 100644 --- a/AVInput/AVInput.h +++ b/AVInput/AVInput.h @@ -47,6 +47,8 @@ class AVInput: public PluginHost::IPlugin, public PluginHost::JSONRPC int m_primVolume; int m_inputVolume; //Player Volume + + dsVRRType_t m_currentVrrType; public: // IPlugin methods // ------------------------------------------------------------------------------------------------------- @@ -79,6 +81,9 @@ class AVInput: public PluginHost::IPlugin, public PluginHost::JSONRPC 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 setVRRSupportWrapper(const JsonObject& parameters, JsonObject& response); + uint32_t getVRRSupportWrapper(const JsonObject& parameters, JsonObject& response); + uint32_t getVRRFrameRateWrapper(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); @@ -95,10 +100,14 @@ class AVInput: public PluginHost::IPlugin, public PluginHost::JSONRPC std::string getSPD(int iPort); int setEdidVersion(int iPort, int iEdidVer); int getEdidVersion(int iPort); + bool setVRRSupport(int portId, bool vrrSupport); + bool getVRRSupport(int portId, bool *vrrSupportValue); bool setVideoRectangle(int x, int y, int width, int height, int type); bool getALLMStatus(int iPort); + bool getVRRStatus(int iPort, dsHdmiInVrrStatus_t *vrrStatus); void AVInputHotplug(int input , int connect, int type); + void AVInputVRRChange( int port , dsVRRType_t vrr_type, bool vrr_mode); static void dsAVEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); void AVInputSignalChange( int port , int signalStatus, int type); diff --git a/AVOutput/AVOutput.h b/AVOutput/AVOutput.h index fb260ada..13536705 100644 --- a/AVOutput/AVOutput.h +++ b/AVOutput/AVOutput.h @@ -60,8 +60,6 @@ namespace Plugin { 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) diff --git a/AVOutput/AVOutputTV.cpp b/AVOutput/AVOutputTV.cpp index e95b81e7..7bdf3876 100644 --- a/AVOutput/AVOutputTV.cpp +++ b/AVOutput/AVOutputTV.cpp @@ -2016,6 +2016,10 @@ namespace Plugin { returnResponse(false); } + if (isPlatformSupport("DimmingMode") != 0) { + returnResponse(false); + } + if (getParamIndex("DimmingMode",inputInfo,indexInfo) == -1) { LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); returnResponse(false); @@ -2072,6 +2076,10 @@ namespace Plugin { returnResponse(false); } + if (isPlatformSupport("DimmingMode") != 0) { + returnResponse(false); + } + if( !isCapablityCheckPassed( "DimmingMode" , inputInfo )) { LOGERR("%s: CapablityCheck failed for DimmingMode\n", __FUNCTION__); returnResponse(false); @@ -2118,6 +2126,10 @@ namespace Plugin { returnResponse(false); } + if (isPlatformSupport("DimmingMode") != 0) { + returnResponse(false); + } + int retval= updateAVoutputTVParam("reset","DimmingMode", inputInfo,PQ_PARAM_DIMMINGMODE,dMode); if(retval != 0 ) { @@ -2171,6 +2183,8 @@ namespace Plugin { returnResponse(false); } else { + response["platformSupport"] = (info.isPlatformSupportVector[0].compare("true") == 0) ? true : false; + for (index = 0; index < info.rangeVector.size(); index++) { supportedDimmingModeArray.Add(info.rangeVector[index]); } @@ -2203,14 +2217,17 @@ namespace Plugin { 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 + tvDolbyMode_t dvModes[tvMode_Max] = { tvDolbyMode_Invalid }; + tvDolbyMode_t *dvModesPtr[tvMode_Max] = { 0 }; unsigned short totalAvailable = 0; - + for (int i = 0; i < tvMode_Max; i++) + { + dvModesPtr[i] = &dvModes[i]; + } // Set an initial value to indicate the mode type dvModes[0] = tvDolbyMode_Dark; - tvError_t ret = GetTVSupportedDolbyVisionModes(&dvModesPtr, &totalAvailable); + tvError_t ret = GetTVSupportedDolbyVisionModes(dvModesPtr, &totalAvailable); if(ret != tvERROR_NONE) { returnResponse(false); } @@ -2235,6 +2252,7 @@ namespace Plugin { paramIndex_t indexInfo; int dolbyMode = 0; int err = 0; + tvVideoFormatType_t video_type = VIDEO_FORMAT_NONE; if (parsingGetInputArgument(parameters, "DolbyVisionMode",inputInfo) != 0) { LOGINFO("%s: Failed to parse argument\n", __FUNCTION__); @@ -2245,6 +2263,12 @@ namespace Plugin { returnResponse(false); } + GetCurrentVideoFormat(&video_type); + if(video_type != VIDEO_FORMAT_DV) + { + LOGERR("%s: Invalid video format: %d \n", __FUNCTION__,video_type); + returnResponse(false); + } if (getParamIndex("DolbyVisionMode",inputInfo,indexInfo) == -1) { LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); @@ -2423,9 +2447,14 @@ namespace Plugin { uint32_t AVOutputTV::getSupportedPictureModes(const JsonObject& parameters, JsonObject& response) { LOGINFO("Entry\n"); - pic_modes_t *pictureModes; + pic_modes_t pictureModes[PIC_MODES_SUPPORTED_MAX]; + pic_modes_t *pictureModesPtr[PIC_MODES_SUPPORTED_MAX]={0}; unsigned short totalAvailable = 0; - tvError_t ret = GetTVSupportedPictureModes(&pictureModes,&totalAvailable); + for (int i = 0; i < PIC_MODES_SUPPORTED_MAX; i++) + { + pictureModesPtr[i] = &pictureModes[i]; + } + tvError_t ret = GetTVSupportedPictureModes(pictureModesPtr,&totalAvailable); if(ret != tvERROR_NONE) { returnResponse(false); } diff --git a/AVOutput/AVOutputTV.h b/AVOutput/AVOutputTV.h index 5e493068..612aebf8 100644 --- a/AVOutput/AVOutputTV.h +++ b/AVOutput/AVOutputTV.h @@ -27,7 +27,6 @@ #include "tvTypes.h" #include "tvSettings.h" -#include "tvSettingsExtODM.h" #include #include "Module.h" #include "tvError.h" @@ -270,7 +269,6 @@ class AVOutputTV : public AVOutputBase { private: - tvContentFormatType_t getContentFormatIndex(tvVideoHDRFormat_t formatToConvert); int getPictureModeIndex(std::string pqmode); int getSourceIndex(std::string source); int getFormatIndex(std::string format); @@ -308,7 +306,6 @@ class AVOutputTV : public AVOutputBase { 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); @@ -340,10 +337,8 @@ class AVOutputTV : public AVOutputBase { 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); diff --git a/AVOutput/AVOutputTVHelper.cpp b/AVOutput/AVOutputTVHelper.cpp index 7e3b28c5..5c5e5b3e 100644 --- a/AVOutput/AVOutputTVHelper.cpp +++ b/AVOutput/AVOutputTVHelper.cpp @@ -32,36 +32,6 @@ 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; @@ -265,14 +235,19 @@ namespace Plugin { 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 + tvDolbyMode_t dolbyModes[tvMode_Max] = { tvDolbyMode_Invalid }; + tvDolbyMode_t *dolbyModesPtr[tvMode_Max] = { 0 }; unsigned short totalAvailable = 0; + for (int i = 0; i < tvMode_Max; i++) + { + dolbyModesPtr[i] = &dolbyModes[i]; + } + // Set an initial value to indicate the mode type dolbyModes[0] = tvDolbyMode_Dark; - tvError_t ret = GetTVSupportedDolbyVisionModes(&dolbyModesPtr, &totalAvailable); + 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) { @@ -321,13 +296,13 @@ namespace Plugin { { tvDimmingMode_t index = tvDimmingMode_MAX; - if(mode.compare("local") == 0 ) { + if(mode.compare("Local") == 0 ) { index=tvDimmingMode_Local; } - else if(mode.compare("fixed") == 0 ) { + else if(mode.compare("Fixed") == 0 ) { index=tvDimmingMode_Fixed; } - else if(mode.compare("global") == 0 ) { + else if(mode.compare("Global") == 0 ) { index=tvDimmingMode_Global; } else { @@ -925,26 +900,6 @@ namespace Plugin { 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; @@ -1254,6 +1209,13 @@ namespace Plugin { LOGERR("Backlight Sync to cache Failed !!!\n"); } + if( !updateAVoutputTVParam("sync","LowLatencyState",info,PQ_PARAM_LOWLATENCY_STATE,level) ) { + LOGINFO("LowLatencyState Successfully Synced to Drive Cache\n"); + } + else { + LOGERR("LowLatencyState Sync to cache Failed !!!\n"); + } + syncCMSParams(); //sync CMS syncWBParams(); @@ -1514,13 +1476,13 @@ namespace Plugin { return 0; } else if( forParam.compare("DimmingMode") == 0 ) { - if (strncmp(param.value, "fixed", strlen(param.value))==0) { + if (strncmp(param.value, "Fixed", strlen(param.value))==0) { value=tvDimmingMode_Fixed; } - else if (strncmp(param.value, "local", strlen(param.value))==0) { + else if (strncmp(param.value, "Local", strlen(param.value))==0) { value=tvDimmingMode_Local; } - else if (strncmp(param.value, "global", strlen(param.value))==0) { + else if (strncmp(param.value, "Global", strlen(param.value))==0) { value=tvDimmingMode_Global; } return 0; @@ -1654,38 +1616,12 @@ namespace Plugin { 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", + [tvDimmingMode_Fixed] = "Fixed", + [tvDimmingMode_Local] = "Local", + [tvDimmingMode_Global] = "Global", }; toStore.clear(); toStore+=color_temp_string[value]; @@ -2373,7 +2309,7 @@ namespace Plugin { } - if ((param == "DolbyVisionMode") || (param == "Backlight") || (param == "CMS") || (param == "CustomWhiteBalance") || (param == "HDRMode") || (param == "BacklightControl")) { + if ((param == "DolbyVisionMode") || (param == "Backlight") || (param == "CMS") || (param == "CustomWhiteBalance") || (param == "HDRMode") || (param == "BacklightControl") || (param == "DimmingMode")) { configString = param + ".platformsupport"; info.isPlatformSupport = inFile.Get(configString); printf(" platformsupport : %s\n",info.isPlatformSupport.c_str() ); diff --git a/AVOutput/CHANGELOG.md b/AVOutput/CHANGELOG.md index a3afa122..7daed548 100644 --- a/AVOutput/CHANGELOG.md +++ b/AVOutput/CHANGELOG.md @@ -14,6 +14,23 @@ All notable changes to this RDK Service will be documented in this file. * 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. +<<<<<<< HEAD +## [1.1.4] - 2025-09-08 +### Fixed +- Sync low latency for AVOutput initialization + +## [1.1.3] - 2025-08-08 +### Fixed +- Fixed getDolbyVisionMode() for non DV content + +## [1.1.2] - 2025-07-01 +### Fixed +- Phase2 ODM + +## [1.1.1] - 2025-06-26 +### Fixed +- Fixed dimmingMode failures + ## [1.1.0] - 2025-03-14 ### Added - Add additional features on AVOutput diff --git a/CHANGELOG.md b/CHANGELOG.md index 73149475..867461dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,154 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.4.7](https://github.com/rdkcentral/entservices-inputoutput/compare/1.4.6...1.4.7) + +- RDKEMW-7712: Sync low latency for AVOutput initialization (#6338) [`#249`](https://github.com/rdkcentral/entservices-inputoutput/pull/249) +- Merge tag '1.4.6' into develop [`bef0aa3`](https://github.com/rdkcentral/entservices-inputoutput/commit/bef0aa3bf2638d0223008f10babecde595d850df) + +#### [1.4.6](https://github.com/rdkcentral/entservices-inputoutput/compare/1.4.5...1.4.6) + +> 4 September 2025 + +- Feature/rdkemw 7169 [`#245`](https://github.com/rdkcentral/entservices-inputoutput/pull/245) +- 1.4.6 release changelog updates [`7a0d569`](https://github.com/rdkcentral/entservices-inputoutput/commit/7a0d569f253b8a08926e959509e329159aa2d509) +- Merge tag '1.4.5' into develop [`7268514`](https://github.com/rdkcentral/entservices-inputoutput/commit/7268514652bf9f0cda3f3a6433a0f0720bf9d63c) + +#### [1.4.5](https://github.com/rdkcentral/entservices-inputoutput/compare/1.4.4...1.4.5) + +> 3 September 2025 + +- RDKEMW-7169 - Gtest Add missing empty files [`#241`](https://github.com/rdkcentral/entservices-inputoutput/pull/241) +- 1.4.5 release changelog updates [`4354afa`](https://github.com/rdkcentral/entservices-inputoutput/commit/4354afac08c4671cbed356d81a2ed2f612139464) +- Merge tag '1.4.4' into develop [`0fabfaf`](https://github.com/rdkcentral/entservices-inputoutput/commit/0fabfaf0816dda67077fd7fe59e074a962e644ef) + +#### [1.4.4](https://github.com/rdkcentral/entservices-inputoutput/compare/1.4.3...1.4.4) + +> 1 September 2025 + +- Update component-release.yml [`#242`](https://github.com/rdkcentral/entservices-inputoutput/pull/242) +- RDKEMW-6515: Scan and Fix coverity issues of Entservices and rdkservices-cpc [`#234`](https://github.com/rdkcentral/entservices-inputoutput/pull/234) +- 1.4.4 release changelog updates [`feec135`](https://github.com/rdkcentral/entservices-inputoutput/commit/feec135c1c56d36401582981b6dfcd11993358fb) +- Merge tag '1.4.3' into develop [`3b90d4b`](https://github.com/rdkcentral/entservices-inputoutput/commit/3b90d4b70baabf9367bfda236f4695b8a7974313) + +#### [1.4.3](https://github.com/rdkcentral/entservices-inputoutput/compare/1.4.2...1.4.3) + +> 19 August 2025 + +- RDKEMW-6681: getDolbyVisionMode api fails to return "Dark/Bright" in … [`#223`](https://github.com/rdkcentral/entservices-inputoutput/pull/223) +- RDKEMW-4778 : Automate git flow merges to main branch for entservices repos [`#209`](https://github.com/rdkcentral/entservices-inputoutput/pull/209) +- RDKEMW-6681: getDolbyVisionMode api fails to return "Dark/Bright" in response for AVOutput plugins. [`9db7ba4`](https://github.com/rdkcentral/entservices-inputoutput/commit/9db7ba48bd2c1d6b45c7f575ae5bacec2b0f8308) +- 1.4.3 release changelog updates [`ef1583d`](https://github.com/rdkcentral/entservices-inputoutput/commit/ef1583d9967693a1607839f41057fb2a8f0f3060) +- Merge tag '1.4.2' into develop [`be41736`](https://github.com/rdkcentral/entservices-inputoutput/commit/be41736e250601991249354d91777def97c17546) + +#### [1.4.2](https://github.com/rdkcentral/entservices-inputoutput/compare/1.4.1...1.4.2) + +> 4 August 2025 + +- RDKEMW-4708: Replacing IARM Power manager with Power Manager Plugin [`#194`](https://github.com/rdkcentral/entservices-inputoutput/pull/194) +- 1.4.2 release change log updates [`e2a57a7`](https://github.com/rdkcentral/entservices-inputoutput/commit/e2a57a710780328c582d3b62c5c559409c83e9f4) +- Merge tag '1.4.1' into develop [`263272d`](https://github.com/rdkcentral/entservices-inputoutput/commit/263272d6c89623461ace94af863e746fda34f9c3) + +#### [1.4.1](https://github.com/rdkcentral/entservices-inputoutput/compare/1.4.0...1.4.1) + +> 1 August 2025 + +- RDKEMW-6582: Improve the ARC volume logo smoothness during the Volume +/- press and hold scenario [`#215`](https://github.com/rdkcentral/entservices-inputoutput/pull/215) +- [RDKEMW-5410] RDKEMW-6572 : Compilation error was not reported for the PR branch [`#211`](https://github.com/rdkcentral/entservices-inputoutput/pull/211) +- 1.4.1 release change log updates [`f6c7916`](https://github.com/rdkcentral/entservices-inputoutput/commit/f6c7916aff03d41fb65e8b631f5c05f666ec92c6) +- Merge tag '1.4.0' into develop [`152ff74`](https://github.com/rdkcentral/entservices-inputoutput/commit/152ff74a4066cd3b6fc10800d1b3835fe7d3b543) + +#### [1.4.0](https://github.com/rdkcentral/entservices-inputoutput/compare/1.3.5...1.4.0) + +> 28 July 2025 + +- RDKEMW-2942 : Remove the HdmiInput plugin and replace its references with AVInput [`#205`](https://github.com/rdkcentral/entservices-inputoutput/pull/205) +- [RDKEMW-3513] PR action to run with latest change [`#163`](https://github.com/rdkcentral/entservices-inputoutput/pull/163) +- RDKEMW-6325: platfromSupport is missing from dimmingMode capabilities [`#198`](https://github.com/rdkcentral/entservices-inputoutput/pull/198) +- RDKTV-37015 - Changelog updates for 1.4.0 [`b969871`](https://github.com/rdkcentral/entservices-inputoutput/commit/b969871181dd194dd835750ec8eb908b66d34537) +- Merge tag '1.3.5' into develop [`024be52`](https://github.com/rdkcentral/entservices-inputoutput/commit/024be52d58d512b138b84aee9b12609e603d7110) + +#### [1.3.5](https://github.com/rdkcentral/entservices-inputoutput/compare/1.3.4...1.3.5) + +> 23 July 2025 + +- RDKEMW-6230: Retry logic used dsGetHDMIARCPortId in HdmiCecSink [`#203`](https://github.com/rdkcentral/entservices-inputoutput/pull/203) +- 1.3.5 release changelog updates [`b12cd97`](https://github.com/rdkcentral/entservices-inputoutput/commit/b12cd97a05c2dc2b7915cfac28c998fb2277d349) +- Merge tag '1.3.4' into develop [`760ee0f`](https://github.com/rdkcentral/entservices-inputoutput/commit/760ee0f9da46e0b0ed2e2adb4523bfec85c5a927) + +#### [1.3.4](https://github.com/rdkcentral/entservices-inputoutput/compare/1.3.3...1.3.4) + +> 22 July 2025 + +- RDKEMW-6279: Revert of HdmiCecSink comrpc changes (#129) [`#199`](https://github.com/rdkcentral/entservices-inputoutput/pull/199) +- RDKEMW-6279 - Changelog updates for 1.3.4 [`8a6fd55`](https://github.com/rdkcentral/entservices-inputoutput/commit/8a6fd55be4c187be3c725d2ca6512720bd6c018b) +- Merge tag '1.3.3' into develop [`7abaec3`](https://github.com/rdkcentral/entservices-inputoutput/commit/7abaec32ed58c36ef05640ca9baaf8077b90a5d5) + +#### [1.3.3](https://github.com/rdkcentral/entservices-inputoutput/compare/1.3.2...1.3.3) + +> 10 July 2025 + +- RDKEMW-3750 : Upgrade Thunder to Version R4.4.3 [`#133`](https://github.com/rdkcentral/entservices-inputoutput/pull/133) +- cmake cleanup [`#151`](https://github.com/rdkcentral/entservices-inputoutput/pull/151) +- RDK-42386 : Improve Unit Tests Coverage for AVInput Plugin [`#164`](https://github.com/rdkcentral/entservices-inputoutput/pull/164) +- RDKEMW-3750 - Changelog updates for 1.3.3 [`ced5287`](https://github.com/rdkcentral/entservices-inputoutput/commit/ced52871e5f60487165bf417af781f3f72e10bfa) +- Merge tag '1.3.2' into develop [`dab1c4a`](https://github.com/rdkcentral/entservices-inputoutput/commit/dab1c4ab82e2983b04d66bdb975a546a79efc47f) + +#### [1.3.2](https://github.com/rdkcentral/entservices-inputoutput/compare/1.3.1...1.3.2) + +> 1 July 2025 + +- RDKEMW-5510: Integrate the ODM Phase 2 middleware changes into RDKE [`#160`](https://github.com/rdkcentral/entservices-inputoutput/pull/160) +- RDKEMW-5510 - Changelog updates for 1.3.2 [`a70cf9a`](https://github.com/rdkcentral/entservices-inputoutput/commit/a70cf9a4229cfcc4f468cdd49064708f8bfd65aa) +- Merge tag '1.3.1' into develop [`8083548`](https://github.com/rdkcentral/entservices-inputoutput/commit/808354842ca703cbcd49d04ee6ceeca5911d1653) + +#### [1.3.1](https://github.com/rdkcentral/entservices-inputoutput/compare/1.3.0...1.3.1) + +> 26 June 2025 + +- RDKEMW-5512: Implement a fix for the SaveTVDimmingMode failure [`#157`](https://github.com/rdkcentral/entservices-inputoutput/pull/157) +- RDKEMW-1015 - Update gtest [`#155`](https://github.com/rdkcentral/entservices-inputoutput/pull/155) +- 1.3.1 release changelog updates [`88527ce`](https://github.com/rdkcentral/entservices-inputoutput/commit/88527cedd22c2ca3d58c8b625ed9f90ba1128066) +- Merge tag '1.3.0' into develop [`2499e0b`](https://github.com/rdkcentral/entservices-inputoutput/commit/2499e0b71c2fbb9e9a303a342fbc4965da5b52c9) + +#### [1.3.0](https://github.com/rdkcentral/entservices-inputoutput/compare/1.2.0...1.3.0) + +> 20 June 2025 + +- Feature/rdkemw 1015 comrpc [`#129`](https://github.com/rdkcentral/entservices-inputoutput/pull/129) +- RDK-57440: Causing config issue for higher versions of cmake [`#146`](https://github.com/rdkcentral/entservices-inputoutput/pull/146) +- RDK-57440 - Changelog updates for 1.3.0 [`cc4f369`](https://github.com/rdkcentral/entservices-inputoutput/commit/cc4f36979ba5a25a4ae96005b7e2c6dce1523044) +- Merge tag '1.2.0' into develop [`7b1dccc`](https://github.com/rdkcentral/entservices-inputoutput/commit/7b1dccc6d7bbba3fdf649c900ad15996e6424a27) + +#### [1.2.0](https://github.com/rdkcentral/entservices-inputoutput/compare/1.1.1...1.2.0) + +> 17 June 2025 + +- RDKEMW-4135:Coverity integration with Entservices repo [`#147`](https://github.com/rdkcentral/entservices-inputoutput/pull/147) +- RDKEMW-4116 : VRR Feature Middleware changes. [`#103`](https://github.com/rdkcentral/entservices-inputoutput/pull/103) +- topic/RDK-58099: HdmiCecSink syntax error [`#142`](https://github.com/rdkcentral/entservices-inputoutput/pull/142) +- [RDKEMW-2711] RDKEMW-4650: Enabling the L1/L2 test in the Testframework [`#130`](https://github.com/rdkcentral/entservices-inputoutput/pull/130) +- Update AVInput.cpp [`78f58ff`](https://github.com/rdkcentral/entservices-inputoutput/commit/78f58ffebdd7dc34588a2202722758881503600c) +- Added L1Tests [`8986170`](https://github.com/rdkcentral/entservices-inputoutput/commit/8986170c1956a7a678b78c142cd0430bae459c58) +- Update AVInput.cpp [`dcee164`](https://github.com/rdkcentral/entservices-inputoutput/commit/dcee164f26692b92e7d7fadf9b36e1523cd84d69) + +#### [1.1.1](https://github.com/rdkcentral/entservices-inputoutput/compare/1.1.0...1.1.1) + +> 11 June 2025 + +- RDKEMW-5124: Higher framerate support in Thunder [`#134`](https://github.com/rdkcentral/entservices-inputoutput/pull/134) +- RDK-57440: Enable HdcpProfile for contract test [`#132`](https://github.com/rdkcentral/entservices-inputoutput/pull/132) +- [RDKEMW-2711] RDKEMW-4232: Moving the L2 Test files to specific entservices for inputoutput repo [`#123`](https://github.com/rdkcentral/entservices-inputoutput/pull/123) +- RDKEMW-4196: Cleanup and remove pwrmgr references from workflows [`#126`](https://github.com/rdkcentral/entservices-inputoutput/pull/126) +- RDKEMW-4220: Fix wpeframework crash on reactivating plugin and powerstate change [`#104`](https://github.com/rdkcentral/entservices-inputoutput/pull/104) +- RDKEMW-4139: Coverity integration with Entservices-inputoutput repo [`#116`](https://github.com/rdkcentral/entservices-inputoutput/pull/116) +- 1.1.1 release change log updates [`6b11c5b`](https://github.com/rdkcentral/entservices-inputoutput/commit/6b11c5b379c1bfdfc533fc090d73245d4cfe264e) +- Merge tag '1.1.0' into develop [`2ce89ed`](https://github.com/rdkcentral/entservices-inputoutput/commit/2ce89edb2c300ecc3275fab6673b48823578d053) + #### [1.1.0](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.12...1.1.0) +> 20 May 2025 + - 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) @@ -14,6 +160,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - 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) +- 1.1.0 release changelog updates [`d6c91fa`](https://github.com/rdkcentral/entservices-inputoutput/commit/d6c91fa3fb9bda7e296ce9321921cc8882b2d50d) - 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) @@ -74,10 +221,15 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - 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) +#### [1.0.6](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.6-RDK7.1...1.0.6) > 27 March 2025 +#### [1.0.6-RDK7.1](https://github.com/rdkcentral/entservices-inputoutput/compare/1.0.5...1.0.6-RDK7.1) + +> 22 May 2025 + +- RDKEMW-4220: Fix wpeframework crash on reactivating plugin and powerstate change [`#104`](https://github.com/rdkcentral/entservices-inputoutput/pull/104) - 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) diff --git a/CMakeLists.txt b/CMakeLists.txt index df70686a..6a222334 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,10 +64,6 @@ if(PLUGIN_HDCPPROFILE) add_subdirectory(HdcpProfile) endif() -if(PLUGIN_HDMIINPUT) - add_subdirectory(HdmiInput) -endif() - if(WPEFRAMEWORK_CREATE_IPKG_TARGETS) set(CPACK_GENERATOR "DEB") diff --git a/HdmiCecSink/HdmiCecSink.cpp b/HdmiCecSink/HdmiCecSink.cpp index 26aef24c..a1ac6a75 100644 --- a/HdmiCecSink/HdmiCecSink.cpp +++ b/HdmiCecSink/HdmiCecSink.cpp @@ -75,7 +75,7 @@ #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 HDMICECSINK_UPDATE_AUDIO_STATUS_INTERVAL_MS 2000 #define SAD_FMT_CODE_AC3 2 @@ -710,6 +710,7 @@ namespace WPEFramework m_isHdmiInConnected = false; hdmiCecAudioDeviceConnected = false; m_isAudioStatusInfoUpdated = false; + m_audioStatusRequestedCount = 0; m_audioStatusReceived = false; m_audioStatusTimerStarted = false; m_audioDevicePowerStatusRequested = false; @@ -1161,9 +1162,11 @@ namespace WPEFramework 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("AudioStatus received from the Audio Device. Updating the AudioStatus info! m_isAudioStatusInfoUpdated :%d, m_audioStatusRequestedCount :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d ", m_isAudioStatusInfoUpdated,m_audioStatusRequestedCount,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()); + if(m_audioStatusRequestedCount > 0) + m_audioStatusRequestedCount--; + 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); @@ -1355,7 +1358,15 @@ namespace WPEFramework return; if(!(_instance->smConnection)) return; + if (m_audioStatusDetectionTimer.isActive()) + { + LOGINFO("Stopping the Audio Status Timer!\n"); + m_audioStatusDetectionTimer.stop(); + m_audioStatusTimerStarted = false; + LOGINFO("m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d ",m_isAudioStatusInfoUpdated,m_audioStatusReceived,m_audioStatusTimerStarted); + } LOGINFO(" Send GiveAudioStatus "); + m_audioStatusRequestedCount++; _instance->smConnection->sendTo(LogicalAddress::AUDIO_SYSTEM,MessageEncoder().encode(GiveAudioStatus()), 100); } @@ -2497,10 +2508,11 @@ namespace WPEFramework m_audioStatusDetectionTimer.stop(); } m_isAudioStatusInfoUpdated = false; + m_audioStatusRequestedCount = 0; 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) + LOGINFO("Audio device removed, reset the audio status info. m_isAudioStatusInfoUpdated :%d, m_audioStatusRequestedCount :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d", m_isAudioStatusInfoUpdated,m_audioStatusRequestedCount,m_audioStatusReceived,m_audioStatusTimerStarted); + sendNotify(eventString[HDMICECSINK_EVENT_AUDIO_DEVICE_CONNECTED_STATUS], params); } _instance->deviceList[logicalAddress].m_isRequestRetry = 0; @@ -3121,10 +3133,10 @@ namespace WPEFramework m_audioStatusDetectionTimer.stop(); } m_isAudioStatusInfoUpdated = false; + m_audioStatusRequestedCount = 0; 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); - + LOGINFO("CEC Disabled, reset the audio status info. m_isAudioStatusInfoUpdated :%d, m_audioStatusRequestedCount :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d ", m_isAudioStatusInfoUpdated,m_audioStatusRequestedCount,m_audioStatusReceived,m_audioStatusTimerStarted); for(int i=0; i< 16; i++) { @@ -3361,6 +3373,8 @@ namespace WPEFramework keyInfo = _instance->m_SendKeyQueue.front(); _instance->m_SendKeyQueue.pop(); + if((keyInfo.logicalAddr != 0x5) || ((keyInfo.logicalAddr == 0x5) && (_instance->hdmiCecAudioDeviceConnected == true))) + { 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()); @@ -3380,16 +3394,16 @@ namespace WPEFramework if((_instance->m_SendKeyQueue.size()<=1 || (_instance->m_SendKeyQueue.size() % 2 == 0)) && ((keyInfo.keyCode == VOLUME_UP) || (keyInfo.keyCode == VOLUME_DOWN) || (keyInfo.keyCode == MUTE)) ) { + LOGINFO("m_isAudioStatusInfoUpdated :%d, m_audioStatusRequestedCount :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d ",_instance->m_isAudioStatusInfoUpdated,_instance->m_audioStatusRequestedCount,_instance->m_audioStatusReceived,_instance->m_audioStatusTimerStarted); 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())) + if ((!(_instance->m_audioStatusDetectionTimer.isActive())) && (_instance->m_audioStatusRequestedCount == 0)) { LOGINFO("Audio status info not updated. Starting the Timer!"); _instance->m_audioStatusTimerStarted = true; @@ -3404,6 +3418,7 @@ namespace WPEFramework } } } + } } }//while(!_instance->m_sendKeyEventThreadExit) @@ -3531,15 +3546,25 @@ namespace WPEFramework { 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; - } + unsigned int retryCount = 1; + do { + usleep(50000); // Sleep for 50ms before retrying + param.portId = -1; // Initialize to an invalid port ID + 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] on retry count[%d]", param.portId, retryCount); + HdmiArcPortID = param.portId; + break; + } + else + { + LOGWARN("IARM_Bus_Call failed with error[%d], retry count[%d]", err, retryCount); + } + } while(retryCount++ <= 6); } void HdmiCecSink::getCecVersion() diff --git a/HdmiCecSink/HdmiCecSink.h b/HdmiCecSink/HdmiCecSink.h index 418fb134..2bc6d7c6 100644 --- a/HdmiCecSink/HdmiCecSink.h +++ b/HdmiCecSink/HdmiCecSink.h @@ -673,6 +673,7 @@ namespace WPEFramework { bool m_isAudioStatusInfoUpdated; bool m_audioStatusReceived; bool m_audioStatusTimerStarted; + int m_audioStatusRequestedCount; std::thread m_sendKeyEventThread; std::mutex m_sendKeyEventMutex; std::queue m_SendKeyQueue; diff --git a/HdmiCecSource/HdmiCecSourceImplementation.h b/HdmiCecSource/HdmiCecSourceImplementation.h index 6239dab5..4a0abbd7 100644 --- a/HdmiCecSource/HdmiCecSourceImplementation.h +++ b/HdmiCecSource/HdmiCecSourceImplementation.h @@ -118,7 +118,7 @@ namespace WPEFramework { std::unique_lock lk; CECDeviceInfo_2() - : m_logicalAddress(0),m_vendorID(0,0,0),m_osdName("NA"), m_isOSDNameUpdated (false), m_isVendorIDUpdated (false) + : m_logicalAddress(0),m_vendorID(0,0,0),m_osdName("NA"), m_deviceInfoStatus(0), m_isOSDNameUpdated (false), m_isVendorIDUpdated (false) { BITMASK_CLEAR(m_deviceInfoStatus, 0xFFFF); //Clear all bits } diff --git a/HdmiInput/CHANGELOG.md b/HdmiInput/CHANGELOG.md deleted file mode 100644 index 3e73c318..00000000 --- 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 b5d667a4..00000000 --- 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 e16bde27..00000000 --- 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 2b918b14..00000000 --- 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 e45efa09..00000000 --- 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 ff93202e..00000000 --- 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 ce759b61..00000000 --- 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 54e672c3..00000000 --- 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 998e3280..00000000 --- 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 926c02e0..00000000 --- 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 bc716bcd..00000000 --- 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/Tests/L1Tests/CMakeLists.txt b/Tests/L1Tests/CMakeLists.txt index 33773882..3d6639c9 100755 --- a/Tests/L1Tests/CMakeLists.txt +++ b/Tests/L1Tests/CMakeLists.txt @@ -19,7 +19,8 @@ cmake_minimum_required(VERSION 3.8) set(PLUGIN_NAME L1TestsIO) set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(${NAMESPACE}Plugins REQUIRED) @@ -27,16 +28,7 @@ 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 ) @@ -114,9 +106,6 @@ set (HDCPPROFILE_INC ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/HdcpProfile 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") @@ -136,19 +125,15 @@ add_plugin_test_ex(PLUGIN_AVINPUT tests/test_AVInput.cpp "${AVINPUT_INC}" "${NAM 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) +set_source_files_properties( + tests/test_HdmiCec2.cpp + tests/test_HdmiCecSource.cpp + tests/test_HdmiCecSink.cpp + PROPERTIES COMPILE_FLAGS "-fexceptions") include_directories(${TEST_INC}) -target_link_directories(${MODULE_NAME} PUBLIC ${CMAKE_INSTALL_PREFIX}/lib/wpeframework/plugins) +target_link_directories(${MODULE_NAME} PUBLIC ${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_INSTALL_PREFIX}/lib/wpeframework/plugins) target_link_libraries(${MODULE_NAME} ${TEST_LIB}) diff --git a/Tests/L1Tests/tests/test_AVInput.cpp b/Tests/L1Tests/tests/test_AVInput.cpp index fae90a90..0d0be6bd 100644 --- a/Tests/L1Tests/tests/test_AVInput.cpp +++ b/Tests/L1Tests/tests/test_AVInput.cpp @@ -21,7 +21,12 @@ #include "AVInput.h" +#include "CompositeInputMock.h" +#include "FactoriesImplementation.h" #include "HdmiInputMock.h" +#include "HostMock.h" +#include "IarmBusMock.h" +#include "ServiceMock.h" #include "ThunderPortability.h" using namespace WPEFramework; @@ -46,13 +51,27 @@ class AVInputTest : public ::testing::Test { class AVInputDsTest : public AVInputTest { protected: - HdmiInputImplMock *p_hdmiInputImplMock = nullptr ; + HdmiInputImplMock* p_hdmiInputImplMock = nullptr; + CompositeInputImplMock* p_compositeInputImplMock = nullptr; + HostImplMock* p_HostImplMock = nullptr; + IARM_EventHandler_t dsAVGameFeatureStatusEventHandler; + IARM_EventHandler_t dsAVEventHandler; + IARM_EventHandler_t dsAVSignalStatusEventHandler; + IARM_EventHandler_t dsAVStatusEventHandler; + IARM_EventHandler_t dsAVVideoModeEventHandler; + IARM_EventHandler_t dsAviContentTypeEventHandler; AVInputDsTest() : AVInputTest() { p_hdmiInputImplMock = new NiceMock ; device::HdmiInput::setImpl(p_hdmiInputImplMock); + + p_compositeInputImplMock = new NiceMock; + device::CompositeInput::setImpl(p_compositeInputImplMock); + + p_HostImplMock = new NiceMock; + device::Host::setImpl(p_HostImplMock); } virtual ~AVInputDsTest() override { @@ -62,16 +81,1799 @@ class AVInputDsTest : public AVInputTest { delete p_hdmiInputImplMock; p_hdmiInputImplMock = nullptr; } + + device::CompositeInput::setImpl(nullptr); + if (p_compositeInputImplMock != nullptr) { + delete p_compositeInputImplMock; + p_compositeInputImplMock = nullptr; + } + + device::Host::setImpl(nullptr); + if (p_HostImplMock != nullptr) { + delete p_HostImplMock; + p_HostImplMock = nullptr; + } } }; -TEST_F(AVInputTest, RegisteredMethods) +class AVInputInit : public AVInputDsTest { +protected: + IarmBusImplMock* p_iarmBusImplMock = nullptr; + NiceMock factoriesImplementation; + PLUGINHOST_DISPATCHER* dispatcher; + NiceMock service; + Core::JSONRPC::Message message; + + AVInputInit() + : AVInputDsTest() + { + p_iarmBusImplMock = new NiceMock; + IarmBus::setImpl(p_iarmBusImplMock); + + 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); + dsAVEventHandler = handler; + } + if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS)) { + EXPECT_TRUE(handler != nullptr); + dsAVStatusEventHandler = handler; + } + if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS)) { + EXPECT_TRUE(handler != nullptr); + dsAVSignalStatusEventHandler = handler; + } + if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE)) { + EXPECT_TRUE(handler != nullptr); + dsAVVideoModeEventHandler = handler; + } + if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS)) { + EXPECT_TRUE(handler != nullptr); + dsAVGameFeatureStatusEventHandler = handler; + } + if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_VRR_STATUS)) { + EXPECT_TRUE(handler != nullptr); + dsAVGameFeatureStatusEventHandler = handler; + } + if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG)) { + EXPECT_TRUE(handler != nullptr); + dsAVEventHandler = handler; + } + if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS)) { + EXPECT_TRUE(handler != nullptr); + dsAVSignalStatusEventHandler = handler; + } + if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_STATUS)) { + EXPECT_TRUE(handler != nullptr); + dsAVStatusEventHandler = handler; + } + if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_VIDEO_MODE_UPDATE)) { + EXPECT_TRUE(handler != nullptr); + dsAVVideoModeEventHandler = handler; + } + if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE)) { + EXPECT_TRUE(handler != nullptr); + dsAviContentTypeEventHandler = handler; + } + return IARM_RESULT_SUCCESS; + })); + EXPECT_EQ(string(""), plugin->Initialize(&service)); + + PluginHost::IFactories::Assign(&factoriesImplementation); + dispatcher = static_cast( + plugin->QueryInterface(PLUGINHOST_DISPATCHER_ID)); + dispatcher->Activate(&service); + } + + virtual ~AVInputInit() override + { + dispatcher->Deactivate(); + dispatcher->Release(); + PluginHost::IFactories::Assign(nullptr); + + plugin->Deinitialize(&service); + + IarmBus::setImpl(nullptr); + if (p_iarmBusImplMock != nullptr) { + delete p_iarmBusImplMock; + p_iarmBusImplMock = 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"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setVRRSupport"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getVRRSupport"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getVRRFrameRate"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getInputDevices"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("writeEDID"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("readEDID"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getRawSPD"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getSPD"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setEdidVersion"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getEdidVersion"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getHdmiVersion"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setMixerLevels"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("startInput"))); + EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("stopInput"))); + 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("getGameFeatureStatus"))); +} + +TEST_F(AVInputInit, getInputDevices) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getNumberOfInputs()) + .WillOnce(::testing::Return(1)); + EXPECT_CALL(*p_compositeInputImplMock, getNumberOfInputs()) + .WillOnce(::testing::Return(1)); + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getInputDevices"), _T("{}"), response)); + EXPECT_EQ(response, string("{\"devices\":[{\"id\":0,\"connected\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\"},{\"id\":0,\"connected\":false,\"locator\":\"cvbsin:\\/\\/localhost\\/deviceid\\/0\"}],\"success\":true}")); +} + +TEST_F(AVInputInit, getInputDevices_HDMI) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getNumberOfInputs()) + .WillOnce(::testing::Return(1)); + EXPECT_CALL(*p_hdmiInputImplMock, isPortConnected(::testing::_)) + .WillOnce(::testing::Return(true)); + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getInputDevices"), _T("{\"typeOfInput\": \"HDMI\"}"), response)); + EXPECT_EQ(response, string("{\"devices\":[{\"id\":0,\"connected\":true,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\"}],\"success\":true}")); +} + +TEST_F(AVInputInit, getInputDevices_COMPOSITE) +{ + EXPECT_CALL(*p_compositeInputImplMock, getNumberOfInputs()) + .WillOnce(::testing::Return(1)); + EXPECT_CALL(*p_compositeInputImplMock, isPortConnected(::testing::_)) + .WillOnce(::testing::Return(true)); + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getInputDevices"), _T("{\"typeOfInput\": \"COMPOSITE\"}"), response)); + EXPECT_EQ(response, string("{\"devices\":[{\"id\":0,\"connected\":true,\"locator\":\"cvbsin:\\/\\/localhost\\/deviceid\\/0\"}],\"success\":true}")); +} + +TEST_F(AVInputInit, getInputDevices_InvalidParameters) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getInputDevices"), _T("{\"typeOfInput\": \"Test\"}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, writeEDID) +{ + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("writeEDID"), _T("{\"portId\": \"1\",\"message\":\"Test\"}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(AVInputInit, writeEDID_InvalidParameters) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("writeEDID"), _T("{}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, readEDID) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getEDIDBytesInfo(::testing::_, ::testing::_)) + .WillOnce([](int port, std::vector& edid) { + EXPECT_EQ(port, 1); + edid = { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("readEDID"), _T("{\"portId\": \"1\"}"), response)); + EXPECT_EQ(response, string("{\"EDID\":\"AP\\/\\/\\/\\/\\/\\/\\/w==\",\"success\":true}")); +} + +TEST_F(AVInputInit, readEDIDFailure) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getEDIDBytesInfo(::testing::_, ::testing::_)) + .WillOnce([](int port, std::vector& edid) { + edid = {}; + }); + + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("readEDID"), _T("{\"portId\": \"1\"}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, readEDID_InvalidParameters) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("readEDID"), _T("{\"portId\": \"test\"}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, getRawSPD) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getHDMISPDInfo(::testing::_, ::testing::_)) + .WillOnce([](int port, std::vector& data) { + data = { 0x53, 0x50, 0x44, 0x00 }; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getRawSPD"), _T("{\"portId\": \"1\"}"), response)); + EXPECT_EQ(response, string("{\"HDMISPD\":\"U1BEAA\",\"success\":true}")); +} + +TEST_F(AVInputInit, getRawSPD_InvalidParameters) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getRawSPD"), _T("{\"portId\": \"test\"}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, getSPD) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getHDMISPDInfo(::testing::_, ::testing::_)) + .WillOnce([](int port, std::vector& data) { + data = { 0x53, 0x50, 0x44, 0x00 }; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getSPD"), _T("{\"portId\": \"1\"}"), response)); + EXPECT_EQ(response, string("{\"HDMISPD\":\"Packet Type:53,Version:80,Length:68,vendor name:wn,product des:,source info:00\",\"success\":true}")); +} + +TEST_F(AVInputInit, getSPD_InvalidParameters) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getSPD"), _T("{\"portId\": \"test\"}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, setEdidVersion) +{ + EXPECT_CALL(*p_hdmiInputImplMock, setEdidVersion(::testing::_, ::testing::_)) + .WillOnce([](int port, int edidVersion) { + EXPECT_EQ(port, 1); + EXPECT_EQ(edidVersion, 0); + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setEdidVersion"), _T("{\"portId\": \"1\", \"edidVersion\":\"HDMI1.4\"}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(AVInputInit, setEdidVersion_InvalidParameters) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setEdidVersion"), _T("{\"portId\": \"test\", \"edidVersion\":\"test\"}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, getEdidVersion1) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getEdidVersion(::testing::_, ::testing::_)) + .WillOnce([](int port, int* edidVersion) { + EXPECT_EQ(port, 0); + *edidVersion = 0; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getEdidVersion"), _T("{\"portId\": \"0\"}"), response)); + EXPECT_EQ(response, string("{\"edidVersion\":\"HDMI1.4\",\"success\":true}")); +} + +TEST_F(AVInputInit, getEdidVersion2) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getEdidVersion(::testing::_, ::testing::_)) + .WillOnce([](int port, int* edidVersion) { + EXPECT_EQ(port, 1); + *edidVersion = 1; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getEdidVersion"), _T("{\"portId\": \"1\"}"), response)); + EXPECT_EQ(response, string("{\"edidVersion\":\"HDMI2.0\",\"success\":true}")); +} + +TEST_F(AVInputInit, getEdidVersion_InvalidParameters) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getEdidVersion"), _T("{\"portId\": \"test\"}}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, getHdmiVersion) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getHdmiVersion(::testing::_, ::testing::_)) + .WillOnce([](int port, dsHdmiMaxCapabilityVersion_t* capVersion) { + if (capVersion) { + *capVersion = HDMI_COMPATIBILITY_VERSION_21; + } + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getHdmiVersion"), _T("{\"portId\": \"1\"}"), response)); + EXPECT_EQ(response, string("{\"HdmiCapabilityVersion\":\"2.1\",\"success\":true}")); +} + +TEST_F(AVInputInit, getHdmiVersion_InvalidParameters) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getHdmiVersion"), _T("{\"portId\": \"test\"}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, setMixerLevels) +{ + EXPECT_CALL(*p_HostImplMock, setAudioMixerLevels(dsAUDIO_INPUT_PRIMARY, ::testing::_)) + .WillOnce([](dsAudioInput_t input, int volume) { + EXPECT_EQ(input, dsAUDIO_INPUT_PRIMARY); + EXPECT_EQ(volume, 50); + }); + + EXPECT_CALL(*p_HostImplMock, setAudioMixerLevels(dsAUDIO_INPUT_SYSTEM, ::testing::_)) + .WillOnce([](dsAudioInput_t input, int volume) { + EXPECT_EQ(input, dsAUDIO_INPUT_SYSTEM); + EXPECT_EQ(volume, 30); + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setMixerLevels"), _T("{\"primaryVolume\": 50 ,\"inputVolume\":30}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(AVInputInit, setMixerLevelsErrorCase) +{ + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setMixerLevels"), _T("{\"primaryVolume\": 110 ,\"inputVolume\":110}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(AVInputInit, startInput_HDMI) +{ + EXPECT_CALL(*p_hdmiInputImplMock, selectPort(::testing::_, ::testing::_, ::testing::_, ::testing::_)) + .WillOnce([](int8_t Port, bool audioMix, int videoPlane, bool topMost) { + EXPECT_EQ(Port, 1); + EXPECT_EQ(audioMix, true); + EXPECT_EQ(videoPlane, 1); + EXPECT_EQ(topMost, true); + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("startInput"), _T("{\"portId\": 1 ,\"typeOfInput\":\"HDMI\", \"requestAudioMix\": true, \"plane\" : 1, \"topMost\" : true}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(AVInputInit, startInput_COMPOSITE) +{ + EXPECT_CALL(*p_compositeInputImplMock, selectPort(::testing::_)) + .WillOnce([](int8_t Port) { + EXPECT_EQ(Port, 2); + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("startInput"), _T("{\"portId\": 2 ,\"typeOfInput\":\"COMPOSITE\", \"requestAudioMix\": true, \"plane\" : 1, \"topMost\" : true}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(AVInputInit, startInput_InvalidParameters) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("startInput"), _T("{\"portId\": \"test\" ,\"typeOfInput\":\"HDMI\", \"requestAudioMix\": true, \"plane\" : 1, \"topMost\" : true}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, stopInput_HDMI) +{ + EXPECT_CALL(*p_hdmiInputImplMock, selectPort(::testing::_, ::testing::_, ::testing::_, ::testing::_)) + .WillOnce([](int8_t Port, bool audioMix, int videoPlane, bool topMost) { + EXPECT_EQ(Port, -1); + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("stopInput"), _T("{\"typeOfInput\":\"HDMI\"}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(AVInputInit, stopInput_COMPOSITE) +{ + EXPECT_CALL(*p_compositeInputImplMock, selectPort(::testing::_)) + .WillOnce([](int8_t Port) { + EXPECT_EQ(Port, -1); + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("stopInput"), _T("{\"typeOfInput\":\"COMPOSITE\"}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(AVInputInit, stopInput_COMPOSITE_InvalidParameters) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("stopInput"), _T("{\"typeOfInput\":\"DP\"}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, setVideoRectangle_HDMI) +{ + EXPECT_CALL(*p_hdmiInputImplMock, scaleVideo(::testing::_, ::testing::_, ::testing::_, ::testing::_)) + .WillOnce([](int32_t x, int32_t y, int32_t width, int32_t height) { + EXPECT_EQ(x, 0); + EXPECT_EQ(y, 0); + EXPECT_EQ(width, 3840); + EXPECT_EQ(height, 2160); + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setVideoRectangle"), _T("{\"x\" : 0, \"y\" : 0, \"w\" : 3840, \"h\" : 2160 ,\"typeOfInput\":\"HDMI\"}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(AVInputInit, setVideoRectangle_COMPOSITE) +{ + EXPECT_CALL(*p_compositeInputImplMock, scaleVideo(::testing::_, ::testing::_, ::testing::_, ::testing::_)) + .WillOnce([](int32_t x, int32_t y, int32_t width, int32_t height) { + EXPECT_EQ(x, 0); + EXPECT_EQ(y, 0); + EXPECT_EQ(width, 720); + EXPECT_EQ(height, 480); + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setVideoRectangle"), _T("{\"x\" : 0, \"y\" : 0, \"w\" : 720, \"h\" : 480 ,\"typeOfInput\":\"COMPOSITE\"}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(AVInputInit, setVideoRectangle_InvalidParameters) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setVideoRectangle"), _T("{\"x\" : 0, \"y\" : 0, \"w\" : 720, \"h\" : 480 ,\"typeOfInput\":\"DP\"}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, getSupportedGameFeatures) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getSupportedGameFeatures(::testing::_)) + .WillOnce([](std::vector& featureList) { + featureList = { "ALLM", "VRR", "QMS" }; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getSupportedGameFeatures"), _T("{}"), response)); + EXPECT_EQ(response, string("{\"supportedGameFeatures\":[\"ALLM\",\"VRR\",\"QMS\"],\"success\":true}")); +} + +TEST_F(AVInputInit, getSupportedGameFeatures_ErrorCase) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getSupportedGameFeatures(::testing::_)) + .WillOnce([](std::vector& featureList) { + featureList = {}; + }); + + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getSupportedGameFeatures"), _T("{}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, getGameFeatureStatus_ALLM) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getHdmiALLMStatus(::testing::_, ::testing::_)) + .WillOnce([](int iHdmiPort, bool* allmStatus) { + EXPECT_EQ(iHdmiPort, 1); + *allmStatus = true; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getGameFeatureStatus"), _T("{\"portId\" : 1, \"gameFeature\" : \"ALLM\"}"), response)); + EXPECT_EQ(response, string("{\"mode\":true,\"success\":true}")); +} + +TEST_F(AVInputInit, getGameFeatureStatus_VRR_HDMI) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getVRRStatus(::testing::_, ::testing::_)) + .WillOnce([](int iHdmiPort, dsHdmiInVrrStatus_t* vrrStatus) { + ASSERT_NE(vrrStatus, nullptr); + vrrStatus->vrrType = dsVRR_HDMI_VRR; + vrrStatus->vrrAmdfreesyncFramerate_Hz = 90.00; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getGameFeatureStatus"), _T("{\"portId\" : 1, \"gameFeature\" : \"VRR-HDMI\"}"), response)); + EXPECT_EQ(response, string("{\"mode\":true,\"success\":true}")); +} + +TEST_F(AVInputInit, getGameFeatureStatus_VRR_FREESYNC) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getVRRStatus(::testing::_, ::testing::_)) + .WillOnce([](int iHdmiPort, dsHdmiInVrrStatus_t* vrrStatus) { + ASSERT_NE(vrrStatus, nullptr); + vrrStatus->vrrType = dsVRR_AMD_FREESYNC; + vrrStatus->vrrAmdfreesyncFramerate_Hz = 100.00; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getGameFeatureStatus"), _T("{\"portId\" : 1, \"gameFeature\" : \"VRR-FREESYNC\"}"), response)); + EXPECT_EQ(response, string("{\"mode\":true,\"success\":true}")); +} + +TEST_F(AVInputInit, getGameFeatureStatus_VRR_FREESYNC_PREMIUM) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getVRRStatus(::testing::_, ::testing::_)) + .WillOnce([](int iHdmiPort, dsHdmiInVrrStatus_t* vrrStatus) { + ASSERT_NE(vrrStatus, nullptr); + vrrStatus->vrrType = dsVRR_AMD_FREESYNC_PREMIUM; + vrrStatus->vrrAmdfreesyncFramerate_Hz = 120.00; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getGameFeatureStatus"), _T("{\"portId\" : 1, \"gameFeature\" : \"VRR-FREESYNC-PREMIUM\"}"), response)); + EXPECT_EQ(response, string("{\"mode\":true,\"success\":true}")); +} + +TEST_F(AVInputInit, getGameFeatureStatus_VRR_FREESYNC_PREMIUM_PRO) +{ + EXPECT_CALL(*p_hdmiInputImplMock, getVRRStatus(::testing::_, ::testing::_)) + .WillOnce([](int iHdmiPort, dsHdmiInVrrStatus_t* vrrStatus) { + ASSERT_NE(vrrStatus, nullptr); + vrrStatus->vrrType = dsVRR_AMD_FREESYNC_PREMIUM_PRO; + vrrStatus->vrrAmdfreesyncFramerate_Hz = 144.00; + }); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getGameFeatureStatus"), _T("{\"portId\" : 1, \"gameFeature\" : \"VRR-FREESYNC-PREMIUM-PRO\"}"), response)); + EXPECT_EQ(response, string("{\"mode\":true,\"success\":true}")); +} + +TEST_F(AVInputInit, getGameFeatureStatus_InvalidParameters) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getGameFeatureStatus"), _T("{\"portId\" : \"test\", \"gameFeature\" : \"VRR-FREESYNC-PREMIUM-PRO\"}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputInit, onDevicesChangedHDMI) +{ + Core::Event onDevicesChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onDevicesChanged\",\"params\":{\"devices\":[]}}"); + + onDevicesChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onDevicesChanged"), _T("org.rdk.AVInput"), message); + + ASSERT_TRUE(dsAVEventHandler != nullptr); + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.hdmi_in_connect.port = dsHDMI_IN_PORT_0; + eventData.data.hdmi_in_connect.isPortConnected = true; + dsAVEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onDevicesChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onDevicesChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onDevicesChangedCOMPOSITE) +{ + Core::Event onDevicesChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onDevicesChanged\",\"params\":{\"devices\":[]}}"); + + onDevicesChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onDevicesChanged"), _T("org.rdk.AVInput"), message); + + ASSERT_TRUE(dsAVEventHandler != nullptr); + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.composite_in_connect.port = dsCOMPOSITE_IN_PORT_0; + eventData.data.composite_in_connect.isPortConnected = true; + dsAVEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onDevicesChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onDevicesChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onSignalChangedStableHDMI) +{ + Core::Event onSignalChanged(false, 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, + "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"stableSignal\"}}"); + + onSignalChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); + + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + 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; + dsAVSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onSignalChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onSignalChangedNoSignalHDMI) +{ + Core::Event onSignalChanged(false, 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, + "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"noSignal\"}}"); + + onSignalChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onSignalChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onSignalChangedUnstableHDMI) +{ + Core::Event onSignalChanged(false, 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, + "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"unstableSignal\"}}"); + + onSignalChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onSignalChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onSignalChangedNotSupportedHDMI) +{ + Core::Event onSignalChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"notSupportedSignal\"}}"); + + onSignalChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onSignalChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onSignalChangedDefaultHDMI) +{ + Core::Event onSignalChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"none\"}}"); + + onSignalChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onSignalChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onSignalChangedStableCOMPOSITE) +{ + Core::Event onSignalChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"cvbsin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"stableSignal\"}}"); + + onSignalChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.composite_in_sig_status.port = dsCOMPOSITE_IN_PORT_0; + eventData.data.composite_in_sig_status.status = dsCOMP_IN_SIGNAL_STATUS_STABLE; + dsAVSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onSignalChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onSignalChangedNoSignalCOMPOSITE) +{ + Core::Event onSignalChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"cvbsin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"noSignal\"}}"); + + onSignalChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.composite_in_sig_status.port = dsCOMPOSITE_IN_PORT_0; + eventData.data.composite_in_sig_status.status = dsCOMP_IN_SIGNAL_STATUS_NOSIGNAL; + dsAVSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onSignalChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onSignalChangedUnstableCOMPOSITE) +{ + Core::Event onSignalChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"cvbsin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"unstableSignal\"}}"); + + onSignalChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.composite_in_sig_status.port = dsCOMPOSITE_IN_PORT_0; + eventData.data.composite_in_sig_status.status = dsCOMP_IN_SIGNAL_STATUS_UNSTABLE; + dsAVSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onSignalChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onSignalChangedNotSupportedCOMPOSITE) +{ + Core::Event onSignalChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"cvbsin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"notSupportedSignal\"}}"); + + onSignalChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.composite_in_sig_status.port = dsCOMPOSITE_IN_PORT_0; + eventData.data.composite_in_sig_status.status = dsCOMP_IN_SIGNAL_STATUS_NOTSUPPORTED; + dsAVSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onSignalChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onSignalChangedDefaultCOMPOSITE) +{ + Core::Event onSignalChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"cvbsin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"none\"}}"); + + onSignalChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.composite_in_sig_status.port = dsCOMPOSITE_IN_PORT_0; + eventData.data.composite_in_sig_status.status = dsCOMP_IN_SIGNAL_STATUS_MAX; + dsAVSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onSignalChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onInputStatusChangeOn_HDMI) +{ + Core::Event onInputStatusChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onInputStatusChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"status\":\"started\",\"plane\":1}}"); + + onInputStatusChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onInputStatusChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("startInput"), _T("{\"portId\": \"0\" , \"typeOfInput\":\"HDMI\", \"requestAudioMix\": true, \"plane\" : 1, \"topMost\" : true}"), 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; + dsAVStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onInputStatusChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onInputStatusChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onInputStatusChangeOff_HDMI) +{ + Core::Event onInputStatusChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onInputStatusChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"status\":\"stopped\",\"plane\":-1}}"); + + onInputStatusChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onInputStatusChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("stopInput"), _T("{\"typeOfInput\":\"HDMI\"}"), 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; + + dsAVStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onInputStatusChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onInputStatusChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onInputStatusChangeOn_COMPOSITE) +{ + Core::Event onInputStatusChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onInputStatusChanged\",\"params\":{\"id\":0,\"locator\":\"cvbsin:\\/\\/localhost\\/deviceid\\/0\",\"status\":\"started\",\"plane\":1}}"); + + onInputStatusChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onInputStatusChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("startInput"), _T("{\"portId\": \"0\" , \"typeOfInput\":\"COMPOSITE\", \"requestAudioMix\": true, \"plane\" : 1, \"topMost\" : true}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.composite_in_status.port = dsCOMPOSITE_IN_PORT_0; + eventData.data.composite_in_status.isPresented = true; + dsAVStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onInputStatusChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onInputStatusChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, onInputStatusChangeOff_COMPOSITE) +{ + Core::Event onInputStatusChanged(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.onInputStatusChanged\",\"params\":{\"id\":0,\"locator\":\"cvbsin:\\/\\/localhost\\/deviceid\\/0\",\"status\":\"stopped\",\"plane\":-1}}"); + + onInputStatusChanged.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("onInputStatusChanged"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("stopInput"), _T("{\"typeOfInput\":\"COMPOSITE\"}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.composite_in_status.port = dsCOMPOSITE_IN_PORT_0; + eventData.data.composite_in_status.isPresented = false; + dsAVStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, onInputStatusChanged.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("onInputStatusChanged"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, hdmiGameFeatureStatusUpdate) +{ + Core::Event gameFeatureStatusUpdate(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.gameFeatureStatusUpdate\",\"params\":{\"id\":0,\"gameFeature\":\"ALLM\",\"mode\":true}}"); + + gameFeatureStatusUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("gameFeatureStatusUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVGameFeatureStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, gameFeatureStatusUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("gameFeatureStatusUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, hdmiGameFeatureStatusUpdate_HDMI_VRR) +{ + Core::Event gameFeatureStatusUpdate(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.gameFeatureStatusUpdate\",\"params\":{\"id\":0,\"gameFeature\":\"VRR-HDMI\",\"mode\":true}}"); + + gameFeatureStatusUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("gameFeatureStatusUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.hdmi_in_vrr_mode.port = dsHDMI_IN_PORT_0; + eventData.data.hdmi_in_vrr_mode.vrr_type = dsVRR_HDMI_VRR; + dsAVGameFeatureStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VRR_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, gameFeatureStatusUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("gameFeatureStatusUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, hdmiGameFeatureStatusUpdate_AMD_FREESYNC) { - 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"))); + Core::Event gameFeatureStatusUpdate(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.gameFeatureStatusUpdate\",\"params\":{\"id\":0,\"gameFeature\":\"VRR-FREESYNC\",\"mode\":true}}"); + + gameFeatureStatusUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("gameFeatureStatusUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.hdmi_in_vrr_mode.port = dsHDMI_IN_PORT_0; + eventData.data.hdmi_in_vrr_mode.vrr_type = dsVRR_AMD_FREESYNC; + dsAVGameFeatureStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VRR_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, gameFeatureStatusUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("gameFeatureStatusUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, hdmiGameFeatureStatusUpdate_AMD_FREESYNC_PREMIUM) +{ + Core::Event gameFeatureStatusUpdate(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.gameFeatureStatusUpdate\",\"params\":{\"id\":0,\"gameFeature\":\"VRR-FREESYNC-PREMIUM\",\"mode\":true}}"); + + gameFeatureStatusUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("gameFeatureStatusUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.hdmi_in_vrr_mode.port = dsHDMI_IN_PORT_0; + eventData.data.hdmi_in_vrr_mode.vrr_type = dsVRR_AMD_FREESYNC_PREMIUM; + dsAVGameFeatureStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VRR_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, gameFeatureStatusUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("gameFeatureStatusUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, hdmiGameFeatureStatusUpdate_AMD_FREESYNC_PREMIUM_PRO) +{ + Core::Event gameFeatureStatusUpdate(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.gameFeatureStatusUpdate\",\"params\":{\"id\":0,\"gameFeature\":\"VRR-FREESYNC-PREMIUM-PRO\",\"mode\":true}}"); + + gameFeatureStatusUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("gameFeatureStatusUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.hdmi_in_vrr_mode.port = dsHDMI_IN_PORT_0; + eventData.data.hdmi_in_vrr_mode.vrr_type = dsVRR_AMD_FREESYNC_PREMIUM_PRO; + dsAVGameFeatureStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VRR_STATUS, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, gameFeatureStatusUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("gameFeatureStatusUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate1_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":1920,\"height\":1080,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":60000,\"frameRateD\":1001}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate2_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":720,\"height\":480,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":24000,\"frameRateD\":1000}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate3_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":720,\"height\":576,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":25000,\"frameRateD\":1000}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate4_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":3840,\"height\":2160,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":30000,\"frameRateD\":1000}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate5_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":4096,\"height\":2160,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":50000,\"frameRateD\":1000}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate6_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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, "{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":4096,\"height\":2160,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":60000,\"frameRateD\":1000}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate7_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":4096,\"height\":2160,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":24000,\"frameRateD\":1001}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate8_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":4096,\"height\":2160,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":30000,\"frameRateD\":1001}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate9_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":1280,\"height\":720,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":30000,\"frameRateD\":1001}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate10_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":1280,\"height\":720,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":100000,\"frameRateD\":1000}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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_100; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate11_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":1280,\"height\":720,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":120000,\"frameRateD\":1001}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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_119dot88; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate12_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":1280,\"height\":720,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":120000,\"frameRateD\":1000}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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_120; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate13_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":1280,\"height\":720,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":200000,\"frameRateD\":1000}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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_200; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate14_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":1280,\"height\":720,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":240000,\"frameRateD\":1001}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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_239dot76; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdate15_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":1280,\"height\":720,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":240000,\"frameRateD\":100}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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_240; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdateDefault_HDMI) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":1920,\"height\":1080,\"progressive\":false,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":60000,\"frameRateD\":1000}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + 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; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + + +TEST_F(AVInputInit, videoStreamInfoUpdate1_COMPOSITE) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":720,\"height\":480,\"progressive\":false,\"locator\":\"cvbsin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":24000,\"frameRateD\":1000}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.composite_in_video_mode.port = dsCOMPOSITE_IN_PORT_0; + eventData.data.composite_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_720x480; + eventData.data.composite_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_24; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + + +TEST_F(AVInputInit, videoStreamInfoUpdate2_COMPOSITE) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":720,\"height\":576,\"progressive\":false,\"locator\":\"cvbsin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":25000,\"frameRateD\":1000}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.composite_in_video_mode.port = dsCOMPOSITE_IN_PORT_0; + eventData.data.composite_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_720x576; + eventData.data.composite_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_25; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, videoStreamInfoUpdateDefault_COMPOSITE) +{ + Core::Event videoStreamInfoUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"width\":720,\"height\":576,\"progressive\":false,\"locator\":\"cvbsin:\\/\\/localhost\\/deviceid\\/0\",\"frameRateN\":60000,\"frameRateD\":1000}}"); + + videoStreamInfoUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.composite_in_video_mode.port = dsCOMPOSITE_IN_PORT_0; + eventData.data.composite_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_MAX; + eventData.data.composite_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_MAX; + dsAVVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_VIDEO_MODE_UPDATE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, videoStreamInfoUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("org.rdk.AVInput"), message); +} + +TEST_F(AVInputInit, aviContentTypeUpdate_HDMI) +{ + Core::Event aviContentTypeUpdate(false, 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,"{\"jsonrpc\":\"2.0\",\"method\":\"org.rdk.AVInput.aviContentTypeUpdate\",\"params\":{\"id\":0,\"aviContentType\":0}}"); + + aviContentTypeUpdate.SetEvent(); + + return Core::ERROR_NONE; + })); + + EVENT_SUBSCRIBE(0, _T("aviContentTypeUpdate"), _T("org.rdk.AVInput"), message); + ASSERT_TRUE(dsAVSignalStatusEventHandler != nullptr); + + IARM_Bus_DSMgr_EventData_t eventData; + eventData.data.hdmi_in_content_type.port = dsHDMI_IN_PORT_0; + eventData.data.hdmi_in_content_type.aviContentType = dsAVICONTENT_TYPE_GRAPHICS; + dsAviContentTypeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE, &eventData, 0); + + EXPECT_EQ(Core::ERROR_NONE, aviContentTypeUpdate.Lock()); + + EVENT_UNSUBSCRIBE(0, _T("aviContentTypeUpdate"), _T("org.rdk.AVInput"), message); } TEST_F(AVInputTest, contentProtected) @@ -104,6 +1906,11 @@ TEST_F(AVInputDsTest, getEdid2AllmSupport) EXPECT_EQ(response, string("{\"allmSupport\":true,\"success\":true}")); } +TEST_F(AVInputDsTest, getEdid2AllmSupport_ErrorCase) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getEdid2AllmSupport"), _T("{\"portId\": \"test\",\"allmSupport\":true}"), response)); + EXPECT_EQ(response, string("")); +} TEST_F(AVInputDsTest, setEdid2AllmSupport) { @@ -111,3 +1918,44 @@ TEST_F(AVInputDsTest, setEdid2AllmSupport) EXPECT_EQ(response, string("{\"success\":true}")); } +TEST_F(AVInputDsTest, setEdid2AllmSupport_ErrorCase) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setEdid2AllmSupport"), _T("{\"portId\": \"test\",\"allmSupport\":true}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputDsTest, getVRRSupport) +{ + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getVRRSupport"), _T("{\"portId\": \"0\",\"vrrSupport\":true}"), response)); + EXPECT_EQ(response, string("{\"vrrSupport\":true,\"success\":true}")); +} + +TEST_F(AVInputDsTest, getVRRSupport_ErrorCase) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getVRRSupport"), _T("{\"portId\": \"test\",\"vrrSupport\":true}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputDsTest, setVRRSupport) +{ + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setVRRSupport"), _T("{\"portId\": \"0\",\"vrrSupport\":true}"), response)); + EXPECT_EQ(response, string("{\"success\":true}")); +} + +TEST_F(AVInputDsTest, setVRRSupport_ErrorCase) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setVRRSupport"), _T("{\"portId\": \"test\",\"vrrSupport\":true}"), response)); + EXPECT_EQ(response, string("")); +} + +TEST_F(AVInputDsTest, getVRRFrameRate) +{ + EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getVRRFrameRate"), _T("{\"portId\": \"0\"}"), response)); + EXPECT_EQ(response, string("{\"currentVRRVideoFrameRate\":0,\"success\":true}")); +} + +TEST_F(AVInputDsTest, getVRRFrameRate_ErrorCase) +{ + EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getVRRFrameRate"), _T("{\"portId\": \"test\"}"), response)); + EXPECT_EQ(response, string("")); +} diff --git a/Tests/L1Tests/tests/test_HdcpProfile.cpp b/Tests/L1Tests/tests/test_HdcpProfile.cpp index f0f6a06f..c474adea 100755 --- a/Tests/L1Tests/tests/test_HdcpProfile.cpp +++ b/Tests/L1Tests/tests/test_HdcpProfile.cpp @@ -378,6 +378,7 @@ TEST_F(HDCPProfileDsTest, getSettopHDCPSupport_Hdcp_v2x) "\\}"))); } + TEST_F(HDCPProfileEventIarmTest, onDisplayConnectionChanged) { ASSERT_TRUE(dsHdmiEventHandler != nullptr); diff --git a/Tests/L1Tests/tests/test_HdmiCecSink.cpp b/Tests/L1Tests/tests/test_HdmiCecSink.cpp index 2f570df1..22df165c 100755 --- a/Tests/L1Tests/tests/test_HdmiCecSink.cpp +++ b/Tests/L1Tests/tests/test_HdmiCecSink.cpp @@ -22,6 +22,7 @@ #include #include + #include "HdmiCecSink.h" #include "FactoriesImplementation.h" #include "IarmBusMock.h" diff --git a/Tests/L1Tests/tests/test_HdmiInput.cpp b/Tests/L1Tests/tests/test_HdmiInput.cpp deleted file mode 100644 index 9b0b1f66..00000000 --- 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/L2Tests/CMakeLists.txt b/Tests/L2Tests/CMakeLists.txt index 7e852330..a142f79e 100755 --- a/Tests/L2Tests/CMakeLists.txt +++ b/Tests/L2Tests/CMakeLists.txt @@ -19,16 +19,10 @@ 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) +set(SRC_FILES tests/test_foo_IN.cpp) if(PLUGIN_AVOUTPUT) set(SRC_FILES ${SRC_FILES} tests/AVOutputTV_L2Test.cpp) @@ -37,7 +31,7 @@ endif() add_library(${MODULE_NAME} SHARED ${SRC_FILES}) set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 + CXX_STANDARD 14 CXX_STANDARD_REQUIRED YES) target_compile_definitions(${MODULE_NAME} @@ -45,8 +39,8 @@ target_compile_definitions(${MODULE_NAME} 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) +# target_compile_options(${MODULE_NAME} PRIVATE -Wno-error) +target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins) if (NOT L2_TEST_OOP_RPC) find_library(TESTMOCKLIB_LIBRARIES NAMES TestMocklib) @@ -78,8 +72,3 @@ target_include_directories( ) install(TARGETS ${MODULE_NAME} DESTINATION lib) - -write_config(${PLUGIN_NAME}) - - - diff --git a/Tests/L2Tests/tests/test_foo_IN.cpp b/Tests/L2Tests/tests/test_foo_IN.cpp new file mode 100755 index 00000000..9ce95a52 --- /dev/null +++ b/Tests/L2Tests/tests/test_foo_IN.cpp @@ -0,0 +1,10 @@ +#include +#include + +class PrintTestIO : public ::testing::Test { +}; + +// Single test with print statement +TEST_F(PrintTestIO, BasicOutputIO) { + std::cout << "this is a print statement from inputoutput" << std::endl; +} \ No newline at end of file diff --git a/Tests/README.md b/Tests/README.md index 4b6eb4ac..48e14c27 100644 --- a/Tests/README.md +++ b/Tests/README.md @@ -6,30 +6,20 @@ Hence, any modifications/additions related to mocks should be commited to entser # 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 +example: git clone https://github.com/rdkcentral/entservices-deviceanddisplay.git 2. switch to entservices- directory -example: cd entservices-testframework +example: cd entservices-deviceanddisplay 3. check and ensure current working branch points to develop example: git branch @@ -37,18 +27,33 @@ 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. Run L1, L2, L2-oop test +example: ./bin/act -W .github/workflows/tests-trigger.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= +NOTE: By default test-trigger.yml will trigger all tests(L1, L2 and etc) parallely, if you want any one test alone to be triggered/verified then remove the other trigger rules from the tests-trigger.yml +``` +# testframework Repo Handling +tf-trigger.yml file of testframework repo will get loaded into github action whenever there is a pull or push happens. This file in-turn triggers all individual repos L1, L2, L2-oop tests. testframework repo test can run only in github workflow. -NOTES: -a/ If you face any secret token related error while run your yml, pls comment the below mentioned line +NOTE: +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 + +# Execution usecases where manual change required before triggering the test: +``` +a/ changes in testframework repo only: +Need to change ref pointer of "Checkout entservices-testframework" job in individual repo yml file, to point your current working branch of testframework and in tftrigger.yml of testframework repo need to change trigger branch name to your individual repo branch name instead of develop which is default. +example: +ref: topic/method_1 /* Checkout entservices-testframework job */ +uses: rdkcentral/entservices-deviceanddisplay/.github/workflows/L1-tests.yml@topic/method_1 /* tf-trigger.yml */ + +b/ changes in both testframework repo and invidual repo: +Changes mentioned in step (a) above + "Checkout entservices-deviceanddisplay-testframework" job in individual repo yml file, ref field to point your deviceanddisplay current working branch. +example: +ref: topic/method_1 /* Checkout entservices-testframework job */ +ref: topic/method_1 /* Checkout entservices-deviceanddisplay-testframework job */ +uses: rdkcentral/entservices-deviceanddisplay/.github/workflows/L1-tests.yml@topic/method_1 /* tf-trigger.yml */ + +c/ changes in individual entservices-* repo only +no changes required +``` diff --git a/build_dependencies.sh b/build_dependencies.sh index 92d10f7f..2ba9a85d 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 @@ -162,6 +162,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/cov_build.sh b/cov_build.sh index bde2bce8..66632fce 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -37,6 +37,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 index a10ad6a6..fdfc5edb 100755 --- a/helpers/PluginInterfaceBuilder.h +++ b/helpers/PluginInterfaceBuilder.h @@ -113,7 +113,6 @@ namespace Plugin { auto pluginInterface = controller->QueryInterfaceByCallsign(callsign.c_str()); if (pluginInterface) { - pluginInterface->AddRef(); LOGINFO("plugin interface succeed and retry count: %d",count); return pluginInterface; }