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 /// The attribute is applied only in Created state.
42 /// For mono recording, set channel to 1.
43 /// For stereo recording, set channel to 2.
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 public RecorderAudioDevice AudioDevice
71 RecorderAudioDevice val = 0;
73 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetAudioDevice(_recorder.GetHandle(), out val),
74 "Failed to get audio device.");
81 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetAudioDevice(_recorder.GetHandle(), value),
82 "Failed to set audio device.");
87 /// Get the peak audio input level in dB
90 /// 0dB indicates maximum input level, -300dB indicates minimum input level.
92 public double AudioLevel
98 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetAudioLevel(_recorder.GetHandle(), out level),
99 "Failed to get Audio level.");
106 /// The sampling rate of an audio stream in hertz.
108 public int AudioSampleRate
114 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetAudioSampleRate(_recorder.GetHandle(), out val),
115 "Failed to get audio sample rate.");
122 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetAudioSampleRate(_recorder.GetHandle(), value),
123 "Failed to set audio sample rate.");
128 /// The bitrate of an audio encoder in bits per second.
130 public int AudioBitRate
136 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetAudioEncoderBitrate(_recorder.GetHandle(), out val),
137 "Failed to get audio bitrate.");
144 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetAudioEncoderBitrate(_recorder.GetHandle(), value),
145 "Failed to set audio bitrate");
150 /// The bitrate of an video encoder in bits per second.
152 public int VideoBitRate
158 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetVideoEncoderBitrate(_recorder.GetHandle(), out val),
159 "Failed to get video bitrate.");
166 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetVideoEncoderBitrate(_recorder.GetHandle(), value),
167 "Failed to set video bitrate");
172 /// The audio codec for encoding an audio stream.
174 public RecorderAudioCodec AudioCodec
178 RecorderAudioCodec val = 0;
180 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetAudioEncoder(_recorder.GetHandle(), out val),
181 "Failed to get audio codec");
188 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetAudioEncoder(_recorder.GetHandle(), value),
189 "Failed to set audio codec");
194 /// The video codec for encoding video stream.
196 public RecorderVideoCodec VideoCodec
200 RecorderVideoCodec val = 0;
202 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetVideoEncoder(_recorder.GetHandle(), out val),
203 "Failed to get video codec");
210 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetVideoEncoder(_recorder.GetHandle(), value),
211 "Failed to set video codec");
216 /// The file format for recording media stream.
218 public RecorderFileFormat FileFormat
222 RecorderFileFormat val = 0;
224 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetFileFormat(_recorder.GetHandle(), out val),
225 "Failed to get file format.");
232 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetFileFormat(_recorder.GetHandle(), value),
233 "Failed to set file format");
238 /// The file path to record.
241 /// If the same file already exists in the file system, then old file
242 /// will be overwritten.
244 public string FilePath
249 int ret = Interop.RecorderSettings.GetFileName(_recorder.GetHandle(), out val);
250 if ((RecorderError)ret != RecorderError.None)
252 Log.Error(RecorderLog.Tag, "Failed to get filepath, " + (RecorderError)ret);
254 string result = Marshal.PtrToStringAnsi(val);
255 Interop.Libc.Free(val);
261 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetFileName(_recorder.GetHandle(), value),
262 "Failed to set filepath");
267 /// The maximum size of a recording file in KB(kilobytes). If 0, means
268 /// unlimited recording size.
271 /// After reaching the limitation, the data which is being recorded will
272 /// be discarded and not written to the file.
273 /// The recorder state must be in 'Ready' or 'Created' state.
282 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetSizeLimit(_recorder.GetHandle(), out val),
283 "Failed to get size limit.");
290 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetSizeLimit(_recorder.GetHandle(), value),
291 "Failed to set size limit");
296 /// The time limit of a recording file in Seconds. If 0, means unlimited recording
300 /// After reaching the limitation, the data which is being recorded will
301 /// be discarded and not written to the file.
302 /// The recorder state must be in 'Ready' or 'Created' state.
310 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetTimeLimit(_recorder.GetHandle(), out val),
311 "Failed to get time limit.");
318 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetTimeLimit(_recorder.GetHandle(), value),
319 "Failed to set time limit.");
324 /// The mute state of a recorder.
330 bool ret = Interop.RecorderSettings.GetMute(_recorder.GetHandle());
332 RecorderErrorFactory.ThrowIfError(ErrorFacts.GetLastResult(),
333 "Failed to get the mute state of recorder");
340 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetMute(_recorder.GetHandle(), value),
341 "Failed to set mute");
346 /// The video recording motion rate
349 /// The attribute is valid only in a video recorder.
350 /// If the rate is in range of 0-1, video is recorded in a slow motion mode.
351 /// If the rate is bigger than 1, video is recorded in a fast motion mode.
353 public double MotionRate
359 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetMotionRate(_recorder.GetHandle(), out val),
360 "Failed to get video motion rate.");
367 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetMotionRate(_recorder.GetHandle(), value),
368 "Failed to set video motion rate");
373 /// The orientation in a video metadata tag.
375 public RecorderOrientation OrientationTag
379 RecorderOrientation val = 0;
381 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.GetOrientationTag(_recorder.GetHandle(), out val),
382 "Failed to get recorder orientation.");
389 RecorderErrorFactory.ThrowIfError(Interop.RecorderSettings.SetOrientationTag(_recorder.GetHandle(), value),
390 "Failed to set recorder orientation");
395 /// Resolution of the video.
398 /// http://tizen.org/privilege/recorder
400 /// <exception cref="ArgumentException">In case of invalid parameters</exception>
401 public Size VideoResolution
408 CameraErrorFactory.ThrowIfError(Interop.RecorderSettings.GetVideoResolution(_recorder.GetHandle(), out width, out height),
409 "Failed to get camera video resolution");
411 return new Size(width, height);
418 CameraErrorFactory.ThrowIfError(Interop.RecorderSettings.SetVideoResolution(_recorder.GetHandle(), res.Width, res.Height),
419 "Failed to set video resolution.");