From 6a8d36d62d29c523bbd1e6eb92b6fd9bfadbef83 Mon Sep 17 00:00:00 2001 From: hsgwon Date: Tue, 16 Jan 2018 17:40:52 +0900 Subject: [PATCH] [Recorder] Change recorder feature (#32) --- .../Recorder/AudioRecorder.cs | 7 ++++++- .../Recorder/Recorder.Capabilities.cs | 9 ++++++++ .../Recorder/RecorderFeatures.cs | 24 ++++++++++++++++++++++ .../Recorder/VideoRecorder.Capabilities.cs | 9 ++++++-- .../Recorder/VideoRecorder.cs | 9 ++++++-- 5 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 src/Tizen.Multimedia.Recorder/Recorder/RecorderFeatures.cs mode change 100755 => 100644 src/Tizen.Multimedia.Recorder/Recorder/VideoRecorder.cs diff --git a/src/Tizen.Multimedia.Recorder/Recorder/AudioRecorder.cs b/src/Tizen.Multimedia.Recorder/Recorder/AudioRecorder.cs index d265440..41d154a 100644 --- a/src/Tizen.Multimedia.Recorder/Recorder/AudioRecorder.cs +++ b/src/Tizen.Multimedia.Recorder/Recorder/AudioRecorder.cs @@ -28,6 +28,11 @@ namespace Tizen.Multimedia { private static NativeHandle CreateHandle() { + if (!Features.IsSupported(RecorderFeatures.AudioRecorder)) + { + throw new NotSupportedException("Audio Recorder is not supported."); + } + Native.Create(out var handle).ThrowIfError("Failed to create Audio recorder"); return handle; @@ -49,7 +54,7 @@ namespace Tizen.Multimedia /// /// The codec for audio encoding. /// The format of result file. - /// http://tizen.org/feature/microphone + /// http://tizen.org/feature/media.audio_recording /// An internal error occurred. /// /// A required feature is not supported.
diff --git a/src/Tizen.Multimedia.Recorder/Recorder/Recorder.Capabilities.cs b/src/Tizen.Multimedia.Recorder/Recorder/Recorder.Capabilities.cs index acd39c3..629c3c7 100644 --- a/src/Tizen.Multimedia.Recorder/Recorder/Recorder.Capabilities.cs +++ b/src/Tizen.Multimedia.Recorder/Recorder/Recorder.Capabilities.cs @@ -69,6 +69,11 @@ namespace Tizen.Multimedia private static Capabilities LoadCapabilities() { + if (!Features.IsSupported(RecorderFeatures.AudioRecorder)) + { + throw new NotSupportedException("Audio Recorder is not supported."); + } + var ret = Native.Create(out var handle); if (ret == RecorderErrorCode.NotSupported) @@ -87,12 +92,16 @@ namespace Tizen.Multimedia /// /// Gets the file formats that the current device supports. /// + /// http://tizen.org/feature/media.audio_recording + /// A required feature is not supported. /// 4 public static IEnumerable GetSupportedFileFormats() => Capabilities.Value.SupportedFileFormats; /// /// Gets the audio encoders that the current device supports. /// + /// http://tizen.org/feature/media.audio_recording + /// A required feature is not supported. /// 4 public static IEnumerable GetSupportedAudioCodecs() => Capabilities.Value.SupportedAudioCodecs; diff --git a/src/Tizen.Multimedia.Recorder/Recorder/RecorderFeatures.cs b/src/Tizen.Multimedia.Recorder/Recorder/RecorderFeatures.cs new file mode 100644 index 0000000..4bb25cd --- /dev/null +++ b/src/Tizen.Multimedia.Recorder/Recorder/RecorderFeatures.cs @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2018 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. + */ + +namespace Tizen.Multimedia +{ + internal static class RecorderFeatures + { + internal const string AudioRecorder = "http://tizen.org/feature/media.audio_recording"; + internal const string VideoRecorder = "http://tizen.org/feature/media.video_recording"; + } +} diff --git a/src/Tizen.Multimedia.Recorder/Recorder/VideoRecorder.Capabilities.cs b/src/Tizen.Multimedia.Recorder/Recorder/VideoRecorder.Capabilities.cs index 8932237..0194cf5 100644 --- a/src/Tizen.Multimedia.Recorder/Recorder/VideoRecorder.Capabilities.cs +++ b/src/Tizen.Multimedia.Recorder/Recorder/VideoRecorder.Capabilities.cs @@ -47,6 +47,11 @@ namespace Tizen.Multimedia private static IEnumerable LoadVideoResolutions(CameraDevice device) { + if (!Features.IsSupported(RecorderFeatures.VideoRecorder)) + { + throw new NotSupportedException("Video Recorder is not supported."); + } + using (var camera = new Camera(device)) { Native.CreateVideo(camera.Handle, out var handle).ThrowIfError("Failed to get the resolutions"); @@ -61,7 +66,7 @@ namespace Tizen.Multimedia /// /// Gets the video resolutions that the current device supports. /// - /// http://tizen.org/feature/camera + /// http://tizen.org/feature/media.video_recording /// The camera device to retrieve the supported resolutions. /// A required feature is not supported. /// is invalid. @@ -88,7 +93,7 @@ namespace Tizen.Multimedia /// /// Gets the video encoders that the current device supports. /// - /// http://tizen.org/feature/camera + /// http://tizen.org/feature/media.video_recording /// A required feature is not supported. /// 4 public static IEnumerable GetSupportedVideoCodecs() diff --git a/src/Tizen.Multimedia.Recorder/Recorder/VideoRecorder.cs b/src/Tizen.Multimedia.Recorder/Recorder/VideoRecorder.cs old mode 100755 new mode 100644 index ffe646b..bce649d --- a/src/Tizen.Multimedia.Recorder/Recorder/VideoRecorder.cs +++ b/src/Tizen.Multimedia.Recorder/Recorder/VideoRecorder.cs @@ -33,6 +33,11 @@ namespace Tizen.Multimedia throw new ArgumentNullException(nameof(camera)); } + if (!Features.IsSupported(RecorderFeatures.VideoRecorder)) + { + throw new NotSupportedException("Video Recorder is not supported."); + } + Native.CreateVideo(camera.Handle, out var handle). ThrowIfError("Failed to create video recorder."); @@ -64,7 +69,7 @@ namespace Tizen.Multimedia /// The camera object. /// The codec for video encoding. /// The format of result file. - /// http://tizen.org/feature/camera + /// http://tizen.org/feature/media.video_recording /// An internal error occurred. /// /// A required feature is not supported.
@@ -108,7 +113,7 @@ namespace Tizen.Multimedia /// The codec for video encoding. /// The codec for audio encoding. /// The format of result file. - /// http://tizen.org/feature/camera + /// http://tizen.org/feature/media.video_recording /// An internal error occurred. /// /// A required feature is not supported.
-- 2.7.4