Skip to content

Commit

Permalink
Match Media Playback Cluster to spec (#30217)
Browse files Browse the repository at this point in the history
* move MediaPlaybackStatusEnum to StatusEnum

* Add compat shim

* Zap regen

* Replace enum name to the new name

* Fix Darwin availability annotations.

---------

Co-authored-by: Andrei Litvin <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Nov 29, 2023
1 parent 10b6e46 commit 9b315a4
Show file tree
Hide file tree
Showing 19 changed files with 169 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3227,7 +3227,14 @@ server cluster TargetNavigator = 1285 {

/** This cluster provides an interface for controlling Media Playback (PLAY, PAUSE, etc) on a media device such as a TV or Speaker. */
server cluster MediaPlayback = 1286 {
enum MediaPlaybackStatusEnum : enum8 {
enum PlaybackStateEnum : enum8 {
kPlaying = 0;
kPaused = 1;
kNotPlaying = 2;
kBuffering = 3;
}

enum StatusEnum : enum8 {
kSuccess = 0;
kInvalidStateForCommand = 1;
kNotAllowed = 2;
Expand All @@ -3236,13 +3243,6 @@ server cluster MediaPlayback = 1286 {
kSeekOutOfRange = 5;
}

enum PlaybackStateEnum : enum8 {
kPlaying = 0;
kPaused = 1;
kNotPlaying = 2;
kBuffering = 3;
}

bitmap Feature : bitmap32 {
kAdvancedSeek = 0x1;
kVariableSpeed = 0x2;
Expand All @@ -3262,7 +3262,7 @@ server cluster MediaPlayback = 1286 {
readonly attribute int16u clusterRevision = 65533;

response struct PlaybackResponse = 10 {
MediaPlaybackStatusEnum status = 0;
StatusEnum status = 0;
optional char_string data = 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,14 @@ server cluster TargetNavigator = 1285 {

/** This cluster provides an interface for controlling Media Playback (PLAY, PAUSE, etc) on a media device such as a TV or Speaker. */
server cluster MediaPlayback = 1286 {
enum MediaPlaybackStatusEnum : enum8 {
enum PlaybackStateEnum : enum8 {
kPlaying = 0;
kPaused = 1;
kNotPlaying = 2;
kBuffering = 3;
}

enum StatusEnum : enum8 {
kSuccess = 0;
kInvalidStateForCommand = 1;
kNotAllowed = 2;
Expand All @@ -1207,13 +1214,6 @@ server cluster MediaPlayback = 1286 {
kSeekOutOfRange = 5;
}

enum PlaybackStateEnum : enum8 {
kPlaying = 0;
kPaused = 1;
kNotPlaying = 2;
kBuffering = 3;
}

bitmap Feature : bitmap32 {
kAdvancedSeek = 0x1;
kVariableSpeed = 0x2;
Expand All @@ -1233,7 +1233,7 @@ server cluster MediaPlayback = 1286 {
readonly attribute int16u clusterRevision = 65533;

response struct PlaybackResponse = 10 {
MediaPlaybackStatusEnum status = 0;
StatusEnum status = 0;
optional char_string data = 1;
}

Expand Down
36 changes: 18 additions & 18 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -5501,7 +5501,14 @@ server cluster TargetNavigator = 1285 {

/** This cluster provides an interface for controlling Media Playback (PLAY, PAUSE, etc) on a media device such as a TV or Speaker. */
client cluster MediaPlayback = 1286 {
enum MediaPlaybackStatusEnum : enum8 {
enum PlaybackStateEnum : enum8 {
kPlaying = 0;
kPaused = 1;
kNotPlaying = 2;
kBuffering = 3;
}

enum StatusEnum : enum8 {
kSuccess = 0;
kInvalidStateForCommand = 1;
kNotAllowed = 2;
Expand All @@ -5510,13 +5517,6 @@ client cluster MediaPlayback = 1286 {
kSeekOutOfRange = 5;
}

enum PlaybackStateEnum : enum8 {
kPlaying = 0;
kPaused = 1;
kNotPlaying = 2;
kBuffering = 3;
}

bitmap Feature : bitmap32 {
kAdvancedSeek = 0x1;
kVariableSpeed = 0x2;
Expand Down Expand Up @@ -5550,7 +5550,7 @@ client cluster MediaPlayback = 1286 {
}

response struct PlaybackResponse = 10 {
MediaPlaybackStatusEnum status = 0;
StatusEnum status = 0;
optional char_string data = 1;
}

Expand Down Expand Up @@ -5584,7 +5584,14 @@ client cluster MediaPlayback = 1286 {

/** This cluster provides an interface for controlling Media Playback (PLAY, PAUSE, etc) on a media device such as a TV or Speaker. */
server cluster MediaPlayback = 1286 {
enum MediaPlaybackStatusEnum : enum8 {
enum PlaybackStateEnum : enum8 {
kPlaying = 0;
kPaused = 1;
kNotPlaying = 2;
kBuffering = 3;
}

enum StatusEnum : enum8 {
kSuccess = 0;
kInvalidStateForCommand = 1;
kNotAllowed = 2;
Expand All @@ -5593,13 +5600,6 @@ server cluster MediaPlayback = 1286 {
kSeekOutOfRange = 5;
}

enum PlaybackStateEnum : enum8 {
kPlaying = 0;
kPaused = 1;
kNotPlaying = 2;
kBuffering = 3;
}

bitmap Feature : bitmap32 {
kAdvancedSeek = 0x1;
kVariableSpeed = 0x2;
Expand Down Expand Up @@ -5637,7 +5637,7 @@ server cluster MediaPlayback = 1286 {
}

response struct PlaybackResponse = 10 {
MediaPlaybackStatusEnum status = 0;
StatusEnum status = 0;
optional char_string data = 1;
}

Expand Down
36 changes: 18 additions & 18 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -5460,7 +5460,14 @@ server cluster TargetNavigator = 1285 {

/** This cluster provides an interface for controlling Media Playback (PLAY, PAUSE, etc) on a media device such as a TV or Speaker. */
client cluster MediaPlayback = 1286 {
enum MediaPlaybackStatusEnum : enum8 {
enum PlaybackStateEnum : enum8 {
kPlaying = 0;
kPaused = 1;
kNotPlaying = 2;
kBuffering = 3;
}

enum StatusEnum : enum8 {
kSuccess = 0;
kInvalidStateForCommand = 1;
kNotAllowed = 2;
Expand All @@ -5469,13 +5476,6 @@ client cluster MediaPlayback = 1286 {
kSeekOutOfRange = 5;
}

enum PlaybackStateEnum : enum8 {
kPlaying = 0;
kPaused = 1;
kNotPlaying = 2;
kBuffering = 3;
}

bitmap Feature : bitmap32 {
kAdvancedSeek = 0x1;
kVariableSpeed = 0x2;
Expand Down Expand Up @@ -5509,7 +5509,7 @@ client cluster MediaPlayback = 1286 {
}

response struct PlaybackResponse = 10 {
MediaPlaybackStatusEnum status = 0;
StatusEnum status = 0;
optional char_string data = 1;
}

Expand Down Expand Up @@ -5543,7 +5543,14 @@ client cluster MediaPlayback = 1286 {

/** This cluster provides an interface for controlling Media Playback (PLAY, PAUSE, etc) on a media device such as a TV or Speaker. */
server cluster MediaPlayback = 1286 {
enum MediaPlaybackStatusEnum : enum8 {
enum PlaybackStateEnum : enum8 {
kPlaying = 0;
kPaused = 1;
kNotPlaying = 2;
kBuffering = 3;
}

enum StatusEnum : enum8 {
kSuccess = 0;
kInvalidStateForCommand = 1;
kNotAllowed = 2;
Expand All @@ -5552,13 +5559,6 @@ server cluster MediaPlayback = 1286 {
kSeekOutOfRange = 5;
}

enum PlaybackStateEnum : enum8 {
kPlaying = 0;
kPaused = 1;
kNotPlaying = 2;
kBuffering = 3;
}

bitmap Feature : bitmap32 {
kAdvancedSeek = 0x1;
kVariableSpeed = 0x2;
Expand Down Expand Up @@ -5596,7 +5596,7 @@ server cluster MediaPlayback = 1286 {
}

response struct PlaybackResponse = 10 {
MediaPlaybackStatusEnum status = 0;
StatusEnum status = 0;
optional char_string data = 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Commands::PlaybackResponse::Type AppMediaPlaybackManager::HandleMediaRequest(Med
// Ideally should not come here
ChipLogProgress(Zcl, "AppMediaPlaybackManager::HandleMediaRequest");
Commands::PlaybackResponse::Type response;
response.status = MediaPlaybackStatusEnum::kInvalidStateForCommand;
response.status = StatusEnum::kInvalidStateForCommand;
return response;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/tv-app/android/java/ContentAppCommandDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ PlaybackResponseType ContentAppCommandDelegate::FormatMediaPlaybackResponse(Json
}
else
{
playbackResponse.status = static_cast<app::Clusters::MediaPlayback::MediaPlaybackStatusEnum>(value[statusFieldId].asInt());
playbackResponse.status = static_cast<app::Clusters::MediaPlayback::StatusEnum>(value[statusFieldId].asInt());
std::string dataFieldId =
std::to_string(to_underlying(app::Clusters::MediaPlayback::Commands::PlaybackResponse::Fields::kData));
if (!value[dataFieldId].empty())
Expand Down
6 changes: 3 additions & 3 deletions examples/tv-app/android/java/MediaPlaybackManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,14 @@ Commands::PlaybackResponse::Type MediaPlaybackManager::HandleMediaRequest(MediaP
ChipLogError(AppServer, "Java exception in MediaPlaybackManager::Request %d", mediaPlaybackRequest);
env->ExceptionDescribe();
env->ExceptionClear();
response.status = MediaPlaybackStatusEnum::kInvalidStateForCommand;
response.status = StatusEnum::kInvalidStateForCommand;
}
response.status = static_cast<MediaPlaybackStatusEnum>(ret);
response.status = static_cast<StatusEnum>(ret);

exit:
if (err != CHIP_NO_ERROR)
{
response.status = MediaPlaybackStatusEnum::kInvalidStateForCommand;
response.status = StatusEnum::kInvalidStateForCommand;
ChipLogError(Zcl, "MediaPlaybackManager::HandleMediaRequest status error: %s", err.AsString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void MediaPlaybackManager::HandlePlay(CommandResponseHelper<Commands::PlaybackRe

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSuccess;
response.status = StatusEnum::kSuccess;
helper.Success(response);
}

Expand All @@ -80,7 +80,7 @@ void MediaPlaybackManager::HandlePause(CommandResponseHelper<Commands::PlaybackR

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSuccess;
response.status = StatusEnum::kSuccess;
helper.Success(response);
}

Expand All @@ -93,7 +93,7 @@ void MediaPlaybackManager::HandleStop(CommandResponseHelper<Commands::PlaybackRe

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSuccess;
response.status = StatusEnum::kSuccess;
helper.Success(response);
}

Expand All @@ -105,7 +105,7 @@ void MediaPlaybackManager::HandleFastForward(CommandResponseHelper<Commands::Pla
// if already at max speed, return error
Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSpeedOutOfRange;
response.status = StatusEnum::kSpeedOutOfRange;
helper.Success(response);
return;
}
Expand All @@ -120,7 +120,7 @@ void MediaPlaybackManager::HandleFastForward(CommandResponseHelper<Commands::Pla

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSuccess;
response.status = StatusEnum::kSuccess;
helper.Success(response);
}

Expand All @@ -133,7 +133,7 @@ void MediaPlaybackManager::HandlePrevious(CommandResponseHelper<Commands::Playba

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSuccess;
response.status = StatusEnum::kSuccess;
helper.Success(response);
}

Expand All @@ -145,7 +145,7 @@ void MediaPlaybackManager::HandleRewind(CommandResponseHelper<Commands::Playback
// if already at max speed in reverse, return error
Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSpeedOutOfRange;
response.status = StatusEnum::kSpeedOutOfRange;
helper.Success(response);
return;
}
Expand All @@ -160,7 +160,7 @@ void MediaPlaybackManager::HandleRewind(CommandResponseHelper<Commands::Playback

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSuccess;
response.status = StatusEnum::kSuccess;
helper.Success(response);
}

Expand All @@ -175,7 +175,7 @@ void MediaPlaybackManager::HandleSkipBackward(CommandResponseHelper<Commands::Pl

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSuccess;
response.status = StatusEnum::kSuccess;
helper.Success(response);
}

Expand All @@ -189,7 +189,7 @@ void MediaPlaybackManager::HandleSkipForward(CommandResponseHelper<Commands::Pla

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSuccess;
response.status = StatusEnum::kSuccess;
helper.Success(response);
}

Expand All @@ -201,7 +201,7 @@ void MediaPlaybackManager::HandleSeek(CommandResponseHelper<Commands::PlaybackRe
{
Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSeekOutOfRange;
response.status = StatusEnum::kSeekOutOfRange;
helper.Success(response);
}
else
Expand All @@ -210,7 +210,7 @@ void MediaPlaybackManager::HandleSeek(CommandResponseHelper<Commands::PlaybackRe

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSuccess;
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
}
Expand All @@ -224,7 +224,7 @@ void MediaPlaybackManager::HandleNext(CommandResponseHelper<Commands::PlaybackRe

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSuccess;
response.status = StatusEnum::kSuccess;
helper.Success(response);
}

Expand All @@ -235,7 +235,7 @@ void MediaPlaybackManager::HandleStartOver(CommandResponseHelper<Commands::Playb

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = MediaPlaybackStatusEnum::kSuccess;
response.status = StatusEnum::kSuccess;
helper.Success(response);
}

Expand Down
Loading

0 comments on commit 9b315a4

Please sign in to comment.