예제 #1
0
        /// <summary>
        /// Returns supported file formats for a <see cref="RecorderVideoCodec"/>.
        /// </summary>
        /// <returns>An IEnumerable of <see cref="RecorderFileFormat"/> representing the supported file formats.</returns>
        /// <param name="videoCodec">The <see cref="RecorderVideoCodec"/>.</param>
        /// <exception cref="ArgumentException"><paramref name="videoCodec"/> is invalid.</exception>
        /// <since_tizen> 4 </since_tizen>
        public static IEnumerable <RecorderFileFormat> GetSupportedFileFormats(this RecorderVideoCodec videoCodec)
        {
            ValidationUtil.ValidateEnum(typeof(RecorderVideoCodec), videoCodec, nameof(videoCodec));

            switch (videoCodec)
            {
            case RecorderVideoCodec.H263:
                yield return(RecorderFileFormat.ThreeGp);

                break;

            case RecorderVideoCodec.H264:
            case RecorderVideoCodec.Mpeg4:
                yield return(RecorderFileFormat.ThreeGp);

                yield return(RecorderFileFormat.Mp4);

                yield return(RecorderFileFormat.M2ts);

                break;

            case RecorderVideoCodec.Theora:
                yield return(RecorderFileFormat.Ogg);

                break;
            }
        }
 internal void ValidateVideoCodec(RecorderVideoCodec codec)
 {
     if (_videoCodecs.Contains(codec) == false)
     {
         throw new NotSupportedException($"{codec.ToString()} is not supported.");
     }
 }
예제 #3
0
        /// <summary>
        /// Sets the video codec, audio codec, and the file format for recording.
        /// </summary>
        /// <param name="videoCodec">The codec for video encoding.</param>
        /// <param name="audioCodec">The codec for audio encoding.</param>
        /// <param name="fileFormat">The format of result file.</param>
        /// <exception cref="NotSupportedException">
        ///     <paramref name="videoCodec"/> is not supported.<br/>
        ///     -or-<br/>
        ///     <paramref name="audioCodec"/> is not supported.<br/>
        ///     -or-<br/>
        ///     <paramref name="fileFormat"/> is not supported with the specified video codec.<br/>
        ///     -or-<br/>
        ///     <paramref name="fileFormat"/> is not supported with the specified audio codec.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     <paramref name="videoCodec"/> is not valid.<br/>
        ///     -or-<br/>
        ///     <paramref name="audioCodec"/> is not valid.<br/>
        ///     -or-<br/>
        ///     <paramref name="fileFormat"/> is not valid.
        /// </exception>
        /// <seealso cref="Recorder.GetSupportedAudioCodecs"/>
        /// <seealso cref="VideoRecorder.GetSupportedVideoCodecs"/>
        /// <seealso cref="Recorder.GetSupportedFileFormats"/>
        /// <seealso cref="RecorderExtensions.GetSupportedFileFormats(RecorderAudioCodec)"/>
        /// <seealso cref="RecorderExtensions.GetSupportedFileFormats(RecorderVideoCodec)"/>
        /// <seealso cref="SetFormatAndCodec(RecorderVideoCodec, RecorderFileFormat)"/>
        /// <seealso cref="Recorder.Start(string)"/>
        /// <since_tizen> 4 </since_tizen>
        public void SetFormatAndCodec(RecorderVideoCodec videoCodec, RecorderAudioCodec audioCodec, RecorderFileFormat fileFormat)
        {
            ThrowIfCodecAndFormatNotValid(videoCodec, audioCodec, fileFormat);

            VideoCodec = videoCodec;
            AudioCodec = audioCodec;
            FileFormat = fileFormat;
        }
예제 #4
0
        internal static void ThrowIfFormatNotSupported(this RecorderVideoCodec videoCodec, RecorderFileFormat fileFormat)
        {
            ValidationUtil.ValidateEnum(typeof(RecorderFileFormat), fileFormat, nameof(fileFormat));

            if (videoCodec.GetSupportedFileFormats().Contains(fileFormat) == false)
            {
                throw new NotSupportedException($"{videoCodec} does not support {fileFormat}.");
            }
        }
예제 #5
0
 /// <summary>
 /// Initialize a new instance of the <see cref="StreamRecorderVideoOptions"/> class with the specified
 /// codec, resolution, source format, frame rate, and bit rate.
 /// </summary>
 /// <param name="codec">The <see cref="RecorderVideoCodec"/> for encoding video stream.</param>
 /// <param name="resolution">The resolution of video recording.</param>
 /// <param name="sourceFormat">The format of source stream.</param>
 /// <param name="frameRate">The frame rate for encoding video stream.</param>
 /// <param name="bitRate">The bit rate for encoding video stream.</param>
 /// <exception cref="ArgumentException">
 ///     <paramref name="codec"/> is not valid.<br/>
 ///     -or-<br/>
 ///     <paramref name="sourceFormat"/> is not valid.<br/>
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 ///     Width or height of <paramref name="resolution"/> is less than or equal to zero.<br/>
 ///     -or-<br/>
 ///     <paramref name="frameRate"/> is less than or equal to zero.<br/>
 ///     -or-<br/>
 ///     <paramref name="bitRate"/> is less than zero.
 /// </exception>
 /// <since_tizen> 4 </since_tizen>
 public StreamRecorderVideoOptions(RecorderVideoCodec codec, Size resolution,
                                   StreamRecorderVideoFormat sourceFormat, int frameRate, int bitRate)
 {
     Codec        = codec;
     Resolution   = resolution;
     SourceFormat = sourceFormat;
     FrameRate    = frameRate;
     BitRate      = bitRate;
 }
예제 #6
0
        private static void ThrowIfCodecAndFormatNotValid(RecorderVideoCodec videoCodec,
                                                          RecorderAudioCodec audioCodec, RecorderFileFormat fileFormat)
        {
            videoCodec.ThrowIfFormatNotSupported(fileFormat);

            if (audioCodec != RecorderAudioCodec.None)
            {
                audioCodec.ThrowIfFormatNotSupported(fileFormat);
            }
        }
예제 #7
0
        internal static StreamRecorderVideoCodec ToStreamRecorderEnum(this RecorderVideoCodec value)
        {
            switch (value)
            {
            case RecorderVideoCodec.H263:
                return(StreamRecorderVideoCodec.H263);

            case RecorderVideoCodec.Mpeg4:
                return(StreamRecorderVideoCodec.Mpeg4);
            }

            throw new NotSupportedException($"{value.ToString()} is not supported.");
        }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VideoRecorder"/> class with the specified
 /// camera, video codec, and file format.
 /// </summary>
 /// <remarks>
 /// If the state of <see cref="Camera"/> is <see cref="CameraState.Created"/>,
 /// the <see cref="CameraSettings.PreviewPixelFormat"/> will be changed to the recommended format for recording.<br/>
 /// <br/>
 /// The initial state of the Recorder will be <see cref="RecorderState.Ready"/>
 /// if the state of <see cref="Camera"/> is <see cref="CameraState.Preview"/> or <see cref="CameraState.Captured"/>.
 /// </remarks>
 /// <param name="camera">The camera object.</param>
 /// <param name="videoCodec">The codec for video encoding.</param>
 /// <param name="fileFormat">The format of result file.</param>
 /// <feature>http://tizen.org/feature/camera</feature>
 /// <exception cref="InvalidOperationException">An internal error occurred.</exception>
 /// <exception cref="NotSupportedException">
 ///     A required feature is not supported.<br/>
 ///     -or-<br/>
 ///     <paramref name="videoCodec"/> is not supported.<br/>
 ///     -or-<br/>
 ///     <paramref name="fileFormat"/> is not supported with the specified video codec.
 /// </exception>
 /// <exception cref="ArgumentException">
 ///     <paramref name="videoCodec"/> is not valid.<br/>
 ///     -or-<br/>
 ///     <paramref name="fileFormat"/> is not valid.<br/>
 ///     -or-<br/>
 ///     <paramref name="camera"/> is being used by another object.
 /// </exception>
 /// <exception cref="ObjectDisposedException"><paramref name="camera"/> has been disposed of.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="camera"/> is null.</exception>
 /// <seealso cref="GetSupportedVideoCodecs"/>
 /// <seealso cref="Recorder.GetSupportedFileFormats"/>
 /// <seealso cref="RecorderExtensions.GetSupportedFileFormats(RecorderVideoCodec)"/>
 /// <seealso cref="SetFormatAndCodec(RecorderVideoCodec, RecorderFileFormat)"/>
 /// <seealso cref="SetFormatAndCodec(RecorderVideoCodec, RecorderAudioCodec, RecorderFileFormat)"/>
 /// <since_tizen> 4 </since_tizen>
 public VideoRecorder(Camera camera, RecorderVideoCodec videoCodec, RecorderFileFormat fileFormat) :
     this(camera, videoCodec, RecorderAudioCodec.None, fileFormat)
 {
 }
예제 #9
0
 /// <summary>
 /// Sets the video codec and the file format for recording. Audio will not be recorded.
 /// </summary>
 /// <param name="videoCodec">The codec for video encoding.</param>
 /// <param name="fileFormat">The format of result file.</param>
 /// <exception cref="NotSupportedException">
 ///     <paramref name="videoCodec"/> is not supported.<br/>
 ///     -or-<br/>
 ///     <paramref name="fileFormat"/> is not supported with the specified video codec.
 /// </exception>
 /// <exception cref="ArgumentException">
 ///     <paramref name="videoCodec"/> is not valid.<br/>
 ///     -or-<br/>
 ///     <paramref name="fileFormat"/> is not valid.
 /// </exception>
 /// <seealso cref="GetSupportedVideoCodecs"/>
 /// <seealso cref="Recorder.GetSupportedFileFormats"/>
 /// <seealso cref="RecorderExtensions.GetSupportedFileFormats(RecorderVideoCodec)"/>
 /// <seealso cref="SetFormatAndCodec(RecorderVideoCodec, RecorderAudioCodec, RecorderFileFormat)"/>
 /// <seealso cref="Recorder.Start(string)"/>
 /// <since_tizen> 4 </since_tizen>
 public void SetFormatAndCodec(RecorderVideoCodec videoCodec, RecorderFileFormat fileFormat)
 {
     SetFormatAndCodec(videoCodec, RecorderAudioCodec.None, fileFormat);
 }
예제 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VideoRecorder"/> class with the specified
 /// camera, video codec, audio codec, and file format.
 /// </summary>
 /// <remarks>
 /// If the state of <see cref="Camera"/> is <see cref="CameraState.Created"/>,
 /// the <see cref="CameraSettings.PreviewPixelFormat"/> will be changed to the recommended format for recording.<br/>
 /// <br/>
 /// The initial state of the Recorder will be <see cref="RecorderState.Ready"/>
 /// if the state of <see cref="Camera"/> is <see cref="CameraState.Preview"/> or <see cref="CameraState.Captured"/>.
 /// </remarks>
 /// <param name="camera">The camera object.</param>
 /// <param name="videoCodec">The codec for video encoding.</param>
 /// <param name="audioCodec">The codec for audio encoding.</param>
 /// <param name="fileFormat">The format of result file.</param>
 /// <feature>http://tizen.org/feature/camera</feature>
 /// <exception cref="InvalidOperationException">An internal error occurred.</exception>
 /// <exception cref="NotSupportedException">
 ///     A required feature is not supported.<br/>
 ///     -or-<br/>
 ///     <paramref name="videoCodec"/> is not supported.<br/>
 ///     -or-<br/>
 ///     <paramref name="audioCodec"/> is not supported.<br/>
 ///     -or-<br/>
 ///     <paramref name="fileFormat"/> is not supported with the specified video codec.<br/>
 ///     -or-<br/>
 ///     <paramref name="fileFormat"/> is not supported with the specified audio codec.
 /// </exception>
 /// <exception cref="ArgumentException">
 ///     <paramref name="videoCodec"/> is not valid.<br/>
 ///     -or-<br/>
 ///     <paramref name="audioCodec"/> is not valid.<br/>
 ///     -or-<br/>
 ///     <paramref name="fileFormat"/> is not valid.
 /// </exception>
 /// <exception cref="ObjectDisposedException"><paramref name="camera"/> has been disposed of.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="camera"/> is null.</exception>
 /// <seealso cref="Recorder.GetSupportedAudioCodecs"/>
 /// <seealso cref="GetSupportedVideoCodecs"/>
 /// <seealso cref="Recorder.GetSupportedFileFormats"/>
 /// <seealso cref="RecorderExtensions.GetSupportedFileFormats(RecorderAudioCodec)"/>
 /// <seealso cref="RecorderExtensions.GetSupportedFileFormats(RecorderVideoCodec)"/>
 /// <seealso cref="SetFormatAndCodec(RecorderVideoCodec, RecorderFileFormat)"/>
 /// <seealso cref="SetFormatAndCodec(RecorderVideoCodec, RecorderAudioCodec, RecorderFileFormat)"/>
 /// <since_tizen> 4 </since_tizen>
 public VideoRecorder(Camera camera, RecorderVideoCodec videoCodec,
                      RecorderAudioCodec audioCodec, RecorderFileFormat fileFormat) : base(CreateHandle(camera))
 {
     SetFormatAndCodec(videoCodec, RecorderAudioCodec.None, fileFormat);
 }
예제 #11
0
 /// <summary>
 /// Initialize a new instance of the <see cref="StreamRecorderVideoOptions"/> class with the specified
 /// codec, resolution, source format, and frame rate.
 /// </summary>
 /// <param name="codec">The <see cref="RecorderVideoCodec"/> for encoding video stream.</param>
 /// <param name="resolution">The resolution of video recording.</param>
 /// <param name="sourceFormat">The format of source stream.</param>
 /// <param name="frameRate">The frame rate for encoding video stream.</param>
 /// <remarks>
 /// <see cref="BitRate"/> will be set as default.
 /// </remarks>
 /// <exception cref="ArgumentException">
 ///     <paramref name="codec"/> is not valid.<br/>
 ///     -or-<br/>
 ///     <paramref name="sourceFormat"/> is not valid.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 ///     Width or height of <paramref name="resolution"/> is less than or equal to zero.<br/>
 ///     -or-<br/>
 ///     <paramref name="frameRate"/> is less than or equal to zero.
 /// </exception>
 /// <since_tizen> 4 </since_tizen>
 public StreamRecorderVideoOptions(RecorderVideoCodec codec, Size resolution,
                                   StreamRecorderVideoFormat sourceFormat, int frameRate) :
     this(codec, resolution, sourceFormat, frameRate, DefaultBitRate)
 {
 }
예제 #12
0
 internal static extern RecorderErrorCode SetVideoEncoder(RecorderHandle handle, RecorderVideoCodec codec);