Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MediaPlayer] Add new API to set video codec type #5359

Merged
merged 5 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,12 @@ internal static extern PlayerErrorCode GetTrackLanguageCode(IntPtr player, Strea

[DllImport(Libraries.Player, EntryPoint = "player_get_audio_codec_type")]
internal static extern PlayerErrorCode GetAudioCodecType(IntPtr player, out CodecType type);

[DllImport(Libraries.Player, EntryPoint = "player_set_video_codec_type")]
internal static extern PlayerErrorCode SetVideoCodecType(IntPtr player, CodecType type);

[DllImport(Libraries.Player, EntryPoint = "player_get_video_codec_type")]
internal static extern PlayerErrorCode GetVideoCodecType(IntPtr player, out CodecType type);
}

internal class PlayerHandle : SafeHandle
Expand Down
46 changes: 42 additions & 4 deletions src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
* limitations under the License.
*/
using System;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.IO;
using System.Threading;
using NativeDisplay = Interop.Display;
using static Interop;

Expand Down Expand Up @@ -740,6 +736,48 @@ public CodecType AudioCodecType
}
}

/// <summary>
/// Gets or sets the codec type of the video decoder.
/// </summary>
/// <value>A <see cref="CodecType"/> specifies the type.
/// The default codec type could be different depending on the device capability.</value>
/// <remarks>
/// <para>To set, the player must be in the <see cref="PlayerState.Idle"/> state.</para>
/// <para>If H/W video codec type is not supported in some cases, S/W video codec type could be used instead.</para>
/// <para>The availability could be changed depending on the codec capability.</para>
/// </remarks>
/// <exception cref="ObjectDisposedException">The player has already been disposed.</exception>
/// <exception cref="ArgumentException">The value is not valid.</exception>
/// <exception cref="InvalidOperationException">
/// The player is not in the valid state.
/// -or-<br/>
/// Operation failed; internal error.
/// </exception>
/// <exception cref="CodecNotSupportedException">The selected codec is not supported.</exception>
/// <since_tizen> 11 </since_tizen>
public CodecType VideoCodecType
{
get
{
ValidateNotDisposed();

NativePlayer.GetVideoCodecType(Handle, out var value).
ThrowIfFailed(this, "Failed to get the type of the video codec");

return value;
}
set
{
ValidateNotDisposed();
ValidatePlayerState(PlayerState.Idle);

ValidationUtil.ValidateEnum(typeof(CodecType), value, nameof(value));

NativePlayer.SetVideoCodecType(Handle, value).
ThrowIfFailed(this, "Failed to set the type of the video codec");
}
}

private SphericalVideo _sphericalVideo;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/Tizen.Multimedia.MediaPlayer/Player/PlayerEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ public enum PlayerAudioExtractOption
NoSyncAndDeinterleave = 0x03,
}


/// <summary>
/// Specifies the types of a codec for <see cref="Player"/>.
/// </summary>
Expand Down
Loading