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;
22 namespace Tizen.Multimedia
25 /// The camera setting class provides methods/properties to get and
26 /// set basic camera attributes.
28 public class RecorderSettings
30 internal readonly Recorder _recorder = null;
32 internal RecorderSettings(Recorder recorder)
38 /// The number of audio channel.
41 /// For mono recording, set channel to 1.
42 /// For stereo recording, set channel to 2.
44 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
45 public int AudioChannel
51 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetAudioChannel(_recorder.GetHandle(), out val),
52 "Failed to get audio channel.");
59 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetAudioChannel(_recorder.GetHandle(), value),
60 "Failed to set audio channel");
65 /// The audio device for recording.
67 /// <value>A <see cref="RecorderAudioDevice"/> that specifies the type of audio device.</value>
68 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
69 public RecorderAudioDevice AudioDevice
73 RecorderAudioDevice val = 0;
75 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetAudioDevice(_recorder.GetHandle(), out val),
76 "Failed to get audio device.");
83 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetAudioDevice(_recorder.GetHandle(), value),
84 "Failed to set audio device.");
89 /// Get the peak audio input level in dB
92 /// 0dB indicates maximum input level, -300dB indicates minimum input level.
94 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
95 public double AudioLevel
101 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetAudioLevel(_recorder.GetHandle(), out level),
102 "Failed to get Audio level.");
109 /// The sampling rate of an audio stream in hertz.
111 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
112 public int AudioSampleRate
118 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetAudioSampleRate(_recorder.GetHandle(), out val),
119 "Failed to get audio sample rate.");
126 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetAudioSampleRate(_recorder.GetHandle(), value),
127 "Failed to set audio sample rate.");
132 /// The bitrate of an audio encoder in bits per second.
134 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
135 public int AudioBitRate
141 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetAudioEncoderBitrate(_recorder.GetHandle(), out val),
142 "Failed to get audio bitrate.");
149 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetAudioEncoderBitrate(_recorder.GetHandle(), value),
150 "Failed to set audio bitrate");
155 /// The bitrate of an video encoder in bits per second.
157 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
158 public int VideoBitRate
164 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetVideoEncoderBitrate(_recorder.GetHandle(), out val),
165 "Failed to get video bitrate.");
172 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetVideoEncoderBitrate(_recorder.GetHandle(), value),
173 "Failed to set video bitrate");
178 /// The audio codec for encoding an audio stream.
180 /// <value>A <see cref="RecorderAudioCodec"/> that specifies the type of audio codec.</value>
181 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
182 public RecorderAudioCodec AudioCodec
186 RecorderAudioCodec val = 0;
188 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetAudioEncoder(_recorder.GetHandle(), out val),
189 "Failed to get audio codec");
196 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetAudioEncoder(_recorder.GetHandle(), value),
197 "Failed to set audio codec");
202 /// The video codec for encoding video stream.
204 /// <value>A <see cref="RecorderVideoCodec"/> that specifies the type of video codec.</value>
205 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
206 public RecorderVideoCodec VideoCodec
210 RecorderVideoCodec val = 0;
212 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetVideoEncoder(_recorder.GetHandle(), out val),
213 "Failed to get video codec");
220 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetVideoEncoder(_recorder.GetHandle(), value),
221 "Failed to set video codec");
226 /// The file format for recording media stream.
228 /// <value>A <see cref="RecorderFileFormat"/> that specifies the file format.</value>
229 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
230 public RecorderFileFormat FileFormat
234 RecorderFileFormat val = 0;
236 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetFileFormat(_recorder.GetHandle(), out val),
237 "Failed to get file format.");
244 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetFileFormat(_recorder.GetHandle(), value),
245 "Failed to set file format");
250 /// The file path to record.
253 /// If the same file already exists in the file system, then old file
254 /// will be overwritten.
256 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
257 public string FilePath
262 RecorderError ret = Interop.RecorderSettings.GetFileName(_recorder.GetHandle(), out val);
263 if (ret != RecorderError.None)
265 Log.Error(RecorderLog.Tag, "Failed to get filepath, " + (RecorderError)ret);
267 string result = Marshal.PtrToStringAnsi(val);
268 Interop.Libc.Free(val);
274 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetFileName(_recorder.GetHandle(), value),
275 "Failed to set filepath");
280 /// The maximum size of a recording file in KB(kilobytes). If 0, means
281 /// unlimited recording size.
284 /// After reaching the limitation, the data which is being recorded will
285 /// be discarded and not written to the file.
286 /// The recorder state must be in 'Ready' or 'Created' state.
288 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
295 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetSizeLimit(_recorder.GetHandle(), out val),
296 "Failed to get size limit.");
303 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetSizeLimit(_recorder.GetHandle(), value),
304 "Failed to set size limit");
309 /// The time limit of a recording file in Seconds. If 0, means unlimited recording
313 /// After reaching the limitation, the data which is being recorded will
314 /// be discarded and not written to the file.
315 /// The recorder state must be in 'Ready' or 'Created' state.
317 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
324 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetTimeLimit(_recorder.GetHandle(), out val),
325 "Failed to get time limit.");
332 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetTimeLimit(_recorder.GetHandle(), value),
333 "Failed to set time limit.");
338 /// The mute state of a recorder.
340 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
345 return Interop.RecorderSettings.GetMute(_recorder.GetHandle());
350 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetMute(_recorder.GetHandle(), value),
351 "Failed to set mute");
356 /// The video recording motion rate
359 /// The attribute is valid only in a video recorder.
360 /// If the rate is in range of 0-1, video is recorded in a slow motion mode.
361 /// If the rate is bigger than 1, video is recorded in a fast motion mode.
363 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
364 public double MotionRate
370 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetMotionRate(_recorder.GetHandle(), out val),
371 "Failed to get video motion rate.");
378 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetMotionRate(_recorder.GetHandle(), value),
379 "Failed to set video motion rate");
384 /// The orientation in a video metadata tag.
386 /// <value>A <see cref="RecorderOrientation"/> that specifies the type of orientation.</value>
387 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
388 public RecorderOrientation OrientationTag
392 RecorderOrientation val = 0;
394 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetOrientationTag(_recorder.GetHandle(), out val),
395 "Failed to get recorder orientation.");
402 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetOrientationTag(_recorder.GetHandle(), value),
403 "Failed to set recorder orientation");
408 /// Resolution of the video.
410 /// <exception cref="ArgumentException">In case of invalid parameters</exception>
411 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
412 public Size VideoResolution
419 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetVideoResolution(_recorder.GetHandle(), out width, out height),
420 "Failed to get camera video resolution");
422 return new Size(width, height);
429 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetVideoResolution(_recorder.GetHandle(), res.Width, res.Height),
430 "Failed to set video resolution.");