[NUI] Change SetMinAndMaxFrameByMarker behavior + Fix some async cases
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.StreamRecorder / StreamRecorder / StreamRecorderEnums.cs
1 /*
2  * Copyright (c) 2016 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.Diagnostics;
19
20 namespace Tizen.Multimedia
21 {
22
23     /// <summary>
24     /// Specifies errors for <see cref="StreamRecorder"/>/
25     /// </summary>
26     /// <since_tizen> 4 </since_tizen>
27     [Obsolete("Deprecated in API10; Will be removed in API12")]
28     public enum StreamRecorderError
29     {
30         /// <summary>
31         /// Internal error.
32         /// </summary>
33         InternalError = StreamRecorderErrorCode.InvalidOperation,
34         /// <summary>
35         /// Out of storage.
36         /// </summary>
37         OutOfStorage = StreamRecorderErrorCode.OutOfStorage
38     }
39
40     /// <summary>
41     /// Specifies the video source formats for <see cref="StreamRecorder"/>.
42     /// </summary>
43     /// <since_tizen> 4 </since_tizen>
44     [Obsolete("Deprecated in API10; Will be removed in API12")]
45     public enum StreamRecorderVideoFormat
46     {
47         /// <summary>
48         /// Nv12 format.
49         /// </summary>
50         Nv12,
51         /// <summary>
52         /// Nv21 format.
53         /// </summary>
54         Nv21,
55         /// <summary>
56         /// I420 format.
57         /// </summary>
58         I420
59     }
60
61     #region Internal enums
62
63     /// <summary>
64     /// Enumeration for Audio Codec.
65     /// </summary>
66     internal enum StreamRecorderAudioCodec
67     {
68         /// <summary>
69         /// AMR codec.
70         /// </summary>
71         Amr = 0,
72         /// <summary>
73         /// AAC codec.
74         /// </summary>
75         Aac,
76         /// <summary>
77         /// PCM codec.
78         /// </summary>
79         Pcm
80     }
81
82     /// <summary>
83     /// Enumeration for the file container format.
84     /// </summary>
85     internal enum StreamRecorderFileFormat
86     {
87         /// <summary>
88         /// 3GP file format.
89         /// </summary>
90         ThreeGp,
91         /// <summary>
92         /// MP4 file format.
93         /// </summary>
94         Mp4,
95         /// <summary>
96         /// AMR file format.
97         /// </summary>
98         Amr,
99         /// <summary>
100         /// ADTS file format.
101         /// </summary>
102         Adts,
103         /// <summary>
104         /// WAV file format.
105         /// </summary>
106         Wav
107     }
108
109     /// <summary>
110     /// Enumeration for the recorder notify type.
111     /// </summary>
112     internal enum StreamRecorderNotify
113     {
114         /// <summary>
115         /// None.
116         /// </summary>
117         None = 0,
118         /// <summary>
119         /// State changed.
120         /// </summary>
121         StateChanged
122     }
123
124     /// <summary>
125     /// Enumeration for video codec.
126     /// </summary>
127     internal enum StreamRecorderVideoCodec
128     {
129         /// <summary>
130         /// H263 codec.
131         /// </summary>
132         H263,
133         /// <summary>
134         /// MPEG4 codec.
135         /// </summary>
136         Mpeg4
137     }
138
139     /// <summary>
140     /// Enumeration for source type.
141     /// </summary>
142     internal enum StreamRecorderSourceType
143     {
144         /// <summary>
145         /// Video source
146         /// </summary>
147         Video,
148         /// <summary>
149         /// Audio source
150         /// </summary>
151         Audio,
152         /// <summary>
153         /// Audio/Video both
154         /// </summary>
155         VideoAudio
156     }
157
158     internal static class StreamRecorderEnumExtensions
159     {
160         internal static RecorderVideoCodec ToRecorderEnum(this StreamRecorderVideoCodec value)
161         {
162             switch (value)
163             {
164                 case StreamRecorderVideoCodec.H263:
165                     return RecorderVideoCodec.H263;
166
167                 case StreamRecorderVideoCodec.Mpeg4:
168                     return RecorderVideoCodec.Mpeg4;
169             }
170
171             Debug.Fail("Unknown video codec value.");
172             return 0;
173         }
174
175         internal static StreamRecorderVideoCodec ToStreamRecorderEnum(this RecorderVideoCodec value)
176         {
177             switch (value)
178             {
179                 case RecorderVideoCodec.H263:
180                     return StreamRecorderVideoCodec.H263;
181
182                 case RecorderVideoCodec.Mpeg4:
183                     return StreamRecorderVideoCodec.Mpeg4;
184             }
185
186             throw new NotSupportedException($"{value.ToString()} is not supported.");
187         }
188
189
190         internal static RecorderAudioCodec ToRecorderEnum(this StreamRecorderAudioCodec value)
191         {
192             switch (value)
193             {
194                 case StreamRecorderAudioCodec.Aac:
195                     return RecorderAudioCodec.Aac;
196
197                 case StreamRecorderAudioCodec.Amr:
198                     return RecorderAudioCodec.Amr;
199
200                 case StreamRecorderAudioCodec.Pcm:
201                     return RecorderAudioCodec.Pcm;
202             }
203
204             Debug.Fail("Unknown audio codec value.");
205             return 0;
206         }
207
208
209         internal static StreamRecorderAudioCodec ToStreamRecorderEnum(this RecorderAudioCodec value)
210         {
211             switch (value)
212             {
213                 case RecorderAudioCodec.Aac:
214                     return StreamRecorderAudioCodec.Aac;
215
216                 case RecorderAudioCodec.Amr:
217                     return StreamRecorderAudioCodec.Amr;
218
219                 case RecorderAudioCodec.Pcm:
220                     return StreamRecorderAudioCodec.Pcm;
221             }
222
223             throw new NotSupportedException($"{value.ToString()} is not supported.");
224         }
225
226
227         internal static RecorderFileFormat ToRecorderEnum(this StreamRecorderFileFormat value)
228         {
229             switch (value)
230             {
231                 case StreamRecorderFileFormat.ThreeGp:
232                     return RecorderFileFormat.ThreeGp;
233
234                 case StreamRecorderFileFormat.Mp4:
235                     return RecorderFileFormat.Mp4;
236
237                 case StreamRecorderFileFormat.Amr:
238                     return RecorderFileFormat.Amr;
239
240                 case StreamRecorderFileFormat.Adts:
241                     return RecorderFileFormat.Adts;
242
243                 case StreamRecorderFileFormat.Wav:
244                     return RecorderFileFormat.Wav;
245             }
246
247             Debug.Fail("Unknown file format value.");
248             return 0;
249         }
250
251
252         internal static StreamRecorderFileFormat ToStreamRecorderEnum(this RecorderFileFormat value)
253         {
254             switch (value)
255             {
256                 case RecorderFileFormat.ThreeGp:
257                     return StreamRecorderFileFormat.ThreeGp;
258
259                 case RecorderFileFormat.Mp4:
260                     return StreamRecorderFileFormat.Mp4;
261
262                 case RecorderFileFormat.Amr:
263                     return StreamRecorderFileFormat.Amr;
264
265                 case RecorderFileFormat.Adts:
266                     return StreamRecorderFileFormat.Adts;
267
268                 case RecorderFileFormat.Wav:
269                     return StreamRecorderFileFormat.Wav;
270             }
271
272             throw new NotSupportedException($"{value.ToString()} is not supported.");
273         }
274     }
275     #endregion
276 }