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.
18 using Native = Interop.StreamRecorder;
20 namespace Tizen.Multimedia
23 /// Specifies the options associated with video recording.
25 /// <seealso cref="StreamRecorder"/>
26 /// <seealso cref="StreamRecorderOptions"/>
27 /// <seealso cref="StreamRecorderAudioOptions"/>
28 /// <since_tizen> 4 </since_tizen>
29 [Obsolete("Deprecated in API10; Will be removed in API12")]
30 public class StreamRecorderVideoOptions
32 private const int DefaultBitRate = 0;
35 /// Initialize a new instance of the <see cref="StreamRecorderVideoOptions"/> class with the specified
36 /// codec, resolution, source format, and frame rate.
38 /// <param name="codec">The <see cref="RecorderVideoCodec"/> for encoding video stream.</param>
39 /// <param name="resolution">The resolution of video recording.</param>
40 /// <param name="sourceFormat">The format of source stream.</param>
41 /// <param name="frameRate">The frame rate for encoding video stream.</param>
43 /// <see cref="BitRate"/> will be set as default.
45 /// <exception cref="ArgumentException">
46 /// <paramref name="codec"/> is not valid.<br/>
48 /// <paramref name="sourceFormat"/> is not valid.
50 /// <exception cref="ArgumentOutOfRangeException">
51 /// Width or height of <paramref name="resolution"/> is less than or equal to zero.<br/>
53 /// <paramref name="frameRate"/> is less than or equal to zero.
55 /// <since_tizen> 4 </since_tizen>
56 [Obsolete("Deprecated in API10; Will be removed in API12")]
57 public StreamRecorderVideoOptions(RecorderVideoCodec codec, Size resolution,
58 StreamRecorderVideoFormat sourceFormat, int frameRate) :
59 this(codec, resolution, sourceFormat, frameRate, DefaultBitRate)
64 /// Initialize a new instance of the <see cref="StreamRecorderVideoOptions"/> class with the specified
65 /// codec, resolution, source format, frame rate, and bit rate.
67 /// <param name="codec">The <see cref="RecorderVideoCodec"/> for encoding video stream.</param>
68 /// <param name="resolution">The resolution of video recording.</param>
69 /// <param name="sourceFormat">The format of source stream.</param>
70 /// <param name="frameRate">The frame rate for encoding video stream.</param>
71 /// <param name="bitRate">The bit rate for encoding video stream.</param>
72 /// <exception cref="ArgumentException">
73 /// <paramref name="codec"/> is not valid.<br/>
75 /// <paramref name="sourceFormat"/> is not valid.<br/>
77 /// <exception cref="ArgumentOutOfRangeException">
78 /// Width or height of <paramref name="resolution"/> is less than or equal to zero.<br/>
80 /// <paramref name="frameRate"/> is less than or equal to zero.<br/>
82 /// <paramref name="bitRate"/> is less than zero.
84 /// <since_tizen> 4 </since_tizen>
85 [Obsolete("Deprecated in API10; Will be removed in API12")]
86 public StreamRecorderVideoOptions(RecorderVideoCodec codec, Size resolution,
87 StreamRecorderVideoFormat sourceFormat, int frameRate, int bitRate)
90 Resolution = resolution;
91 SourceFormat = sourceFormat;
92 FrameRate = frameRate;
96 private RecorderVideoCodec _codec;
99 /// Gets or sets the video codec for encoding video stream.
101 /// <value>The codec for video stream recording.</value>
102 /// <exception cref="ArgumentException"><paramref name="value"/> is not valid.</exception>
103 /// <seealso cref="StreamRecorder.GetSupportedVideoCodecs"/>
104 /// <since_tizen> 4 </since_tizen>
105 [Obsolete("Deprecated in API10; Will be removed in API12")]
106 public RecorderVideoCodec Codec
111 ValidationUtil.ValidateEnum(typeof(RecorderVideoCodec), value, nameof(value));
117 private Size _resolution;
120 /// Gets or sets the resolution of the video recording.
122 /// <value>The output resolution for video stream recording.</value>
123 /// <exception cref="ArgumentOutOfRangeException">
124 /// Width or height of <paramref name="value"/> is less than or equal to zero.
126 /// <seealso cref="StreamRecorder.GetSupportedVideoResolutions"/>
127 /// <since_tizen> 4 </since_tizen>
128 [Obsolete("Deprecated in API10; Will be removed in API12")]
129 public Size Resolution
134 if (value.Width <= 0 || value.Height <= 0)
136 throw new ArgumentOutOfRangeException(nameof(value), value,
137 "Resolution can't be less than or equal to zero.");
144 private int _frameRate;
147 /// Gets or sets the frame rate for recording media stream.
149 /// <value>The frame rate value for video stream recording.</value>
150 /// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is less than or equal to zero.</exception>
151 /// <since_tizen> 4 </since_tizen>
152 [Obsolete("Deprecated in API10; Will be removed in API12")]
160 throw new ArgumentOutOfRangeException(nameof(value), value,
161 "Frame rate can't be less than or equal to zero.");
167 private StreamRecorderVideoFormat _sourceFormat;
170 /// Gets or sets the video source format for recording media stream.
172 /// <value>The source format of buffers for video stream recording.</value>
173 /// <exception cref="ArgumentException"><paramref name="value"/> is not valid.</exception>
174 /// <since_tizen> 4 </since_tizen>
175 [Obsolete("Deprecated in API10; Will be removed in API12")]
176 public StreamRecorderVideoFormat SourceFormat
178 get => _sourceFormat;
181 ValidationUtil.ValidateEnum(typeof(StreamRecorderVideoFormat), value, nameof(value));
183 _sourceFormat = value;
187 private int _bitRate;
190 /// The bit rate of the video encoder in bits per second.
192 /// <value>The bit rate value for video stream recording. The default is 0.</value>
193 /// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is less than zero.</exception>
194 /// <since_tizen> 4 </since_tizen>
195 [Obsolete("Deprecated in API10; Will be removed in API12")]
203 throw new ArgumentOutOfRangeException(nameof(value), value,
204 "Bit rate can't be less than or equal to zero.");
210 internal void Apply(StreamRecorder recorder)
212 recorder.ValidateVideoCodec(Codec);
214 Native.SetVideoEncoder(recorder.Handle, Codec.ToStreamRecorderEnum()).
215 ThrowIfError("Failed to set video codec.");
217 recorder.ValidateVideoResolution(Resolution);
219 Native.SetVideoResolution(recorder.Handle, Resolution.Width, Resolution.Height).
220 ThrowIfError("Failed to set video resolution.");
222 Native.SetVideoFrameRate(recorder.Handle, FrameRate).
223 ThrowIfError("Failed to set video frame rate.");
225 Native.SetVideoEncoderBitRate(recorder.Handle, BitRate).
226 ThrowIfError("Failed to set video bit rate.");
228 Native.SetVideoSourceFormat(recorder.Handle, SourceFormat).
229 ThrowIfError("Failed to set video source format.");