[Multimedia] Fix VD SVACE issues (#5445)
[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                 default: break;
401             }
402
403             Debug.Fail($"Not supported code for playback state{nativeState}.");
404             return MediaControlPlaybackState.None;
405         }
406
407         internal static MediaControllerNativePlaybackState ToNative(this MediaControlPlaybackState state)
408         {
409             switch (state)
410             {
411                 case MediaControlPlaybackState.Playing: return MediaControllerNativePlaybackState.Play;
412                 case MediaControlPlaybackState.Paused: return MediaControllerNativePlaybackState.Pause;
413                 case MediaControlPlaybackState.Stopped: return MediaControllerNativePlaybackState.Stop;
414                 case MediaControlPlaybackState.MovingToNext: return MediaControllerNativePlaybackState.MovingToNext;
415                 case MediaControlPlaybackState.MovingToPrevious: return MediaControllerNativePlaybackState.MovingToPrev;
416                 case MediaControlPlaybackState.FastForwarding: return MediaControllerNativePlaybackState.FastForwarding;
417                 case MediaControlPlaybackState.Rewinding: return MediaControllerNativePlaybackState.Rewinding;
418                 case MediaControlPlaybackState.Connecting: return MediaControllerNativePlaybackState.Connecting;
419                 case MediaControlPlaybackState.Buffering: return MediaControllerNativePlaybackState.Buffering;
420                 case MediaControlPlaybackState.Error: return MediaControllerNativePlaybackState.Error;
421                 default: break;
422             }
423             return MediaControllerNativePlaybackState.None;
424         }
425
426         internal static MediaControlPlaybackCommand ToPublic(this MediaControllerNativePlaybackAction nativeAction)
427         {
428             switch (nativeAction)
429             {
430                 case MediaControllerNativePlaybackAction.Play: return MediaControlPlaybackCommand.Play;
431                 case MediaControllerNativePlaybackAction.Pause: return MediaControlPlaybackCommand.Pause;
432                 case MediaControllerNativePlaybackAction.Stop: return MediaControlPlaybackCommand.Stop;
433                 case MediaControllerNativePlaybackAction.Next: return MediaControlPlaybackCommand.Next;
434                 case MediaControllerNativePlaybackAction.Prev: return MediaControlPlaybackCommand.Previous;
435                 case MediaControllerNativePlaybackAction.FastForward: return MediaControlPlaybackCommand.FastForward;
436                 case MediaControllerNativePlaybackAction.Rewind: return MediaControlPlaybackCommand.Rewind;
437                 case MediaControllerNativePlaybackAction.Toggle: return MediaControlPlaybackCommand.Toggle;
438                 default: break;
439             }
440
441             Debug.Fail($"Not supported code for playback command{nativeAction}.");
442             return MediaControlPlaybackCommand.Play;
443         }
444
445         internal static MediaControllerNativePlaybackAction ToNative(this MediaControlPlaybackCommand command)
446         {
447             switch (command)
448             {
449                 case MediaControlPlaybackCommand.Play: return MediaControllerNativePlaybackAction.Play;
450                 case MediaControlPlaybackCommand.Pause: return MediaControllerNativePlaybackAction.Pause;
451                 case MediaControlPlaybackCommand.Stop: return MediaControllerNativePlaybackAction.Stop;
452                 case MediaControlPlaybackCommand.Next: return MediaControllerNativePlaybackAction.Next;
453                 case MediaControlPlaybackCommand.Previous: return MediaControllerNativePlaybackAction.Prev;
454                 case MediaControlPlaybackCommand.FastForward: return MediaControllerNativePlaybackAction.FastForward;
455                 case MediaControlPlaybackCommand.Rewind: return MediaControllerNativePlaybackAction.Rewind;
456                 case MediaControlPlaybackCommand.Toggle: return MediaControllerNativePlaybackAction.Toggle;
457                 default: break;
458             }
459             return MediaControllerNativePlaybackAction.Play;
460         }
461
462         internal static MediaControlRepeatMode ToPublic(this MediaControllerNativeRepeatMode mode)
463         {
464             Debug.Assert(Enum.IsDefined(typeof(MediaControllerNativeRepeatMode), mode));
465
466             return mode == MediaControllerNativeRepeatMode.Off ? MediaControlRepeatMode.On :
467                 (mode == MediaControllerNativeRepeatMode.On ? MediaControlRepeatMode.Off : MediaControlRepeatMode.OneMedia);
468         }
469
470         internal static MediaControllerNativeRepeatMode ToNative(this MediaControlRepeatMode mode)
471         {
472             Debug.Assert(Enum.IsDefined(typeof(MediaControlRepeatMode), mode));
473
474             return mode == MediaControlRepeatMode.Off ? MediaControllerNativeRepeatMode.On :
475                 (mode == MediaControlRepeatMode.On ? MediaControllerNativeRepeatMode.Off : MediaControllerNativeRepeatMode.OneMedia);
476         }
477
478         internal static MediaControlNativeDisplayMode ToNative(this MediaControlDisplayMode mode)
479         {
480             Debug.Assert(Enum.IsDefined(typeof(MediaControlDisplayMode), mode));
481
482             MediaControlNativeDisplayMode nativeMode = MediaControlNativeDisplayMode.LetterBox;
483             switch (mode)
484             {
485                 case MediaControlDisplayMode.LetterBox:
486                     nativeMode = MediaControlNativeDisplayMode.LetterBox;
487                     break;
488                 case MediaControlDisplayMode.OriginSize:
489                     nativeMode = MediaControlNativeDisplayMode.OriginSize;
490                     break;
491                 case MediaControlDisplayMode.FullScreen:
492                     nativeMode = MediaControlNativeDisplayMode.FullScreen;
493                     break;
494                 case MediaControlDisplayMode.CroppedFull:
495                     nativeMode = MediaControlNativeDisplayMode.CroppedFull;
496                     break;
497                 default:
498                     break;
499             }
500             return nativeMode;
501         }
502
503         internal static MediaControlDisplayMode ToPublic(this MediaControlNativeDisplayMode mode)
504         {
505             Debug.Assert(Enum.IsDefined(typeof(MediaControlNativeDisplayMode), mode));
506             MediaControlDisplayMode nativeMode = MediaControlDisplayMode.LetterBox;
507             switch (mode)
508             {
509                 case MediaControlNativeDisplayMode.LetterBox:
510                     nativeMode = MediaControlDisplayMode.LetterBox;
511                     break;
512                 case MediaControlNativeDisplayMode.OriginSize:
513                     nativeMode = MediaControlDisplayMode.OriginSize;
514                     break;
515                 case MediaControlNativeDisplayMode.FullScreen:
516                     nativeMode = MediaControlDisplayMode.FullScreen;
517                     break;
518                 case MediaControlNativeDisplayMode.CroppedFull:
519                     nativeMode = MediaControlDisplayMode.CroppedFull;
520                     break;
521                 default:
522                     break;
523             }
524             return nativeMode;
525         }
526
527         internal static IList<MediaControlDisplayMode> ToPublicList(this MediaControlNativeDisplayMode modes)
528         {
529             var supportedModes = new List<MediaControlDisplayMode>();
530
531             foreach (MediaControlNativeDisplayMode mode in Enum.GetValues(typeof(MediaControlNativeDisplayMode)))
532             {
533                 if (modes.HasFlag(mode))
534                 {
535                     supportedModes.Add(mode.ToPublic());
536                 }
537             }
538
539             return supportedModes.AsReadOnly();
540         }
541
542         internal static MediaControlNativeDisplayRotation ToNative(this Rotation mode)
543         {
544             Debug.Assert(Enum.IsDefined(typeof(Rotation), mode));
545
546             MediaControlNativeDisplayRotation nativeMode = MediaControlNativeDisplayRotation.Rotate0;
547             switch (mode)
548             {
549                 case Rotation.Rotate0:
550                     nativeMode = MediaControlNativeDisplayRotation.Rotate0;
551                     break;
552                 case Rotation.Rotate90:
553                     nativeMode = MediaControlNativeDisplayRotation.Rotate90;
554                     break;
555                 case Rotation.Rotate180:
556                     nativeMode = MediaControlNativeDisplayRotation.Rotate180;
557                     break;
558                 case Rotation.Rotate270:
559                     nativeMode = MediaControlNativeDisplayRotation.Rotate270;
560                     break;
561                 default:
562                     break;
563             }
564             return nativeMode;
565         }
566
567         internal static Rotation ToPublic(this MediaControlNativeDisplayRotation mode)
568         {
569             Debug.Assert(Enum.IsDefined(typeof(MediaControlNativeDisplayRotation), mode));
570             Rotation nativeMode = Rotation.Rotate0;
571             switch (mode)
572             {
573                 case MediaControlNativeDisplayRotation.Rotate0:
574                     nativeMode = Rotation.Rotate0;
575                     break;
576                 case MediaControlNativeDisplayRotation.Rotate90:
577                     nativeMode = Rotation.Rotate90;
578                     break;
579                 case MediaControlNativeDisplayRotation.Rotate180:
580                     nativeMode = Rotation.Rotate180;
581                     break;
582                 case MediaControlNativeDisplayRotation.Rotate270:
583                     nativeMode = Rotation.Rotate270;
584                     break;
585                 default:
586                     break;
587             }
588             return nativeMode;
589         }
590
591         internal static IList<Rotation> ToPublicList(this MediaControlNativeDisplayRotation modes)
592         {
593             var supportedRotations = new List<Rotation>();
594
595             foreach (MediaControlNativeDisplayRotation mode in Enum.GetValues(typeof(MediaControlNativeDisplayRotation)))
596             {
597                 if (modes.HasFlag(mode))
598                 {
599                     supportedRotations.Add(mode.ToPublic());
600                 }
601             }
602
603             return supportedRotations.AsReadOnly();
604         }
605     }
606 }