[Multimedia] Added a new constructor in Display class for NUI.Window. 36/146736/3
authorcoderhyme <jhyo.kim@samsung.com>
Wed, 30 Aug 2017 08:22:34 +0000 (17:22 +0900)
committercoderhyme <jhyo.kim@samsung.com>
Tue, 5 Sep 2017 06:47:19 +0000 (15:47 +0900)
Change-Id: Ia284b3ed8c1d31ca0760a255163d7f7c0bc3c82b
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
src/Tizen.Multimedia.Camera/Camera/Camera.cs
src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Display.cs
src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs
src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
src/Tizen.Multimedia.Remoting/ScreenMirroring/ScreenMirroring.cs
src/Tizen.Multimedia/Common/Display.cs
src/Tizen.Multimedia/Tizen.Multimedia.csproj

index 1323187..4a1bf65 100755 (executable)
@@ -374,7 +374,7 @@ namespace Tizen.Multimedia
         /// Get/set various camera display properties.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        public CameraDisplaySettings DisplaySettings{ get; }
+        public CameraDisplaySettings DisplaySettings { get; }
 
         private Display _display;
 
@@ -443,6 +443,11 @@ namespace Tizen.Multimedia
             return CameraDisplay.SetTarget(GetHandle(), type, evasObject);
         }
 
+        CameraError IDisplayable<CameraError>.ApplyEcoreWindow(IntPtr windowHandle)
+        {
+            throw new NotSupportedException("Camera does not support NUI.Window display.");
+        }
+
         /// <summary>
         /// Gets the state of the camera.
         /// </summary>
index 3572b6a..6c4acc4 100644 (file)
@@ -42,5 +42,13 @@ internal static partial class Interop
 
         [DllImport(Libraries.Player, EntryPoint = "player_set_display_roi_area")]
         internal static extern PlayerErrorCode SetRoi(IntPtr player, int x, int y, int width, int height);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_set_display")]
+        internal static extern PlayerErrorCode SetDisplay(IntPtr player, PlayerDisplayType type, IntPtr display);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_set_ecore_wl_display")]
+        internal static extern PlayerErrorCode SetEcoreDisplay(IntPtr player, PlayerDisplayType type, IntPtr
+              ecoreWindow, int x = 0, int y = 0, int width = 1920, int height = 1080);
+
     }
 }
index 494b084..d95e8d5 100644 (file)
@@ -75,9 +75,6 @@ internal static partial class Interop
         [DllImport(Libraries.Player, EntryPoint = "player_set_uri")]
         internal static extern PlayerErrorCode SetUri(IntPtr player, string uri);
 
-        [DllImport(Libraries.Player, EntryPoint = "player_set_display")]
-        internal static extern PlayerErrorCode SetDisplay(IntPtr player, PlayerDisplayType type, IntPtr display);
-
         [DllImport(Libraries.Player, EntryPoint = "player_start")]
         internal static extern PlayerErrorCode Start(IntPtr player);
 
index 097be5d..f0cb03e 100644 (file)
@@ -19,6 +19,7 @@ using System.Runtime.InteropServices;
 using System.Diagnostics;
 using System.IO;
 using System.Threading;
+using NativeDisplay = Interop.Display;
 using static Interop;
 
 namespace Tizen.Multimedia
@@ -215,8 +216,7 @@ namespace Tizen.Multimedia
         {
             if (display == null)
             {
-                Log.Info(PlayerLog.Tag, "set display to none");
-                return NativePlayer.SetDisplay(Handle, PlayerDisplayType.None, IntPtr.Zero);
+                return NativeDisplay.SetDisplay(Handle, PlayerDisplayType.None, IntPtr.Zero);
             }
 
             return display.ApplyTo(this);
@@ -269,9 +269,16 @@ namespace Tizen.Multimedia
             Debug.Assert(Enum.IsDefined(typeof(DisplayType), type));
             Debug.Assert(type != DisplayType.None);
 
-            return NativePlayer.SetDisplay(Handle,
+            return NativeDisplay.SetDisplay(Handle,
                 type == DisplayType.Overlay ? PlayerDisplayType.Overlay : PlayerDisplayType.Evas, evasObject);
         }
+
+        PlayerErrorCode IDisplayable<PlayerErrorCode>.ApplyEcoreWindow(IntPtr windowHandle)
+        {
+            Debug.Assert(IsDisposed == false);
+
+            return NativeDisplay.SetEcoreDisplay(Handle, PlayerDisplayType.Overlay, windowHandle);
+        }
         #endregion
 
         private PlayerTrackInfo _audioTrack;
index de32341..2d02dc8 100644 (file)
@@ -112,6 +112,11 @@ namespace Tizen.Multimedia.Remoting
 
             return Native.SetDisplay(Handle, (int)type, evasObject);
         }
+
+        ScreenMirroringErrorCode IDisplayable<ScreenMirroringErrorCode>.ApplyEcoreWindow(IntPtr windowHandle)
+        {
+            throw new NotSupportedException("ScreenMirroring does not support NUI.Window display.");
+        }
         #endregion
 
         /// <summary>
index d300c57..636fb8f 100644 (file)
@@ -36,50 +36,112 @@ namespace Tizen.Multimedia
         None,
     }
 
-    internal interface IDisplayable<ErrorType>
+    internal interface IDisplayable<TError>
     {
-        ErrorType ApplyEvasDisplay(DisplayType type, EvasObject evasObject);
+        TError ApplyEvasDisplay(DisplayType type, EvasObject evasObject);
+        TError ApplyEcoreWindow(IntPtr windowHandle);
     }
 
-    /// <summary>
-    /// Provides a means to wrap various display types.
-    /// </summary>
-    /// <seealso cref="Player"/>
-    /// <seealso cref="Camera"/>
-    /// <seealso cref="ScreenMirroring"/>
-    public class Display
+    internal interface IDisplaySetter
     {
-        private Display(DisplayType type, EvasObject target)
-        {
-            if (target == null)
-            {
-                throw new ArgumentNullException(nameof(target));
-            }
+        TError SetDisplay<TError>(IDisplayable<TError> target);
+    }
 
+    internal class EvasDisplaySetter : IDisplaySetter
+    {
+        private readonly DisplayType _type;
+        private readonly EvasObject _target;
+
+        internal EvasDisplaySetter(DisplayType type, EvasObject target)
+        {
             if (target == IntPtr.Zero)
             {
                 throw new ArgumentException("The evas object is not realized.");
             }
 
-            Type = type;
-            EvasObject = target;
+            _type = type;
+            _target = target;
         }
 
+        public TError SetDisplay<TError>(IDisplayable<TError> target)
+        {
+            return target.ApplyEvasDisplay(_type, _target);
+        }
+    }
+
+    internal class EcoreDisplaySetter : IDisplaySetter
+    {
+        private readonly IntPtr _windowHandle;
+
+        internal EcoreDisplaySetter(IntPtr windowHandle)
+        {
+            _windowHandle = windowHandle;
+        }
+
+        public TError SetDisplay<TError>(IDisplayable<TError> target)
+        {
+            return target.ApplyEcoreWindow(_windowHandle);
+        }
+    }
+
+    /// <summary>
+    /// Provides a means to wrap various display types.
+    /// </summary>
+    /// <seealso cref="Player"/>
+    /// <seealso cref="Camera"/>
+    /// <seealso cref="Tizen.Multimedia.Remoting.ScreenMirroring"/>
+    public class Display
+    {
+        private readonly IDisplaySetter _setter;
+
         /// <summary>
         /// Initializes a new instance of the <see cref="Display"/> class with a <see cref="MediaView"/> class.
         /// </summary>
+        /// <param name="mediaView">A <see cref="MediaView"/> to display.</param>
         /// <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)
+        public Display(MediaView mediaView)
         {
             ValidationUtil.ValidateFeatureSupported(Features.RawVideo);
+
+            if (mediaView == null)
+            {
+                throw new ArgumentNullException(nameof(mediaView));
+            }
+
+            _setter = new EvasDisplaySetter(DisplayType.Surface, mediaView);
         }
 
         /// <summary>
         /// Initializes a new instance of the <see cref="Display"/> class with a <see cref="Window"/> class.
         /// </summary>
-        public Display(Window window) : this(DisplayType.Overlay, window)
+        /// <param name="window">A <see cref="Window"/> to display.</param>
+        public Display(Window window)
+        {
+            if (window == null)
+            {
+                throw new ArgumentNullException(nameof(window));
+            }
+
+            _setter = new EvasDisplaySetter(DisplayType.Overlay, window);
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Display"/> class with a <see cref="NUI.Window"/> class.
+        /// </summary>
+        /// <param name="window">A <see cref="NUI.Window"/> to display.</param>
+        /// <remarks>
+        /// The <see cref="NUI.Window.BackgroundColor"/> must be <see cref="NUI.Color.Transparent"/>
+        /// for the <see cref="Display"/> to be rendered correctly.
+        /// </remarks>
+        public Display(NUI.Window window)
         {
+            if (window == null)
+            {
+                throw new ArgumentNullException(nameof(window));
+            }
+
+            _setter = new EcoreDisplaySetter(window.GetNativeWindowHandler());
         }
 
         private EvasObject EvasObject { get; }
@@ -100,9 +162,9 @@ namespace Tizen.Multimedia
             _owner = newOwner;
         }
 
-        internal ErrorType ApplyTo<ErrorType>(IDisplayable<ErrorType> target)
+        internal TError ApplyTo<TError>(IDisplayable<TError> target)
         {
-            return target.ApplyEvasDisplay(Type, EvasObject);
+            return _setter.SetDisplay(target);
         }
     }
 }
index 5b07fe6..fd0854a 100644 (file)
@@ -8,6 +8,7 @@
     <ProjectReference Include="..\ElmSharp\ElmSharp.csproj" />
     <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
     <ProjectReference Include="..\Tizen.System.Information\Tizen.System.Information.csproj" />
+    <ProjectReference Include="..\Tizen.NUI\Tizen.NUI.csproj" />
   </ItemGroup>
 
 </Project>
\ No newline at end of file