2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 using System.Runtime.InteropServices;
20 using Tizen.Internals.Errors;
21 using Native = Interop.RecorderSettings;
23 namespace Tizen.Multimedia
26 /// The camera setting class provides methods/properties to get and
27 /// set basic camera attributes.
29 public class RecorderSettings
31 internal readonly Recorder _recorder = null;
33 internal RecorderSettings(Recorder recorder)
39 /// The number of audio channel.
41 /// <since_tizen> 3 </since_tizen>
43 /// For mono recording, set channel to 1.
44 /// For stereo recording, set channel to 2.
46 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
47 public int AudioChannel
53 RecorderErrorFactory.ThrowIfError(Native.GetAudioChannel(_recorder.GetHandle(), out val),
54 "Failed to get audio channel.");
61 RecorderErrorFactory.ThrowIfError(Native.SetAudioChannel(_recorder.GetHandle(), value),
62 "Failed to set audio channel");
67 /// The audio device for recording.
69 /// <since_tizen> 3 </since_tizen>
70 /// <value>A <see cref="RecorderAudioDevice"/> that specifies the type of audio device.</value>
71 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
72 public RecorderAudioDevice AudioDevice
76 RecorderAudioDevice val = 0;
78 RecorderErrorFactory.ThrowIfError(Native.GetAudioDevice(_recorder.GetHandle(), out val),
79 "Failed to get audio device.");
86 RecorderErrorFactory.ThrowIfError(Native.SetAudioDevice(_recorder.GetHandle(), value),
87 "Failed to set audio device.");
92 /// Get the peak audio input level in dB
94 /// <since_tizen> 3 </since_tizen>
96 /// 0dB indicates maximum input level, -300dB indicates minimum input level.
98 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
99 public double AudioLevel
105 RecorderErrorFactory.ThrowIfError(Native.GetAudioLevel(_recorder.GetHandle(), out level),
106 "Failed to get Audio level.");
113 /// The sampling rate of an audio stream in hertz.
115 /// <since_tizen> 3 </since_tizen>
116 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
117 public int AudioSampleRate
123 RecorderErrorFactory.ThrowIfError(Native.GetAudioSampleRate(_recorder.GetHandle(), out val),
124 "Failed to get audio sample rate.");
131 RecorderErrorFactory.ThrowIfError(Native.SetAudioSampleRate(_recorder.GetHandle(), value),
132 "Failed to set audio sample rate.");
137 /// The bitrate of an audio encoder in bits per second.
139 /// <since_tizen> 3 </since_tizen>
140 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
141 public int AudioBitRate
147 RecorderErrorFactory.ThrowIfError(Native.GetAudioEncoderBitrate(_recorder.GetHandle(), out val),
148 "Failed to get audio bitrate.");
155 RecorderErrorFactory.ThrowIfError(Native.SetAudioEncoderBitrate(_recorder.GetHandle(), value),
156 "Failed to set audio bitrate");
161 /// The bitrate of an video encoder in bits per second.
163 /// <since_tizen> 3 </since_tizen>
164 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
165 public int VideoBitRate
171 RecorderErrorFactory.ThrowIfError(Native.GetVideoEncoderBitrate(_recorder.GetHandle(), out val),
172 "Failed to get video bitrate.");
179 RecorderErrorFactory.ThrowIfError(Native.SetVideoEncoderBitrate(_recorder.GetHandle(), value),
180 "Failed to set video bitrate");
185 /// The audio codec for encoding an audio stream.
187 /// <since_tizen> 3 </since_tizen>
188 /// <value>A <see cref="RecorderAudioCodec"/> that specifies the type of audio codec.</value>
189 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
190 public RecorderAudioCodec AudioCodec
194 RecorderAudioCodec val = 0;
196 RecorderErrorFactory.ThrowIfError(Native.GetAudioEncoder(_recorder.GetHandle(), out val),
197 "Failed to get audio codec");
204 RecorderErrorFactory.ThrowIfError(Native.SetAudioEncoder(_recorder.GetHandle(), value),
205 "Failed to set audio codec");
210 /// The video codec for encoding video stream.
212 /// <since_tizen> 3 </since_tizen>
213 /// <value>A <see cref="RecorderVideoCodec"/> that specifies the type of video codec.</value>
214 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
215 public RecorderVideoCodec VideoCodec
219 RecorderVideoCodec val = 0;
221 RecorderErrorFactory.ThrowIfError(Native.GetVideoEncoder(_recorder.GetHandle(), out val),
222 "Failed to get video codec");
229 RecorderErrorFactory.ThrowIfError(Native.SetVideoEncoder(_recorder.GetHandle(), value),
230 "Failed to set video codec");
235 /// The file format for recording media stream.
237 /// <since_tizen> 3 </since_tizen>
238 /// <value>A <see cref="RecorderFileFormat"/> that specifies the file format.</value>
239 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
240 public RecorderFileFormat FileFormat
244 RecorderFileFormat val = 0;
246 RecorderErrorFactory.ThrowIfError(Native.GetFileFormat(_recorder.GetHandle(), out val),
247 "Failed to get file format.");
254 RecorderErrorFactory.ThrowIfError(Native.SetFileFormat(_recorder.GetHandle(), value),
255 "Failed to set file format");
260 /// The file path to record.
262 /// <since_tizen> 3 </since_tizen>
264 /// If the same file already exists in the file system, then old file
265 /// will be overwritten.
267 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
268 public string FilePath
273 RecorderError ret = Native.GetFileName(_recorder.GetHandle(), out val);
274 if (ret != RecorderError.None)
276 Log.Error(RecorderLog.Tag, "Failed to get filepath, " + (RecorderError)ret);
278 string result = Marshal.PtrToStringAnsi(val);
279 LibcSupport.Free(val);
285 RecorderErrorFactory.ThrowIfError(Native.SetFileName(_recorder.GetHandle(), value),
286 "Failed to set filepath");
291 /// The maximum size of a recording file in KB(kilobytes). If 0, means
292 /// unlimited recording size.
294 /// <since_tizen> 3 </since_tizen>
296 /// After reaching the limitation, the data which is being recorded will
297 /// be discarded and not written to the file.
298 /// The recorder state must be in 'Ready' or 'Created' state.
300 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
307 RecorderErrorFactory.ThrowIfError(Native.GetSizeLimit(_recorder.GetHandle(), out val),
308 "Failed to get size limit.");
315 RecorderErrorFactory.ThrowIfError(Native.SetSizeLimit(_recorder.GetHandle(), value),
316 "Failed to set size limit");
321 /// The time limit of a recording file in Seconds. If 0, means unlimited recording
324 /// <since_tizen> 3 </since_tizen>
326 /// After reaching the limitation, the data which is being recorded will
327 /// be discarded and not written to the file.
328 /// The recorder state must be in 'Ready' or 'Created' state.
330 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
337 RecorderErrorFactory.ThrowIfError(Native.GetTimeLimit(_recorder.GetHandle(), out val),
338 "Failed to get time limit.");
345 RecorderErrorFactory.ThrowIfError(Native.SetTimeLimit(_recorder.GetHandle(), value),
346 "Failed to set time limit.");
351 /// The mute state of a recorder.
353 /// <since_tizen> 3 </since_tizen>
354 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
359 return Native.GetMute(_recorder.GetHandle());
364 RecorderErrorFactory.ThrowIfError(Native.SetMute(_recorder.GetHandle(), value),
365 "Failed to set mute");
370 /// The video recording motion rate
372 /// <since_tizen> 3 </since_tizen>
374 /// The attribute is valid only in a video recorder.
375 /// If the rate is in range of 0-1, video is recorded in a slow motion mode.
376 /// If the rate is bigger than 1, video is recorded in a fast motion mode.
378 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
379 public double MotionRate
385 RecorderErrorFactory.ThrowIfError(Native.GetMotionRate(_recorder.GetHandle(), out val),
386 "Failed to get video motion rate.");
393 RecorderErrorFactory.ThrowIfError(Native.SetMotionRate(_recorder.GetHandle(), value),
394 "Failed to set video motion rate");
399 /// The orientation in a video metadata tag.
401 /// <since_tizen> 3 </since_tizen>
402 /// <value>A <see cref="Rotation"/> that specifies the type of orientation.</value>
403 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
404 public Rotation OrientationTag
408 RecorderErrorFactory.ThrowIfError(Native.GetOrientationTag(_recorder.GetHandle(), out var val),
409 "Failed to get recorder orientation.");
416 RecorderErrorFactory.ThrowIfError(Native.SetOrientationTag(_recorder.GetHandle(), value),
417 "Failed to set recorder orientation");
422 /// Resolution of the video.
424 /// <since_tizen> 3 </since_tizen>
425 /// <exception cref="ArgumentException">In case of invalid parameters</exception>
426 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
427 public Size VideoResolution
434 RecorderErrorFactory.ThrowIfError(Native.GetVideoResolution(_recorder.GetHandle(), out width, out height),
435 "Failed to get camera video resolution");
437 return new Size(width, height);
444 RecorderErrorFactory.ThrowIfError(Native.SetVideoResolution(_recorder.GetHandle(), res.Width, res.Height),
445 "Failed to set video resolution.");