2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Runtime.InteropServices;
19 using Tizen.Applications;
20 using Tizen.Multimedia.Remoting;
22 internal static partial class Interop
24 internal static partial class MediaControllerServer
26 #region Callback delegate
27 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
28 internal delegate bool ActivatedClientCallback(string clientName, IntPtr userData);
32 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
33 internal delegate void PlaybackStateCommandReceivedCallback(string clientName,
34 MediaControllerNativePlaybackAction nativeAction, IntPtr userData);
36 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
37 internal delegate void PlaybackActionCommandReceivedCallback(string clientName,
38 string requestId, MediaControllerNativePlaybackAction nativeAction, IntPtr userData);
40 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
41 internal delegate void PlaybackPositionCommandReceivedCallback(string clientName,
42 string requestId, ulong playbackPosition, IntPtr userData);
44 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
45 internal delegate void PlaylistCommandReceivedCallback(string clientName,
46 string requestId, string playlistName, string index, MediaControllerNativePlaybackAction nativeAction,
47 ulong playbackPosition, IntPtr userData);
49 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
50 internal delegate void ShuffleModeCommandReceivedCallback(string clientName,
51 string requestId, MediaControllerNativeShuffleMode mode, IntPtr userData);
53 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
54 internal delegate void RepeatModeCommandReceivedCallback(string clientName,
55 string requestId, MediaControllerNativeRepeatMode mode, IntPtr userData);
57 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
58 internal delegate void DisplayModeCommandReceivedCallback(string clientName,
59 string requestId, MediaControlNativeDisplayMode mode, IntPtr userData);
61 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
62 internal delegate void DisplayRotationCommandReceivedCallback(string clientName,
63 string requestId, MediaControlNativeDisplayRotation rotation, IntPtr userData);
65 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
66 internal delegate void SimpleCommandReceivedCallback(string clientName,
67 string requestId, bool isEnabled, IntPtr userData);
69 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
70 internal delegate void CustomCommandReceivedCallback(string clientName,
71 string requestId, string customCommand, IntPtr bundleHandle, IntPtr userData);
75 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
76 internal delegate void CommandCompletedCallback(string clientName, string requestId, int result, IntPtr bundleHandle,
77 IntPtr userData = default(IntPtr));
79 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
80 internal delegate void SearchCommandReceivedCallback(string clientName, string requestId, IntPtr searchHandle,
81 IntPtr userData = default(IntPtr));
85 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
86 internal delegate bool SearchItemCallback(MediaControlContentType type, MediaControlSearchCategory category,
87 string keyword, IntPtr bundleHandle, IntPtr userData = default(IntPtr));
88 #endregion Callback delegate
91 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_create")]
92 internal static extern MediaControllerError Create(out IntPtr handle);
94 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_destroy")]
95 internal static extern MediaControllerError Destroy(IntPtr handle);
97 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_foreach_client")]
98 internal static extern MediaControllerError ForeachActivatedClient(IntPtr handle, ActivatedClientCallback callback,
99 IntPtr userData = default(IntPtr));
102 #region Set information
103 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_playback_state")]
104 internal static extern MediaControllerError SetPlaybackState(IntPtr handle,
105 MediaControllerNativePlaybackState state);
107 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_playback_position")]
108 internal static extern MediaControllerError SetPlaybackPosition(IntPtr handle, ulong position);
110 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_update_playback_info")]
111 internal static extern MediaControllerError UpdatePlayback(IntPtr handle);
113 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_metadata")]
114 internal static extern MediaControllerError SetMetadata(IntPtr handle,
115 MediaControllerNativeAttribute attribute, string value);
117 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_update_metadata")]
118 internal static extern MediaControllerError UpdateMetadata(IntPtr handle);
120 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_update_shuffle_mode")]
121 internal static extern MediaControllerError UpdateShuffleMode(IntPtr handle,
122 MediaControllerNativeShuffleMode mode);
124 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_update_repeat_mode")]
125 internal static extern MediaControllerError UpdateRepeatMode(IntPtr handle, MediaControllerNativeRepeatMode mode);
127 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_content_age_rating")]
128 internal static extern MediaControllerError SetAgeRating(IntPtr handle, int rating);
130 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_update_subtitles_enabled")]
131 internal static extern MediaControllerError UpdateSubtitleMode(IntPtr handle, bool isEnabled);
133 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_update_360_mode_enabled")]
134 internal static extern MediaControllerError UpdateMode360(IntPtr handle, bool isEnabled);
136 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_update_display_mode")]
137 internal static extern MediaControllerError UpdateDisplayMode(IntPtr handle, MediaControlNativeDisplayMode mode);
139 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_update_display_rotation")]
140 internal static extern MediaControllerError UpdateDisplayRotaton(IntPtr handle, MediaControlNativeDisplayRotation rotation);
141 #endregion Set information
144 #region Received callback
145 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_playback_action_cmd_received_cb")]
146 internal static extern MediaControllerError SetPlaybackActionCommandReceivedCb(IntPtr handle,
147 PlaybackActionCommandReceivedCallback callback, IntPtr userData = default(IntPtr));
149 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_unset_playback_action_cmd_received_cb")]
150 internal static extern MediaControllerError UnsetPlaybackActionCommandReceivedCb(IntPtr handle);
152 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_playback_position_cmd_received_cb")]
153 internal static extern MediaControllerError SetPlaybackPosotionCommandReceivedCb(IntPtr handle,
154 PlaybackPositionCommandReceivedCallback callback, IntPtr userData = default(IntPtr));
156 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_unset_playback_position_cmd_received_cb")]
157 internal static extern MediaControllerError UnsetPlaybackPositionCommandReceivedCb(IntPtr handle);
159 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_playlist_cmd_received_cb")]
160 internal static extern MediaControllerError SetPlaylistCommandReceivedCb(IntPtr handle,
161 PlaylistCommandReceivedCallback callback, IntPtr userData = default(IntPtr));
163 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_unset_playlist_cmd_received_cb")]
164 internal static extern MediaControllerError UnsetPlaylistCommandReceivedCb(IntPtr handle);
166 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_shuffle_mode_cmd_received_cb")]
167 internal static extern MediaControllerError SetShuffleModeCommandReceivedCb(IntPtr handle,
168 ShuffleModeCommandReceivedCallback callback, IntPtr userData = default(IntPtr));
170 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_unset_shuffle_mode_cmd_received_cb")]
171 internal static extern MediaControllerError UnsetShuffleModeCommandReceivedCb(IntPtr handle);
173 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_repeat_mode_cmd_received_cb")]
174 internal static extern MediaControllerError SetRepeatModeCommandReceivedCb(IntPtr handle,
175 RepeatModeCommandReceivedCallback callback, IntPtr userData = default(IntPtr));
177 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_unset_repeat_mode_cmd_received_cb")]
178 internal static extern MediaControllerError UnsetRepeatModeCommandReceivedCb(IntPtr handle);
180 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_subtitles_cmd_received_cb")]
181 internal static extern MediaControllerError SetSubtitleModeCommandReceivedCb(IntPtr handle,
182 SimpleCommandReceivedCallback callback, IntPtr userData = default(IntPtr));
184 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_360_mode_cmd_received_cb")]
185 internal static extern MediaControllerError SetMode360CommandReceivedCb(IntPtr handle,
186 SimpleCommandReceivedCallback callback, IntPtr userData = default(IntPtr));
188 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_display_mode_cmd_received_cb")]
189 internal static extern MediaControllerError SetDisplayModeCommandReceivedCb(IntPtr handle,
190 DisplayModeCommandReceivedCallback callback, IntPtr userData = default(IntPtr));
192 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_display_rotation_cmd_received_cb")]
193 internal static extern MediaControllerError SetDisplayRotationCommandReceivedCb(IntPtr handle,
194 DisplayRotationCommandReceivedCallback callback, IntPtr userData = default(IntPtr));
196 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_custom_cmd_received_cb")]
197 internal static extern MediaControllerError SetCustomCommandReceivedCb(IntPtr handle,
198 CustomCommandReceivedCallback callback, IntPtr userData = default(IntPtr));
200 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_unset_custom_cmd_received_cb")]
201 internal static extern MediaControllerError UnsetCustomCommandReceivedCb(IntPtr handle);
203 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_search_cmd_received_cb")]
204 internal static extern MediaControllerError SetSearchCommandReceivedCb(IntPtr handle,
205 SearchCommandReceivedCallback callback, IntPtr userData = default(IntPtr));
207 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_unset_search_cmd_received_cb")]
208 internal static extern MediaControllerError UnsetSearchCommandReceivedCb(IntPtr handle);
209 #endregion Received callback
213 [DllImport(Libraries.MediaController, EntryPoint = "mc_db_connect")]
214 internal static extern MediaControllerError ConnectDb(out IntPtr dbHandle);
216 [DllImport(Libraries.MediaController, EntryPoint = "mc_db_disconnect")]
217 internal static extern MediaControllerError DisconnectDb(IntPtr dbHandle);
219 [DllImport(Libraries.MediaController, EntryPoint = "mc_db_check_server_table_exist")]
220 internal static extern MediaControllerError CheckServerExist(IntPtr dbHandle, string appId, out bool value);
225 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_create_playlist")]
226 internal static extern MediaControllerError CreatePlaylist(IntPtr handle, string name, out IntPtr playlist);
228 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_delete_playlist")]
229 internal static extern MediaControllerError DeletePlaylist(IntPtr handle, IntPtr playlist);
231 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_playlist_item_index")]
232 internal static extern MediaControllerError SetIndexOfCurrentPlayingMedia(IntPtr handle, string index);
234 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_playlist_item_info")]
235 internal static extern MediaControllerError SetInfoOfCurrentPlayingMedia(IntPtr handle, string name, string index);
237 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_add_item_to_playlist")]
238 internal static extern MediaControllerError AddItemToPlaylist(IntPtr handle,
239 IntPtr playlist, string index, MediaControllerNativeAttribute attribute, string value);
241 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_update_playlist_done")]
242 internal static extern MediaControllerError SavePlaylist(IntPtr handle, IntPtr playlist);
247 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_playback_content_type")]
248 internal static extern MediaControllerError SetPlaybackContentType(IntPtr serverHandle,
249 MediaControlContentType type);
251 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_icon")]
252 internal static extern MediaControllerError SetIconPath(IntPtr serverHandle, string uri);
254 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_playback_ability")]
255 internal static extern MediaControllerError SetPlaybackCapability(IntPtr serverHandle,
256 MediaControllerNativePlaybackAction action, MediaControlCapabilitySupport support);
258 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_update_playback_ability")]
259 internal static extern MediaControllerError SaveAndNotifyPlaybackCapabilityUpdated(IntPtr serverHandle);
261 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_display_mode_ability")]
262 internal static extern MediaControllerError SetDisplayModeCapability(IntPtr serverHandle,
263 uint modes, MediaControlCapabilitySupport support);
265 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_display_rotation_ability")]
266 internal static extern MediaControllerError SetDisplayRotationCapability(IntPtr serverHandle,
267 uint rotations, MediaControlCapabilitySupport support);
269 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_ability_support")]
270 internal static extern MediaControllerError SetSimpleCapability(IntPtr serverHandle,
271 MediaControlNativeCapabilityCategory category, MediaControlCapabilitySupport support);
272 #endregion Capability
276 [DllImport(Libraries.MediaController, EntryPoint = "mc_search_foreach_condition")]
277 internal static extern MediaControllerError ForeachSearchCondition(IntPtr serverHandle,
278 SearchItemCallback callback, IntPtr userData = default(IntPtr));
280 [DllImport(Libraries.MediaController, EntryPoint = "mc_search_clone")]
281 internal static extern MediaControllerError CloneSearchHandle(IntPtr srcHandle, out IntPtr dstHandle);
283 [DllImport(Libraries.MediaController, EntryPoint = "mc_search_destroy")]
284 internal static extern MediaControllerError DestroySearchHandle(IntPtr searchHandle);
290 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_send_cmd_reply")]
291 internal static extern MediaControllerError SendCommandReplyBundle(IntPtr handle,
292 string appId, string requestID, int result, SafeBundleHandle bundleHandle);
294 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_send_cmd_reply")]
295 internal static extern MediaControllerError SendCommandReply(IntPtr handle,
296 string appId, string requestID, int result, IntPtr bundleHandle);
301 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_send_custom_event")]
302 internal static extern MediaControllerError SendCustomEvent(IntPtr handle, string appId, string customEvent,
303 IntPtr bundle, out string requestId);
305 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_send_custom_event")]
306 internal static extern MediaControllerError SendCustomEventBundle(IntPtr handle, string appId, string customEvent,
307 SafeBundleHandle bundle, out string requestId);
309 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_event_reply_received_cb")]
310 internal static extern MediaControllerError SetEventReceivedCb(IntPtr handle, CommandCompletedCallback callback,
311 IntPtr userData = default(IntPtr));
313 [DllImport(Libraries.MediaController, EntryPoint = "mc_server_unset_event_reply_received_cb")]
314 internal static extern MediaControllerError UnsetEventReceivedCb(IntPtr handle);