[MediaPlayer] Add API to export audio PCM data (#930)
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.MediaPlayer / Interop / Interop.Player.cs
index d49ec44..8c0cf7a 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * 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.Runtime.InteropServices;
 using Tizen;
@@ -21,6 +37,9 @@ internal static partial class Interop
         internal delegate void VideoFrameDecodedCallback(IntPtr packetHandle, IntPtr userData);
 
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void AudioFrameDecodedCallback(IntPtr packetHandle, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate void SubtitleUpdatedCallback(uint duration, string text, IntPtr userData);
 
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
@@ -44,6 +63,8 @@ internal static partial class Interop
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate void SeekCompletedCallback(IntPtr userData);
 
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AdaptiveVariantCallback(int bandwidth, int width, int height, IntPtr userData);
 
         [DllImport(Libraries.Player, EntryPoint = "player_create")]
         internal static extern PlayerErrorCode Create(out PlayerHandle player);
@@ -60,9 +81,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, DisplayType type, IntPtr display);
-
         [DllImport(Libraries.Player, EntryPoint = "player_start")]
         internal static extern PlayerErrorCode Start(IntPtr player);
 
@@ -84,8 +102,14 @@ internal static partial class Interop
         [DllImport(Libraries.Player, EntryPoint = "player_get_volume")]
         internal static extern PlayerErrorCode GetVolume(IntPtr player, out float left, out float right);
 
+        [DllImport(Libraries.Player, EntryPoint = "player_set_replaygain_enabled")]
+        internal static extern PlayerErrorCode SetReplayGain(IntPtr player, bool enabled);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_is_replaygain_enabled")]
+        internal static extern PlayerErrorCode IsReplayGain(IntPtr player, out bool enabled);
+
         [DllImport(Libraries.Player, EntryPoint = "player_set_sound_stream_info")]
-        internal static extern PlayerErrorCode SetAudioPolicyInfo(IntPtr player, IntPtr streamInfo);
+        internal static extern PlayerErrorCode SetAudioPolicyInfo(IntPtr player, AudioStreamPolicyHandle streamInfo);
 
         [DllImport(Libraries.Player, EntryPoint = "player_set_audio_latency_mode")]
         internal static extern PlayerErrorCode SetAudioLatencyMode(IntPtr player, AudioLatencyMode latencyMode);
@@ -100,6 +124,13 @@ internal static partial class Interop
         internal static extern PlayerErrorCode SetPlayPosition(IntPtr player, int millisecond,
             bool accurate, SeekCompletedCallback cb, IntPtr userData = default(IntPtr));
 
+        [DllImport(Libraries.Player, EntryPoint = "player_get_play_position_nsec")]
+        internal static extern PlayerErrorCode GetPlayPositionNanoseconds(IntPtr player, out long nanoseconds);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_set_play_position_nsec")]
+        internal static extern PlayerErrorCode SetPlayPositionNanoseconds(IntPtr player, long nanoseconds,
+            bool accurate, SeekCompletedCallback cb, IntPtr userData = default(IntPtr));
+
         [DllImport(Libraries.Player, EntryPoint = "player_set_mute")]
         internal static extern PlayerErrorCode SetMute(IntPtr player, bool muted);
 
@@ -144,6 +175,13 @@ internal static partial class Interop
         [DllImport(Libraries.Player, EntryPoint = "player_unset_media_packet_video_frame_decoded_cb")]
         internal static extern PlayerErrorCode UnsetVideoFrameDecodedCb(IntPtr player);
 
+        [DllImport(Libraries.Player, EntryPoint = "player_set_media_packet_audio_frame_decoded_cb")]
+        internal static extern PlayerErrorCode SetAudioFrameDecodedCb(IntPtr player, IntPtr format, PlayerAudioExtractOption opt,
+            AudioFrameDecodedCallback callback, IntPtr userData = default(IntPtr));
+
+        [DllImport(Libraries.Player, EntryPoint = "player_unset_media_packet_audio_frame_decoded_cb")]
+        internal static extern PlayerErrorCode UnsetAudioFrameDecodedCb(IntPtr player);
+
         [DllImport(Libraries.Player, EntryPoint = "player_set_streaming_cookie")]
         internal static extern PlayerErrorCode SetStreamingCookie(IntPtr player, string cookie, int size);
 
@@ -153,6 +191,12 @@ internal static partial class Interop
         [DllImport(Libraries.Player, EntryPoint = "player_get_streaming_download_progress")]
         internal static extern PlayerErrorCode GetStreamingDownloadProgress(IntPtr player, out int start, out int current);
 
+        [DllImport(Libraries.Player, EntryPoint = "player_set_streaming_buffering_time")]
+        internal static extern PlayerErrorCode SetStreamingBufferingTime(IntPtr player, int bufferingTime, int reBufferingTime);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_get_streaming_buffering_time")]
+        internal static extern PlayerErrorCode GetStreamingBufferingTime(IntPtr player, out int bufferingTime, out int reBufferingTime);
+
         [DllImport(Libraries.Player, EntryPoint = "player_set_buffering_cb")]
         internal static extern PlayerErrorCode SetBufferingCb(IntPtr player,
             BufferingProgressCallback callback, IntPtr userData = default(IntPtr));
@@ -167,7 +211,7 @@ internal static partial class Interop
         internal static extern PlayerErrorCode PushMediaStream(IntPtr player, IntPtr packet);
 
         [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_info")]
-        internal static extern PlayerErrorCode SetMediaStreamInfo(IntPtr player, int type, IntPtr format);
+        internal static extern PlayerErrorCode SetMediaStreamInfo(IntPtr player, StreamType type, IntPtr format);
 
         [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_buffer_status_cb")]
         internal static extern PlayerErrorCode SetMediaStreamBufferStatusCb(IntPtr player, StreamType type,
@@ -195,54 +239,6 @@ internal static partial class Interop
         [DllImport(Libraries.Player, EntryPoint = "player_get_media_stream_buffer_min_threshold")]
         internal static extern PlayerErrorCode GetMediaStreamBufferMinThreshold(IntPtr player, int type, out uint percent);
 
-        [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_bands_count")]
-        internal static extern PlayerErrorCode AudioEffectGetEqualizerBandsCount(IntPtr player, out int count);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_set_equalizer_band_level")]
-        internal static extern PlayerErrorCode AudioEffectSetEqualizerBandLevel(IntPtr player, int index, int level);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_band_level")]
-        internal static extern PlayerErrorCode AudioEffectGetEqualizerBandLevel(IntPtr player, int index, out int level);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_set_equalizer_all_bands")]
-        internal static extern PlayerErrorCode AudioEffectSetEqualizerAllBands(IntPtr player, out int band_levels, int length);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_level_range")]
-        internal static extern PlayerErrorCode AudioEffectGetEqualizerLevelRange(IntPtr player, out int min, out int max);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_band_frequency")]
-        internal static extern PlayerErrorCode AudioEffectGetEqualizerBandFrequency(IntPtr player, int index, out int frequency);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_band_frequency_range")]
-        internal static extern PlayerErrorCode AudioEffectGetEqualizerBandFrequencyRange(IntPtr player, int index, out int range);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_equalizer_clear")]
-        internal static extern PlayerErrorCode AudioEffectEqualizerClear(IntPtr player);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_audio_effect_equalizer_is_available")]
-        internal static extern PlayerErrorCode AudioEffectEqualizerIsAvailable(IntPtr player, out bool available);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_set_display_mode")]
-        internal static extern PlayerErrorCode SetDisplayMode(IntPtr player, PlayerDisplayMode mode);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_get_display_mode")]
-        internal static extern PlayerErrorCode GetDisplayMode(IntPtr player, out int mode);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_set_display_visible")]
-        internal static extern PlayerErrorCode SetDisplayVisible(IntPtr player, bool visible);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_is_display_visible")]
-        internal static extern PlayerErrorCode IsDisplayVisible(IntPtr player, out bool visible);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_set_display_rotation")]
-        internal static extern PlayerErrorCode SetDisplayRotation(IntPtr player, PlayerDisplayRotation rotation);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_get_display_rotation")]
-        internal static extern PlayerErrorCode GetDisplayRotation(IntPtr player, out int rotation);
-
-        [DllImport(Libraries.Player, EntryPoint = "player_set_display_roi_area")]
-        internal static extern PlayerErrorCode SetDisplayRoi(IntPtr player, int x, int y, int width, int height);
-
         [DllImport(Libraries.Player, EntryPoint = "player_get_content_info")]
         internal static extern PlayerErrorCode GetContentInfo(IntPtr player, StreamMetadataKey key, out IntPtr value);
 
@@ -264,6 +260,9 @@ internal static partial class Interop
         [DllImport(Libraries.Player, EntryPoint = "player_get_duration")]
         internal static extern PlayerErrorCode GetDuration(IntPtr player, out int duration);
 
+        [DllImport(Libraries.Player, EntryPoint = "player_get_duration_nsec")]
+        internal static extern PlayerErrorCode GetDurationNanoseconds(IntPtr player, out long duration);
+
         [DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_path")]
         internal static extern PlayerErrorCode SetSubtitlePath(IntPtr player, string path);
 
@@ -285,16 +284,81 @@ internal static partial class Interop
         internal static extern PlayerErrorCode UnsetVideoStreamChangedCb(IntPtr player);
 
         [DllImport(Libraries.Player, EntryPoint = "player_get_track_count")]
-        internal static extern PlayerErrorCode GetTrackCount(IntPtr player, int type, out int count);
+        internal static extern PlayerErrorCode GetTrackCount(IntPtr player, StreamType type, out int count);
 
         [DllImport(Libraries.Player, EntryPoint = "player_select_track")]
-        internal static extern PlayerErrorCode SelectTrack(IntPtr player, int type, int index);
+        internal static extern PlayerErrorCode SelectTrack(IntPtr player, StreamType type, int index);
 
         [DllImport(Libraries.Player, EntryPoint = "player_get_current_track")]
-        internal static extern PlayerErrorCode GetCurrentTrack(IntPtr player, int type, out int index);
+        internal static extern PlayerErrorCode GetCurrentTrack(IntPtr player, StreamType type,
+            out int index);
 
         [DllImport(Libraries.Player, EntryPoint = "player_get_track_language_code")]
-        internal static extern PlayerErrorCode GetTrackLanguageCode(IntPtr player, int type, int index, out IntPtr code);
+        internal static extern PlayerErrorCode GetTrackLanguageCode(IntPtr player, StreamType type,
+            int index, out IntPtr code);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_set_audio_only")]
+        internal static extern PlayerErrorCode SetAudioOnly(IntPtr player, bool audioOnly);
+
+        [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);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_360_set_zoom_with_field_of_view")]
+        internal static extern PlayerErrorCode SetZoomWithFieldOfView(IntPtr player, float level, int horizontalDegrees, int verticalDegrees);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_foreach_adaptive_variant")]
+        internal static extern PlayerErrorCode ForeachAdaptiveVariants(IntPtr player, AdaptiveVariantCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_set_max_adaptive_variant_limit")]
+        internal static extern PlayerErrorCode SetMaxLimit(IntPtr player, int bandwidth, int width, int height);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_get_max_adaptive_variant_limit")]
+        internal static extern PlayerErrorCode GetMaxLimit(IntPtr player, out int bandwidth, out int width, out int height);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_set_video_roi_area")]
+        internal static extern PlayerErrorCode SetVideoRoi(IntPtr player, double scaleX, double scaleY, double scaleWidth, double scaleHeight);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_get_video_roi_area")]
+        internal static extern PlayerErrorCode GetVideoRoi(IntPtr player, out double scaleX, out double scaleY, out double scaleWidth, out double scaleHeight);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_audio_pitch_set_enabled")]
+        internal static extern PlayerErrorCode SetAudioPitchEnabled(IntPtr player, bool enabled);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_audio_pitch_is_enabled")]
+        internal static extern PlayerErrorCode IsAudioPitchEnabled(IntPtr player, out bool enabled);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_audio_pitch_set_value")]
+        internal static extern PlayerErrorCode SetAudioPitch(IntPtr player, float level);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_audio_pitch_get_value")]
+        internal static extern PlayerErrorCode GetAudioPitch(IntPtr player, out float level);
     }
 
     internal class PlayerHandle : SafeHandle
@@ -303,6 +367,11 @@ internal static partial class Interop
         {
         }
 
+        internal PlayerHandle(IntPtr rawHandle) : this()
+        {
+            handle = rawHandle;
+        }
+
         public override bool IsInvalid => handle == IntPtr.Zero;
 
         protected override bool ReleaseHandle()