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