diff --git a/examples/tv-app/android/java/MediaPlaybackManager.cpp b/examples/tv-app/android/java/MediaPlaybackManager.cpp index 1c5fac5c2522ba..78b0bd308c6796 100644 --- a/examples/tv-app/android/java/MediaPlaybackManager.cpp +++ b/examples/tv-app/android/java/MediaPlaybackManager.cpp @@ -75,8 +75,8 @@ uint64_t MediaPlaybackManager::HandleGetDuration() float MediaPlaybackManager::HandleGetPlaybackSpeed() { - uint64_t ret = HandleMediaRequestGetAttribute(MEDIA_PLAYBACK_ATTRIBUTE_SPEED); - return static_cast(ret) / 10000.0f; + long ret = HandleMediaRequestGetLongAttribute(MEDIA_PLAYBACK_ATTRIBUTE_SPEED); + return static_cast(ret); } uint64_t MediaPlaybackManager::HandleGetSeekRangeStart() @@ -220,6 +220,38 @@ uint64_t MediaPlaybackManager::HandleMediaRequestGetAttribute(MediaPlaybackReque return ret; } +long MediaPlaybackManager::HandleMediaRequestGetLongAttribute(MediaPlaybackRequestAttribute attribute) +{ + long ret = 0; + jlong jAttributeValue = -1; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + + ChipLogProgress(Zcl, "Received MediaPlaybackManager::HandleMediaRequestGetLongAttribute:%d", attribute); + VerifyOrExit(mMediaPlaybackManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mGetAttributeMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); + + jAttributeValue = env->CallLongMethod(mMediaPlaybackManagerObject, mGetAttributeMethod, static_cast(attribute)); + if (env->ExceptionCheck()) + { + ChipLogError(AppServer, "Java exception in MediaPlaybackManager::GetAttribute"); + env->ExceptionDescribe(); + env->ExceptionClear(); + goto exit; + } + + ret = static_cast(jAttributeValue); + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "MediaPlaybackManager::GetAttribute status error: %s", err.AsString()); + } + + return ret; +} + Commands::PlaybackResponse::Type MediaPlaybackManager::HandleMediaRequest(MediaPlaybackRequest mediaPlaybackRequest, uint64_t deltaPositionMilliseconds) @@ -287,8 +319,8 @@ CHIP_ERROR MediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncoder jclass inputClass = env->GetObjectClass(positionObj); jfieldID positionId = env->GetFieldID(inputClass, "position", "J"); jfieldID updatedAtId = env->GetFieldID(inputClass, "updatedAt", "J"); - response.position = Nullable(static_cast(env->GetIntField(positionObj, positionId))); - response.updatedAt = static_cast(env->GetIntField(positionObj, updatedAtId)); + response.position = Nullable(static_cast(env->GetLongField(positionObj, positionId))); + response.updatedAt = static_cast(env->GetLongField(positionObj, updatedAtId)); } exit: diff --git a/examples/tv-app/android/java/MediaPlaybackManager.h b/examples/tv-app/android/java/MediaPlaybackManager.h index 822fcf55fafd55..e704963b84d391 100644 --- a/examples/tv-app/android/java/MediaPlaybackManager.h +++ b/examples/tv-app/android/java/MediaPlaybackManager.h @@ -90,6 +90,7 @@ class MediaPlaybackManager : public MediaPlaybackDelegate jmethodID mGetPositionMethod = nullptr; uint64_t HandleMediaRequestGetAttribute(MediaPlaybackRequestAttribute attribute); + long HandleMediaRequestGetLongAttribute(MediaPlaybackRequestAttribute attribute); chip::app::Clusters::MediaPlayback::Commands::PlaybackResponse::Type HandleMediaRequest(MediaPlaybackRequest mediaPlaybackRequest, uint64_t deltaPositionMilliseconds); diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ContentLaunchManagerStub.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ContentLaunchManagerStub.java index 4bdee5ed2bfee1..e8179b4a63e3de 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ContentLaunchManagerStub.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ContentLaunchManagerStub.java @@ -58,12 +58,17 @@ public ContentLaunchResponse launchContent( Log.d(TAG, "launchContent:" + data + " autoplay=" + autoplay + " at " + endpoint); boolean found = false; - for (ContentLaunchEntry entry : entries) { - for (ContentLaunchSearchParameter parameter : entry.parameters) { - for (ContentLaunchSearchParameter query : search) { - if (query.type == parameter.type && query.data.equals(parameter.data)) { - Log.d(TAG, " TEST CASE found match=" + entry.name); - found = true; + if ((entries != null) && (search != null)) { + for (ContentLaunchEntry entry : entries) { + if (entry.parameters == null) { + continue; + } + for (ContentLaunchSearchParameter parameter : entry.parameters) { + for (ContentLaunchSearchParameter query : search) { + if (query.type == parameter.type && query.data.equals(parameter.data)) { + Log.d(TAG, " TEST CASE found match=" + entry.name); + found = true; + } } } } diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaPlaybackManagerStub.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaPlaybackManagerStub.java index 85d2f90c0031de..062e83008677e0 100755 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaPlaybackManagerStub.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaPlaybackManagerStub.java @@ -55,15 +55,19 @@ public long getAttributes(int attributesId) { return playbackDuration; case ATTRIBUTE_PLAYBACK_SPEED: - Log.d(TAG, "getAttributes SampledPosition PlaybackSpeed at " + endpoint); + Log.d( + TAG, + "getAttributes SampledPosition PlaybackSpeed " + playbackSpeed + " at " + endpoint); return playbackSpeed; case ATTRIBUTE_PLAYBACK_SEEK_RANGE_END: - Log.d(TAG, "getAttributes SampledPosition SeekRangeEnd at " + endpoint); + Log.d( + TAG, + "getAttributes SampledPosition SeekRangeEnd " + playbackDuration + " at " + endpoint); return playbackDuration; case ATTRIBUTE_PLAYBACK_SEEK_RANGE_START: - Log.d(TAG, "getAttributes SampledPosition SeekRangeStart at " + endpoint); + Log.d(TAG, "getAttributes SampledPosition SeekRangeStart " + startTime + " at " + endpoint); return startTime; } @@ -124,7 +128,7 @@ public int request(int cmd, long parameter) { } playbackState = PLAYBACK_STATE_PLAYING; playbackSpeed = - (playbackSpeed >= 0 ? -1 : Math.min(playbackSpeed * 2, playbackMaxRewindSpeed)); + (playbackSpeed >= 0 ? -1 : Math.max(playbackSpeed * 2, playbackMaxRewindSpeed)); return RESPONSE_STATUS_SUCCESS; @@ -135,7 +139,7 @@ public int request(int cmd, long parameter) { } playbackState = PLAYBACK_STATE_PLAYING; playbackSpeed = - (playbackSpeed <= 0 ? 1 : Math.max(playbackSpeed * 2, playbackMaxForwardSpeed)); + (playbackSpeed <= 0 ? 1 : Math.min(playbackSpeed * 2, playbackMaxForwardSpeed)); return RESPONSE_STATUS_SUCCESS; @@ -176,6 +180,7 @@ public int request(int cmd, long parameter) { @Override public MediaPlaybackPosition getPosition() { + Log.d(TAG, "getPosition " + playbackPosition); return new MediaPlaybackPosition(playbackPosition); } }