From: nam <36914158+kqjy777@users.noreply.github.com>
Date: Wed, 23 May 2018 05:16:31 +0000 (+0900)
Subject: [MediaPlayer] add API related to 360 video (#236)
X-Git-Tag: 5.0.0.14562~207
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a2c1177f7c89e13e33238210aef8da255cfa43c9;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git
[MediaPlayer] add API related to 360 video (#236)
* [MediaPlayer] add API to set audio-only mode
* Update Player.Properties.cs
* Update Player.Properties.cs
* Update Interop.Player.cs
* [MediaPlayer] add API related to 360 video
* update patch
* 1. truncate the decimal number for direction of view
2. add features for 360 playback
* values will be rounded off instead of being truncated
* fixed the document issues
---
diff --git a/src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs b/src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs
index 6380d0f..94e9f54 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs
@@ -267,6 +267,34 @@ internal static partial class Interop
[DllImport(Libraries.Player, EntryPoint = "player_is_audio_only")]
internal static extern PlayerErrorCode IsAudioOnly(IntPtr player, out bool audioOnly);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_360_is_content_spherical")]
+ internal static extern PlayerErrorCode IsSphericalContent(IntPtr player, out bool isspherical);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_360_set_enabled")]
+ internal static extern PlayerErrorCode SetSphericalMode(IntPtr player, bool enabled);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_360_is_enabled")]
+ internal static extern PlayerErrorCode IsSphericalMode(IntPtr player, out bool enabled);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_360_set_direction_of_view")]
+ internal static extern PlayerErrorCode SetDirectionOfView(IntPtr player, float yaw, float pitch);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_360_get_direction_of_view")]
+ internal static extern PlayerErrorCode GetDirectionOfView(IntPtr player, out float yaw, out float pitch);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_360_set_zoom")]
+ internal static extern PlayerErrorCode SetZoom(IntPtr player, float level);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_360_get_zoom")]
+ internal static extern PlayerErrorCode GetZoom(IntPtr player, out float level);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_360_set_field_of_view")]
+ internal static extern PlayerErrorCode SetFieldOfView(IntPtr player, int horizontalDegrees, int verticalDegrees);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_360_get_field_of_view")]
+ internal static extern PlayerErrorCode GetFieldOfView(IntPtr player, out int horizontalDegrees, out int verticalDegrees);
+
}
internal class PlayerHandle : SafeHandle
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs b/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
index cd1e46b..77a5958 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
@@ -444,5 +444,24 @@ namespace Tizen.Multimedia
ThrowIfFailed(this, "Failed to set the audio-only state of the player");
}
}
+
+ private SphericalVideo _sphericalVideo;
+
+ ///
+ /// Gets the spherical video settings.
+ ///
+ /// 5
+ public SphericalVideo SphericalVideo
+ {
+ get
+ {
+ if (_sphericalVideo == null)
+ {
+ _sphericalVideo = new SphericalVideo(this);
+ }
+
+ return _sphericalVideo;
+ }
+ }
}
}
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/PlayerFeatures.cs b/src/Tizen.Multimedia.MediaPlayer/Player/PlayerFeatures.cs
index a554d4d..eeacff2 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/PlayerFeatures.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/PlayerFeatures.cs
@@ -20,5 +20,7 @@ namespace Tizen.Multimedia
{
internal const string AudioEffect = "http://tizen.org/feature/multimedia.custom_audio_effect";
internal const string RawVideo = "http://tizen.org/feature/multimedia.raw_video";
+ internal const string OpenGl = "http://tizen.org/feature/opengles.version.2_0";
+ internal const string SphericalVideo = "http://tizen.org/feature/multimedia.player.spherical_video";
}
}
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/SphericalVideo.cs b/src/Tizen.Multimedia.MediaPlayer/Player/SphericalVideo.cs
new file mode 100644
index 0000000..631b150
--- /dev/null
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/SphericalVideo.cs
@@ -0,0 +1,397 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Diagnostics;
+using static Interop;
+
+namespace Tizen.Multimedia
+{
+ ///
+ /// Represents properties for the spherical video direction of view
+ ///
+ /// 5
+ public struct DirectionOfView
+ {
+ ///
+ /// Initializes a new instance of the struct with the specified direction of view for the spherical video.
+ ///
+ /// Pointer to store current value of direction of view angle around vertical axis.
+ /// valid range is [-3.141593, 3.141593]. value will be rounded off to 6 decimal places.
+ /// Default value is 0.
+ /// Pointer to store current value of direction of view angle around lateral axis.
+ /// valid range is [-1.570796, 1.570796]. value will be rounded off to 6 decimal places.
+ /// Default value is 0.
+ /// 5
+ public DirectionOfView(float yaw, float pitch)
+ {
+ Yaw = yaw;
+ Pitch = pitch;
+
+ Log.Debug(PlayerLog.Tag, $"yaw={yaw}, pitch={pitch}");
+ }
+
+ ///
+ /// Gets or sets the Yaw.
+ ///
+ /// 5
+ public float Yaw
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Gets or sets the Pitch.
+ ///
+ /// 5
+ public float Pitch
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Returns a string that represents the current object.
+ ///
+ /// A string that represents the current object.
+ /// 5
+ public override string ToString() =>
+ $"Yaw={ Yaw.ToString() }, Pitch={ Pitch.ToString() }";
+ }
+
+ ///
+ /// Represents properties for the spherical video field of view
+ ///
+ /// 5
+ public struct FieldOfView
+ {
+ ///
+ /// Initializes a new instance of the struct with the specified field of view for the spherical video.
+ ///
+ /// The horizontal field of view to display in degrees.
+ ///
+ /// Valid range is 1-360 degrees. Default value is 120 degrees.
+ ///
+ /// The vertical field of view to display in degrees.
+ ///
+ /// Valid range is 1-180 degrees. Default value is 67 degrees.
+ ///
+ /// 5
+ public FieldOfView(int horizontalDegrees, int verticalDegrees)
+ {
+ HorizontalDegrees = horizontalDegrees;
+ VerticalDegrees = verticalDegrees;
+
+ Log.Debug(PlayerLog.Tag, $"horizontalDegrees={horizontalDegrees}, verticalDegrees={verticalDegrees}");
+ }
+
+ ///
+ /// Gets or sets the HorizontalDegrees.
+ ///
+ /// 5
+ public int HorizontalDegrees
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Gets or sets the VerticalDegrees.
+ ///
+ /// 5
+ public int VerticalDegrees
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Returns a string that represents the current object.
+ ///
+ /// A string that represents the current object.
+ /// 5
+ public override string ToString() =>
+ $"HorizontalDegrees={ HorizontalDegrees.ToString() }, VerticalDegrees={ VerticalDegrees.ToString() }";
+ }
+
+ ///
+ /// Provides the ability to control the spherical video for .
+ ///
+ /// 5
+ public class SphericalVideo
+ {
+ ///
+ /// Gets the that owns this instance.
+ ///
+ /// 5
+ public Player Player { get; }
+
+ ///
+ /// Provides a means to retrieve spherical video information.
+ ///
+ /// 5
+ internal SphericalVideo(Player player)
+ {
+ Debug.Assert(player != null);
+ Player = player;
+ }
+
+ ///
+ /// Gets information whether the current content of the player is spherical.
+ ///
+ /// True if the current content is spherical; otherwise false.
+ ///
+ /// The that owns this instance must be in the ,
+ /// , or state.
+ ///
+ /// http://tizen.org/feature/opengles.version.2_0
+ /// http://tizen.org/feature/multimedia.player.spherical_video
+ /// The required feature is not supported.
+ /// The that this instance belongs to has been disposed of.
+ /// The that this instance belongs to is not in the valid state.
+ /// 5
+ public bool IsSphericalContent()
+ {
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.OpenGl);
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.SphericalVideo);
+
+ Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+ NativePlayer.IsSphericalContent(Player.Handle, out var value).
+ ThrowIfFailed(Player, "Failed to get the spherical state of the content");
+
+ return value;
+ }
+
+ ///
+ /// Gets the level of the zoom of spherical video.
+ ///
+ /// The current zoom level of spherical video.
+ /// Remark.
+ /// http://tizen.org/feature/opengles.version.2_0
+ /// http://tizen.org/feature/multimedia.player.spherical_video
+ /// The required feature is not supported.
+ /// The player has already been disposed of.
+ /// The player is not in the valid state.
+ ///
+ /// 5
+ public float GetZoom()
+ {
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.OpenGl);
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.SphericalVideo);
+
+ Player.ValidateNotDisposed();
+
+ NativePlayer.GetZoom(Player.Handle, out var value).
+ ThrowIfFailed(Player, "Failed to get the level of the zoom");
+
+ return value;
+ }
+
+ ///
+ /// Sets the level of the zoom of spherical video.
+ ///
+ /// The zoom level.
+ /// http://tizen.org/feature/opengles.version.2_0
+ /// http://tizen.org/feature/multimedia.player.spherical_video
+ /// The required feature is not supported.
+ /// The player has already been disposed of.
+ /// The player is not in the valid state.
+ ///
+ /// 5
+ public void SetZoom(float level)
+ {
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.OpenGl);
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.SphericalVideo);
+
+ Player.ValidateNotDisposed();
+
+ if (level < 1.0F || 10.0F < level)
+ {
+ throw new ArgumentOutOfRangeException(nameof(level), level, "Valid level is 1.0 to 10.0");
+ }
+
+ NativePlayer.SetZoom(Player.Handle, level).ThrowIfFailed(Player, "Failed to set the level of the zoom.");
+ }
+
+ ///
+ /// Gets or sets the spherical mode.
+ ///
+ /// The player must be in the , ,
+ /// or state.
+ /// http://tizen.org/feature/opengles.version.2_0
+ /// http://tizen.org/feature/multimedia.player.spherical_video
+ /// The required feature is not supported.
+ /// The player has already been disposed of.
+ /// The player is not in the valid state.
+ /// 5
+ public bool IsEnabled
+ {
+ get
+ {
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.OpenGl);
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.SphericalVideo);
+
+ Player.ValidateNotDisposed();
+ NativePlayer.IsSphericalMode(Player.Handle, out var value).
+ ThrowIfFailed(Player, "Failed to get whether the spherical mode of the player is enabled or not");
+ return value;
+ }
+
+ set
+ {
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.OpenGl);
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.SphericalVideo);
+
+ Player.ValidateNotDisposed();
+ NativePlayer.SetSphericalMode(Player.Handle, value).
+ ThrowIfFailed(Player, "Failed to set the spherical mode of the player");
+ }
+ }
+
+
+ ///
+ /// Gets the direction of view for spherical video.
+ ///
+ /// The containing the angle information.
+ /// http://tizen.org/feature/opengles.version.2_0
+ /// http://tizen.org/feature/multimedia.player.spherical_video
+ /// The required feature is not supported.
+ ///
+ /// The that this instance belongs to has been disposed of.
+ ///
+ ///
+ /// The that this instance belongs to is not in the valid state.
+ ///
+ /// 5
+ public DirectionOfView GetDirectionOfView()
+ {
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.OpenGl);
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.SphericalVideo);
+
+ Player.ValidateNotDisposed();
+
+ NativePlayer.GetDirectionOfView(Player.Handle, out var yaw, out var pitch).
+ ThrowIfFailed(Player, "Failed to get the direction of view");
+
+ return new DirectionOfView(yaw, pitch);
+ }
+
+ ///
+ /// Sets the direction of view for spherical video.
+ ///
+ /// The angle values around the vertical and lateral axis.
+ /// http://tizen.org/feature/opengles.version.2_0
+ /// http://tizen.org/feature/multimedia.player.spherical_video
+ /// The required feature is not supported.
+ ///
+ /// The that this instance belongs to has been disposed of.
+ ///
+ ///
+ /// The that this instance belongs to is not in the valid state.
+ ///
+ ///
+ /// 5
+ public void SetDirectionOfView(DirectionOfView directionOfView)
+ {
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.OpenGl);
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.SphericalVideo);
+
+ Player.ValidateNotDisposed();
+
+ if (directionOfView.Yaw > (float)Math.PI || directionOfView.Yaw < -(float)Math.PI)
+ {
+ throw new ArgumentOutOfRangeException(nameof(directionOfView.Yaw), directionOfView.Yaw,
+ $"Valid values are in range [-PI, PI] : " + directionOfView.Yaw);
+ }
+
+ if (directionOfView.Pitch > (float)Math.PI/2 || directionOfView.Pitch < -(float)Math.PI/2)
+ {
+ throw new ArgumentOutOfRangeException(nameof(directionOfView.Pitch), directionOfView.Pitch,
+ $"Valid values are in range [-PI/2, PI/2] : " + directionOfView.Pitch);
+ }
+
+ NativePlayer.SetDirectionOfView(Player.Handle, (float)directionOfView.Yaw, (float)directionOfView.Pitch).
+ ThrowIfFailed(Player, "Failed to set the direction of the view.");
+ }
+
+ ///
+ /// Gets the field of view for spherical video.
+ ///
+ /// The containing the degree information to display.
+ /// http://tizen.org/feature/opengles.version.2_0
+ /// http://tizen.org/feature/multimedia.player.spherical_video
+ /// The required feature is not supported.
+ ///
+ /// The that this instance belongs to has been disposed of.
+ ///
+ ///
+ /// The that this instance belongs to is not in the valid state.
+ ///
+ /// 5
+ public FieldOfView GetFieldOfView()
+ {
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.OpenGl);
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.SphericalVideo);
+
+ Player.ValidateNotDisposed();
+
+ NativePlayer.GetFieldOfView(Player.Handle, out var horizontalDegrees, out var verticalDegrees).
+ ThrowIfFailed(Player, "Failed to get the field of view");
+
+ return new FieldOfView(horizontalDegrees, verticalDegrees);
+ }
+
+ ///
+ /// Sets the field of view for spherical video.
+ ///
+ /// The degree values to display.
+ /// http://tizen.org/feature/opengles.version.2_0
+ /// http://tizen.org/feature/multimedia.player.spherical_video
+ /// The required feature is not supported.
+ ///
+ /// The that this instance belongs to has been disposed of.
+ ///
+ ///
+ /// The that this instance belongs to is not in the valid state.
+ ///
+ ///
+ /// 5
+ public void SetFieldOfView(FieldOfView fieldOfView)
+ {
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.OpenGl);
+ ValidationUtil.ValidateFeatureSupported(PlayerFeatures.SphericalVideo);
+
+ Player.ValidateNotDisposed();
+
+ if (fieldOfView.HorizontalDegrees < 1 || fieldOfView.HorizontalDegrees > 360)
+ {
+ throw new ArgumentOutOfRangeException(nameof(fieldOfView.HorizontalDegrees), fieldOfView.HorizontalDegrees,
+ $"Valid range is 1-360 degrees. : " + fieldOfView.HorizontalDegrees);
+ }
+
+ if (fieldOfView.VerticalDegrees < 1 || fieldOfView.VerticalDegrees > 180)
+ {
+ throw new ArgumentOutOfRangeException(nameof(fieldOfView.VerticalDegrees), fieldOfView.VerticalDegrees,
+ $"Valid range is 1-180 degrees. : " + fieldOfView.VerticalDegrees);
+ }
+
+ NativePlayer.SetFieldOfView(Player.Handle, fieldOfView.HorizontalDegrees, fieldOfView.VerticalDegrees).
+ ThrowIfFailed(Player, "Failed to set the field of the view.");
+ }
+ }
+}