summaryrefslogtreecommitdiff
path: root/src/Tizen.Multimedia.Remoting/MediaController
diff options
context:
space:
mode:
Diffstat (limited to 'src/Tizen.Multimedia.Remoting/MediaController')
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/CustomCommandEventArgs.cs57
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/CustomCommandReplyEventArgs.cs57
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/MediaControllerClient.cs595
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/MediaControllerEnums.cs236
-rw-r--r--src/Tizen.Multimedia.Remoting/MediaController/MediaControllerError.cs57
-rw-r--r--src/Tizen.Multimedia.Remoting/MediaController/MediaControllerLog.cs25
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/MediaControllerMetadata.cs123
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/MediaControllerPlayback.cs76
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/MediaControllerServer.cs302
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/MetadataUpdatedEventArgs.cs49
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/PlaybackStateCommandEventArgs.cs49
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/PlaybackUpdatedEventArgs.cs49
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/RepeatModeUpdatedEventArgs.cs49
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/ServerInformation.cs45
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/ServerUpdatedEventArgs.cs42
-rwxr-xr-xsrc/Tizen.Multimedia.Remoting/MediaController/ShuffleModeUpdatedEventArgs.cs49
16 files changed, 1860 insertions, 0 deletions
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/CustomCommandEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/CustomCommandEventArgs.cs
new file mode 100755
index 0000000..a485e3f
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/CustomCommandEventArgs.cs
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2016 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 Tizen.Applications;
+
+namespace Tizen.Multimedia.MediaController
+{
+
+ /// <summary>
+ /// CustomCommandRecieved event arguments
+ /// </summary>
+ /// <remarks>
+ /// CustomCommandRecieved event arguments
+ /// </remarks>
+ public class CustomCommandEventArgs : EventArgs
+ {
+ internal CustomCommandEventArgs(string name, string command, Bundle bundle)
+ {
+ ClientName = name;
+ Command = command;
+ BundleData = bundle;
+ }
+
+ /// <summary>
+ /// Get the Client Name.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string ClientName { get; }
+
+ /// <summary>
+ /// Get the Custom Command.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string Command { get; }
+
+ /// <summary>
+ /// Get the Bundle Data.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public Bundle BundleData { get; }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/CustomCommandReplyEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/CustomCommandReplyEventArgs.cs
new file mode 100755
index 0000000..e7bac0e
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/CustomCommandReplyEventArgs.cs
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2016 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 Tizen.Applications;
+
+namespace Tizen.Multimedia.MediaController
+{
+
+ /// <summary>
+ /// CustomCommandRecieved event arguments
+ /// </summary>
+ /// <remarks>
+ /// CustomCommandRecieved event arguments
+ /// </remarks>
+ public class CustomCommandReplyEventArgs : EventArgs
+ {
+ internal CustomCommandReplyEventArgs(string serverName, int result, Bundle bundle)
+ {
+ ServerName = serverName;
+ Result = result;
+ BundleData = bundle;
+ }
+
+ /// <summary>
+ /// Get the Sserver Name.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string ServerName { get; }
+
+ /// <summary>
+ /// Get the Result.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public int Result { get; }
+
+ /// <summary>
+ /// Get the Bundle Data.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public Bundle BundleData { get; }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerClient.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerClient.cs
new file mode 100755
index 0000000..529719a
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerClient.cs
@@ -0,0 +1,595 @@
+/*
+* Copyright (c) 2016 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.Runtime.InteropServices;
+using System.Threading.Tasks;
+using Tizen.Applications;
+using Native = Interop.MediaControllerClient;
+
+namespace Tizen.Multimedia.MediaController
+{
+
+ /// <summary>
+ /// The MediaControllerClient class provides APIs required for media-controller-client.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/mediacontroller.client
+ /// </privilege>
+ /// <remarks>
+ /// The MediaControllerClient APIs provides functions to get media information from server.
+ /// </remarks>
+ public class MediaControllerClient : IDisposable
+ {
+ internal IntPtr _handle = IntPtr.Zero;
+
+ private bool _disposed = false;
+ private EventHandler<ServerUpdatedEventArgs> _serverUpdated;
+ private Native.ServerUpdatedCallback _serverUpdatedCallback;
+ private EventHandler<PlaybackUpdatedEventArgs> _playbackUpdated;
+ private Native.PlaybackUpdatedCallback _playbackUpdatedCallback;
+ private EventHandler<MetadataUpdatedEventArgs> _metadataUpdated;
+ private Native.MetadataUpdatedCallback _metadataUpdatedCallback;
+ private EventHandler<ShuffleModeUpdatedEventArgs> _shufflemodeUpdated;
+ private Native.ShuffleModeUpdatedCallback _shufflemodeUpdatedCallback;
+ private EventHandler<RepeatModeUpdatedEventArgs> _repeatmodeUpdated;
+ private Native.RepeatModeUpdatedCallback _repeatmodeUpdatedCallback;
+ private EventHandler<CustomCommandReplyEventArgs> _customcommandReply;
+ private Native.CommandReplyRecievedCallback _customcommandReplyCallback;
+
+ private bool IsValidHandle
+ {
+ get { return (_handle != IntPtr.Zero); }
+ }
+
+ private IntPtr SafeHandle
+ {
+ get
+ {
+ if (!IsValidHandle)
+ {
+ throw new ObjectDisposedException(nameof(MediaControllerClient), "Fail to operate MediaControllerClient");
+ }
+
+ return _handle;
+ }
+ }
+
+ /// <summary>
+ /// The constructor of MediaControllerClient class.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when the access is denied for media controller client</exception>
+ public MediaControllerClient()
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.Create(out _handle), "Create client failed");
+ }
+
+ ~MediaControllerClient()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ // To be used if there are any other disposable objects
+ }
+
+ if (IsValidHandle)
+ {
+ Native.Destroy(_handle);
+ _handle = IntPtr.Zero;
+ }
+
+ _disposed = true;
+ }
+ }
+
+ /// <summary>
+ /// ServerUpdated event is raised when server is changed
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public event EventHandler<ServerUpdatedEventArgs> ServerUpdated
+ {
+ add
+ {
+ if (_serverUpdated == null)
+ {
+ RegisterServerUpdatedEvent();
+ }
+
+ _serverUpdated += value;
+
+ }
+
+ remove
+ {
+ _serverUpdated -= value;
+ if (_serverUpdated == null)
+ {
+ UnregisterServerUpdatedEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// PlaybackUpdated event is raised when playback is changed
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public event EventHandler<PlaybackUpdatedEventArgs> PlaybackUpdated
+ {
+ add
+ {
+ if (_playbackUpdated == null)
+ {
+ RegisterPlaybackUpdatedEvent();
+ }
+
+ _playbackUpdated += value;
+
+ }
+
+ remove
+ {
+ _playbackUpdated -= value;
+ if (_playbackUpdated == null)
+ {
+ UnregisterPlaybackUpdatedEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// MetadataUpdated event is raised when metadata is changed
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public event EventHandler<MetadataUpdatedEventArgs> MetadataUpdated
+ {
+ add
+ {
+ if (_metadataUpdated == null)
+ {
+ RegisterMetadataUpdatedEvent();
+ }
+
+ _metadataUpdated += value;
+
+ }
+
+ remove
+ {
+ _metadataUpdated -= value;
+ if (_metadataUpdated == null)
+ {
+ UnregisterMetadataUpdatedEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// ShuffleModeUpdated event is raised when shuffle mode is changed
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public event EventHandler<ShuffleModeUpdatedEventArgs> ShuffleModeUpdated
+ {
+ add
+ {
+ if (_shufflemodeUpdated == null)
+ {
+ RegisterShuffleModeUpdatedEvent();
+ }
+
+ _shufflemodeUpdated += value;
+
+ }
+
+ remove
+ {
+ _shufflemodeUpdated -= value;
+ if (_shufflemodeUpdated == null)
+ {
+ UnregisterShuffleModeUpdatedEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// RepeatModeUpdated event is raised when server is changed
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public event EventHandler<RepeatModeUpdatedEventArgs> RepeatModeUpdated
+ {
+ add
+ {
+ if (_repeatmodeUpdated == null)
+ {
+ RegisterRepeatModeUpdatedEvent();
+ }
+
+ _repeatmodeUpdated += value;
+ }
+
+ remove
+ {
+ _repeatmodeUpdated -= value;
+ if (_repeatmodeUpdated == null)
+ {
+ UnregisterRepeatModeUpdatedEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// CommandReply event is raised when reply for command is recieved
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public event EventHandler<CustomCommandReplyEventArgs> CustomCommandReply
+ {
+ add
+ {
+ if (_customcommandReply == null)
+ {
+ _customcommandReplyCallback = (IntPtr serverName, int result, IntPtr bundle, IntPtr userData) =>
+ {
+ SafeBundleHandle safeBundleHandle = new SafeBundleHandle(bundle, true);
+ Bundle bundleData = new Bundle(safeBundleHandle);
+ CustomCommandReplyEventArgs eventArgs = new CustomCommandReplyEventArgs(Marshal.PtrToStringAnsi(serverName), result, bundleData);
+ _customcommandReply?.Invoke(this, eventArgs);
+ };
+ }
+
+ _customcommandReply += value;
+
+ }
+
+ remove
+ {
+ _customcommandReply -= value;
+ if (_customcommandReply == null)
+ {
+ _customcommandReplyCallback = null;
+ }
+ }
+ }
+
+ /// <summary>
+ /// gets latest server information </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <returns>The name and state of the latest media controller server application: ServerInformation object</returns>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public ServerInformation GetLatestServer()
+ {
+ IntPtr name = IntPtr.Zero;
+ MediaControllerServerState state = MediaControllerServerState.None;
+
+ try
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.GetLatestServer(SafeHandle, out name, out state), "Get Latest server failed");
+ return new ServerInformation(Marshal.PtrToStringAnsi(name), (MediaControllerServerState)state);
+ }
+ finally
+ {
+ LibcSupport.Free(name);
+ }
+ }
+
+ /// <summary>
+ /// gets playback information for specific server </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="serverName"> Server Name </param>
+ /// <returns>The playback state and playback position of the specific media controller server application:MediaControllerPlayback object</returns>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public MediaControllerPlayback GetPlayback(string serverName)
+ {
+ IntPtr playbackHandle = IntPtr.Zero;
+ MediaControllerPlayback playback = null;
+
+ try
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.GetServerPlayback(SafeHandle, serverName, out playbackHandle), "Get Playback handle failed");
+ playback = new MediaControllerPlayback(playbackHandle);
+ }
+ finally
+ {
+ if (playbackHandle != IntPtr.Zero)
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.DestroyPlayback(playbackHandle), "Destroy playback failed");
+ }
+ }
+
+ return playback;
+ }
+
+ /// <summary>
+ /// gets metadata information for specific server </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="serverName"> Server Name </param>
+ /// <returns>The metadata information of the specific media controller server application:MediaControllerMetadata object</returns>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public MediaControllerMetadata GetMetadata(string serverName)
+ {
+ IntPtr metadataHandle = IntPtr.Zero;
+ MediaControllerMetadata metadata = null;
+
+ try
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.GetServerMetadata(SafeHandle, serverName, out metadataHandle), "Get Metadata handle failed");
+ metadata = new MediaControllerMetadata(metadataHandle);
+ }
+ finally
+ {
+ if (metadataHandle != IntPtr.Zero)
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.DestroyMetadata(metadataHandle), "Destroy metadata failed");
+ }
+ }
+
+ return metadata;
+ }
+
+ /// <summary>
+ /// gets shuffle mode for specific server </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="serverName"> Server Name </param>
+ /// <returns>The shuffle mode of the specific media controller server application:MediaControllerShuffleMode enum</returns>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public MediaControllerShuffleMode GetShuffleMode(string serverName)
+ {
+ MediaControllerShuffleMode shuffleMode = MediaControllerShuffleMode.Off;
+
+ MediaControllerValidator.ThrowIfError(
+ Native.GetServerShuffleMode(SafeHandle, serverName, out shuffleMode), "Get ShuffleMode failed");
+
+ return shuffleMode;
+ }
+
+ /// <summary>
+ /// gets repeat mode for specific server </summary>\
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="serverName"> Server Name </param>
+ /// <returns>The repeat mode of the specific media controller server application:MediaControllerRepeatMode enum</returns>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public MediaControllerRepeatMode GetRepeatMode(string serverName)
+ {
+ MediaControllerRepeatMode repeatMode = MediaControllerRepeatMode.Off;
+
+ MediaControllerValidator.ThrowIfError(
+ Native.GetServerRepeatMode(SafeHandle, serverName, out repeatMode), "Get RepeatMode failed");
+
+ return repeatMode;
+ }
+
+ /// <summary>
+ /// Send command of playback state to server application </summary>
+ /// <param name="serverName"> Server Name </param>
+ /// <param name="state"> Playback State </param>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public void SendPlaybackStateCommand(string serverName, MediaControllerPlaybackState state)
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.SendPlaybackStateCommand(SafeHandle, serverName, state), "Send playback state command failed");
+ }
+
+ /// <summary>
+ /// Send customized command to server application </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="serverName"> Server Name </param>
+ /// <param name="command"> Command </param>
+ /// <param name="bundle"> Bundle data </param>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public void SendCustomCommand(string serverName, string command, Bundle bundle)
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.SendCustomCommand(SafeHandle, serverName, command, bundle.SafeBundleHandle, _customcommandReplyCallback, IntPtr.Zero),
+ "Send custom command failed");
+ }
+
+ /// <summary>
+ /// Subscribe subscription type from specific server application </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="type"> Subscription Type </param>
+ /// <param name="serverName"> Server Name </param>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ public void Subscribe(MediaControllerSubscriptionType type, string serverName)
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.Subscribe(SafeHandle, type, serverName), "Subscribe failed");
+ }
+
+ /// <summary>
+ /// Subscribe subscription type from specific server application </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="type"> Subscription Type </param>
+ /// <param name="serverName"> Server Name </param>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ public void Unsubscribe(MediaControllerSubscriptionType type, string serverName)
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.Unsubscribe(SafeHandle, type, serverName), "Unsubscribe failed");
+ }
+
+ /// <summary>
+ /// gets activated server list </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <returns>The list of activated media controller server applications: IEnumerable of string</returns>
+ public Task<IEnumerable<string>> GetActivatedServerList()
+ {
+ var task = new TaskCompletionSource<IEnumerable<string>>();
+
+ List<string> collectionList = ForEachActivatedServer(SafeHandle);
+ task.TrySetResult((IEnumerable<string>)collectionList);
+
+ return task.Task;
+ }
+
+ /// <summary>
+ /// gets subscribed server list </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="subscriptionType"> Subscription Type </param>
+ /// <returns>The list of subscribed media controller server applications: IEnumerable of string</returns>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public Task<IEnumerable<string>> GetSubscribedServerList(MediaControllerSubscriptionType subscriptionType)
+ {
+ var task = new TaskCompletionSource<IEnumerable<string>>();
+
+ List<string> collectionList = ForEachSubscribedServer(SafeHandle, subscriptionType);
+ task.TrySetResult((IEnumerable<string>)collectionList);
+
+ return task.Task;
+ }
+
+ private void RegisterServerUpdatedEvent()
+ {
+ _serverUpdatedCallback = (IntPtr serverName, MediaControllerServerState serverState, IntPtr userData) =>
+ {
+ ServerUpdatedEventArgs eventArgs = new ServerUpdatedEventArgs(Marshal.PtrToStringAnsi(serverName), serverState);
+ _serverUpdated?.Invoke(this, eventArgs);
+ };
+ Native.SetServerUpdatedCb(SafeHandle, _serverUpdatedCallback, IntPtr.Zero);
+ }
+
+ private void UnregisterServerUpdatedEvent()
+ {
+ Native.UnsetServerUpdatedCb(SafeHandle);
+ }
+
+ private void RegisterPlaybackUpdatedEvent()
+ {
+ _playbackUpdatedCallback = (IntPtr serverName, IntPtr playback, IntPtr userData) =>
+ {
+ PlaybackUpdatedEventArgs eventArgs = new PlaybackUpdatedEventArgs(Marshal.PtrToStringAnsi(serverName), playback);
+ _playbackUpdated?.Invoke(this, eventArgs);
+ };
+ Native.SetPlaybackUpdatedCb(SafeHandle, _playbackUpdatedCallback, IntPtr.Zero);
+ }
+
+ private void UnregisterPlaybackUpdatedEvent()
+ {
+ Native.UnsetPlaybackUpdatedCb(SafeHandle);
+ }
+
+ private void RegisterMetadataUpdatedEvent()
+ {
+ _metadataUpdatedCallback = (IntPtr serverName, IntPtr metadata, IntPtr userData) =>
+ {
+ MetadataUpdatedEventArgs eventArgs = new MetadataUpdatedEventArgs(Marshal.PtrToStringAnsi(serverName), metadata);
+ _metadataUpdated?.Invoke(this, eventArgs);
+ };
+ Native.SetMetadataUpdatedCb(SafeHandle, _metadataUpdatedCallback, IntPtr.Zero);
+ }
+
+ private void UnregisterMetadataUpdatedEvent()
+ {
+ Native.UnsetMetadataUpdatedCb(SafeHandle);
+ }
+
+ private void RegisterShuffleModeUpdatedEvent()
+ {
+ _shufflemodeUpdatedCallback = (IntPtr serverName, MediaControllerShuffleMode shuffleMode, IntPtr userData) =>
+ {
+ ShuffleModeUpdatedEventArgs eventArgs = new ShuffleModeUpdatedEventArgs(Marshal.PtrToStringAnsi(serverName), shuffleMode);
+ _shufflemodeUpdated?.Invoke(this, eventArgs);
+ };
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetShuffleModeUpdatedCb(SafeHandle, _shufflemodeUpdatedCallback, IntPtr.Zero),
+ "Set ShuffleModeUpdated callback failed");
+ }
+
+ private void UnregisterShuffleModeUpdatedEvent()
+ {
+ Native.UnsetShuffleModeUpdatedCb(SafeHandle);
+ }
+
+ private void RegisterRepeatModeUpdatedEvent()
+ {
+ _repeatmodeUpdatedCallback = (IntPtr serverName, MediaControllerRepeatMode repeatMode, IntPtr userData) =>
+ {
+ RepeatModeUpdatedEventArgs eventArgs = new RepeatModeUpdatedEventArgs(Marshal.PtrToStringAnsi(serverName), repeatMode);
+ _repeatmodeUpdated?.Invoke(this, eventArgs);
+ };
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetRepeatModeUpdatedCb(SafeHandle, _repeatmodeUpdatedCallback, IntPtr.Zero),
+ "Set RepeatModeUpdated callback failed");
+ }
+
+ private void UnregisterRepeatModeUpdatedEvent()
+ {
+ Native.UnsetRepeatModeUpdatedCb(SafeHandle);
+ }
+
+ private static List<string> ForEachSubscribedServer(IntPtr handle, MediaControllerSubscriptionType subscriptionType)
+ {
+ List<string> subscribedServerCollections = new List<string>();
+
+ Native.SubscribedServerCallback serverCallback = (IntPtr serverName, IntPtr userData) =>
+ {
+ subscribedServerCollections.Add(Marshal.PtrToStringAnsi(serverName));
+ return true;
+ };
+
+ MediaControllerValidator.ThrowIfError(
+ Native.ForeachSubscribedServer(handle, subscriptionType, serverCallback, IntPtr.Zero),
+ "Foreach Subscribed server failed");
+
+ return subscribedServerCollections;
+ }
+
+ private static List<string> ForEachActivatedServer(IntPtr handle)
+ {
+ List<string> activatedServerCollections = new List<string>();
+
+ Native.ActivatedServerCallback serverCallback = (IntPtr serverName, IntPtr userData) =>
+ {
+ activatedServerCollections.Add(Marshal.PtrToStringAnsi(serverName));
+ return true;
+ };
+
+ MediaControllerValidator.ThrowIfError(
+ Native.ForeachActivatedServer(handle, serverCallback, IntPtr.Zero),
+ "Foreach Activated server failed");
+
+ return activatedServerCollections;
+ }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerEnums.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerEnums.cs
new file mode 100755
index 0000000..dc12318
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerEnums.cs
@@ -0,0 +1,236 @@
+/*
+* Copyright (c) 2016 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.
+*/
+
+
+namespace Tizen.Multimedia.MediaController
+{
+ /// <summary>
+ /// Specifies states that a <see cref="ServerInformation"/> can have.
+ /// </summary>
+ public enum MediaControllerServerState
+ {
+ /// <summary>
+ /// Server state is unknown
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ None,
+
+ /// <summary>
+ /// Server is activated
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Activated,
+
+ /// <summary>
+ /// Server is deactivated
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Deactivated,
+ }
+
+ /// <summary>
+ /// Enumeration for playback state
+ /// </summary>
+ public enum MediaControllerPlaybackState
+ {
+ /// <summary>
+ /// Playback state is unknown
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ None,
+
+ /// <summary>
+ /// Playback is playing
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Play,
+
+ /// <summary>
+ /// Playback is paused
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Pause,
+
+ /// <summary>
+ /// Playback is next
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Next,
+
+ /// <summary>
+ /// Playback is prev
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Prev,
+
+ /// <summary>
+ /// Playback is fastforward
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ FastForward,
+
+ /// <summary>
+ /// Playback is rewind
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Rewind,
+ }
+
+ /// <summary>
+ /// Enumeration for shuffle mode
+ /// </summary>
+ public enum MediaControllerShuffleMode
+ {
+ /// <summary>
+ /// Shuffle mode is On
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ On,
+
+ /// <summary>
+ /// Shuffle mode is Off
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Off,
+ }
+
+ /// <summary>
+ /// Enumeration for repeat mode
+ /// </summary>
+ public enum MediaControllerRepeatMode
+ {
+ /// <summary>
+ /// Repeat mode is On
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ On,
+
+ /// <summary>
+ /// Repeat mode is Off
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Off,
+ }
+
+ /// <summary>
+ /// Enumeration for repeat mode
+ /// </summary>
+ public enum MediaControllerSubscriptionType
+ {
+ /// <summary>
+ /// The type of subscription is the state of server
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ ServerState,
+
+ /// <summary>
+ /// The type of subscription is the playback
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Playback,
+
+ /// <summary>
+ /// The type of subscription is the metadata
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Metadata,
+
+ /// <summary>
+ /// The type of subscription is the shuffle mode
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ ShuffleMode,
+
+ /// <summary>
+ /// The type of subscription is the repeat mode
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ RepeatMode,
+ }
+
+ /// <summary>
+ /// Enumeration for metadata attributes
+ /// </summary>
+ internal enum MediaControllerAttributes
+ {
+ /// <summary>
+ /// Attribute is title
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Title,
+
+ /// <summary>
+ /// Attribute is artist
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Artist,
+
+ /// <summary>
+ /// Attribute is album
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Album,
+
+ /// <summary>
+ /// Attribute is author
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Author,
+
+ /// <summary>
+ /// Attribute is genre
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Genre,
+
+ /// <summary>
+ /// Attribute is duration
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Duration,
+
+ /// <summary>
+ /// Attribute is date
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Date,
+
+ /// <summary>
+ /// Attribute is copyright
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Copyright,
+
+ /// <summary>
+ /// Attribute is description
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Description,
+
+ /// <summary>
+ /// Attribute is track number
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ TrackNumber,
+
+ /// <summary>
+ /// Attribute is picture
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ Picture,
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerError.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerError.cs
new file mode 100644
index 0000000..680bedd
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerError.cs
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2016 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.IO;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Multimedia.MediaController
+{
+ internal enum MediaControllerError
+ {
+ None = ErrorCode.None,
+ InvalidParameter = ErrorCode.InvalidParameter,
+ OutOfMemory = ErrorCode.OutOfMemory,
+ InvalidOperation = ErrorCode.InvalidOperation,
+ NoSpaceOnDevice = ErrorCode.FileNoSpaceOnDevice,
+ PermissionDenied = ErrorCode.PermissionDenied,
+ };
+
+ internal static class MediaControllerValidator
+ {
+ internal static void ThrowIfError(MediaControllerError error, string errorMessage)
+ {
+ switch (error)
+ {
+ case MediaControllerError.InvalidParameter:
+ throw new ArgumentException(errorMessage);
+
+ case MediaControllerError.OutOfMemory:
+ throw new OutOfMemoryException(errorMessage);
+
+ case MediaControllerError.InvalidOperation:
+ throw new InvalidOperationException(errorMessage);
+
+ case MediaControllerError.NoSpaceOnDevice:
+ throw new IOException(errorMessage);
+
+ case MediaControllerError.PermissionDenied:
+ throw new UnauthorizedAccessException(errorMessage);
+ }
+ }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerLog.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerLog.cs
new file mode 100644
index 0000000..44eac12
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerLog.cs
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2016 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.MediaController
+{
+ static internal class MediaControllerLog
+ {
+ internal const string LogTag = "Tizen.Multimedia.MediaController";
+ }
+} \ No newline at end of file
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerMetadata.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerMetadata.cs
new file mode 100755
index 0000000..1b0968b
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerMetadata.cs
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2016 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 Native = Interop.MediaControllerClient;
+
+namespace Tizen.Multimedia.MediaController
+{
+ /// <summary>
+ /// Metadata represents a metadata of media for server application to play
+ /// </summary>
+ public class MediaControllerMetadata
+ {
+ /// <summary>
+ /// The constructor of MediaControllerMetadata class.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public MediaControllerMetadata()
+ {
+ // Do nothing
+ }
+
+ internal MediaControllerMetadata(IntPtr handle)
+ {
+ if (handle == IntPtr.Zero)
+ {
+ throw new InvalidOperationException("MediaControllerMetadata is not valid.");
+ }
+
+ Title = Native.GetMetadata(handle, MediaControllerAttributes.Title);
+ Artist = Native.GetMetadata(handle, MediaControllerAttributes.Artist);
+ Album = Native.GetMetadata(handle, MediaControllerAttributes.Album);
+ Author = Native.GetMetadata(handle, MediaControllerAttributes.Author);
+ Genre = Native.GetMetadata(handle, MediaControllerAttributes.Genre);
+ Duration = Native.GetMetadata(handle, MediaControllerAttributes.Duration);
+ Date = Native.GetMetadata(handle, MediaControllerAttributes.Date);
+ Copyright = Native.GetMetadata(handle, MediaControllerAttributes.Copyright);
+ Description = Native.GetMetadata(handle, MediaControllerAttributes.Description);
+ TrackNumber = Native.GetMetadata(handle, MediaControllerAttributes.TrackNumber);
+ Picture = Native.GetMetadata(handle, MediaControllerAttributes.Picture);
+ }
+
+ /// <summary>
+ /// Set/Get the Title of media
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string Title { get; set; }
+
+ /// <summary>
+ /// Set/Get the Artist of media
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string Artist { get; set; }
+
+ /// <summary>
+ /// Set/Get the Album of media
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string Album { get; set; }
+
+ /// <summary>
+ /// Set/Get the Author of media
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string Author { get; set; }
+
+ /// <summary>
+ /// Set/Get the Genre of media
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string Genre { get; set; }
+
+ /// <summary>
+ /// Set/Get the Duration of media
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string Duration { get; set; }
+
+ /// <summary>
+ /// Set/Get the Date of media
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string Date { get; set; }
+
+ /// <summary>
+ /// Set/Get the Copyright of media
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string Copyright { get; set; }
+
+ /// <summary>
+ /// Set/Get the Description of media
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string Description { get; set; }
+
+ /// <summary>
+ /// Set/Get the Track Number of media
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string TrackNumber { get; set; }
+
+ /// <summary>
+ /// Set/Get the Picture of media
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string Picture { get; set; }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerPlayback.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerPlayback.cs
new file mode 100755
index 0000000..52143e5
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerPlayback.cs
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2016 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 Native = Interop.MediaControllerClient;
+
+namespace Tizen.Multimedia.MediaController
+{
+ /// <summary>
+ /// Playback represents a playback state and playback position.
+ /// </summary>
+ public class MediaControllerPlayback
+ {
+ /// <summary>
+ /// The constructor of MediaControllerPlayback class.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="state">
+ /// The state of the playback which is playing in MediaConttoller server application
+ /// </param>
+ /// <param name="position">
+ /// The position of the playback which is playing in MediaConttoller server application
+ /// </param>
+ public MediaControllerPlayback(MediaControllerPlaybackState state, ulong position)
+ {
+ State = state;
+ Position = position;
+ }
+
+ internal MediaControllerPlayback(IntPtr handle)
+ {
+ MediaControllerPlaybackState state = MediaControllerPlaybackState.None;
+ ulong position = 0L;
+
+ if (handle == IntPtr.Zero)
+ {
+ throw new InvalidOperationException("MediaControllerPlayback is not valid.");
+ }
+
+ MediaControllerValidator.ThrowIfError(
+ Native.GetPlaybackState(handle, out state), "Get Playback state failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.GetPlaybackPosition(handle, out position), "Get Playback position failed");
+
+ State = state;
+ Position = position;
+ }
+
+ /// <summary>
+ /// Set/Get the State of playback information
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public MediaControllerPlaybackState State { get; }
+
+ /// <summary>
+ /// Set/Get the Position of playback information
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public ulong Position { get; }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerServer.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerServer.cs
new file mode 100755
index 0000000..9928e53
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControllerServer.cs
@@ -0,0 +1,302 @@
+/*
+* Copyright (c) 2016 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.Runtime.InteropServices;
+using Tizen.Applications;
+using Native = Interop.MediaControllerServer;
+
+namespace Tizen.Multimedia.MediaController
+{
+
+ /// <summary>
+ /// The MediaControllerServer class provides APIs required for media-controller-server.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/mediacontroller.server
+ /// </privilege>
+ /// <remarks>
+ /// The MediaControllerServer APIs provides functions to update media information.
+ /// </remarks>
+ public class MediaControllerServer : IDisposable
+ {
+ internal IntPtr _handle = IntPtr.Zero;
+
+ private bool _disposed = false;
+ private EventHandler<PlaybackStateCommandEventArgs> _playbackCommand;
+ private Native.PlaybackStateCommandRecievedCallback _playbackCommandCallback;
+ private EventHandler<CustomCommandEventArgs> _customCommand;
+ private Native.CustomCommandRecievedCallback _customCommandCallback;
+
+ private bool IsValidHandle
+ {
+ get { return (_handle != IntPtr.Zero); }
+ }
+
+ private IntPtr SafeHandle
+ {
+ get
+ {
+ if (!IsValidHandle)
+ {
+ throw new ObjectDisposedException(nameof(MediaControllerServer), "Fail to operate MediaControllerServer");
+ }
+
+ return _handle;
+ }
+ }
+
+ /// <summary>
+ /// The constructor of MediaControllerServer class.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when the access is denied for media controller client</exception>
+ public MediaControllerServer()
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.Create(out _handle), "Create server failed");
+ }
+
+ ~MediaControllerServer()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ // To be used if there are any other disposable objects
+ }
+
+ if (IsValidHandle)
+ {
+ Native.Destroy(_handle);
+ _handle = IntPtr.Zero;
+ }
+
+ _disposed = true;
+ }
+ }
+
+ /// <summary>
+ /// PlaybackStateCommandRecieved event is raised when client send command for playback
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public event EventHandler<PlaybackStateCommandEventArgs> PlaybackStateCommand
+ {
+ add
+ {
+ if (_playbackCommand == null)
+ {
+ RegisterPlaybackCmdRecvEvent();
+ }
+
+ _playbackCommand += value;
+
+ }
+
+ remove
+ {
+ _playbackCommand -= value;
+ if (_playbackCommand == null)
+ {
+ UnregisterPlaybackCmdRecvEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// CustomCommandRecieved event is raised when client send customized command
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public event EventHandler<CustomCommandEventArgs> CustomCommand
+ {
+ add
+ {
+ if (_customCommand == null)
+ {
+ RegisterCustomCommandEvent();
+ }
+
+ _customCommand += value;
+
+ }
+
+ remove
+ {
+ _customCommand -= value;
+ if (_customCommand == null)
+ {
+ UnregisterCustomCommandEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Update playback state and playback position</summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="playback"> playback state and playback position </param>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public void UpdatePlayback(MediaControllerPlayback playback)
+ {
+ if (playback == null)
+ {
+ throw new ArgumentNullException("playback is null");
+ }
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetPlaybackState(SafeHandle, playback.State), "Set Playback state failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetPlaybackPosition(SafeHandle, playback.Position), "Set Playback position failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.UpdatePlayback(SafeHandle), "Update Playback failed");
+ }
+
+ /// <summary>
+ /// Update metadata information </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="metadata"> metadata information </param>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public void UpdateMetadata(MediaControllerMetadata metadata)
+ {
+ if (metadata == null)
+ {
+ throw new ArgumentNullException("metadata is null");
+ }
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetMetadata(SafeHandle, MediaControllerAttributes.Title, metadata.Title), "Set Title failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetMetadata(SafeHandle, MediaControllerAttributes.Artist, metadata.Artist), "Set Artist failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetMetadata(SafeHandle, MediaControllerAttributes.Album, metadata.Album), "Set Album failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetMetadata(SafeHandle, MediaControllerAttributes.Author, metadata.Author), "Set Author failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetMetadata(SafeHandle, MediaControllerAttributes.Genre, metadata.Genre), "Set Genre failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetMetadata(SafeHandle, MediaControllerAttributes.Duration, metadata.Duration), "Set Duration failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetMetadata(SafeHandle, MediaControllerAttributes.Date, metadata.Date), "Set Date failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetMetadata(SafeHandle, MediaControllerAttributes.Copyright, metadata.Copyright), "Set Copyright failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetMetadata(SafeHandle, MediaControllerAttributes.Description, metadata.Description), "Set Description failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetMetadata(SafeHandle, MediaControllerAttributes.TrackNumber, metadata.TrackNumber), "Set TrackNumber failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.SetMetadata(SafeHandle, MediaControllerAttributes.Picture, metadata.Picture), "Set Picture failed");
+
+ MediaControllerValidator.ThrowIfError(
+ Native.UpdateMetadata(SafeHandle), "UpdateMetadata Metadata failed");
+ }
+
+ /// <summary>
+ /// Update shuffle mode </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="mode"> shuffle mode </param>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public void UpdateShuffleMode(MediaControllerShuffleMode mode)
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.UpdateShuffleMode(SafeHandle, mode), "Update Shuffle Mode failed");
+ }
+
+ /// <summary>
+ /// Update repeat mode </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="mode"> repeat mode </param>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public void UpdateRepeatMode(MediaControllerRepeatMode mode)
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.UpdateRepeatMode(SafeHandle, mode), "Update Repeat Mode failed");
+ }
+
+ /// <summary>
+ /// Send reply for command from server to client </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="clientName"> client name to recieve reply </param>
+ /// <param name="result"> result to run command </param>
+ /// <param name="bundle"> Bundle to send various data </param>
+ /// <exception cref="ArgumentException">Thrown when an invalid argument is used</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state</exception>
+ public void SendCustomCommandReply(string clientName, int result, Bundle bundle)
+ {
+ MediaControllerValidator.ThrowIfError(
+ Native.SendCommandReply(SafeHandle, clientName, result, bundle.SafeBundleHandle), "Send reply for command failed");
+ }
+
+ private void RegisterPlaybackCmdRecvEvent()
+ {
+ _playbackCommandCallback = (IntPtr clientName, MediaControllerPlaybackState state, IntPtr userData) =>
+ {
+ PlaybackStateCommandEventArgs eventArgs = new PlaybackStateCommandEventArgs(Marshal.PtrToStringAnsi(clientName), state);
+ _playbackCommand?.Invoke(this, eventArgs);
+ };
+ Native.SetPlaybackStateCmdRecvCb(SafeHandle, _playbackCommandCallback, IntPtr.Zero);
+ }
+
+ private void UnregisterPlaybackCmdRecvEvent()
+ {
+ Native.UnsetPlaybackStateCmdRecvCb(SafeHandle);
+ }
+
+ private void RegisterCustomCommandEvent()
+ {
+ _customCommandCallback = (IntPtr clientName, IntPtr command, IntPtr bundle, IntPtr userData) =>
+ {
+ SafeBundleHandle safeBundleHandle = new SafeBundleHandle(bundle, true);
+ Bundle bundleData = new Bundle(safeBundleHandle);
+ CustomCommandEventArgs eventArgs = new CustomCommandEventArgs(Marshal.PtrToStringAnsi(clientName), Marshal.PtrToStringAnsi(command), bundleData);
+ _customCommand?.Invoke(this, eventArgs);
+ };
+ Native.SetCustomCmdRecvCb(SafeHandle, _customCommandCallback, IntPtr.Zero);
+ }
+
+ private void UnregisterCustomCommandEvent()
+ {
+ Native.UnsetCustomCmdRecvCb(SafeHandle);
+ }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MetadataUpdatedEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/MetadataUpdatedEventArgs.cs
new file mode 100755
index 0000000..51a718c
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/MetadataUpdatedEventArgs.cs
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2016 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.MediaController
+{
+
+ /// <summary>
+ /// MetadataUpdated event arguments
+ /// </summary>
+ /// <remarks>
+ /// MetadataUpdated event arguments
+ /// </remarks>
+ public class MetadataUpdatedEventArgs : EventArgs
+ {
+ internal MetadataUpdatedEventArgs(string name, IntPtr handle)
+ {
+ ServerName = name;
+ Metadata = new MediaControllerMetadata(handle);
+ }
+
+ /// <summary>
+ /// Get the Server Name.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string ServerName { get; }
+
+ /// <summary>
+ /// Get the Metadata information.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public MediaControllerMetadata Metadata { get; }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/PlaybackStateCommandEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/PlaybackStateCommandEventArgs.cs
new file mode 100755
index 0000000..339a90b
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/PlaybackStateCommandEventArgs.cs
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2016 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.MediaController
+{
+
+ /// <summary>
+ /// PlaybackStateCommand event arguments
+ /// </summary>
+ /// <remarks>
+ /// PlaybackStateCommand event arguments
+ /// </remarks>
+ public class PlaybackStateCommandEventArgs : EventArgs
+ {
+ internal PlaybackStateCommandEventArgs(string name, MediaControllerPlaybackState state)
+ {
+ ClientName = name;
+ State = state;
+ }
+
+ /// <summary>
+ /// Get the Client Name.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string ClientName { get; }
+
+ /// <summary>
+ /// Get the State of playback.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public MediaControllerPlaybackState State { get; }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/PlaybackUpdatedEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/PlaybackUpdatedEventArgs.cs
new file mode 100755
index 0000000..e6db63d
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/PlaybackUpdatedEventArgs.cs
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2016 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.MediaController
+{
+
+ /// <summary>
+ /// PlaybackUpdated event arguments
+ /// </summary>
+ /// <remarks>
+ /// PlaybackUpdated event arguments
+ /// </remarks>
+ public class PlaybackUpdatedEventArgs : EventArgs
+ {
+ internal PlaybackUpdatedEventArgs(string name, IntPtr handle)
+ {
+ ServerName = name;
+ PlaybackInfo = new MediaControllerPlayback(handle);
+ }
+
+ /// <summary>
+ /// Get the Server Name.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string ServerName { get; }
+
+ /// <summary>
+ /// Get the Playback Information.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public MediaControllerPlayback PlaybackInfo { get; }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/RepeatModeUpdatedEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/RepeatModeUpdatedEventArgs.cs
new file mode 100755
index 0000000..e9abebd
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/RepeatModeUpdatedEventArgs.cs
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2016 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.MediaController
+{
+
+ /// <summary>
+ /// RepeatModeUpdated event arguments
+ /// </summary>
+ /// <remarks>
+ /// RepeatModeUpdated event arguments
+ /// </remarks>
+ public class RepeatModeUpdatedEventArgs : EventArgs
+ {
+ internal RepeatModeUpdatedEventArgs(string name, MediaControllerRepeatMode mode)
+ {
+ ServerName = name;
+ RepeatMode = mode;
+ }
+
+ /// <summary>
+ /// Get the Server Name.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string ServerName { get; }
+
+ /// <summary>
+ /// Get the Repeat Mode.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public MediaControllerRepeatMode RepeatMode { get; }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/ServerInformation.cs b/src/Tizen.Multimedia.Remoting/MediaController/ServerInformation.cs
new file mode 100755
index 0000000..39684e8
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/ServerInformation.cs
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2016 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.MediaController
+{
+ /// <summary>
+ /// ServerInformation represents a name and state of server application.
+ /// </summary>
+ public class ServerInformation
+ {
+ internal ServerInformation(string name, MediaControllerServerState state)
+ {
+ Name = name;
+ State = state;
+ }
+
+ /// <summary>
+ /// Get the Name of server
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string Name { get; }
+
+ /// <summary>
+ /// Get the State of server
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public MediaControllerServerState State { get; }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/ServerUpdatedEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/ServerUpdatedEventArgs.cs
new file mode 100755
index 0000000..1fa8319
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/ServerUpdatedEventArgs.cs
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2016 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.MediaController
+{
+
+ /// <summary>
+ /// ServerUpdated event arguments
+ /// </summary>
+ /// <remarks>
+ /// ServerUpdated event arguments
+ /// </remarks>
+ public class ServerUpdatedEventArgs : EventArgs
+ {
+ internal ServerUpdatedEventArgs(string name, MediaControllerServerState state)
+ {
+ ServerInfo = new ServerInformation(name, state);
+ }
+
+ /// <summary>
+ /// Get the Server Information.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public ServerInformation ServerInfo { get; }
+ }
+}
+
diff --git a/src/Tizen.Multimedia.Remoting/MediaController/ShuffleModeUpdatedEventArgs.cs b/src/Tizen.Multimedia.Remoting/MediaController/ShuffleModeUpdatedEventArgs.cs
new file mode 100755
index 0000000..6d5a5c3
--- /dev/null
+++ b/src/Tizen.Multimedia.Remoting/MediaController/ShuffleModeUpdatedEventArgs.cs
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2016 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.MediaController
+{
+
+ /// <summary>
+ /// ShuffleModeUpdated event arguments
+ /// </summary>
+ /// <remarks>
+ /// ShuffleModeUpdated event arguments
+ /// </remarks>
+ public class ShuffleModeUpdatedEventArgs : EventArgs
+ {
+ internal ShuffleModeUpdatedEventArgs(string name, MediaControllerShuffleMode mode)
+ {
+ ServerName = name;
+ ShuffleMode = mode;
+ }
+
+ /// <summary>
+ /// Get the Server Name.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string ServerName { get; }
+
+ /// <summary>
+ /// Get the Shuffle Mode.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public MediaControllerShuffleMode ShuffleMode { get; }
+ }
+}
+