2797d6dce98f07070330530495e84c18525727f6
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Remoting / MediaController / MediaControlEnums.cs
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.Collections.Generic;
19 using System.Diagnostics;
20
21 namespace Tizen.Multimedia.Remoting
22 {
23     /// <summary>
24     /// Specifies the playlist mode.
25     /// </summary>
26     /// <since_tizen> 5 </since_tizen>
27     public enum MediaControlPlaylistMode
28     {
29         /// <summary>
30         /// Playlist is created or update.
31         /// </summary>
32         Updated,
33
34         /// <summary>
35         /// Playlist is removed.
36         /// </summary>
37         Removed,
38     }
39
40     /// <summary>
41     /// Specifies the repeat mode.
42     /// </summary>
43     /// <since_tizen> 4 </since_tizen>
44     public enum MediaControlRepeatMode
45     {
46         /// <summary>
47         /// Off.
48         /// </summary>
49         Off,
50
51         /// <summary>
52         /// On.
53         /// </summary>
54         On,
55
56         /// <summary>
57         /// One media.
58         /// </summary>
59         /// <since_tizen> 5 </since_tizen>
60         OneMedia
61     }
62
63     /// <summary>
64     /// Specifies playback commands.
65     /// </summary>
66     /// <since_tizen> 4 </since_tizen>
67     public enum MediaControlPlaybackCommand
68     {
69         /// <summary>
70         /// Play.
71         /// </summary>
72         Play,
73
74         /// <summary>
75         /// Pause.
76         /// </summary>
77         Pause,
78
79         /// <summary>
80         /// Stop.
81         /// </summary>
82         Stop,
83
84         /// <summary>
85         /// Skip to next.
86         /// </summary>
87         Next,
88
89         /// <summary>
90         /// Skip to previous.
91         /// </summary>
92         Previous,
93
94         /// <summary>
95         /// Fast forward.
96         /// </summary>
97         FastForward,
98
99         /// <summary>
100         /// Rewind.
101         /// </summary>
102         Rewind,
103
104         /// <summary>
105         /// Toggle play/pause.
106         /// </summary>
107         /// <since_tizen> 5 </since_tizen>
108         Toggle,
109     }
110
111     /// <summary>
112     /// Specifies playback states.
113     /// </summary>
114     /// <since_tizen> 4 </since_tizen>
115     public enum MediaControlPlaybackState
116     {
117         /// <summary>
118         /// Unknown; no state is set.
119         /// </summary>
120         None,
121
122         /// <summary>
123         /// Playing.
124         /// </summary>
125         Playing,
126
127         /// <summary>
128         /// Paused.
129         /// </summary>
130         Paused,
131
132         /// <summary>
133         /// Stopped.
134         /// </summary>
135         Stopped,
136
137         /// <summary>
138         /// Fast forwarding.
139         /// </summary>
140         FastForwarding,
141
142         /// <summary>
143         /// Rewinding.
144         /// </summary>
145         Rewinding,
146
147         /// <summary>
148         /// Skipping to the next item.
149         /// </summary>
150         /// <since_tizen> 5 </since_tizen>
151         MovingToNext,
152
153         /// <summary>
154         /// Skipping to the previous item.
155         /// </summary>
156         /// <since_tizen> 5 </since_tizen>
157         MovingToPrevious,
158
159         /// <summary>
160         /// Connecting.
161         /// </summary>
162         /// <since_tizen> 8 </since_tizen>
163         Connecting,
164
165         /// <summary>
166         /// Buffering.
167         /// </summary>
168         /// <since_tizen> 8 </since_tizen>
169         Buffering,
170
171         /// <summary>
172         /// Error while playback.
173         /// </summary>
174         /// <since_tizen> 8 </since_tizen>
175         Error
176     }
177
178     /// <summary>
179     /// Specifies the support type of media control capability.
180     /// </summary>
181     /// <since_tizen> 5 </since_tizen>
182     public enum MediaControlCapabilitySupport
183     {
184         /// <summary>
185         /// Supported.
186         /// </summary>
187         Supported,
188
189         /// <summary>
190         /// Not supported.
191         /// </summary>
192         NotSupported,
193
194         /// <summary>
195         /// There's no support info in server.
196         /// </summary>
197         /// <remarks>User should not set this value directly.</remarks>
198         NotDecided
199     }
200
201     /// <summary>
202     /// Specifies the content type.
203     /// </summary>
204     /// <since_tizen> 5 </since_tizen>
205     public enum MediaControlContentType
206     {
207         /// <summary>
208         /// Image type.
209         /// </summary>
210         Image,
211
212         /// <summary>
213         /// Video type.
214         /// </summary>
215         Video,
216
217         /// <summary>
218         /// Music type.
219         /// </summary>
220         Music,
221
222         /// <summary>
223         /// Other type.
224         /// </summary>
225         Other,
226
227         /// <summary>
228         /// There's no content type info in server.
229         /// </summary>
230         NotDecided
231     }
232
233     /// <summary>
234     /// Specifies the search category.
235     /// </summary>
236     /// <since_tizen> 5 </since_tizen>
237     public enum MediaControlSearchCategory
238     {
239         /// <summary>
240         /// Search by all category.
241         /// </summary>
242         All,
243
244         /// <summary>
245         /// Search by content title.
246         /// </summary>
247         Title,
248
249         /// <summary>
250         /// Search by content artist.
251         /// </summary>
252         Artist,
253
254         /// <summary>
255         /// Search by content album.
256         /// </summary>
257         Album,
258
259         /// <summary>
260         /// Search by content genre.
261         /// </summary>
262         Genre,
263
264         /// <summary>
265         /// Search by TPO(Time Place Occasion).
266         /// </summary>
267         Tpo
268     }
269
270     /// <summary>
271     /// Specifies the display mode.
272     /// </summary>
273     /// <since_tizen> 6 </since_tizen>
274     public enum MediaControlDisplayMode
275     {
276         /// <summary>
277         /// Letter box
278         /// </summary>
279         LetterBox,
280
281         /// <summary>
282         /// Original size
283         /// </summary>
284         OriginSize,
285
286         /// <summary>
287         /// Full screen
288         /// </summary>
289         FullScreen,
290
291         /// <summary>
292         /// Cropped full screen
293         /// </summary>
294         CroppedFull
295     }
296
297     /// <summary>
298     /// Specifies the code which represents the result of communication between client and server.
299     /// </summary>
300     /// <since_tizen> 8 </since_tizen>
301     public enum MediaControlResult
302     {
303         /// <summary>
304         /// The command or the event has been successfully completed.
305         /// </summary>
306         Success,
307
308         /// <summary>
309         /// The command or the event had already been completed.
310         /// </summary>
311         AlreadyDone = 200,
312
313         /// <summary>
314         /// The command or the event is aborted by some external event (e.g. aborted play command by incoming call).
315         /// </summary>
316         Aborted = 300,
317
318         /// <summary>
319         /// The command or the event is denied due to application policy (e.g. cannot rewind in recording).
320         /// </summary>
321         ActionDenied,
322
323         /// <summary>
324         /// The command or the event is not supported.
325         /// </summary>
326         NotSupported,
327
328         /// <summary>
329         /// The command or the event is out of supported range or the limit is reached.
330         /// </summary>
331         Invalid,
332
333         /// <summary>
334         /// Timeout has occurred.
335         /// </summary>
336         Timeout = 400,
337
338         /// <summary>
339         /// The application has failed.
340         /// </summary>
341         ApplicationFailed,
342
343         /// <summary>
344         /// The command or the event has failed because the application has no media.
345         /// </summary>
346         NoMedia,
347
348         /// <summary>
349         /// The command or the event has failed because there is no audio output device.
350         /// </summary>
351         NoAudioOutputDevice,
352
353         /// <summary>
354         /// The command or the event has failed because there is no peer.
355         /// </summary>
356         NoPeer,
357
358         /// <summary>
359         /// The network has failed.
360         /// </summary>
361         NetworkFailed = 500,
362
363         /// <summary>
364         /// The application does not have account.
365         /// </summary>
366         NoAccount = 600,
367
368         /// <summary>
369         /// The application could not log in.
370         /// </summary>
371         LoginFailed,
372
373         /// <summary>
374         /// Unknown error.
375         /// </summary>
376         Unknown = Int32.MaxValue
377     }
378
379     internal static class EnumExtensions
380     {
381         internal static MediaControlPlaybackState ToPublic(this MediaControllerNativePlaybackState nativeState)
382         {
383             switch (nativeState)
384             {
385                 case MediaControllerNativePlaybackState.None: return MediaControlPlaybackState.None;
386                 case MediaControllerNativePlaybackState.Play: return MediaControlPlaybackState.Playing;
387                 case MediaControllerNativePlaybackState.Pause: return MediaControlPlaybackState.Paused;
388                 case MediaControllerNativePlaybackState.Stop: return MediaControlPlaybackState.Stopped;
389                 case MediaControllerNativePlaybackState.Next:
390                 case MediaControllerNativePlaybackState.MovingToNext: return MediaControlPlaybackState.MovingToNext;
391                 case MediaControllerNativePlaybackState.Prev:
392                 case MediaControllerNativePlaybackState.MovingToPrev: return MediaControlPlaybackState.MovingToPrevious;
393                 case MediaControllerNativePlaybackState.FastForward:
394                 case MediaControllerNativePlaybackState.FastForwarding: return MediaControlPlaybackState.FastForwarding;
395                 case MediaControllerNativePlaybackState.Rewind:
396                 case MediaControllerNativePlaybackState.Rewinding: return MediaControlPlaybackState.Rewinding;
397                 case MediaControllerNativePlaybackState.Connecting: return MediaControlPlaybackState.Connecting;
398                 case MediaControllerNativePlaybackState.Buffering: return MediaControlPlaybackState.Buffering;
399                 case MediaControllerNativePlaybackState.Error: return MediaControlPlaybackState.Error;
400             }
401
402             Debug.Fail($"Not supported code for playback state{nativeState}.");
403             return MediaControlPlaybackState.None;
404         }
405
406         internal static MediaControllerNativePlaybackState ToNative(this MediaControlPlaybackState state)
407         {
408             switch (state)
409             {
410                 case MediaControlPlaybackState.Playing: return MediaControllerNativePlaybackState.Play;
411                 case MediaControlPlaybackState.Paused: return MediaControllerNativePlaybackState.Pause;
412                 case MediaControlPlaybackState.Stopped: return MediaControllerNativePlaybackState.Stop;
413                 case MediaControlPlaybackState.MovingToNext: return MediaControllerNativePlaybackState.MovingToNext;
414                 case MediaControlPlaybackState.MovingToPrevious: return MediaControllerNativePlaybackState.MovingToPrev;
415                 case MediaControlPlaybackState.FastForwarding: return MediaControllerNativePlaybackState.FastForwarding;
416                 case MediaControlPlaybackState.Rewinding: return MediaControllerNativePlaybackState.Rewinding;
417                 case MediaControlPlaybackState.Connecting: return MediaControllerNativePlaybackState.Connecting;
418                 case MediaControlPlaybackState.Buffering: return MediaControllerNativePlaybackState.Buffering;
419                 case MediaControlPlaybackState.Error: return MediaControllerNativePlaybackState.Error;
420             }
421             return MediaControllerNativePlaybackState.None;
422         }
423
424         internal static MediaControlPlaybackCommand ToPublic(this MediaControllerNativePlaybackAction nativeAction)
425         {
426             switch (nativeAction)
427             {
428                 case MediaControllerNativePlaybackAction.Play: return MediaControlPlaybackCommand.Play;
429                 case MediaControllerNativePlaybackAction.Pause: return MediaControlPlaybackCommand.Pause;
430                 case MediaControllerNativePlaybackAction.Stop: return MediaControlPlaybackCommand.Stop;
431                 case MediaControllerNativePlaybackAction.Next: return MediaControlPlaybackCommand.Next;
432                 case MediaControllerNativePlaybackAction.Prev: return MediaControlPlaybackCommand.Previous;
433                 case MediaControllerNativePlaybackAction.FastForward: return MediaControlPlaybackCommand.FastForward;
434                 case MediaControllerNativePlaybackAction.Rewind: return MediaControlPlaybackCommand.Rewind;
435                 case MediaControllerNativePlaybackAction.Toggle: return MediaControlPlaybackCommand.Toggle;
436             }
437
438             Debug.Fail($"Not supported code for playback command{nativeAction}.");
439             return MediaControlPlaybackCommand.Play;
440         }
441
442         internal static MediaControllerNativePlaybackAction ToNative(this MediaControlPlaybackCommand command)
443         {
444             switch (command)
445             {
446                 case MediaControlPlaybackCommand.Play: return MediaControllerNativePlaybackAction.Play;
447                 case MediaControlPlaybackCommand.Pause: return MediaControllerNativePlaybackAction.Pause;
448                 case MediaControlPlaybackCommand.Stop: return MediaControllerNativePlaybackAction.Stop;
449                 case MediaControlPlaybackCommand.Next: return MediaControllerNativePlaybackAction.Next;
450                 case MediaControlPlaybackCommand.Previous: return MediaControllerNativePlaybackAction.Prev;
451                 case MediaControlPlaybackCommand.FastForward: return MediaControllerNativePlaybackAction.FastForward;
452                 case MediaControlPlaybackCommand.Rewind: return MediaControllerNativePlaybackAction.Rewind;
453                 case MediaControlPlaybackCommand.Toggle: return MediaControllerNativePlaybackAction.Toggle;
454             }
455             return MediaControllerNativePlaybackAction.Play;
456         }
457
458         internal static MediaControlRepeatMode ToPublic(this MediaControllerNativeRepeatMode mode)
459         {
460             Debug.Assert(Enum.IsDefined(typeof(MediaControllerNativeRepeatMode), mode));
461
462             return mode == MediaControllerNativeRepeatMode.Off ? MediaControlRepeatMode.On :
463                 (mode == MediaControllerNativeRepeatMode.On ? MediaControlRepeatMode.Off : MediaControlRepeatMode.OneMedia);
464         }
465
466         internal static MediaControllerNativeRepeatMode ToNative(this MediaControlRepeatMode mode)
467         {
468             Debug.Assert(Enum.IsDefined(typeof(MediaControlRepeatMode), mode));
469
470             return mode == MediaControlRepeatMode.Off ? MediaControllerNativeRepeatMode.On :
471                 (mode == MediaControlRepeatMode.On ? MediaControllerNativeRepeatMode.Off : MediaControllerNativeRepeatMode.OneMedia);
472         }
473
474         internal static MediaControlNativeDisplayMode ToNative(this MediaControlDisplayMode mode)
475         {
476             Debug.Assert(Enum.IsDefined(typeof(MediaControlDisplayMode), mode));
477
478             MediaControlNativeDisplayMode nativeMode = MediaControlNativeDisplayMode.LetterBox;
479             switch (mode)
480             {
481                 case MediaControlDisplayMode.LetterBox:
482                     nativeMode = MediaControlNativeDisplayMode.LetterBox;
483                     break;
484                 case MediaControlDisplayMode.OriginSize:
485                     nativeMode = MediaControlNativeDisplayMode.OriginSize;
486                     break;
487                 case MediaControlDisplayMode.FullScreen:
488                     nativeMode = MediaControlNativeDisplayMode.FullScreen;
489                     break;
490                 case MediaControlDisplayMode.CroppedFull:
491                     nativeMode = MediaControlNativeDisplayMode.CroppedFull;
492                     break;
493             }
494             return nativeMode;
495         }
496
497         internal static MediaControlDisplayMode ToPublic(this MediaControlNativeDisplayMode mode)
498         {
499             Debug.Assert(Enum.IsDefined(typeof(MediaControlNativeDisplayMode), mode));
500             MediaControlDisplayMode nativeMode = MediaControlDisplayMode.LetterBox;
501             switch (mode)
502             {
503                 case MediaControlNativeDisplayMode.LetterBox:
504                     nativeMode = MediaControlDisplayMode.LetterBox;
505                     break;
506                 case MediaControlNativeDisplayMode.OriginSize:
507                     nativeMode = MediaControlDisplayMode.OriginSize;
508                     break;
509                 case MediaControlNativeDisplayMode.FullScreen:
510                     nativeMode = MediaControlDisplayMode.FullScreen;
511                     break;
512                 case MediaControlNativeDisplayMode.CroppedFull:
513                     nativeMode = MediaControlDisplayMode.CroppedFull;
514                     break;
515             }
516             return nativeMode;
517         }
518
519         internal static IList<MediaControlDisplayMode> ToPublicList(this MediaControlNativeDisplayMode modes)
520         {
521             var supportedModes = new List<MediaControlDisplayMode>();
522
523             foreach (MediaControlNativeDisplayMode mode in Enum.GetValues(typeof(MediaControlNativeDisplayMode)))
524             {
525                 if (modes.HasFlag(mode))
526                 {
527                     supportedModes.Add(mode.ToPublic());
528                 }
529             }
530
531             return supportedModes.AsReadOnly();
532         }
533
534         internal static MediaControlNativeDisplayRotation ToNative(this Rotation mode)
535         {
536             Debug.Assert(Enum.IsDefined(typeof(Rotation), mode));
537
538             MediaControlNativeDisplayRotation nativeMode = MediaControlNativeDisplayRotation.Rotate0;
539             switch (mode)
540             {
541                 case Rotation.Rotate0:
542                     nativeMode = MediaControlNativeDisplayRotation.Rotate0;
543                     break;
544                 case Rotation.Rotate90:
545                     nativeMode = MediaControlNativeDisplayRotation.Rotate90;
546                     break;
547                 case Rotation.Rotate180:
548                     nativeMode = MediaControlNativeDisplayRotation.Rotate180;
549                     break;
550                 case Rotation.Rotate270:
551                     nativeMode = MediaControlNativeDisplayRotation.Rotate270;
552                     break;
553             }
554             return nativeMode;
555         }
556
557         internal static Rotation ToPublic(this MediaControlNativeDisplayRotation mode)
558         {
559             Debug.Assert(Enum.IsDefined(typeof(MediaControlNativeDisplayRotation), mode));
560             Rotation nativeMode = Rotation.Rotate0;
561             switch (mode)
562             {
563                 case MediaControlNativeDisplayRotation.Rotate0:
564                     nativeMode = Rotation.Rotate0;
565                     break;
566                 case MediaControlNativeDisplayRotation.Rotate90:
567                     nativeMode = Rotation.Rotate90;
568                     break;
569                 case MediaControlNativeDisplayRotation.Rotate180:
570                     nativeMode = Rotation.Rotate180;
571                     break;
572                 case MediaControlNativeDisplayRotation.Rotate270:
573                     nativeMode = Rotation.Rotate270;
574                     break;
575             }
576             return nativeMode;
577         }
578
579         internal static IList<Rotation> ToPublicList(this MediaControlNativeDisplayRotation modes)
580         {
581             var supportedRotations = new List<Rotation>();
582
583             foreach (MediaControlNativeDisplayRotation mode in Enum.GetValues(typeof(MediaControlNativeDisplayRotation)))
584             {
585                 if (modes.HasFlag(mode))
586                 {
587                     supportedRotations.Add(mode.ToPublic());
588                 }
589             }
590
591             return supportedRotations.AsReadOnly();
592         }
593     }
594 }