[Player]Added raw_video and custom_audio_effect features.
authorcoderhyme <jhyo.kim@samsung.com>
Wed, 10 May 2017 11:33:39 +0000 (20:33 +0900)
committercoderhyme <jhyo.kim@samsung.com>
Wed, 10 May 2017 11:33:39 +0000 (20:33 +0900)
- Related apis
raw_video : Player.VideoFrameDecoded, Display.Display(MediaView), Player.CaptureVideoAsync()
custom_audio_effect : Player.AudioEffect

Change-Id: Ic89ceb3be1ccafe8b5078af3cafc38e991f650af
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
src/Tizen.Multimedia/Common/Display.cs
src/Tizen.Multimedia/Common/Features.cs [new file with mode: 0644]
src/Tizen.Multimedia/Common/ValdiationUtil.cs
src/Tizen.Multimedia/Player/Player.cs
src/Tizen.Multimedia/Tizen.Multimedia.csproj

index cb86dbe..e093386 100644 (file)
@@ -68,8 +68,11 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Initialize a new instance of the <see cref="Display"/> class with a <see cref="MediaView"/> class.
         /// </summary>
+        /// <feature>http://tizen.org/feature/multimedia.raw_video</feature>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
         public Display(MediaView mediaView) : this(DisplayType.Surface, mediaView)
         {
+            ValidationUtil.ValidateFeatureSupported(Features.RawVideo);
         }
 
         /// <summary>
diff --git a/src/Tizen.Multimedia/Common/Features.cs b/src/Tizen.Multimedia/Common/Features.cs
new file mode 100644 (file)
index 0000000..ebb0c82
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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 Tizen.System;
+
+namespace Tizen.Multimedia
+{
+    internal static class Features
+    {
+        internal static string AudioEffect = "http://tizen.org/feature/multimedia.custom_audio_effect";
+        internal static string RawVideo = "http://tizen.org/feature/multimedia.raw_video";
+
+        internal static bool IsSupported(string featureKey)
+        {
+            bool supported = false;
+            SystemInfo.TryGetValue(featureKey, out supported);
+            return supported;
+        }
+
+    }
+}
index f63913b..d4d6383 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 using System;
+using Tizen.System;
 
 namespace Tizen.Multimedia
 {
@@ -27,6 +28,7 @@ namespace Tizen.Multimedia
                 throw new ArgumentException($"Invalid { enumType.Name } value : { value }");
             }
         }
+
         internal static void ValidateEnum(Type enumType, object value, string paramName)
         {
             if (!Enum.IsDefined(enumType, value))
@@ -34,5 +36,13 @@ namespace Tizen.Multimedia
                 throw new ArgumentException($"Invalid { enumType.Name } value : { value }", paramName);
             }
         }
+
+        internal static void ValidateFeatureSupported(string featureKey)
+        {
+            if (Features.IsSupported(featureKey) == false)
+            {
+                throw new NotSupportedException($"The feature({featureKey}) is not supported.");
+            }
+        }
     }
 }
index baad7b9..c226937 100755 (executable)
@@ -62,17 +62,6 @@ namespace Tizen.Multimedia
         private Interop.Player.PlaybackErrorCallback _playbackErrorCallback;
 
         /// <summary>
-        /// Occurs when a video frame is decoded
-        /// </summary>
-        /// <remarks>
-        ///     <para>The event handler will be executed on an internal thread.</para>
-        ///     <para>The <see cref="VideoFrameDecodedEventArgs.Packet"/> in event args should be disposed after use.</para>
-        /// </remarks>
-        /// <see cref="VideoFrameDecodedEventArgs.Packet"/>
-        public event EventHandler<VideoFrameDecodedEventArgs> VideoFrameDecoded;
-        private Interop.Player.VideoFrameDecodedCallback _videoFrameDecodedCallback;
-
-        /// <summary>
         /// Occurs when the video stream changed.
         /// </summary>
         /// <remarks>The event handler will be executed on an internal thread.</remarks>
@@ -117,10 +106,15 @@ namespace Tizen.Multimedia
 
             RetrieveProperties();
 
-            AudioEffect = new AudioEffect(this);
-            DisplaySettings = new PlayerDisplaySettings(this);
+            if (Features.IsSupported(Features.AudioEffect))
+            {
+                _audioEffect = new AudioEffect(this);
+            }
 
-            RegisterVideoFrameDecodedCallback();
+            if (Features.IsSupported(Features.RawVideo))
+            {
+                RegisterVideoFrameDecodedCallback();
+            }
         }
 
         private void RetrieveProperties()
@@ -490,10 +484,25 @@ namespace Tizen.Multimedia
             }
         }
 
+        private readonly AudioEffect _audioEffect;
+
         /// <summary>
-        /// Gets audio effect.
+        /// Gets the audio effect.
         /// </summary>
-        public AudioEffect AudioEffect { get; }
+        /// <feature>http://tizen.org/feature/multimedia.custom_audio_effect</feature>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+        public AudioEffect AudioEffect
+        {
+            get
+            {
+                if (_audioEffect == null)
+                {
+                    throw new NotSupportedException($"The feature({Features.AudioEffect}) is not supported.");
+                }
+
+                return _audioEffect;
+            }
+        }
 
         #endregion
 
@@ -927,12 +936,17 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Captures a video frame asynchronously.
         /// </summary>
+        /// <feature>http://tizen.org/feature/multimedia.raw_video</feature>
         /// <remarks>The player must be in the <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
         public async Task<CapturedFrame> CaptureVideoAsync()
         {
             Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
+
+            ValidationUtil.ValidateFeatureSupported(Features.RawVideo);
+
             ValidatePlayerState(PlayerState.Playing, PlayerState.Paused);
 
             TaskCompletionSource<CapturedFrame> t = new TaskCompletionSource<CapturedFrame>();
@@ -1156,11 +1170,43 @@ namespace Tizen.Multimedia
                 ThrowIfFailed("Failed to set PlaybackError");
         }
 
+        #region VideoFrameDecoded event
+
+        private EventHandler<VideoFrameDecodedEventArgs> _videoFrameDecoded;
+
+        private Interop.Player.VideoFrameDecodedCallback _videoFrameDecodedCallback;
+
+        /// <summary>
+        /// Occurs when a video frame is decoded
+        /// </summary>
+        /// <remarks>
+        ///     <para>The event handler will be executed on an internal thread.</para>
+        ///     <para>The <see cref="VideoFrameDecodedEventArgs.Packet"/> in event args should be disposed after use.</para>
+        /// </remarks>
+        /// <feature>http://tizen.org/feature/multimedia.raw_video</feature>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+        /// <seealso cref="VideoFrameDecodedEventArgs.Packet"/>
+        public event EventHandler<VideoFrameDecodedEventArgs> VideoFrameDecoded
+        {
+            add
+            {
+                ValidationUtil.ValidateFeatureSupported(Features.RawVideo);
+
+                _videoFrameDecoded += value;
+            }
+            remove
+            {
+                ValidationUtil.ValidateFeatureSupported(Features.RawVideo);
+
+                _videoFrameDecoded -= value;
+            }
+        }
+
         private void RegisterVideoFrameDecodedCallback()
         {
             _videoFrameDecodedCallback = (packetHandle, _) =>
             {
-                var handler = VideoFrameDecoded;
+                var handler = _videoFrameDecoded;
                 if (handler != null)
                 {
                     Log.Debug(PlayerLog.Tag, "packet : " + packetHandle);
@@ -1176,6 +1222,7 @@ namespace Tizen.Multimedia
             Interop.Player.SetVideoFrameDecodedCb(Handle, _videoFrameDecodedCallback).
                 ThrowIfFailed("Failed to register the VideoFrameDecoded");
         }
+        #endregion
 
         private void RegisterVideoStreamChangedCallback()
         {
index 85feb4b..0df2ed3 100755 (executable)
@@ -99,6 +99,7 @@
     <Compile Include="Common\Range.cs" />
     <Compile Include="Common\Rectangle.cs" />
     <Compile Include="Common\Size.cs" />
+    <Compile Include="Common\Features.cs" />
     <Compile Include="Common\ValdiationUtil.cs" />
     <Compile Include="Common\Visibility.cs" />
     <Compile Include="Interop\Interop.AudioIO.cs" />