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.
42 /// For mono recording, set channel to 1.
43 /// For stereo recording, set channel to 2.
45 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
46 public int AudioChannel
52 RecorderErrorFactory.ThrowIfError(Native.GetAudioChannel(_recorder.GetHandle(), out val),
53 "Failed to get audio channel.");
60 RecorderErrorFactory.ThrowIfError(Native.SetAudioChannel(_recorder.GetHandle(), value),
61 "Failed to set audio channel");
66 /// The audio device for recording.
68 /// <value>A <see cref="RecorderAudioDevice"/> that specifies the type of audio device.</value>
69 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
70 public RecorderAudioDevice AudioDevice
74 RecorderAudioDevice val = 0;
76 RecorderErrorFactory.ThrowIfError(Native.GetAudioDevice(_recorder.GetHandle(), out val),
77 "Failed to get audio device.");
84 RecorderErrorFactory.ThrowIfError(Native.SetAudioDevice(_recorder.GetHandle(), value),
85 "Failed to set audio device.");
90 /// Get the peak audio input level in dB
93 /// 0dB indicates maximum input level, -300dB indicates minimum input level.
95 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
96 public double AudioLevel
102 RecorderErrorFactory.ThrowIfError(Native.GetAudioLevel(_recorder.GetHandle(), out level),
103 "Failed to get Audio level.");
110 /// The sampling rate of an audio stream in hertz.
112 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
113 public int AudioSampleRate
119 RecorderErrorFactory.ThrowIfError(Native.GetAudioSampleRate(_recorder.GetHandle(), out val),
120 "Failed to get audio sample rate.");
127 RecorderErrorFactory.ThrowIfError(Native.SetAudioSampleRate(_recorder.GetHandle(), value),
128 "Failed to set audio sample rate.");
133 /// The bitrate of an audio encoder in bits per second.
135 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
136 public int AudioBitRate
142 RecorderErrorFactory.ThrowIfError(Native.GetAudioEncoderBitrate(_recorder.GetHandle(), out val),
143 "Failed to get audio bitrate.");
150 RecorderErrorFactory.ThrowIfError(Native.SetAudioEncoderBitrate(_recorder.GetHandle(), value),
151 "Failed to set audio bitrate");
156 /// The bitrate of an video encoder in bits per second.
158 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
159 public int VideoBitRate
165 RecorderErrorFactory.ThrowIfError(Native.GetVideoEncoderBitrate(_recorder.GetHandle(), out val),
166 "Failed to get video bitrate.");
173 RecorderErrorFactory.ThrowIfError(Native.SetVideoEncoderBitrate(_recorder.GetHandle(), value),
174 "Failed to set video bitrate");
179 /// The audio codec for encoding an audio stream.
181 /// <value>A <see cref="RecorderAudioCodec"/> that specifies the type of audio codec.</value>
182 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
183 public RecorderAudioCodec AudioCodec
187 RecorderAudioCodec val = 0;
189 RecorderErrorFactory.ThrowIfError(Native.GetAudioEncoder(_recorder.GetHandle(), out val),
190 "Failed to get audio codec");
197 RecorderErrorFactory.ThrowIfError(Native.SetAudioEncoder(_recorder.GetHandle(), value),
198 "Failed to set audio codec");
203 /// The video codec for encoding video stream.
205 /// <value>A <see cref="RecorderVideoCodec"/> that specifies the type of video codec.</value>
206 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
207 public RecorderVideoCodec VideoCodec
211 RecorderVideoCodec val = 0;
213 RecorderErrorFactory.ThrowIfError(Native.GetVideoEncoder(_recorder.GetHandle(), out val),
214 "Failed to get video codec");
221 RecorderErrorFactory.ThrowIfError(Native.SetVideoEncoder(_recorder.GetHandle(), value),
222 "Failed to set video codec");
227 /// The file format for recording media stream.
229 /// <value>A <see cref="RecorderFileFormat"/> that specifies the file format.</value>
230 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
231 public RecorderFileFormat FileFormat
235 RecorderFileFormat val = 0;
237 RecorderErrorFactory.ThrowIfError(Native.GetFileFormat(_recorder.GetHandle(), out val),
238 "Failed to get file format.");
245 RecorderErrorFactory.ThrowIfError(Native.SetFileFormat(_recorder.GetHandle(), value),
246 "Failed to set file format");
251 /// The file path to record.
254 /// If the same file already exists in the file system, then old file
255 /// will be overwritten.
257 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
258 public string FilePath
263 RecorderError ret = Native.GetFileName(_recorder.GetHandle(), out val);
264 if (ret != RecorderError.None)
266 Log.Error(RecorderLog.Tag, "Failed to get filepath, " + (RecorderError)ret);
268 string result = Marshal.PtrToStringAnsi(val);
269 LibcSupport.Free(val);
275 RecorderErrorFactory.ThrowIfError(Native.SetFileName(_recorder.GetHandle(), value),
276 "Failed to set filepath");
281 /// The maximum size of a recording file in KB(kilobytes). If 0, means
282 /// unlimited recording size.
285 /// After reaching the limitation, the data which is being recorded will
286 /// be discarded and not written to the file.
287 /// The recorder state must be in 'Ready' or 'Created' state.
289 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
296 RecorderErrorFactory.ThrowIfError(Native.GetSizeLimit(_recorder.GetHandle(), out val),
297 "Failed to get size limit.");
304 RecorderErrorFactory.ThrowIfError(Native.SetSizeLimit(_recorder.GetHandle(), value),
305 "Failed to set size limit");
310 /// The time limit of a recording file in Seconds. If 0, means unlimited recording
314 /// After reaching the limitation, the data which is being recorded will
315 /// be discarded and not written to the file.
316 /// The recorder state must be in 'Ready' or 'Created' state.
318 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
325 RecorderErrorFactory.ThrowIfError(Native.GetTimeLimit(_recorder.GetHandle(), out val),
326 "Failed to get time limit.");
333 RecorderErrorFactory.ThrowIfError(Native.SetTimeLimit(_recorder.GetHandle(), value),
334 "Failed to set time limit.");
339 /// The mute state of a recorder.
341 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
346 return Native.GetMute(_recorder.GetHandle());
351 RecorderErrorFactory.ThrowIfError(Native.SetMute(_recorder.GetHandle(), value),
352 "Failed to set mute");
357 /// The video recording motion rate
360 /// The attribute is valid only in a video recorder.
361 /// If the rate is in range of 0-1, video is recorded in a slow motion mode.
362 /// If the rate is bigger than 1, video is recorded in a fast motion mode.
364 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
365 public double MotionRate
371 RecorderErrorFactory.ThrowIfError(Native.GetMotionRate(_recorder.GetHandle(), out val),
372 "Failed to get video motion rate.");
379 RecorderErrorFactory.ThrowIfError(Native.SetMotionRate(_recorder.GetHandle(), value),
380 "Failed to set video motion rate");
385 /// The orientation in a video metadata tag.
387 /// <value>A <see cref="RecorderOrientation"/> that specifies the type of orientation.</value>
388 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
389 public RecorderOrientation OrientationTag
393 RecorderOrientation val = 0;
395 RecorderErrorFactory.ThrowIfError(Native.GetOrientationTag(_recorder.GetHandle(), out val),
396 "Failed to get recorder orientation.");
403 RecorderErrorFactory.ThrowIfError(Native.SetOrientationTag(_recorder.GetHandle(), value),
404 "Failed to set recorder orientation");
409 /// Resolution of the video.
411 /// <exception cref="ArgumentException">In case of invalid parameters</exception>
412 /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
413 public Size VideoResolution
420 RecorderErrorFactory.ThrowIfError(Native.GetVideoResolution(_recorder.GetHandle(), out width, out height),
421 "Failed to get camera video resolution");
423 return new Size(width, height);
430 RecorderErrorFactory.ThrowIfError(Native.SetVideoResolution(_recorder.GetHandle(), res.Width, res.Height),
431 "Failed to set video resolution.");