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