From f2fe32ed08f28d0eab97d30b4abb4c4ad366e237 Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Fri, 11 Aug 2023 14:22:40 +0900 Subject: [PATCH] [MediaController] Add new capability APIs (#5472) --- .../CustomCommandCapabilityUpdatedEventArgs.cs | 47 ++++++++++++ .../MediaController/InternalEnums.cs | 2 +- .../MediaController/MediaControlServer.cs | 76 ++++++++++++++++++++ .../MediaController/MediaController.Events.cs | 74 +++++++++++++++++-- .../MediaController/MediaController.cs | 84 ++++++++++++++++++++++ .../MediaControllerManager.Events.cs | 25 ++++++- .../Mode360CapabilityUpdatedEventArgs.cs | 46 ++++++++++++ .../PlaybackPositionCapabilityUpdatedEventArgs.cs | 46 ++++++++++++ .../PlaylistCapabilityUpdatedEventArgs.cs | 46 ++++++++++++ .../SearchCapabilityUpdatedEventArgs.cs | 46 ++++++++++++ .../SubtitleCapabilityUpdatedEventArgs.cs | 46 ++++++++++++ 11 files changed, 531 insertions(+), 7 deletions(-) create mode 100644 src/Tizen.Multimedia.Remoting/MediaController/CustomCommandCapabilityUpdatedEventArgs.cs create mode 100644 src/Tizen.Multimedia.Remoting/MediaController/Mode360CapabilityUpdatedEventArgs.cs create mode 100644 src/Tizen.Multimedia.Remoting/MediaController/PlaybackPositionCapabilityUpdatedEventArgs.cs create mode 100644 src/Tizen.Multimedia.Remoting/MediaController/PlaylistCapabilityUpdatedEventArgs.cs create mode 100644 src/Tizen.Multimedia.Remoting/MediaController/SearchCapabilityUpdatedEventArgs.cs create mode 100644 src/Tizen.Multimedia.Remoting/MediaController/SubtitleCapabilityUpdatedEventArgs.cs diff --git a/src/Tizen.Multimedia.Remoting/MediaController/CustomCommandCapabilityUpdatedEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/CustomCommandCapabilityUpdatedEventArgs.cs new file mode 100644 index 0000000..fef9e6a --- /dev/null +++ b/src/Tizen.Multimedia.Remoting/MediaController/CustomCommandCapabilityUpdatedEventArgs.cs @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +using System; + +namespace Tizen.Multimedia.Remoting +{ + /// + /// Provides data for the event. + /// + /// 11 + public class CustomCommandCapabilityUpdatedEventArgs : EventArgs + { + /// + /// Initializes a new instance of the class. + /// + /// The custom command capability. + /// is not valid. + /// + /// 11 + internal CustomCommandCapabilityUpdatedEventArgs(MediaControlCapabilitySupport support) + { + ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support)); + + Support = support; + } + + /// + /// Gets the value whether the custom command is supported or not. + /// + /// 11 + public MediaControlCapabilitySupport Support { get; } + } +} \ No newline at end of file diff --git a/src/Tizen.Multimedia.Remoting/MediaController/InternalEnums.cs b/src/Tizen.Multimedia.Remoting/MediaController/InternalEnums.cs index 1ce95d7..f981c34 100644 --- a/src/Tizen.Multimedia.Remoting/MediaController/InternalEnums.cs +++ b/src/Tizen.Multimedia.Remoting/MediaController/InternalEnums.cs @@ -92,7 +92,7 @@ namespace Tizen.Multimedia.Remoting Repeat, PlaybackPosition, Playlist, - ClientCustom, + CustomCommand, // The same as CLIENT_CUSTOM of native fw Search, Subtitle, Mode360 diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControlServer.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControlServer.cs index 7e0d5e3..a3e24af 100644 --- a/src/Tizen.Multimedia.Remoting/MediaController/MediaControlServer.cs +++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControlServer.cs @@ -638,6 +638,82 @@ namespace Tizen.Multimedia.Remoting } /// + /// Sets the indicating playback position is supported or not. + /// + /// A value indicating whether the playback position is supported or not. + /// + /// The server is not running .
+ /// -or-
+ /// An internal error occurs. + ///
+ /// is invalid. + /// 11 + public static void SetPlaybackPositionCapability(MediaControlCapabilitySupport support) + { + ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support)); + + Native.SetSimpleCapability(Handle, MediaControlNativeCapabilityCategory.PlaybackPosition, support). + ThrowIfError("Failed to set playback position capability."); + } + + /// + /// Sets the indicating playlist is supported or not. + /// + /// A value indicating whether the playlist is supported or not. + /// + /// The server is not running .
+ /// -or-
+ /// An internal error occurs. + ///
+ /// is invalid. + /// 11 + public static void SetPlaylistCapability(MediaControlCapabilitySupport support) + { + ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support)); + + Native.SetSimpleCapability(Handle, MediaControlNativeCapabilityCategory.Playlist, support). + ThrowIfError("Failed to set playlist capability."); + } + + /// + /// Sets the indicating custom command is supported or not. + /// + /// A value indicating whether the custom command is supported or not. + /// + /// The server is not running .
+ /// -or-
+ /// An internal error occurs. + ///
+ /// is invalid. + /// 11 + public static void SetCustomCommandCapability(MediaControlCapabilitySupport support) + { + ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support)); + + Native.SetSimpleCapability(Handle, MediaControlNativeCapabilityCategory.CustomCommand, support). + ThrowIfError("Failed to set custom command capability."); + } + + /// + /// Sets the indicating search is supported or not. + /// + /// A value indicating whether the search is supported or not. + /// + /// The server is not running .
+ /// -or-
+ /// An internal error occurs. + ///
+ /// is invalid. + /// 11 + public static void SetSearchCapability(MediaControlCapabilitySupport support) + { + ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support)); + + Native.SetSimpleCapability(Handle, MediaControlNativeCapabilityCategory.Search, support). + ThrowIfError("Failed to set search capability."); + } + + /// /// Sets the indicating whether subtitle mode is supported or not. /// /// A value indicating whether the subtitle mode is supported or not. diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaController.Events.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaController.Events.cs index a9b0fa7..98907a6 100644 --- a/src/Tizen.Multimedia.Remoting/MediaController/MediaController.Events.cs +++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaController.Events.cs @@ -237,7 +237,7 @@ namespace Tizen.Multimedia.Remoting } /// - /// Occurs when the repeat mode capabilities are updated. + /// Occurs when the repeat mode capability is updated. /// /// 5 public event EventHandler RepeatModeCapabilityUpdated; @@ -248,7 +248,7 @@ namespace Tizen.Multimedia.Remoting } /// - /// Occurs when the shuffle mode capabilities are updated. + /// Occurs when the shuffle mode capability is updated. /// /// 5 public event EventHandler ShuffleModeCapabilityUpdated; @@ -259,7 +259,73 @@ namespace Tizen.Multimedia.Remoting } /// - /// Occurs when the display mode capabilities are updated. + /// Occurs when the playback position capability is updated. + /// + /// 11 + public event EventHandler PlaybackPositionCapabilityUpdated; + + internal void RaisePlaybackPositionCapabilityUpdatedEvent(MediaControlCapabilitySupport support) + { + PlaybackPositionCapabilityUpdated?.Invoke(this, new PlaybackPositionCapabilityUpdatedEventArgs(support)); + } + + /// + /// Occurs when the playlist capability is updated. + /// + /// 11 + public event EventHandler PlaylistCapabilityUpdated; + + internal void RaisePlaylistCapabilityUpdatedEvent(MediaControlCapabilitySupport support) + { + PlaylistCapabilityUpdated?.Invoke(this, new PlaylistCapabilityUpdatedEventArgs(support)); + } + + /// + /// Occurs when the custom command capability is updated. + /// + /// 11 + public event EventHandler CustomCommandCapabilityUpdated; + + internal void RaiseCustomCommandCapabilityUpdatedEvent(MediaControlCapabilitySupport support) + { + CustomCommandCapabilityUpdated?.Invoke(this, new CustomCommandCapabilityUpdatedEventArgs(support)); + } + + /// + /// Occurs when the search capability is updated. + /// + /// 11 + public event EventHandler SearchCapabilityUpdated; + + internal void RaiseSearchCapabilityUpdatedEvent(MediaControlCapabilitySupport support) + { + SearchCapabilityUpdated?.Invoke(this, new SearchCapabilityUpdatedEventArgs(support)); + } + + /// + /// Occurs when the subtitle capability is updated. + /// + /// 11 + public event EventHandler SubtitleCapabilityUpdated; + + internal void RaiseSubtitleCapabilityUpdatedEvent(MediaControlCapabilitySupport support) + { + SubtitleCapabilityUpdated?.Invoke(this, new SubtitleCapabilityUpdatedEventArgs(support)); + } + + /// + /// Occurs when the mode360 capability is updated. + /// + /// 11 + public event EventHandler Mode360CapabilityUpdated; + + internal void RaiseMode360CapabilityUpdatedEvent(MediaControlCapabilitySupport support) + { + Mode360CapabilityUpdated?.Invoke(this, new Mode360CapabilityUpdatedEventArgs(support)); + } + + /// + /// Occurs when the display mode capability is updated. /// /// 6 public event EventHandler DisplayModeCapabilityUpdated; @@ -270,7 +336,7 @@ namespace Tizen.Multimedia.Remoting } /// - /// Occurs when the display rotation capabilities are updated. + /// Occurs when the display rotation capability is updated. /// /// 6 public event EventHandler DisplayRotationCapabilityUpdated; diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaController.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaController.cs index 51ac909..6aaf55d 100644 --- a/src/Tizen.Multimedia.Remoting/MediaController/MediaController.cs +++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaController.cs @@ -680,6 +680,90 @@ namespace Tizen.Multimedia.Remoting } /// + /// Gets the value whether the playback position is supported or not. + /// + /// A . + /// + /// The server has already been stopped.
+ /// -or-
+ /// An internal error occurs. + ///
+ /// The has already been disposed. + /// 11 + public MediaControlCapabilitySupport GetPlaybackPositionCapability() + { + ThrowIfStopped(); + + Native.GetSimpleCapability(Manager.Handle, ServerAppId, MediaControlNativeCapabilityCategory.PlaybackPosition, out MediaControlCapabilitySupport support). + ThrowIfError("Failed to get playback position capability"); + + return support; + } + + /// + /// Gets the value whether the playlist is supported or not. + /// + /// A . + /// + /// The server has already been stopped.
+ /// -or-
+ /// An internal error occurs. + ///
+ /// The has already been disposed. + /// 11 + public MediaControlCapabilitySupport GetPlaylistCapability() + { + ThrowIfStopped(); + + Native.GetSimpleCapability(Manager.Handle, ServerAppId, MediaControlNativeCapabilityCategory.Playlist, out MediaControlCapabilitySupport support). + ThrowIfError("Failed to get playlist capability"); + + return support; + } + + /// + /// Gets the value whether the custom command is supported or not. + /// + /// A . + /// + /// The server has already been stopped.
+ /// -or-
+ /// An internal error occurs. + ///
+ /// The has already been disposed. + /// 11 + public MediaControlCapabilitySupport GetCustomCommandCapability() + { + ThrowIfStopped(); + + Native.GetSimpleCapability(Manager.Handle, ServerAppId, MediaControlNativeCapabilityCategory.CustomCommand, out MediaControlCapabilitySupport support). + ThrowIfError("Failed to get custom command capability"); + + return support; + } + + /// + /// Gets the value whether the search is supported or not. + /// + /// A . + /// + /// The server has already been stopped.
+ /// -or-
+ /// An internal error occurs. + ///
+ /// The has already been disposed. + /// 11 + public MediaControlCapabilitySupport GetSearchCapability() + { + ThrowIfStopped(); + + Native.GetSimpleCapability(Manager.Handle, ServerAppId, MediaControlNativeCapabilityCategory.Search, out MediaControlCapabilitySupport support). + ThrowIfError("Failed to get search capability"); + + return support; + } + + /// /// Gets the value whether the repeat mode is supported or not. /// /// diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerManager.Events.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerManager.Events.cs index 7fa8125..6ef8bcf 100644 --- a/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerManager.Events.cs +++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerManager.Events.cs @@ -293,11 +293,32 @@ namespace Tizen.Multimedia.Remoting { switch (category) { + case MediaControlNativeCapabilityCategory.Shuffle: + GetController(serverName)?.RaiseShuffleModeCapabilityUpdatedEvent(support); + break; case MediaControlNativeCapabilityCategory.Repeat: GetController(serverName)?.RaiseRepeatModeCapabilityUpdatedEvent(support); break; - case MediaControlNativeCapabilityCategory.Shuffle: - GetController(serverName)?.RaiseShuffleModeCapabilityUpdatedEvent(support); + case MediaControlNativeCapabilityCategory.PlaybackPosition: + GetController(serverName)?.RaisePlaybackPositionCapabilityUpdatedEvent(support); + break; + case MediaControlNativeCapabilityCategory.Playlist: + GetController(serverName)?.RaisePlaylistCapabilityUpdatedEvent(support); + break; + case MediaControlNativeCapabilityCategory.CustomCommand: + GetController(serverName)?.RaiseCustomCommandCapabilityUpdatedEvent(support); + break; + case MediaControlNativeCapabilityCategory.Search: + GetController(serverName)?.RaiseSearchCapabilityUpdatedEvent(support); + break; + case MediaControlNativeCapabilityCategory.Subtitle: + GetController(serverName)?.RaiseSubtitleCapabilityUpdatedEvent(support); + break; + case MediaControlNativeCapabilityCategory.Mode360: + GetController(serverName)?.RaiseMode360CapabilityUpdatedEvent(support); + break; + default: + Log.Info(GetType().FullName, $"There's no category : {category}"); break; } }; diff --git a/src/Tizen.Multimedia.Remoting/MediaController/Mode360CapabilityUpdatedEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/Mode360CapabilityUpdatedEventArgs.cs new file mode 100644 index 0000000..e036ce3 --- /dev/null +++ b/src/Tizen.Multimedia.Remoting/MediaController/Mode360CapabilityUpdatedEventArgs.cs @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +using System; + +namespace Tizen.Multimedia.Remoting +{ + /// + /// Provides data for the event. + /// + /// 11 + public class Mode360CapabilityUpdatedEventArgs : EventArgs + { + /// + /// Initializes a new instance of the class. + /// + /// The mode360 capability. + /// is not valid. + /// 11 + internal Mode360CapabilityUpdatedEventArgs(MediaControlCapabilitySupport support) + { + ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support)); + + Support = support; + } + + /// + /// Gets the value whether the mode360 is supported or not. + /// + /// 11 + public MediaControlCapabilitySupport Support { get; } + } +} \ No newline at end of file diff --git a/src/Tizen.Multimedia.Remoting/MediaController/PlaybackPositionCapabilityUpdatedEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/PlaybackPositionCapabilityUpdatedEventArgs.cs new file mode 100644 index 0000000..8a722f6 --- /dev/null +++ b/src/Tizen.Multimedia.Remoting/MediaController/PlaybackPositionCapabilityUpdatedEventArgs.cs @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +using System; + +namespace Tizen.Multimedia.Remoting +{ + /// + /// Provides data for the event. + /// + /// 11 + public class PlaybackPositionCapabilityUpdatedEventArgs : EventArgs + { + /// + /// Initializes a new instance of the class. + /// + /// The playback position capability. + /// is not valid. + /// 11 + internal PlaybackPositionCapabilityUpdatedEventArgs(MediaControlCapabilitySupport support) + { + ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support)); + + Support = support; + } + + /// + /// Gets the value whether the playback position is supported or not. + /// + /// 11 + public MediaControlCapabilitySupport Support { get; } + } +} \ No newline at end of file diff --git a/src/Tizen.Multimedia.Remoting/MediaController/PlaylistCapabilityUpdatedEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/PlaylistCapabilityUpdatedEventArgs.cs new file mode 100644 index 0000000..aeb3f1a --- /dev/null +++ b/src/Tizen.Multimedia.Remoting/MediaController/PlaylistCapabilityUpdatedEventArgs.cs @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +using System; + +namespace Tizen.Multimedia.Remoting +{ + /// + /// Provides data for the event. + /// + /// 11 + public class PlaylistCapabilityUpdatedEventArgs : EventArgs + { + /// + /// Initializes a new instance of the class. + /// + /// The repeat mode capability. + /// is not valid. + /// 11 + internal PlaylistCapabilityUpdatedEventArgs(MediaControlCapabilitySupport support) + { + ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support)); + + Support = support; + } + + /// + /// Gets the value whether the playlist is supported or not. + /// + /// 11 + public MediaControlCapabilitySupport Support { get; } + } +} \ No newline at end of file diff --git a/src/Tizen.Multimedia.Remoting/MediaController/SearchCapabilityUpdatedEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/SearchCapabilityUpdatedEventArgs.cs new file mode 100644 index 0000000..f1b0bd8 --- /dev/null +++ b/src/Tizen.Multimedia.Remoting/MediaController/SearchCapabilityUpdatedEventArgs.cs @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +using System; + +namespace Tizen.Multimedia.Remoting +{ + /// + /// Provides data for the event. + /// + /// 11 + public class SearchCapabilityUpdatedEventArgs : EventArgs + { + /// + /// Initializes a new instance of the class. + /// + /// The search capability. + /// is not valid. + /// 11 + internal SearchCapabilityUpdatedEventArgs(MediaControlCapabilitySupport support) + { + ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support)); + + Support = support; + } + + /// + /// Gets the value whether the search is supported or not. + /// + /// 11 + public MediaControlCapabilitySupport Support { get; } + } +} \ No newline at end of file diff --git a/src/Tizen.Multimedia.Remoting/MediaController/SubtitleCapabilityUpdatedEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/SubtitleCapabilityUpdatedEventArgs.cs new file mode 100644 index 0000000..2fbcf49 --- /dev/null +++ b/src/Tizen.Multimedia.Remoting/MediaController/SubtitleCapabilityUpdatedEventArgs.cs @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +using System; + +namespace Tizen.Multimedia.Remoting +{ + /// + /// Provides data for the event. + /// + /// 11 + public class SubtitleCapabilityUpdatedEventArgs : EventArgs + { + /// + /// Initializes a new instance of the class. + /// + /// The subtitle capability. + /// is not valid. + /// 11 + internal SubtitleCapabilityUpdatedEventArgs(MediaControlCapabilitySupport support) + { + ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support)); + + Support = support; + } + + /// + /// Gets the value whether the subtitle is supported or not. + /// + /// 11 + public MediaControlCapabilitySupport Support { get; } + } +} \ No newline at end of file -- 2.7.4