[StreamRecorder] Handle NotSupportedException as new feature added (#1483)
authorhancepark <alseou@gmail.com>
Wed, 25 Mar 2020 06:08:50 +0000 (15:08 +0900)
committerGitHub <noreply@github.com>
Wed, 25 Mar 2020 06:08:50 +0000 (15:08 +0900)
* Adds new feature exception

As new feature added, related API is modified.

Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
* Adds description

-Tizen.Multimedia.StreamRecorder.StreamRecorder()

Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
* Change feature information

Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
* Change feature applied API information

Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
* Remove exception which doesn't return NOT_SUPPORTED

Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
* Remove NOT_SUPPORTED exception on start api

Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
* !fixup 'Remove NOT_SUPPORTED exception on start api'

Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
Co-authored-by: Hyunsoo Park <hance.park@samsung.com>
src/Tizen.Multimedia.StreamRecorder/StreamRecorder/StreamRecorder.cs [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index fd62136..14e7fca
@@ -34,14 +34,27 @@ namespace Tizen.Multimedia
         private bool _audioEnabled;
         private bool _videoEnabled;
         private StreamRecorderVideoFormat _sourceFormat;
+        private const string Feature = "http://tizen.org/feature/multimedia.stream_recorder";
+
+        private static bool IsSupported()
+        {
+            return System.Information.TryGetValue(Feature, out bool isSupported) && isSupported;
+        }
 
         /// <summary>
         /// Initialize a new instance of the <see cref="StreamRecorder"/> class.
         /// </summary>
         /// <exception cref="NotSupportedException">The feature is not supported.</exception>
         /// <since_tizen> 3 </since_tizen>
+        /// <feature> http://tizen.org/feature/multimedia.stream_recorder </feature>
         public StreamRecorder()
         {
+            if (IsSupported() == false)
+            {
+                throw new NotSupportedException(
+                    $"The feature({Feature}) is not supported on the current device.");
+            }
+
             try
             {
                 Native.Create(out _handle).ThrowIfError("Failed to create stream recorder.");