[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);
+
}
}
using System.Diagnostics;
using System.IO;
using System.Threading;
+using NativeDisplay = Interop.Display;
using static Interop;
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);
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;
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; }
_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);
}
}
}