/*
* Copyright (c) 2018 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;
using System.Collections.Generic;
using System.Diagnostics;
namespace Tizen.Multimedia.Remoting
{
///
/// Specifies the playlist mode.
///
/// 5
public enum MediaControlPlaylistMode
{
///
/// Playlist is created or update.
///
Updated,
///
/// Playlist is removed.
///
Removed,
}
///
/// Specifies the repeat mode.
///
/// 4
public enum MediaControlRepeatMode
{
///
/// Off.
///
Off,
///
/// On.
///
On,
///
/// One media.
///
/// 5
OneMedia
}
///
/// Specifies playback commands.
///
/// 4
public enum MediaControlPlaybackCommand
{
///
/// Play.
///
Play,
///
/// Pause.
///
Pause,
///
/// Stop.
///
Stop,
///
/// Skip to next.
///
Next,
///
/// Skip to previous.
///
Previous,
///
/// Fast forward.
///
FastForward,
///
/// Rewind.
///
Rewind,
///
/// Toggle play/pause.
///
/// 5
Toggle,
}
///
/// Specifies playback states.
///
/// 4
public enum MediaControlPlaybackState
{
///
/// Unknown; no state is set.
///
None,
///
/// Playing.
///
Playing,
///
/// Paused.
///
Paused,
///
/// Stopped.
///
Stopped,
///
/// Fast forwarding.
///
FastForwarding,
///
/// Rewinding.
///
Rewinding,
///
/// Skipping to the next item.
///
/// 5
MovingToNext,
///
/// Skipping to the previous item.
///
/// 5
MovingToPrevious,
///
/// Connecting.
///
/// 8
Connecting,
///
/// Buffering.
///
/// 8
Buffering,
///
/// Error while playback.
///
/// 8
Error
}
///
/// Specifies the support type of media control capability.
///
/// 5
public enum MediaControlCapabilitySupport
{
///
/// Supported.
///
Supported,
///
/// Not supported.
///
NotSupported,
///
/// There's no support info in server.
///
/// User should not set this value directly.
NotDecided
}
///
/// Specifies the content type.
///
/// 5
public enum MediaControlContentType
{
///
/// Image type.
///
Image,
///
/// Video type.
///
Video,
///
/// Music type.
///
Music,
///
/// Other type.
///
Other,
///
/// There's no content type info in server.
///
NotDecided
}
///
/// Specifies the search category.
///
/// 5
public enum MediaControlSearchCategory
{
///
/// Search by all category.
///
All,
///
/// Search by content title.
///
Title,
///
/// Search by content artist.
///
Artist,
///
/// Search by content album.
///
Album,
///
/// Search by content genre.
///
Genre,
///
/// Search by TPO(Time Place Occasion).
///
Tpo
}
///
/// Specifies the display mode.
///
/// 6
public enum MediaControlDisplayMode
{
///
/// Letter box
///
LetterBox,
///
/// Original size
///
OriginSize,
///
/// Full screen
///
FullScreen,
///
/// Cropped full screen
///
CroppedFull
}
///
/// Specifies the code which represents the result of communication between client and server.
///
/// 8
public enum MediaControlResult
{
///
/// The command or the event has been successfully completed.
///
Success,
///
/// The command or the event had already been completed.
///
AlreadyDone = 200,
///
/// The command or the event is aborted by some external event (e.g. aborted play command by incoming call).
///
Aborted = 300,
///
/// The command or the event is denied due to application policy (e.g. cannot rewind in recording).
///
ActionDenied,
///
/// The command or the event is not supported.
///
NotSupported,
///
/// The command or the event is out of supported range or the limit is reached.
///
Invalid,
///
/// Timeout has occurred.
///
Timeout = 400,
///
/// The application has failed.
///
ApplicationFailed,
///
/// The command or the event has failed because the application has no media.
///
NoMedia,
///
/// The command or the event has failed because there is no audio output device.
///
NoAudioOutputDevice,
///
/// The command or the event has failed because there is no peer.
///
NoPeer,
///
/// The network has failed.
///
NetworkFailed = 500,
///
/// The application does not have account.
///
NoAccount = 600,
///
/// The application could not log in.
///
LoginFailed,
///
/// Unknown error.
///
Unknown = Int32.MaxValue
}
internal static class EnumExtensions
{
internal static MediaControlPlaybackState ToPublic(this MediaControllerNativePlaybackState nativeState)
{
switch (nativeState)
{
case MediaControllerNativePlaybackState.None: return MediaControlPlaybackState.None;
case MediaControllerNativePlaybackState.Play: return MediaControlPlaybackState.Playing;
case MediaControllerNativePlaybackState.Pause: return MediaControlPlaybackState.Paused;
case MediaControllerNativePlaybackState.Stop: return MediaControlPlaybackState.Stopped;
case MediaControllerNativePlaybackState.Next:
case MediaControllerNativePlaybackState.MovingToNext: return MediaControlPlaybackState.MovingToNext;
case MediaControllerNativePlaybackState.Prev:
case MediaControllerNativePlaybackState.MovingToPrev: return MediaControlPlaybackState.MovingToPrevious;
case MediaControllerNativePlaybackState.FastForward:
case MediaControllerNativePlaybackState.FastForwarding: return MediaControlPlaybackState.FastForwarding;
case MediaControllerNativePlaybackState.Rewind:
case MediaControllerNativePlaybackState.Rewinding: return MediaControlPlaybackState.Rewinding;
case MediaControllerNativePlaybackState.Connecting: return MediaControlPlaybackState.Connecting;
case MediaControllerNativePlaybackState.Buffering: return MediaControlPlaybackState.Buffering;
case MediaControllerNativePlaybackState.Error: return MediaControlPlaybackState.Error;
}
Debug.Fail($"Not supported code for playback state{nativeState}.");
return MediaControlPlaybackState.None;
}
internal static MediaControllerNativePlaybackState ToNative(this MediaControlPlaybackState state)
{
switch (state)
{
case MediaControlPlaybackState.Playing: return MediaControllerNativePlaybackState.Play;
case MediaControlPlaybackState.Paused: return MediaControllerNativePlaybackState.Pause;
case MediaControlPlaybackState.Stopped: return MediaControllerNativePlaybackState.Stop;
case MediaControlPlaybackState.MovingToNext: return MediaControllerNativePlaybackState.MovingToNext;
case MediaControlPlaybackState.MovingToPrevious: return MediaControllerNativePlaybackState.MovingToPrev;
case MediaControlPlaybackState.FastForwarding: return MediaControllerNativePlaybackState.FastForwarding;
case MediaControlPlaybackState.Rewinding: return MediaControllerNativePlaybackState.Rewinding;
case MediaControlPlaybackState.Connecting: return MediaControllerNativePlaybackState.Connecting;
case MediaControlPlaybackState.Buffering: return MediaControllerNativePlaybackState.Buffering;
case MediaControlPlaybackState.Error: return MediaControllerNativePlaybackState.Error;
}
return MediaControllerNativePlaybackState.None;
}
internal static MediaControlPlaybackCommand ToPublic(this MediaControllerNativePlaybackAction nativeAction)
{
switch (nativeAction)
{
case MediaControllerNativePlaybackAction.Play: return MediaControlPlaybackCommand.Play;
case MediaControllerNativePlaybackAction.Pause: return MediaControlPlaybackCommand.Pause;
case MediaControllerNativePlaybackAction.Stop: return MediaControlPlaybackCommand.Stop;
case MediaControllerNativePlaybackAction.Next: return MediaControlPlaybackCommand.Next;
case MediaControllerNativePlaybackAction.Prev: return MediaControlPlaybackCommand.Previous;
case MediaControllerNativePlaybackAction.FastForward: return MediaControlPlaybackCommand.FastForward;
case MediaControllerNativePlaybackAction.Rewind: return MediaControlPlaybackCommand.Rewind;
case MediaControllerNativePlaybackAction.Toggle: return MediaControlPlaybackCommand.Toggle;
}
Debug.Fail($"Not supported code for playback command{nativeAction}.");
return MediaControlPlaybackCommand.Play;
}
internal static MediaControllerNativePlaybackAction ToNative(this MediaControlPlaybackCommand command)
{
switch (command)
{
case MediaControlPlaybackCommand.Play: return MediaControllerNativePlaybackAction.Play;
case MediaControlPlaybackCommand.Pause: return MediaControllerNativePlaybackAction.Pause;
case MediaControlPlaybackCommand.Stop: return MediaControllerNativePlaybackAction.Stop;
case MediaControlPlaybackCommand.Next: return MediaControllerNativePlaybackAction.Next;
case MediaControlPlaybackCommand.Previous: return MediaControllerNativePlaybackAction.Prev;
case MediaControlPlaybackCommand.FastForward: return MediaControllerNativePlaybackAction.FastForward;
case MediaControlPlaybackCommand.Rewind: return MediaControllerNativePlaybackAction.Rewind;
case MediaControlPlaybackCommand.Toggle: return MediaControllerNativePlaybackAction.Toggle;
}
return MediaControllerNativePlaybackAction.Play;
}
internal static MediaControlRepeatMode ToPublic(this MediaControllerNativeRepeatMode mode)
{
Debug.Assert(Enum.IsDefined(typeof(MediaControllerNativeRepeatMode), mode));
return mode == MediaControllerNativeRepeatMode.Off ? MediaControlRepeatMode.On :
(mode == MediaControllerNativeRepeatMode.On ? MediaControlRepeatMode.Off : MediaControlRepeatMode.OneMedia);
}
internal static MediaControllerNativeRepeatMode ToNative(this MediaControlRepeatMode mode)
{
Debug.Assert(Enum.IsDefined(typeof(MediaControlRepeatMode), mode));
return mode == MediaControlRepeatMode.Off ? MediaControllerNativeRepeatMode.On :
(mode == MediaControlRepeatMode.On ? MediaControllerNativeRepeatMode.Off : MediaControllerNativeRepeatMode.OneMedia);
}
internal static MediaControlNativeDisplayMode ToNative(this MediaControlDisplayMode mode)
{
Debug.Assert(Enum.IsDefined(typeof(MediaControlDisplayMode), mode));
MediaControlNativeDisplayMode nativeMode = MediaControlNativeDisplayMode.LetterBox;
switch (mode)
{
case MediaControlDisplayMode.LetterBox:
nativeMode = MediaControlNativeDisplayMode.LetterBox;
break;
case MediaControlDisplayMode.OriginSize:
nativeMode = MediaControlNativeDisplayMode.OriginSize;
break;
case MediaControlDisplayMode.FullScreen:
nativeMode = MediaControlNativeDisplayMode.FullScreen;
break;
case MediaControlDisplayMode.CroppedFull:
nativeMode = MediaControlNativeDisplayMode.CroppedFull;
break;
}
return nativeMode;
}
internal static MediaControlDisplayMode ToPublic(this MediaControlNativeDisplayMode mode)
{
Debug.Assert(Enum.IsDefined(typeof(MediaControlNativeDisplayMode), mode));
MediaControlDisplayMode nativeMode = MediaControlDisplayMode.LetterBox;
switch (mode)
{
case MediaControlNativeDisplayMode.LetterBox:
nativeMode = MediaControlDisplayMode.LetterBox;
break;
case MediaControlNativeDisplayMode.OriginSize:
nativeMode = MediaControlDisplayMode.OriginSize;
break;
case MediaControlNativeDisplayMode.FullScreen:
nativeMode = MediaControlDisplayMode.FullScreen;
break;
case MediaControlNativeDisplayMode.CroppedFull:
nativeMode = MediaControlDisplayMode.CroppedFull;
break;
}
return nativeMode;
}
internal static IList ToPublicList(this MediaControlNativeDisplayMode modes)
{
var supportedModes = new List();
foreach (MediaControlNativeDisplayMode mode in Enum.GetValues(typeof(MediaControlNativeDisplayMode)))
{
if (modes.HasFlag(mode))
{
supportedModes.Add(mode.ToPublic());
}
}
return supportedModes.AsReadOnly();
}
internal static MediaControlNativeDisplayRotation ToNative(this Rotation mode)
{
Debug.Assert(Enum.IsDefined(typeof(Rotation), mode));
MediaControlNativeDisplayRotation nativeMode = MediaControlNativeDisplayRotation.Rotate0;
switch (mode)
{
case Rotation.Rotate0:
nativeMode = MediaControlNativeDisplayRotation.Rotate0;
break;
case Rotation.Rotate90:
nativeMode = MediaControlNativeDisplayRotation.Rotate90;
break;
case Rotation.Rotate180:
nativeMode = MediaControlNativeDisplayRotation.Rotate180;
break;
case Rotation.Rotate270:
nativeMode = MediaControlNativeDisplayRotation.Rotate270;
break;
}
return nativeMode;
}
internal static Rotation ToPublic(this MediaControlNativeDisplayRotation mode)
{
Debug.Assert(Enum.IsDefined(typeof(MediaControlNativeDisplayRotation), mode));
Rotation nativeMode = Rotation.Rotate0;
switch (mode)
{
case MediaControlNativeDisplayRotation.Rotate0:
nativeMode = Rotation.Rotate0;
break;
case MediaControlNativeDisplayRotation.Rotate90:
nativeMode = Rotation.Rotate90;
break;
case MediaControlNativeDisplayRotation.Rotate180:
nativeMode = Rotation.Rotate180;
break;
case MediaControlNativeDisplayRotation.Rotate270:
nativeMode = Rotation.Rotate270;
break;
}
return nativeMode;
}
internal static IList ToPublicList(this MediaControlNativeDisplayRotation modes)
{
var supportedRotations = new List();
foreach (MediaControlNativeDisplayRotation mode in Enum.GetValues(typeof(MediaControlNativeDisplayRotation)))
{
if (modes.HasFlag(mode))
{
supportedRotations.Add(mode.ToPublic());
}
}
return supportedRotations.AsReadOnly();
}
}
}