[Multimedia] Fix VD SVACE issues (#5445)
[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                 default:
171                     break;
172             }
173
174             Debug.Fail("Unknown video codec value.");
175             return 0;
176         }
177
178         internal static StreamRecorderVideoCodec ToStreamRecorderEnum(this RecorderVideoCodec value)
179         {
180             switch (value)
181             {
182                 case RecorderVideoCodec.H263:
183                     return StreamRecorderVideoCodec.H263;
184
185                 case RecorderVideoCodec.Mpeg4:
186                     return StreamRecorderVideoCodec.Mpeg4;
187
188                 default:
189                     break;
190             }
191
192             throw new NotSupportedException($"{value.ToString()} is not supported.");
193         }
194
195
196         internal static RecorderAudioCodec ToRecorderEnum(this StreamRecorderAudioCodec value)
197         {
198             switch (value)
199             {
200                 case StreamRecorderAudioCodec.Aac:
201                     return RecorderAudioCodec.Aac;
202
203                 case StreamRecorderAudioCodec.Amr:
204                     return RecorderAudioCodec.Amr;
205
206                 case StreamRecorderAudioCodec.Pcm:
207                     return RecorderAudioCodec.Pcm;
208
209                 default:
210                     break;
211             }
212
213             Debug.Fail("Unknown audio codec value.");
214             return 0;
215         }
216
217
218         internal static StreamRecorderAudioCodec ToStreamRecorderEnum(this RecorderAudioCodec value)
219         {
220             switch (value)
221             {
222                 case RecorderAudioCodec.Aac:
223                     return StreamRecorderAudioCodec.Aac;
224
225                 case RecorderAudioCodec.Amr:
226                     return StreamRecorderAudioCodec.Amr;
227
228                 case RecorderAudioCodec.Pcm:
229                     return StreamRecorderAudioCodec.Pcm;
230
231                 default:
232                     break;
233             }
234
235             throw new NotSupportedException($"{value.ToString()} is not supported.");
236         }
237
238
239         internal static RecorderFileFormat ToRecorderEnum(this StreamRecorderFileFormat value)
240         {
241             switch (value)
242             {
243                 case StreamRecorderFileFormat.ThreeGp:
244                     return RecorderFileFormat.ThreeGp;
245
246                 case StreamRecorderFileFormat.Mp4:
247                     return RecorderFileFormat.Mp4;
248
249                 case StreamRecorderFileFormat.Amr:
250                     return RecorderFileFormat.Amr;
251
252                 case StreamRecorderFileFormat.Adts:
253                     return RecorderFileFormat.Adts;
254
255                 case StreamRecorderFileFormat.Wav:
256                     return RecorderFileFormat.Wav;
257
258                 default:
259                     break;
260             }
261
262             Debug.Fail("Unknown file format value.");
263             return 0;
264         }
265
266
267         internal static StreamRecorderFileFormat ToStreamRecorderEnum(this RecorderFileFormat value)
268         {
269             switch (value)
270             {
271                 case RecorderFileFormat.ThreeGp:
272                     return StreamRecorderFileFormat.ThreeGp;
273
274                 case RecorderFileFormat.Mp4:
275                     return StreamRecorderFileFormat.Mp4;
276
277                 case RecorderFileFormat.Amr:
278                     return StreamRecorderFileFormat.Amr;
279
280                 case RecorderFileFormat.Adts:
281                     return StreamRecorderFileFormat.Adts;
282
283                 case RecorderFileFormat.Wav:
284                     return StreamRecorderFileFormat.Wav;
285
286                 default:
287                     break;
288             }
289
290             throw new NotSupportedException($"{value.ToString()} is not supported.");
291         }
292     }
293     #endregion
294 }