[MediaPlayer] add APIs to use AudioOffload (#974)
authornam <36914158+aferin@users.noreply.github.com>
Mon, 26 Aug 2019 04:39:49 +0000 (13:39 +0900)
committerGitHub <noreply@github.com>
Mon, 26 Aug 2019 04:39:49 +0000 (13:39 +0900)
* [MediaPlayer] add APIs to use AudioOffload

src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs
src/Tizen.Multimedia.MediaPlayer/Player/AudioEffect.cs
src/Tizen.Multimedia.MediaPlayer/Player/AudioOffload.cs [new file with mode: 0644]
src/Tizen.Multimedia.MediaPlayer/Player/EqualizerBand.cs
src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
src/Tizen.Multimedia.MediaPlayer/Player/Player.cs
src/Tizen.Multimedia.MediaPlayer/Player/PlayerFeatures.cs
src/Tizen.Multimedia.MediaPlayer/Player/PlayerTrackInfo.cs

index fc70274..819ce0f 100644 (file)
@@ -66,6 +66,9 @@ internal static partial class Interop
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate bool AdaptiveVariantCallback(int bandwidth, int width, int height, IntPtr userData);
 
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool SupportedMediaFormatCallback(int format, IntPtr userData);
+
         [DllImport(Libraries.Player, EntryPoint = "player_create")]
         internal static extern PlayerErrorCode Create(out PlayerHandle player);
 
@@ -363,6 +366,18 @@ internal static partial class Interop
 
         [DllImport(Libraries.Player, EntryPoint = "player_audio_pitch_get_value")]
         internal static extern PlayerErrorCode GetAudioPitch(IntPtr player, out float level);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_audio_offload_set_enabled")]
+        internal static extern PlayerErrorCode SetAudioOffloadEnabled(IntPtr player, bool value);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_audio_offload_is_enabled")]
+        internal static extern PlayerErrorCode IsAudioOffloadEnabled(IntPtr player, out bool value);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_audio_offload_is_activated")]
+        internal static extern PlayerErrorCode IsAudioOffloadActivated(IntPtr player, out bool value);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_audio_offload_foreach_supported_format")]
+        internal static extern PlayerErrorCode SupportedAudioOffloadFormat(IntPtr player, SupportedMediaFormatCallback callback, IntPtr userData);
     }
 
     internal class PlayerHandle : SafeHandle
index d7a2e84..8cc310d 100644 (file)
@@ -31,31 +31,12 @@ namespace Tizen.Multimedia
         {
             Player = owner;
 
-            bool available = false;
-
-            Native.EqualizerIsAvailable(Player.Handle, out available).
-                ThrowIfFailed(Player, "Failed to initialize the AudioEffect");
-
-            IsAvailable = available;
-
-            if (IsAvailable == false)
+            if (IsAvailable== false)
             {
                 return;
             }
 
-            int count = 0;
-            Native.GetEqualizerBandsCount(Player.Handle, out count).
-                ThrowIfFailed(Player, "Failed to initialize the AudioEffect");
-
-            int min = 0;
-            int max = 0;
-            Native.GetEqualizerLevelRange(Player.Handle, out min, out max).
-                ThrowIfFailed(Player, "Failed to initialize the AudioEffect");
-
-            Count = count;
-            BandLevelRange = new Range(min, max);
-
-            _bands = new EqualizerBand[count];
+            _bands = new EqualizerBand[Count];
         }
 
         /// <summary>
@@ -68,12 +49,16 @@ namespace Tizen.Multimedia
         ///     -or-<br/>
         ///     <paramref name="index"/> is equal to or greater than <see cref="Count"/>.
         /// </exception>
+        /// <exception cref="InvalidOperationException">
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <since_tizen> 3 </since_tizen>
         public EqualizerBand this[int index]
         {
             get
             {
                 Player.ValidateNotDisposed();
+                Player.AudioOffload.CheckDisabled();
 
                 if (index < 0 || Count <= index)
                 {
@@ -94,10 +79,14 @@ namespace Tizen.Multimedia
         /// Clears the equalizer effect.
         /// </summary>
         /// <exception cref="ObjectDisposedException">The <see cref="Player"/> has already been disposed of.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <since_tizen> 3 </since_tizen>
         public void Clear()
         {
             Player.ValidateNotDisposed();
+            Player.AudioOffload.CheckDisabled();
 
             Native.EqualizerClear(Player.Handle).
                 ThrowIfFailed(Player, "Failed to clear equalizer effect");
@@ -106,20 +95,61 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Gets the number of items.
         /// </summary>
+        /// <exception cref="InvalidOperationException">
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <since_tizen> 3 </since_tizen>
-        public int Count { get; }
+        public int Count
+        {
+            get
+            {
+                Player.AudioOffload.CheckDisabled();
+
+                Native.GetEqualizerBandsCount(Player.Handle, out var count).
+                    ThrowIfFailed(Player, "Failed to initialize the AudioEffect");
+
+                return count;
+            }
+        }
 
         /// <summary>
         /// Gets the band level range of the bands in the dB.
         /// </summary>
+        /// <exception cref="InvalidOperationException">
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <since_tizen> 3 </since_tizen>
-        public Range BandLevelRange { get; }
+        public Range BandLevelRange
+        {
+            get
+            {
+                Player.AudioOffload.CheckDisabled();
+
+                Native.GetEqualizerLevelRange(Player.Handle, out var min, out var max).
+                    ThrowIfFailed(Player, "Failed to initialize the AudioEffect");
+
+                return new Range(min, max);
+            }
+        }
 
         /// <summary>
         /// Gets the value whether the AudioEffect is available or not.
         /// </summary>
+        /// <exception cref="InvalidOperationException">
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <since_tizen> 3 </since_tizen>
-        public bool IsAvailable { get; }
+        public bool IsAvailable
+        {
+            get
+            {
+                Player.AudioOffload.CheckDisabled();
+
+                Native.EqualizerIsAvailable(Player.Handle, out var available).
+                    ThrowIfFailed(Player, "Failed to initialize the AudioEffect");
+                return available;
+            }
+        }
 
         /// <summary>
         /// Gets the player that this AudioEffect belongs to.
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/AudioOffload.cs b/src/Tizen.Multimedia.MediaPlayer/Player/AudioOffload.cs
new file mode 100644 (file)
index 0000000..30569bf
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2019 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 System.Collections.Generic;
+using static Interop;
+
+namespace Tizen.Multimedia
+{
+    /// <summary>
+    /// Provides the ability to control the audio offload for <see cref="Multimedia.Player"/>.
+    /// </summary>
+    /// <since_tizen> 6 </since_tizen>
+    public class AudioOffload
+    {
+        private IList<MediaFormatAudioMimeType> _supportedFormat;
+        private Player _player { get; }
+
+        /// <summary>
+        /// Provides a means to retrieve audio offload information.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        internal AudioOffload(Player player)
+        {
+            Debug.Assert(player != null);
+            _player = player;
+        }
+
+        private bool _enabled;
+        internal void CheckDisabled()
+        {
+            if (_enabled)
+            {
+                throw new InvalidOperationException("the audio offload is enabled.");
+            }
+        }
+
+        /// <summary>
+        /// Enables or disables the audio offload.
+        /// </summary>
+        /// <value>The value indicating whether or not AudioOffload is enabled. The default value is false.</value>
+        /// <remarks><para>The player lets the hardware decode and render the sound if the audio offload is enabled.
+        /// This will reduce the power consumption, but will disable the ability to handle output PCM.
+        /// Please check the below list of functions which will not work if offloading is enabled.</para>
+        /// <para>If audio offload is enabled, the following functions will return <see cref="InvalidOperationException"/>
+        /// and they will not work at all even if they were called before offload is enabled.<br/>
+        /// <see cref="AudioEffect"/><br/>
+        /// <see cref="EqualizerBand"/><br/>
+        /// <see cref="PlayerTrackInfo"/><br/>
+        /// <see cref="Player.EnableExportingAudioData"/><br/>
+        /// <see cref="Player.AudioLatencyMode"/><br/>
+        /// <see cref="Player.SetPlaybackRate"/><br/>
+        /// <see cref="Player.ReplayGain"/><br/>
+        /// <see cref="Player.AudioPitch"/><br/>
+        /// <see cref="Player.AudioPitchEnabled"/><br/></para>
+        /// <para>To set, the player must be in the <see cref="PlayerState.Idle"/> state.
+        /// The sound stream type of the player should be <see cref="AudioStreamType.Media"/>.</para></remarks>
+        /// <feature>http://tizen.org/feature/multimedia.player.audio_offload</feature>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     The player is not in the valid state.<br/>
+        ///     -or-<br/>
+        ///     Operation failed; internal error.
+        /// </exception>
+        /// <since_tizen> 6 </since_tizen>
+        public bool IsEnabled
+        {
+            get
+            {
+                ValidationUtil.ValidateFeatureSupported(PlayerFeatures.AudioOffload);
+                _player.ValidateNotDisposed();
+
+                NativePlayer.IsAudioOffloadEnabled(_player.Handle, out var value).
+                    ThrowIfFailed(_player, "Failed to get whether the audio offload of the player is enabled or not");
+                return value;
+            }
+
+            set
+            {
+                ValidationUtil.ValidateFeatureSupported(PlayerFeatures.AudioOffload);
+                _player.ValidateNotDisposed();
+                _player.ValidatePlayerState(PlayerState.Idle);
+
+                NativePlayer.SetAudioOffloadEnabled(_player.Handle, value).
+                    ThrowIfFailed(_player, "Failed to set the audio offload of the player");
+                _enabled = value;
+            }
+        }
+
+        /// <summary>
+        /// Get a state whether or not the audio offload is activated.
+        /// </summary>
+        /// <value>The value indicating whether or not AudioOffload is activated.</value>
+        /// <remarks>
+        /// Audio offload could be inactivated depending on the audio device capability even if the audio offload feature is supported.
+        /// The <see cref="Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>,
+        /// <see cref="PlayerState.Playing"/>, or <see cref="PlayerState.Paused"/> state.
+        /// </remarks>
+        /// <feature>http://tizen.org/feature/multimedia.player.audio_offload</feature>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     The player is not in the valid state.<br/>
+        ///     -or-<br/>
+        ///     Operation failed; internal error.
+        /// </exception>
+        /// <since_tizen> 6 </since_tizen>
+        public bool IsActivated
+        {
+            get
+            {
+                ValidationUtil.ValidateFeatureSupported(PlayerFeatures.AudioOffload);
+                _player.ValidateNotDisposed();
+                _player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+                NativePlayer.IsAudioOffloadActivated(_player.Handle, out var value).
+                    ThrowIfFailed(_player, "Failed to get whether the audio offload of the player is enabled or not");
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// Retrieves all formats for audio offload.
+        /// </summary>
+        /// <returns>
+        /// It returns a list contained all formats for audio offload.
+        /// </returns>
+        /// <remarks>The supported media format can vary depending on the device capabilities.</remarks>
+        /// <feature>http://tizen.org/feature/multimedia.player.audio_offload</feature>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+        /// <exception cref="ObjectDisposedException">The <see cref="Player"/> has already been disposed of.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     Operation failed; internal error.
+        /// </exception>
+        /// <seealso cref="MediaFormatAudioMimeType"/>
+        /// <since_tizen> 6 </since_tizen>
+        public IEnumerable<MediaFormatAudioMimeType> SupportedFormats
+        {
+            get
+            {
+                if (_supportedFormat == null)
+                {
+                    _supportedFormat = GetSupportedFormats();
+                }
+
+                return _supportedFormat;
+            }
+        }
+
+        private IList<MediaFormatAudioMimeType> GetSupportedFormats()
+        {
+            List<MediaFormatAudioMimeType> audioFormats = new List<MediaFormatAudioMimeType>();
+
+            NativePlayer.SupportedMediaFormatCallback callback = (int format, IntPtr userData) =>
+            {
+                if (!Enum.IsDefined(typeof(MediaFormatAudioMimeType), format))
+                {
+                    Log.Warn(PlayerLog.Tag, "not supported : " + format.ToString());
+                    return false;
+                }
+
+                Log.Debug(PlayerLog.Tag, "supported : " + ((MediaFormatAudioMimeType)format).ToString());
+                audioFormats.Add((MediaFormatAudioMimeType)format);
+                return true;
+            };
+
+            NativePlayer.SupportedAudioOffloadFormat(_player.Handle, callback, IntPtr.Zero).
+                ThrowIfFailed(_player, "Failed to get the supported formats for audio offload");
+
+            return audioFormats.AsReadOnly();
+        }
+    }
+}
index 86cdc73..569572d 100644 (file)
@@ -37,15 +37,7 @@ namespace Tizen.Multimedia
             _owner = owner;
             _index = index;
 
-            Native.GetEqualizerBandFrequency(_owner.Player.Handle, _index, out var frequency).
-                ThrowIfFailed(_owner.Player, "Failed to initialize equalizer band");
-
-            Native.GetEqualizerBandFrequencyRange(_owner.Player.Handle, _index, out var range).
-                ThrowIfFailed(_owner.Player, "Failed to initialize equalizer band");
-
-            Frequency = frequency;
-            FrequencyRange = range;
-            Log.Debug(PlayerLog.Tag, "frequency : " + frequency + ", range : " + range);
+            Log.Debug(PlayerLog.Tag, "frequency : " + Frequency + ", range : " + FrequencyRange);
         }
 
         /// <summary>
@@ -56,12 +48,16 @@ namespace Tizen.Multimedia
         /// <exception cref="ArgumentOutOfRangeException">
         ///     <paramref name="value"/> is not inside of <see cref="AudioEffect.BandLevelRange"/>.
         /// </exception>
+        /// <exception cref="InvalidOperationException">
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <since_tizen> 3 </since_tizen>
         public int Level
         {
             get
             {
                 _owner.Player.ValidateNotDisposed();
+                _owner.Player.AudioOffload.CheckDisabled();
 
                 Native.GetEqualizerBandLevel(_owner.Player.Handle, _index, out var value).
                     ThrowIfFailed(_owner.Player, "Failed to get the level of the equalizer band");
@@ -72,6 +68,7 @@ namespace Tizen.Multimedia
             set
             {
                 _owner.Player.ValidateNotDisposed();
+                _owner.Player.AudioOffload.CheckDisabled();
 
                 if (value < _owner.BandLevelRange.Min || _owner.BandLevelRange.Max < value)
                 {
@@ -90,14 +87,42 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Gets the frequency in the dB.
         /// </summary>
+        /// <exception cref="InvalidOperationException">
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <since_tizen> 3 </since_tizen>
-        public int Frequency { get; }
+        public int Frequency
+        {
+            get
+            {
+                _owner.Player.AudioOffload.CheckDisabled();
+
+                Native.GetEqualizerBandFrequency(_owner.Player.Handle, _index, out var frequency).
+                ThrowIfFailed(_owner.Player, "Failed to initialize equalizer band");
+
+                return frequency;
+            }
+        }
 
         /// <summary>
         /// Gets the frequency range in the dB.
         /// </summary>
+        /// <exception cref="InvalidOperationException">
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <since_tizen> 3 </since_tizen>
-        public int FrequencyRange { get; }
+        public int FrequencyRange
+        {
+            get
+            {
+                _owner.Player.AudioOffload.CheckDisabled();
+
+                Native.GetEqualizerBandFrequencyRange(_owner.Player.Handle, _index, out var frequencyRange).
+                ThrowIfFailed(_owner.Player, "Failed to initialize equalizer band");
+
+                return frequencyRange;
+            }
+        }
 
     }
 }
index 6c2c8fc..fd90eee 100644 (file)
@@ -233,11 +233,16 @@ namespace Tizen.Multimedia
         /// </remarks>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="ArgumentException">The value is not valid.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <since_tizen> 3 </since_tizen>
         public AudioLatencyMode AudioLatencyMode
         {
             get
             {
+                AudioOffload.CheckDisabled();
+
                 NativePlayer.GetAudioLatencyMode(Handle, out var value).
                     ThrowIfFailed(this, "Failed to get the audio latency mode of the player");
 
@@ -246,6 +251,7 @@ namespace Tizen.Multimedia
             set
             {
                 ValidateNotDisposed();
+                AudioOffload.CheckDisabled();
 
                 ValidationUtil.ValidateEnum(typeof(AudioLatencyMode), value, nameof(value));
 
@@ -540,13 +546,19 @@ namespace Tizen.Multimedia
         /// <value>If the replaygain status is true, replaygain is applied (if contents has a replaygain tag);
         /// otherwise, the replaygain is not affected by tag and properties.</value>
         /// <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="InvalidOperationException">
+        ///     The player is not in the valid state.
+        ///     -or-<br/>
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <since_tizen> 5 </since_tizen>
         public bool ReplayGain
         {
             get
             {
                 ValidateNotDisposed();
+                AudioOffload.CheckDisabled();
+
                 NativePlayer.IsReplayGain(Handle, out var value).
                     ThrowIfFailed(this, "Failed to get the replaygain of the player");
                 return value;
@@ -554,6 +566,8 @@ namespace Tizen.Multimedia
             set
             {
                 ValidateNotDisposed();
+                AudioOffload.CheckDisabled();
+
                 NativePlayer.SetReplayGain(Handle, value).
                     ThrowIfFailed(this, "Failed to set the replaygain of the player");
             }
@@ -566,7 +580,11 @@ namespace Tizen.Multimedia
         /// <value>The value indicating whether or not AudioPitch is enabled. The default is false.</value>
         /// <remarks>This function is used for audio content only.
         /// To set, the player must be in the <see cref="PlayerState.Idle"/> state.</remarks>
-        /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     The player is not in the valid state.
+        ///     -or-<br/>
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <seealso cref="AudioPitch"/>
         /// <since_tizen> 6 </since_tizen>
@@ -575,6 +593,8 @@ namespace Tizen.Multimedia
             get
             {
                 ValidateNotDisposed();
+                AudioOffload.CheckDisabled();
+
                 NativePlayer.IsAudioPitchEnabled(Handle, out var value).
                     ThrowIfFailed(this, "Failed to get whether the audio pitch is enabled or not");
                 return value;
@@ -583,6 +603,7 @@ namespace Tizen.Multimedia
             set
             {
                 ValidateNotDisposed();
+                AudioOffload.CheckDisabled();
                 ValidatePlayerState(PlayerState.Idle);
 
                 NativePlayer.SetAudioPitchEnabled(Handle, value).
@@ -596,7 +617,11 @@ namespace Tizen.Multimedia
         /// <value>The audio stream pitch value. The default is 1.</value>
         /// <remarks>Enabling pitch control could increase the CPU usage on some devices.
         /// This function is used for audio content only.</remarks>
-        /// <exception cref="InvalidOperationException">A pitch is not enabled.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     A pitch is not enabled.
+        ///     -or-<br/>
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="ArgumentOutOfRangeException">
         ///     value is less than 0.5.
@@ -610,6 +635,7 @@ namespace Tizen.Multimedia
             get
             {
                 ValidateNotDisposed();
+                AudioOffload.CheckDisabled();
 
                 if (AudioPitchEnabled == false)
                 {
@@ -625,6 +651,7 @@ namespace Tizen.Multimedia
             set
             {
                 ValidateNotDisposed();
+                AudioOffload.CheckDisabled();
 
                 if (AudioPitchEnabled == false)
                 {
@@ -677,5 +704,24 @@ namespace Tizen.Multimedia
                 return _adaptiveVariants;
             }
         }
+
+        private AudioOffload _audioOffload;
+
+        /// <summary>
+        /// Gets the setting for audio offload.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public AudioOffload AudioOffload
+        {
+            get
+            {
+                if (_audioOffload == null)
+                {
+                    _audioOffload = new AudioOffload(this);
+                }
+
+                return _audioOffload;
+            }
+        }
     }
 }
index ac1b78f..5188fcb 100644 (file)
@@ -767,6 +767,8 @@ namespace Tizen.Multimedia
         ///     The player is not in the valid state.<br/>
         ///     -or-<br/>
         ///     Streaming playback.
+        ///     -or-<br/>
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
         /// </exception>
         /// <exception cref="ArgumentOutOfRangeException">
         ///     <paramref name="rate"/> is less than -5.0.<br/>
@@ -783,6 +785,7 @@ namespace Tizen.Multimedia
                 throw new ArgumentOutOfRangeException(nameof(rate), rate, "Valid range is -5.0 to 5.0 (except 0.0)");
             }
 
+            AudioOffload.CheckDisabled();
             ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
 
             NativePlayer.SetPlaybackRate(Handle, rate).ThrowIfFailed(this, "Failed to set the playback rate.");
@@ -975,14 +978,17 @@ namespace Tizen.Multimedia
         ///     Operation failed; internal error.
         ///     -or-<br/>
         ///     The player is not in the valid state.
+        ///     -or-<br/>
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
         ///     </exception>
         /// <seealso cref="PlayerAudioExtractOption"/>
         /// <seealso cref="DisableExportingAudioData"/>
         /// <since_tizen> 6 </since_tizen>
         public void EnableExportingAudioData(AudioMediaFormat format, PlayerAudioExtractOption option)
         {
-            ValidatePlayerState(PlayerState.Idle);
             ValidationUtil.ValidateEnum(typeof(PlayerAudioExtractOption), option, nameof(option));
+            AudioOffload.CheckDisabled();
+            ValidatePlayerState(PlayerState.Idle);
 
             _audioFrameDecodedCallback = (IntPtr packetHandle, IntPtr userData) =>
             {
index eeacff2..dda3cc2 100644 (file)
@@ -22,5 +22,6 @@ namespace Tizen.Multimedia
         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";
+        internal const string AudioOffload = "http://tizen.org/feature/multimedia.player.audio_offload";
     }
 }
index fa88af8..4694756 100644 (file)
@@ -48,10 +48,15 @@ namespace Tizen.Multimedia
         /// <see cref="PlayerState.Playing"/>, or <see cref="PlayerState.Paused"/> state.
         /// </remarks>
         /// <exception cref="ObjectDisposedException">The <see cref="Player"/> that this instance belongs to has been disposed of.</exception>
-        /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.</exception>
+        /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.
+        ///     -or-<br/>
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <since_tizen> 3 </since_tizen>
         public int GetCount()
         {
+            _owner.ValidateNotDisposed();
+            _owner.AudioOffload.CheckDisabled();
             _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
 
             NativePlayer.GetTrackCount(_owner.Handle, _streamType, out var count).
@@ -73,7 +78,10 @@ namespace Tizen.Multimedia
         ///     <para>The language codes are defined in ISO 639-1.</para>
         /// </remarks>
         /// <exception cref="ObjectDisposedException">The <see cref="Player"/> that this instance belongs to has been disposed of.</exception>
-        /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.</exception>
+        /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.
+        ///     -or-<br/>
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <exception cref="ArgumentOutOfRangeException">
         ///     <paramref name="index"/> is less than zero.<br/>
         ///     -or-<br/>
@@ -82,7 +90,7 @@ namespace Tizen.Multimedia
         /// <since_tizen> 3 </since_tizen>
         public string GetLanguageCode(int index)
         {
-            _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+            _owner.ValidateNotDisposed();
 
             if (index < 0 || GetCount() <= index)
             {
@@ -90,6 +98,9 @@ namespace Tizen.Multimedia
                     $"Valid index range is 0 <= x < {nameof(GetCount)}(), but got { index }.");
             }
 
+            _owner.AudioOffload.CheckDisabled();
+            _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
             IntPtr code = IntPtr.Zero;
 
             try
@@ -122,7 +133,11 @@ namespace Tizen.Multimedia
         /// <see cref="PlayerState.Playing"/>, or <see cref="PlayerState.Paused"/> state.
         /// </remarks>
         /// <exception cref="ObjectDisposedException">The <see cref="Player"/> that this instance belongs to has been disposed of.</exception>
-        /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     The <see cref="Player"/> that this instance belongs to is not in the valid state.<br/>
+        ///     -or-<br/>
+        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
+        /// </exception>
         /// <exception cref="ArgumentOutOfRangeException">
         ///     <paramref name="value"/> is less than zero.<br/>
         ///     -or-<br/>
@@ -133,6 +148,8 @@ namespace Tizen.Multimedia
         {
             get
             {
+                _owner.ValidateNotDisposed();
+                _owner.AudioOffload.CheckDisabled();
                 _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
 
                 NativePlayer.GetCurrentTrack(_owner.Handle, _streamType, out var value).
@@ -142,12 +159,15 @@ namespace Tizen.Multimedia
             }
             set
             {
+                _owner.ValidateNotDisposed();
+
                 if (value < 0 || GetCount() <= value)
                 {
                     throw new ArgumentOutOfRangeException(nameof(value), value,
                         $"Valid index range is 0 <= x < {nameof(GetCount)}(), but got { value }.");
                 }
 
+                _owner.AudioOffload.CheckDisabled();
                 _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
 
                 NativePlayer.SelectTrack(_owner.Handle, _streamType, value).