diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CertTestFragment.java b/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CertTestFragment.java index 3f7d05197a9f04..7540c3a3f8b6c1 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CertTestFragment.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CertTestFragment.java @@ -15,6 +15,8 @@ import com.chip.casting.FailureCallback; import com.chip.casting.MatterCallbackHandler; import com.chip.casting.MatterError; +import com.chip.casting.MediaPlaybackTypes; +import com.chip.casting.SubscriptionEstablishedCallback; import com.chip.casting.SuccessCallback; import com.chip.casting.TvCastingApp; import java.util.ArrayList; @@ -197,6 +199,46 @@ private void runCertTests(Activity activity) { tvCastingApp.mediaPlayback_stopPlayback(kContentApp, callback); }); + runAndWait( + "mediaPlayback_previous", + successFailureCallback, + () -> { + // 3.8.5. [TC-MEDIAPLAYBACK-6.5] Mandatory Media Playback Verification (DUT as Client) + tvCastingApp.mediaPlayback_previous(kContentApp, callback); + }); + + runAndWait( + "mediaPlayback_rewind", + successFailureCallback, + () -> { + // 3.8.5. [TC-MEDIAPLAYBACK-6.5] Mandatory Media Playback Verification (DUT as Client) + tvCastingApp.mediaPlayback_rewind(kContentApp, callback); + }); + + runAndWait( + "mediaPlayback_fastForward", + successFailureCallback, + () -> { + // 3.8.5. [TC-MEDIAPLAYBACK-6.5] Mandatory Media Playback Verification (DUT as Client) + tvCastingApp.mediaPlayback_fastForward(kContentApp, callback); + }); + + runAndWait( + "mediaPlayback_startOver", + successFailureCallback, + () -> { + // 3.8.5. [TC-MEDIAPLAYBACK-6.5] Mandatory Media Playback Verification (DUT as Client) + tvCastingApp.mediaPlayback_startOver(kContentApp, callback); + }); + + runAndWait( + "mediaPlayback_seek", + successFailureCallback, + () -> { + // 3.8.5. [TC-MEDIAPLAYBACK-6.5] Mandatory Media Playback Verification (DUT as Client) + tvCastingApp.mediaPlayback_seek(kContentApp, 10000, callback); + }); + // Additional Tests // Mandatory // OnOff cluster @@ -262,6 +304,45 @@ private void runCertTests(Activity activity) { kContentApp, successFailureCallbackInteger, successFailureCallbackInteger); }); + runAndWait( + "mediaPlayback_subscribeToCurrentState", + successFailureCallback, + () -> { + tvCastingApp.mediaPlayback_subscribeToCurrentState( + kContentApp, + new SuccessCallback() { + @Override + public void handle(MediaPlaybackTypes.PlaybackStateEnum response) { + // Lets wait for the timeout to avoid the race condition issue in the SDK with + // ReadClient::Close() + // successFailureCallback.handle(MatterError.NO_ERROR); + addCertTestStatus( + activity, MatterError.NO_ERROR, "mediaPlayback_subscribeToCurrentState"); + } + }, + successFailureCallback, + 0, + 20, + new SubscriptionEstablishedCallback() { + @Override + public void handle() { + // Lets wait for the timeout to avoid the race condition issue in the SDK with + // ReadClient::Close() + // successFailureCallback.handle(MatterError.NO_ERROR); + addCertTestStatus( + activity, MatterError.NO_ERROR, "mediaPlayback_subscribeToCurrentState"); + } + }); + }); + + runAndWait( + "shutdownAllSubscriptions", + successFailureCallback, + () -> { + tvCastingApp.shutdownAllSubscriptions(); + successFailureCallback.handle(MatterError.NO_ERROR); + }); + // Unsupported & Optional // 3.2.2. [TC-LOWPOWER-2.2] Low Power Mode Verification (DUT as Client) // 3.5.5. [TC-MEDIAINPUT-3.14] Select Input Verification (DUT as Client) @@ -304,7 +385,7 @@ private void runAndWait( callback.setCountDownLatch(cdl); runnable.run(); try { - if (!cdl.await(10, TimeUnit.SECONDS)) { + if (!cdl.await(5, TimeUnit.SECONDS)) { Log.d(TAG, "Timed out for test to finish : " + testMethod); } } catch (InterruptedException e) { diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java index 68b98fc72feb03..43e7860e6b0527 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java @@ -249,6 +249,14 @@ public native boolean levelControl_subscribeToMaxLevel( public native boolean mediaPlayback_next(ContentApp contentApp, Object responseHandler); + public native boolean mediaPlayback_previous(ContentApp contentApp, Object responseHandler); + + public native boolean mediaPlayback_rewind(ContentApp contentApp, Object responseHandler); + + public native boolean mediaPlayback_fastForward(ContentApp contentApp, Object responseHandler); + + public native boolean mediaPlayback_startOver(ContentApp contentApp, Object responseHandler); + public native boolean mediaPlayback_seek( ContentApp contentApp, long position, Object responseHandler); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/Constants.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/Constants.h index 293e6683f4509b..b1947541c9c9b7 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/Constants.h +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/Constants.h @@ -30,6 +30,10 @@ enum MediaCommandName MediaPlayback_Pause, MediaPlayback_StopPlayback, MediaPlayback_Next, + MediaPlayback_Previous, + MediaPlayback_Rewind, + MediaPlayback_FastForward, + MediaPlayback_StartOver, MediaPlayback_Seek, MediaPlayback_SkipForward, MediaPlayback_SkipBackward, diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp index bb502078b501a5..b6eb30b142d4d6 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp @@ -944,6 +944,80 @@ JNI_METHOD(jboolean, mediaPlayback_1skipBackward) return (err == CHIP_NO_ERROR); } +JNI_METHOD(jboolean, mediaPlayback_1previous) +(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) +{ + return TvCastingAppJNIMgr().runCastingServerCommand( + env, contentApp, jResponseHandler, "MediaPlayback_Previous", MediaPlayback_Previous, + [](TargetEndpointInfo endpoint) -> CHIP_ERROR { + return CastingServer::GetInstance()->MediaPlayback_Previous(&endpoint, [](CHIP_ERROR err) { + TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_Previous).Handle(err); + }); + }); +} + +JNI_METHOD(jboolean, mediaPlayback_1rewind) +(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) +{ + return TvCastingAppJNIMgr().runCastingServerCommand( + env, contentApp, jResponseHandler, "MediaPlayback_Rewind", MediaPlayback_Rewind, + [](TargetEndpointInfo endpoint) -> CHIP_ERROR { + return CastingServer::GetInstance()->MediaPlayback_Rewind(&endpoint, [](CHIP_ERROR err) { + TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_Rewind).Handle(err); + }); + }); +} + +JNI_METHOD(jboolean, mediaPlayback_1fastForward) +(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) +{ + return TvCastingAppJNIMgr().runCastingServerCommand( + env, contentApp, jResponseHandler, "MediaPlayback_FastForward", MediaPlayback_FastForward, + [](TargetEndpointInfo endpoint) -> CHIP_ERROR { + return CastingServer::GetInstance()->MediaPlayback_FastForward(&endpoint, [](CHIP_ERROR err) { + TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_FastForward).Handle(err); + }); + }); +} + +JNI_METHOD(jboolean, mediaPlayback_1startOver) +(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) +{ + return TvCastingAppJNIMgr().runCastingServerCommand( + env, contentApp, jResponseHandler, "MediaPlayback_StartOver", MediaPlayback_StartOver, + [](TargetEndpointInfo endpoint) -> CHIP_ERROR { + return CastingServer::GetInstance()->MediaPlayback_StartOver(&endpoint, [](CHIP_ERROR err) { + TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_StartOver).Handle(err); + }); + }); +} + +jboolean TvCastingAppJNI::runCastingServerCommand(JNIEnv * env, jobject contentApp, jobject jResponseHandler, + const char * commandName, MediaCommandName command, + const std::function & commandRunner) +{ + chip::DeviceLayer::StackLock lock; + + ChipLogProgress(AppServer, "JNI_METHOD %s called", commandName); + + TargetEndpointInfo endpoint; + CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); + VerifyOrExit(err == CHIP_NO_ERROR, + ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, + err.Format())); + + err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(command).SetUp(env, jResponseHandler); + VerifyOrExit(CHIP_NO_ERROR == err, + ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); + + err = commandRunner(endpoint); + VerifyOrExit(CHIP_NO_ERROR == err, + ChipLogError(AppServer, "CastingServer.%s failed %" CHIP_ERROR_FORMAT, commandName, err.Format())); + +exit: + return (err == CHIP_NO_ERROR); +} + JNI_METHOD(jboolean, mediaPlayback_1subscribeToCurrentState) (JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, jint maxInterval, jobject jSubscriptionEstablishedHandler) diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.h index 7d2b384b3718ae..d77f3a7eac8cce 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.h +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.h @@ -91,6 +91,9 @@ class TvCastingAppJNI return mReadApplicationVersionSuccessHandlerJNI; } + jboolean runCastingServerCommand(JNIEnv * env, jobject contentApp, jobject jResponseHandler, const char * commandName, + MediaCommandName command, const std::function & commandRunner); + private: friend TvCastingAppJNI & TvCastingAppJNIMgr(); diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.h index 1dc7e3417b949c..b306e39072d617 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.h @@ -482,6 +482,70 @@ clientQueue:(dispatch_queue_t _Nonnull)clientQueue requestSentHandler:(void (^_Nonnull)(bool))requestSentHandler; +/*! + @brief Send a MediaPlayback:Previous request to a TV + + @param contentApp Content app endpoint to target + + @param responseCallback Callback for when the response has been received + + @param clientQueue Queue to invoke callbacks on + + @param requestSentHandler Handler to call on sending the request + */ +- (void)mediaPlayback_previous:(ContentApp * _Nonnull)contentApp + responseCallback:(void (^_Nonnull)(bool))responseCallback + clientQueue:(dispatch_queue_t _Nonnull)clientQueue + requestSentHandler:(void (^_Nonnull)(bool))requestSentHandler; + +/*! + @brief Send a MediaPlayback:FastForward request to a TV + + @param contentApp Content app endpoint to target + + @param responseCallback Callback for when the response has been received + + @param clientQueue Queue to invoke callbacks on + + @param requestSentHandler Handler to call on sending the request + */ +- (void)mediaPlayback_fastForward:(ContentApp * _Nonnull)contentApp + responseCallback:(void (^_Nonnull)(bool))responseCallback + clientQueue:(dispatch_queue_t _Nonnull)clientQueue + requestSentHandler:(void (^_Nonnull)(bool))requestSentHandler; + +/*! + @brief Send a MediaPlayback:Rewind request to a TV + + @param contentApp Content app endpoint to target + + @param responseCallback Callback for when the response has been received + + @param clientQueue Queue to invoke callbacks on + + @param requestSentHandler Handler to call on sending the request + */ +- (void)mediaPlayback_rewind:(ContentApp * _Nonnull)contentApp + responseCallback:(void (^_Nonnull)(bool))responseCallback + clientQueue:(dispatch_queue_t _Nonnull)clientQueue + requestSentHandler:(void (^_Nonnull)(bool))requestSentHandler; + +/*! + @brief Send a MediaPlayback:StartOver request to a TV + + @param contentApp Content app endpoint to target + + @param responseCallback Callback for when the response has been received + + @param clientQueue Queue to invoke callbacks on + + @param requestSentHandler Handler to call on sending the request + */ +- (void)mediaPlayback_startOver:(ContentApp * _Nonnull)contentApp + responseCallback:(void (^_Nonnull)(bool))responseCallback + clientQueue:(dispatch_queue_t _Nonnull)clientQueue + requestSentHandler:(void (^_Nonnull)(bool))requestSentHandler; + /*! @brief Send a MediaPlayback:Seek request to a TV diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm index cb73255f4e7252..9d37390b084023 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm @@ -1166,6 +1166,102 @@ - (void)mediaPlayback_skipBackward:(ContentApp * _Nonnull)contentApp }); } +- (void)mediaPlayback_previous:(ContentApp * _Nonnull)contentApp + responseCallback:(void (^_Nonnull)(bool))responseCallback + clientQueue:(dispatch_queue_t _Nonnull)clientQueue + requestSentHandler:(void (^_Nonnull)(bool))requestSentHandler +{ + ChipLogProgress(AppServer, "CastingServerBridge().mediaPlayback_previous() called on Content App with endpoint ID %d", + contentApp.endpointId); + + [_commandResponseCallbacks setObject:responseCallback forKey:@"mediaPlayback_previous"]; + dispatch_async(_chipWorkQueue, ^{ + TargetEndpointInfo endpoint; + [ConversionUtils convertToCppTargetEndpointInfoFrom:contentApp outTargetEndpointInfo:endpoint]; + + CHIP_ERROR err = CastingServer::GetInstance()->MediaPlayback_Previous(&endpoint, [](CHIP_ERROR err) { + void (^responseCallback)(bool) = + [[CastingServerBridge getSharedInstance].commandResponseCallbacks objectForKey:@"mediaPlayback_previous"]; + responseCallback(CHIP_NO_ERROR == err); + }); + dispatch_async(clientQueue, ^{ + requestSentHandler(CHIP_NO_ERROR == err); + }); + }); +} + +- (void)mediaPlayback_rewind:(ContentApp * _Nonnull)contentApp + responseCallback:(void (^_Nonnull)(bool))responseCallback + clientQueue:(dispatch_queue_t _Nonnull)clientQueue + requestSentHandler:(void (^_Nonnull)(bool))requestSentHandler +{ + ChipLogProgress( + AppServer, "CastingServerBridge().mediaPlayback_rewind() called on Content App with endpoint ID %d", contentApp.endpointId); + + [_commandResponseCallbacks setObject:responseCallback forKey:@"mediaPlayback_rewind"]; + dispatch_async(_chipWorkQueue, ^{ + TargetEndpointInfo endpoint; + [ConversionUtils convertToCppTargetEndpointInfoFrom:contentApp outTargetEndpointInfo:endpoint]; + + CHIP_ERROR err = CastingServer::GetInstance()->MediaPlayback_Rewind(&endpoint, [](CHIP_ERROR err) { + void (^responseCallback)(bool) = + [[CastingServerBridge getSharedInstance].commandResponseCallbacks objectForKey:@"mediaPlayback_rewind"]; + responseCallback(CHIP_NO_ERROR == err); + }); + dispatch_async(clientQueue, ^{ + requestSentHandler(CHIP_NO_ERROR == err); + }); + }); +} + +- (void)mediaPlayback_fastForward:(ContentApp * _Nonnull)contentApp + responseCallback:(void (^_Nonnull)(bool))responseCallback + clientQueue:(dispatch_queue_t _Nonnull)clientQueue + requestSentHandler:(void (^_Nonnull)(bool))requestSentHandler +{ + ChipLogProgress(AppServer, "CastingServerBridge().mediaPlayback_fastForward() called on Content App with endpoint ID %d", + contentApp.endpointId); + + [_commandResponseCallbacks setObject:responseCallback forKey:@"mediaPlayback_fastForward"]; + dispatch_async(_chipWorkQueue, ^{ + TargetEndpointInfo endpoint; + [ConversionUtils convertToCppTargetEndpointInfoFrom:contentApp outTargetEndpointInfo:endpoint]; + + CHIP_ERROR err = CastingServer::GetInstance()->MediaPlayback_FastForward(&endpoint, [](CHIP_ERROR err) { + void (^responseCallback)(bool) = + [[CastingServerBridge getSharedInstance].commandResponseCallbacks objectForKey:@"mediaPlayback_fastForward"]; + responseCallback(CHIP_NO_ERROR == err); + }); + dispatch_async(clientQueue, ^{ + requestSentHandler(CHIP_NO_ERROR == err); + }); + }); +} + +- (void)mediaPlayback_startOver:(ContentApp * _Nonnull)contentApp + responseCallback:(void (^_Nonnull)(bool))responseCallback + clientQueue:(dispatch_queue_t _Nonnull)clientQueue + requestSentHandler:(void (^_Nonnull)(bool))requestSentHandler +{ + ChipLogProgress(AppServer, "CastingServerBridge().mediaPlayback_startOver() called on Content App with endpoint ID %d", + contentApp.endpointId); + + [_commandResponseCallbacks setObject:responseCallback forKey:@"mediaPlayback_startOver"]; + dispatch_async(_chipWorkQueue, ^{ + TargetEndpointInfo endpoint; + [ConversionUtils convertToCppTargetEndpointInfoFrom:contentApp outTargetEndpointInfo:endpoint]; + + CHIP_ERROR err = CastingServer::GetInstance()->MediaPlayback_StartOver(&endpoint, [](CHIP_ERROR err) { + void (^responseCallback)(bool) = + [[CastingServerBridge getSharedInstance].commandResponseCallbacks objectForKey:@"mediaPlayback_startOver"]; + responseCallback(CHIP_NO_ERROR == err); + }); + dispatch_async(clientQueue, ^{ + requestSentHandler(CHIP_NO_ERROR == err); + }); + }); +} + - (void)mediaPlayback_subscribeCurrentState:(ContentApp * _Nonnull)contentApp minInterval:(uint16_t)minInterval maxInterval:(uint16_t)maxInterval diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/CertTestViewModel.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/CertTestViewModel.swift index 154c8156f22d97..df6c5f319be5a6 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/CertTestViewModel.swift +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/CertTestViewModel.swift @@ -254,6 +254,57 @@ class CertTestViewModel: ObservableObject { } ) + runCertTest(testCaseName: "mediaPlayback_seek", + test: { (callbackHelper: CallbackHelper) -> () in + castingServerBridge.mediaPlayback_seek(targetContentApp!, + position: 10000, + responseCallback:callbackHelper.responseCallback, + clientQueue: DispatchQueue.main, + requestSentHandler:callbackHelper.requestSentHandler + ) + } + ) + + runCertTest(testCaseName: "mediaPlayback_previous", + test: { (callbackHelper: CallbackHelper) -> () in + castingServerBridge.mediaPlayback_previous(targetContentApp!, + responseCallback:callbackHelper.responseCallback, + clientQueue: DispatchQueue.main, + requestSentHandler:callbackHelper.requestSentHandler + ) + } + ) + + runCertTest(testCaseName: "mediaPlayback_rewind", + test: { (callbackHelper: CallbackHelper) -> () in + castingServerBridge.mediaPlayback_rewind(targetContentApp!, + responseCallback:callbackHelper.responseCallback, + clientQueue: DispatchQueue.main, + requestSentHandler:callbackHelper.requestSentHandler + ) + } + ) + + runCertTest(testCaseName: "mediaPlayback_fastForward", + test: { (callbackHelper: CallbackHelper) -> () in + castingServerBridge.mediaPlayback_fastForward(targetContentApp!, + responseCallback:callbackHelper.responseCallback, + clientQueue: DispatchQueue.main, + requestSentHandler:callbackHelper.requestSentHandler + ) + } + ) + + runCertTest(testCaseName: "mediaPlayback_startOver", + test: { (callbackHelper: CallbackHelper) -> () in + castingServerBridge.mediaPlayback_startOver(targetContentApp!, + responseCallback:callbackHelper.responseCallback, + clientQueue: DispatchQueue.main, + requestSentHandler:callbackHelper.requestSentHandler + ) + } + ) + runCertTest(testCaseName: "onOff_on", test: { (callbackHelper: CallbackHelper) -> () in castingServerBridge.onOff_(on: deviceEndpoint!, @@ -338,6 +389,27 @@ class CertTestViewModel: ObservableObject { ) } ) + + runCertTest(testCaseName: "mediaPlayback_subscribeCurrentState", + test: { (callbackHelper: CallbackHelper) -> () in + castingServerBridge.mediaPlayback_subscribeCurrentState(targetContentApp!, + minInterval: 0, maxInterval: 2, clientQueue: DispatchQueue.main, + requestSentHandler: callbackHelper.requestSentHandlerError, + successCallback: {(state : MediaPlayback_PlaybackState) -> () in}, + failureCallback: callbackHelper.failureCallback, + subscriptionEstablishedCallback: {() -> () in} + ) + } + ) + + runCertTest(testCaseName: "shutdownAllSubscriptions", + test: { (callbackHelper: CallbackHelper) -> () in + castingServerBridge.shutdownAllSubscriptions(DispatchQueue.main, + requestSentHandler: {() -> () in} + ) + } + ) + } } else diff --git a/examples/tv-casting-app/tv-casting-common/include/CastingServer.h b/examples/tv-casting-app/tv-casting-common/include/CastingServer.h index ad124676a8bcd1..205978e1788cf4 100644 --- a/examples/tv-casting-app/tv-casting-common/include/CastingServer.h +++ b/examples/tv-casting-app/tv-casting-common/include/CastingServer.h @@ -185,6 +185,10 @@ class CastingServer CHIP_ERROR MediaPlayback_Pause(TargetEndpointInfo * endpoint, std::function responseCallback); CHIP_ERROR MediaPlayback_StopPlayback(TargetEndpointInfo * endpoint, std::function responseCallback); CHIP_ERROR MediaPlayback_Next(TargetEndpointInfo * endpoint, std::function responseCallback); + CHIP_ERROR MediaPlayback_Previous(TargetEndpointInfo * endpoint, std::function responseCallback); + CHIP_ERROR MediaPlayback_Rewind(TargetEndpointInfo * endpoint, std::function responseCallback); + CHIP_ERROR MediaPlayback_FastForward(TargetEndpointInfo * endpoint, std::function responseCallback); + CHIP_ERROR MediaPlayback_StartOver(TargetEndpointInfo * endpoint, std::function responseCallback); CHIP_ERROR MediaPlayback_Seek(TargetEndpointInfo * endpoint, uint64_t position, std::function responseCallback); CHIP_ERROR MediaPlayback_SkipForward(TargetEndpointInfo * endpoint, uint64_t deltaPositionMilliseconds, @@ -477,6 +481,10 @@ class CastingServer PauseCommand mPauseCommand; StopPlaybackCommand mStopPlaybackCommand; NextCommand mNextCommand; + PreviousCommand mPreviousCommand; + RewindCommand mRewindCommand; + FastForwardCommand mFastForwardCommand; + StartOverCommand mStartOverCommand; SeekCommand mSeekCommand; SkipForwardCommand mSkipForwardCommand; SkipBackwardCommand mSkipBackwardCommand; diff --git a/examples/tv-casting-app/tv-casting-common/include/MediaPlayback.h b/examples/tv-casting-app/tv-casting-common/include/MediaPlayback.h index 8a0c9c55326caa..149ed2e6affc70 100644 --- a/examples/tv-casting-app/tv-casting-common/include/MediaPlayback.h +++ b/examples/tv-casting-app/tv-casting-common/include/MediaPlayback.h @@ -86,6 +86,42 @@ class SkipBackwardCommand : public MediaCommandBase responseCallback); }; +class FastForwardCommand : public MediaCommandBase +{ +public: + FastForwardCommand() : MediaCommandBase(chip::app::Clusters::MediaPlayback::Id) {} + + CHIP_ERROR Invoke(std::function responseCallback); +}; + +class RewindCommand : public MediaCommandBase +{ +public: + RewindCommand() : MediaCommandBase(chip::app::Clusters::MediaPlayback::Id) {} + + CHIP_ERROR Invoke(std::function responseCallback); +}; + +class PreviousCommand : public MediaCommandBase +{ +public: + PreviousCommand() : MediaCommandBase(chip::app::Clusters::MediaPlayback::Id) {} + + CHIP_ERROR Invoke(std::function responseCallback); +}; + +class StartOverCommand : public MediaCommandBase +{ +public: + StartOverCommand() : MediaCommandBase(chip::app::Clusters::MediaPlayback::Id) {} + + CHIP_ERROR Invoke(std::function responseCallback); +}; + // SUBSCRIBER CLASSES class CurrentStateSubscriber : public MediaSubscriptionBase { diff --git a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp index f793f8a9ca7509..2c7a34e92795f5 100644 --- a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp @@ -688,6 +688,30 @@ CHIP_ERROR CastingServer::MediaPlayback_Next(TargetEndpointInfo * endpoint, std: return mNextCommand.Invoke(responseCallback); } +CHIP_ERROR CastingServer::MediaPlayback_Previous(TargetEndpointInfo * endpoint, std::function responseCallback) +{ + ReturnErrorOnFailure(mPreviousCommand.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId())); + return mPreviousCommand.Invoke(responseCallback); +} + +CHIP_ERROR CastingServer::MediaPlayback_Rewind(TargetEndpointInfo * endpoint, std::function responseCallback) +{ + ReturnErrorOnFailure(mRewindCommand.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId())); + return mRewindCommand.Invoke(responseCallback); +} + +CHIP_ERROR CastingServer::MediaPlayback_FastForward(TargetEndpointInfo * endpoint, std::function responseCallback) +{ + ReturnErrorOnFailure(mFastForwardCommand.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId())); + return mFastForwardCommand.Invoke(responseCallback); +} + +CHIP_ERROR CastingServer::MediaPlayback_StartOver(TargetEndpointInfo * endpoint, std::function responseCallback) +{ + ReturnErrorOnFailure(mStartOverCommand.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId())); + return mStartOverCommand.Invoke(responseCallback); +} + CHIP_ERROR CastingServer::MediaPlayback_Seek(TargetEndpointInfo * endpoint, uint64_t position, std::function responseCallback) { diff --git a/examples/tv-casting-app/tv-casting-common/src/MediaPlayback.cpp b/examples/tv-casting-app/tv-casting-common/src/MediaPlayback.cpp index 419ef729616d5a..25549f9c8f8dab 100644 --- a/examples/tv-casting-app/tv-casting-common/src/MediaPlayback.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/MediaPlayback.cpp @@ -65,3 +65,27 @@ CHIP_ERROR SkipBackwardCommand::Invoke(uint64_t deltaPositionMilliseconds, std:: request.deltaPositionMilliseconds = deltaPositionMilliseconds; return MediaCommandBase::Invoke(request, responseCallback); } + +CHIP_ERROR PreviousCommand::Invoke(std::function responseCallback) +{ + MediaPlayback::Commands::Previous::Type request; + return MediaCommandBase::Invoke(request, responseCallback); +} + +CHIP_ERROR StartOverCommand::Invoke(std::function responseCallback) +{ + MediaPlayback::Commands::StartOver::Type request; + return MediaCommandBase::Invoke(request, responseCallback); +} + +CHIP_ERROR RewindCommand::Invoke(std::function responseCallback) +{ + MediaPlayback::Commands::Rewind::Type request; + return MediaCommandBase::Invoke(request, responseCallback); +} + +CHIP_ERROR FastForwardCommand::Invoke(std::function responseCallback) +{ + MediaPlayback::Commands::FastForward::Type request; + return MediaCommandBase::Invoke(request, responseCallback); +}