/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using Native = Interop.StreamRecorder;
namespace Tizen.Multimedia
{
///
/// Specifies the options associated with video recording.
///
///
///
///
/// 4
[Obsolete("Deprecated in API10; Will be removed in API12")]
public class StreamRecorderVideoOptions
{
private const int DefaultBitRate = 0;
///
/// Initialize a new instance of the class with the specified
/// codec, resolution, source format, and frame rate.
///
/// The for encoding video stream.
/// The resolution of video recording.
/// The format of source stream.
/// The frame rate for encoding video stream.
///
/// will be set as default.
///
///
/// is not valid.
/// -or-
/// is not valid.
///
///
/// Width or height of is less than or equal to zero.
/// -or-
/// is less than or equal to zero.
///
/// 4
[Obsolete("Deprecated in API10; Will be removed in API12")]
public StreamRecorderVideoOptions(RecorderVideoCodec codec, Size resolution,
StreamRecorderVideoFormat sourceFormat, int frameRate) :
this(codec, resolution, sourceFormat, frameRate, DefaultBitRate)
{
}
///
/// Initialize a new instance of the class with the specified
/// codec, resolution, source format, frame rate, and bit rate.
///
/// The for encoding video stream.
/// The resolution of video recording.
/// The format of source stream.
/// The frame rate for encoding video stream.
/// The bit rate for encoding video stream.
///
/// is not valid.
/// -or-
/// is not valid.
///
///
/// Width or height of is less than or equal to zero.
/// -or-
/// is less than or equal to zero.
/// -or-
/// is less than zero.
///
/// 4
[Obsolete("Deprecated in API10; Will be removed in API12")]
public StreamRecorderVideoOptions(RecorderVideoCodec codec, Size resolution,
StreamRecorderVideoFormat sourceFormat, int frameRate, int bitRate)
{
Codec = codec;
Resolution = resolution;
SourceFormat = sourceFormat;
FrameRate = frameRate;
BitRate = bitRate;
}
private RecorderVideoCodec _codec;
///
/// Gets or sets the video codec for encoding video stream.
///
/// The codec for video stream recording.
/// is not valid.
///
/// 4
[Obsolete("Deprecated in API10; Will be removed in API12")]
public RecorderVideoCodec Codec
{
get => _codec;
set
{
ValidationUtil.ValidateEnum(typeof(RecorderVideoCodec), value, nameof(value));
_codec = value;
}
}
private Size _resolution;
///
/// Gets or sets the resolution of the video recording.
///
/// The output resolution for video stream recording.
///
/// Width or height of is less than or equal to zero.
///
///
/// 4
[Obsolete("Deprecated in API10; Will be removed in API12")]
public Size Resolution
{
get => _resolution;
set
{
if (value.Width <= 0 || value.Height <= 0)
{
throw new ArgumentOutOfRangeException(nameof(value), value,
"Resolution can't be less than or equal to zero.");
}
_resolution = value;
}
}
private int _frameRate;
///
/// Gets or sets the frame rate for recording media stream.
///
/// The frame rate value for video stream recording.
/// is less than or equal to zero.
/// 4
[Obsolete("Deprecated in API10; Will be removed in API12")]
public int FrameRate
{
get => _frameRate;
set
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException(nameof(value), value,
"Frame rate can't be less than or equal to zero.");
}
_frameRate = value;
}
}
private StreamRecorderVideoFormat _sourceFormat;
///
/// Gets or sets the video source format for recording media stream.
///
/// The source format of buffers for video stream recording.
/// is not valid.
/// 4
[Obsolete("Deprecated in API10; Will be removed in API12")]
public StreamRecorderVideoFormat SourceFormat
{
get => _sourceFormat;
set
{
ValidationUtil.ValidateEnum(typeof(StreamRecorderVideoFormat), value, nameof(value));
_sourceFormat = value;
}
}
private int _bitRate;
///
/// The bit rate of the video encoder in bits per second.
///
/// The bit rate value for video stream recording. The default is 0.
/// is less than zero.
/// 4
[Obsolete("Deprecated in API10; Will be removed in API12")]
public int BitRate
{
get => _bitRate;
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException(nameof(value), value,
"Bit rate can't be less than or equal to zero.");
}
_bitRate = value;
}
}
internal void Apply(StreamRecorder recorder)
{
recorder.ValidateVideoCodec(Codec);
Native.SetVideoEncoder(recorder.Handle, Codec.ToStreamRecorderEnum()).
ThrowIfError("Failed to set video codec.");
recorder.ValidateVideoResolution(Resolution);
Native.SetVideoResolution(recorder.Handle, Resolution.Width, Resolution.Height).
ThrowIfError("Failed to set video resolution.");
Native.SetVideoFrameRate(recorder.Handle, FrameRate).
ThrowIfError("Failed to set video frame rate.");
Native.SetVideoEncoderBitRate(recorder.Handle, BitRate).
ThrowIfError("Failed to set video bit rate.");
Native.SetVideoSourceFormat(recorder.Handle, SourceFormat).
ThrowIfError("Failed to set video source format.");
}
}
}