Skip to content

Commit

Permalink
[MediaController] Add new capability APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
hsgwon committed Aug 2, 2023
1 parent e29cc74 commit d204159
Show file tree
Hide file tree
Showing 10 changed files with 529 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Provides data for the <see cref="MediaController.ClientCustomCapabilityUpdated"/> event.
/// </summary>
/// <since_tizen> 11 </since_tizen>
public class ClientCustomCapabilityUpdatedEventArgs : EventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="ClientCustomCapabilityUpdatedEventArgs"/> class.
/// </summary>
/// <param name="support">The client custom capability.</param>
/// <exception cref="ArgumentException"><paramref name="support"/> is not valid.</exception>
/// <since_tizen> 11 </since_tizen>
internal ClientCustomCapabilityUpdatedEventArgs(MediaControlCapabilitySupport support)
{
ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support));

Support = support;
}

/// <summary>
/// Gets the value whether the client custom is supported or not.
/// </summary>
/// <since_tizen> 11 </since_tizen>
public MediaControlCapabilitySupport Support { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,82 @@ public static void SetMode360Capability(MediaControlCapabilitySupport support)
ThrowIfError("Failed to set 360 mode capability.");
}

/// <summary>
/// Sets the <see cref="MediaControlCapabilitySupport"/> indicating playback position is supported or not.
/// </summary>
/// <param name="support">A value indicating whether the playback position is supported or not.</param>
/// <exception cref="InvalidOperationException">
/// The server is not running .<br/>
/// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ArgumentException"><paramref name="support"/> is invalid.</exception>
/// <since_tizen> 11 </since_tizen>
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.");
}

/// <summary>
/// Sets the <see cref="MediaControlCapabilitySupport"/> indicating playlist is supported or not.
/// </summary>
/// <param name="support">A value indicating whether the playlist is supported or not.</param>
/// <exception cref="InvalidOperationException">
/// The server is not running .<br/>
/// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ArgumentException"><paramref name="support"/> is invalid.</exception>
/// <since_tizen> 11 </since_tizen>
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.");
}

/// <summary>
/// Sets the <see cref="MediaControlCapabilitySupport"/> indicating client custom is supported or not.
/// </summary>
/// <param name="support">A value indicating whether the client custom is supported or not.</param>
/// <exception cref="InvalidOperationException">
/// The server is not running .<br/>
/// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ArgumentException"><paramref name="support"/> is invalid.</exception>
/// <since_tizen> 11 </since_tizen>
public static void SetClientCustomCapability(MediaControlCapabilitySupport support)
{
ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support));

Native.SetSimpleCapability(Handle, MediaControlNativeCapabilityCategory.ClientCustom, support).
ThrowIfError("Failed to set client custom capability.");
}

/// <summary>
/// Sets the <see cref="MediaControlCapabilitySupport"/> indicating search is supported or not.
/// </summary>
/// <param name="support">A value indicating whether the search is supported or not.</param>
/// <exception cref="InvalidOperationException">
/// The server is not running .<br/>
/// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ArgumentException"><paramref name="support"/> is invalid.</exception>
/// <since_tizen> 11 </since_tizen>
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.");
}

/// <summary>
/// Sets the <see cref="MediaControlCapabilitySupport"/> indicating whether subtitle mode is supported or not.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ internal void RaisePlaybackCapabilityUpdatedEvent(IntPtr playbackCapaHandle)
}

/// <summary>
/// Occurs when the repeat mode capabilities are updated.
/// Occurs when the repeat mode capability is updated.
/// </summary>
/// <since_tizen> 5 </since_tizen>
public event EventHandler<RepeatModeCapabilityUpdatedEventArgs> RepeatModeCapabilityUpdated;
Expand All @@ -248,7 +248,7 @@ internal void RaiseRepeatModeCapabilityUpdatedEvent(MediaControlCapabilitySuppor
}

/// <summary>
/// Occurs when the shuffle mode capabilities are updated.
/// Occurs when the shuffle mode capability is updated.
/// </summary>
/// <since_tizen> 5 </since_tizen>
public event EventHandler<ShuffleModeCapabilityUpdatedEventArgs> ShuffleModeCapabilityUpdated;
Expand All @@ -259,7 +259,73 @@ internal void RaiseShuffleModeCapabilityUpdatedEvent(MediaControlCapabilitySuppo
}

/// <summary>
/// Occurs when the display mode capabilities are updated.
/// Occurs when the playback position capability is updated.
/// </summary>
/// <since_tizen> 11 </since_tizen>
public event EventHandler<PlaybackPositionCapabilityUpdatedEventArgs> PlaybackPositionCapabilityUpdated;

internal void RaisePlaybackPositionCapabilityUpdatedEvent(MediaControlCapabilitySupport support)
{
PlaybackPositionCapabilityUpdated?.Invoke(this, new PlaybackPositionCapabilityUpdatedEventArgs(support));
}

/// <summary>
/// Occurs when the playlist capability is updated.
/// </summary>
/// <since_tizen> 11 </since_tizen>
public event EventHandler<PlaylistCapabilityUpdatedEventArgs> PlaylistCapabilityUpdated;

internal void RaisePlaylistCapabilityUpdatedEvent(MediaControlCapabilitySupport support)
{
PlaylistCapabilityUpdated?.Invoke(this, new PlaylistCapabilityUpdatedEventArgs(support));
}

/// <summary>
/// Occurs when the client custom capability is updated.
/// </summary>
/// <since_tizen> 11 </since_tizen>
public event EventHandler<ClientCustomCapabilityUpdatedEventArgs> ClientCustomCapabilityUpdated;

internal void RaiseClientCustomCapabilityUpdatedEvent(MediaControlCapabilitySupport support)
{
ClientCustomCapabilityUpdated?.Invoke(this, new ClientCustomCapabilityUpdatedEventArgs(support));
}

/// <summary>
/// Occurs when the search capability is updated.
/// </summary>
/// <since_tizen> 11 </since_tizen>
public event EventHandler<SearchCapabilityUpdatedEventArgs> SearchCapabilityUpdated;

internal void RaiseSearchCapabilityUpdatedEvent(MediaControlCapabilitySupport support)
{
SearchCapabilityUpdated?.Invoke(this, new SearchCapabilityUpdatedEventArgs(support));
}

/// <summary>
/// Occurs when the subtitle capability is updated.
/// </summary>
/// <since_tizen> 11 </since_tizen>
public event EventHandler<SubtitleCapabilityUpdatedEventArgs> SubtitleCapabilityUpdated;

internal void RaiseSubtitleCapabilityUpdatedEvent(MediaControlCapabilitySupport support)
{
SubtitleCapabilityUpdated?.Invoke(this, new SubtitleCapabilityUpdatedEventArgs(support));
}

/// <summary>
/// Occurs when the mode360 capability is updated.
/// </summary>
/// <since_tizen> 11 </since_tizen>
public event EventHandler<Mode360CapabilityUpdatedEventArgs> Mode360CapabilityUpdated;

internal void RaiseMode360CapabilityUpdatedEvent(MediaControlCapabilitySupport support)
{
Mode360CapabilityUpdated?.Invoke(this, new Mode360CapabilityUpdatedEventArgs(support));
}

/// <summary>
/// Occurs when the display mode capability is updated.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public event EventHandler<DisplayModeCapabilityUpdatedEventArgs> DisplayModeCapabilityUpdated;
Expand All @@ -270,7 +336,7 @@ internal void RaiseDisplayModeCapabilityUpdatedEvent(MediaControlNativeDisplayMo
}

/// <summary>
/// Occurs when the display rotation capabilities are updated.
/// Occurs when the display rotation capability is updated.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public event EventHandler<DisplayRotationCapabilityUpdatedEventArgs> DisplayRotationCapabilityUpdated;
Expand Down
84 changes: 84 additions & 0 deletions src/Tizen.Multimedia.Remoting/MediaController/MediaController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,90 @@ public MediaControlCapabilitySupport GetSubtitleModeCapability()
return support;
}

/// <summary>
/// Gets the value whether the playback position is supported or not.
/// </summary>
/// <returns>A <see cref="MediaControlCapabilitySupport"/>.</returns>
/// <exception cref="InvalidOperationException">
/// The server has already been stopped.<br/>
/// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MediaControllerManager"/> has already been disposed.</exception>
/// <since_tizen> 11 </since_tizen>
public MediaControlCapabilitySupport GetPlaybackPositionCapability()
{
ThrowIfStopped();

Native.GetSimpleCapability(Manager.Handle, ServerAppId, MediaControlNativeCapabilityCategory.PlaybackPosition, out MediaControlCapabilitySupport support).
ThrowIfError("Failed to get playback position capability");

return support;
}

/// <summary>
/// Gets the value whether the playlist is supported or not.
/// </summary>
/// <returns>A <see cref="MediaControlCapabilitySupport"/>.</returns>
/// <exception cref="InvalidOperationException">
/// The server has already been stopped.<br/>
/// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MediaControllerManager"/> has already been disposed.</exception>
/// <since_tizen> 11 </since_tizen>
public MediaControlCapabilitySupport GetPlaylistCapability()
{
ThrowIfStopped();

Native.GetSimpleCapability(Manager.Handle, ServerAppId, MediaControlNativeCapabilityCategory.Playlist, out MediaControlCapabilitySupport support).
ThrowIfError("Failed to get playlist capability");

return support;
}

/// <summary>
/// Gets the value whether the client custom is supported or not.
/// </summary>
/// <returns>A <see cref="MediaControlCapabilitySupport"/>.</returns>
/// <exception cref="InvalidOperationException">
/// The server has already been stopped.<br/>
/// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MediaControllerManager"/> has already been disposed.</exception>
/// <since_tizen> 11 </since_tizen>
public MediaControlCapabilitySupport GetClientCustomCapability()
{
ThrowIfStopped();

Native.GetSimpleCapability(Manager.Handle, ServerAppId, MediaControlNativeCapabilityCategory.ClientCustom, out MediaControlCapabilitySupport support).
ThrowIfError("Failed to get client custom capability");

return support;
}

/// <summary>
/// Gets the value whether the search is supported or not.
/// </summary>
/// <returns>A <see cref="MediaControlCapabilitySupport"/>.</returns>
/// <exception cref="InvalidOperationException">
/// The server has already been stopped.<br/>
/// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MediaControllerManager"/> has already been disposed.</exception>
/// <since_tizen> 11 </since_tizen>
public MediaControlCapabilitySupport GetSearchCapability()
{
ThrowIfStopped();

Native.GetSimpleCapability(Manager.Handle, ServerAppId, MediaControlNativeCapabilityCategory.Search, out MediaControlCapabilitySupport support).
ThrowIfError("Failed to get search capability");

return support;
}

/// <summary>
/// Gets the value whether the repeat mode is supported or not.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,32 @@ private void RegisterSimpleCapabilityUpdatedEvent()
{
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.ClientCustom:
GetController(serverName)?.RaiseClientCustomCapabilityUpdatedEvent(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;
}
};
Expand Down
Loading

0 comments on commit d204159

Please sign in to comment.