Implemented Events and Async methods.
Rebased spec file with new package name
Change-Id: I93793be5528f3fadbd2fa2be8026f5d46dc279ec
Signed-off-by: Ravi Kiran K N <ravi.kiran@samsung.com>
Requires(postun): mono-core
# P/Invoke Dependencies
BuildRequires: pkgconfig(capi-media-player)
+BuildRequires: pkgconfig(csapi-tizen)
# P/Invoke Runtime Dependencies
# TODO: It should be removed after fix tizen-rpm-config
#Requires: capi-multimedia-device
cp %{SOURCE1} .
%build
# build dll
-mcs -target:library -out:%{dllname} -keyfile:Tizen.Multimedia/Tizen.Multimedia.snk \
+mcs -target:library -out:%{dllname} -keyfile:Tizen.Multimedia/Tizen.Multimedia.snk -pkg:'csapi-tizen' \
Tizen.Multimedia/Properties/AssemblyInfo.cs \
Tizen.Multimedia/Player/*.cs \
Tizen.Multimedia/Interop/*.cs
internal static partial class Interop
{
- internal static partial class PlayerInterop
+ internal static partial class Player
{
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate bool MediaTagCallback(IntPtr tagHandle, IntPtr UserData);
-
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void PlaybackCompletedCallback(IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void PlaybackInterruptedCallback(int code, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void PlaybackErrorCallback(int code, IntPtr userData);
+
+ //[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ //internal delegate void VideoFrameDecodedCallback(MediaPacket packet, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void SubtitleUpdatedCallback(ulong duration, string text, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void BufferingProgressCallback(int percent, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ProgressiveDownloadMessageCallback(int type, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VideoStreamChangedCallback(int width, int height, int fps, int bitrate, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void BufferStatusCallback(int status, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void SeekOffsetChangedCallback(UInt64 offset, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VideoCaptureCallback(byte[] data, int width, int height, uint size, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void PrepareCallback(IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void SeekCompletedCallback(IntPtr userData);
+
+
[DllImport(Libraries.Player, EntryPoint = "player_create")]
internal static extern int Create(out IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_prepare")]
internal static extern int Prepare(IntPtr player);
+ [DllImport(Libraries.Player, EntryPoint = "player_prepare_async")]
+ internal static extern int PrepareAsync(IntPtr player, PrepareCallback cb, IntPtr userData);
+
[DllImport(Libraries.Player, EntryPoint = "player_unprepare")]
internal static extern int Unprepare(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_get_play_position")]
internal static extern int GetPlayPosition(IntPtr player, out int millisecond);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_play_position")]
+ internal static extern int SetPlayPosition(IntPtr player, int millisecond, bool accurate, SeekCompletedCallback cb, IntPtr userData);
+
[DllImport(Libraries.Player, EntryPoint = "player_set_mute")]
internal static extern int SetMute(IntPtr player, bool muted);
[DllImport(Libraries.Player, EntryPoint = "player_is_looping")]
internal static extern int IsLooping(IntPtr player, out bool looping);
- //[DllImport(Libraries.Player, EntryPoint = "player_set_completed_cb")]
- //internal static extern int SetCompletedCb(IntPtr player, player_completed_cb callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_completed_cb")]
+ internal static extern int SetCompletedCb(IntPtr player, PlaybackCompletedCallback callback, IntPtr user_data);
[DllImport(Libraries.Player, EntryPoint = "player_unset_completed_cb")]
internal static extern int UnsetCompletedCb(IntPtr player);
- //[DllImport(Libraries.Player, EntryPoint = "player_set_interrupted_cb")]
- //internal static extern int SetInterruptedCb(IntPtr player, player_interrupted_cb callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_interrupted_cb")]
+ internal static extern int SetInterruptedCb(IntPtr player, PlaybackInterruptedCallback callback, IntPtr user_data);
[DllImport(Libraries.Player, EntryPoint = "player_unset_interrupted_cb")]
internal static extern int UnsetInterruptedCb(IntPtr player);
- //[DllImport(Libraries.Player, EntryPoint = "player_set_error_cb")]
- //internal static extern int SetErrorCb(IntPtr player, player_error_cb callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_error_cb")]
+ internal static extern int SetErrorCb(IntPtr player, PlaybackErrorCallback callback, IntPtr user_data);
[DllImport(Libraries.Player, EntryPoint = "player_unset_error_cb")]
internal static extern int UnsetErrorCb(IntPtr player);
- //[DllImport(Libraries.Player, EntryPoint = "player_capture_video")]
- //internal static extern int CaptureVideo(IntPtr player, player_video_captured_cb callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_capture_video")]
+ internal static extern int CaptureVideo(IntPtr player, VideoCaptureCallback callback, IntPtr user_data);
//[DllImport(Libraries.Player, EntryPoint = "player_set_media_packet_video_frame_decoded_cb")]
- //internal static extern int SetMediaPacketVideoFrameDecodedCb(IntPtr player, player_media_packet_video_decoded_cb callback, IntPtr user_data);
+ //internal static extern int SetMediaPacketVideoFrameDecodedCb(IntPtr player, _videoFrameDecodedCallback callback, IntPtr user_data);
[DllImport(Libraries.Player, EntryPoint = "player_unset_media_packet_video_frame_decoded_cb")]
internal static extern int UnsetMediaPacketVideoFrameDecodedCb(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_get_streaming_download_progress")]
internal static extern int GetStreamingDownloadProgress(IntPtr player, out int start, out int current);
- //[DllImport(Libraries.Player, EntryPoint = "player_set_buffering_cb")]
- //internal static extern int SetBufferingCb(IntPtr player, player_buffering_cb callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_buffering_cb")]
+ internal static extern int SetBufferingCb(IntPtr player, BufferingProgressCallback callback, IntPtr user_data);
[DllImport(Libraries.Player, EntryPoint = "player_unset_buffering_cb")]
internal static extern int UnsetBufferingCb(IntPtr player);
//[DllImport(Libraries.Player, EntryPoint = "player_get_progressive_download_status")]
//internal static extern int GetProgressiveDownloadStatus(IntPtr player, unsigned long *current, unsigned long *total_size);
- //[DllImport(Libraries.Player, EntryPoint = "player_set_progressive_download_message_cb")]
- //internal static extern int SetProgressiveDownloadMessageCb(IntPtr player, player_pd_message_cb callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_progressive_download_message_cb")]
+ internal static extern int SetProgressiveDownloadMessageCb(IntPtr player, ProgressiveDownloadMessageCallback callback, IntPtr user_data);
[DllImport(Libraries.Player, EntryPoint = "player_unset_progressive_download_message_cb")]
internal static extern int UnsetProgressiveDownloadMessageCb(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_info")]
internal static extern int SetMediaStreamInfo(IntPtr player, int type, IntPtr format);
- //[DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_buffer_status_cb")]
- //internal static extern int SetMediaStreamBufferStatusCb(IntPtr player, int type, player_media_stream_buffer_status_cb callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_buffer_status_cb")]
+ internal static extern int SetMediaStreamBufferStatusCb(IntPtr player, int type, BufferStatusCallback callback, IntPtr user_data);
[DllImport(Libraries.Player, EntryPoint = "player_unset_media_stream_buffer_status_cb")]
internal static extern int UnsetMediaStreamBufferStatusCb(IntPtr player, int type);
- //[DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_seek_cb")]
- //internal static extern int SetMediaStreamSeekCb(IntPtr player, int type, player_media_stream_seek_cb callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_seek_cb")]
+ internal static extern int SetMediaStreamSeekCb(IntPtr player, int type, SeekOffsetChangedCallback callback, IntPtr user_data);
[DllImport(Libraries.Player, EntryPoint = "player_unset_media_stream_seek_cb")]
internal static extern int UnsetMediaStreamSeekCb(IntPtr player, int type);
[DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_path")]
internal static extern int SetSubtitlePath(IntPtr player, string path);
- //[DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_updated_cb")]
- //internal static extern int SetSubtitleUpdatedCb(IntPtr player, player_subtitle_updated_cb callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_updated_cb")]
+ internal static extern int SetSubtitleUpdatedCb(IntPtr player, SubtitleUpdatedCallback callback, IntPtr user_data);
[DllImport(Libraries.Player, EntryPoint = "player_unset_subtitle_updated_cb")]
internal static extern int UnsetSubtitleUpdatedCb(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_position_offset")]
internal static extern int SetSubtitlePositionOffset(IntPtr player, int millisecond);
- //[DllImport(Libraries.Player, EntryPoint = "player_set_video_stream_changed_cb")]
- //internal static extern int SetVideoStreamChangedCb(IntPtr player, player_video_stream_changed_cb callback, IntPtr user_data);
+ [DllImport(Libraries.Player, EntryPoint = "player_set_video_stream_changed_cb")]
+ internal static extern int SetVideoStreamChangedCb(IntPtr player, VideoStreamChangedCallback callback, IntPtr user_data);
[DllImport(Libraries.Player, EntryPoint = "player_unset_video_stream_changed_cb")]
internal static extern int UnsetVideoStreamChangedCb(IntPtr player);
{
set
{
+ int ret;
_bands = value;
foreach(EqualizerBand band in _bands)
{
- if (Interop.PlayerInterop.AudioEffectSetEqualizerBandLevel (_playerHandle, _bands.IndexOf (band), band.Level) != 0) {
- // throw Exception;
+ ret = Interop.Player.AudioEffectSetEqualizerBandLevel (_playerHandle, _bands.IndexOf (band), band.Level);
+ if ( ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to set equalizer band" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Failed to set equalizer band");
}
}
{
get
{
- int min, max;
- if (Interop.PlayerInterop.AudioEffectGetEqualizerLevelRange (_playerHandle, out min, out max) != 0) {
- //throw Exception;
+ int min, max, ret;
+ ret = Interop.Player.AudioEffectGetEqualizerLevelRange (_playerHandle, out min, out max);
+ if ( ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get min level" + (PlayerError)ret);
}
return min;
}
{
get
{
- int min, max;
- if (Interop.PlayerInterop.AudioEffectGetEqualizerLevelRange (_playerHandle, out min, out max) != 0) {
- //throw Exception;
+ int min, max, ret;
+ ret = Interop.Player.AudioEffectGetEqualizerLevelRange (_playerHandle, out min, out max);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get max level" + (PlayerError)ret);
}
return max;
}
get
{
bool available = false;
- if (Interop.PlayerInterop.AudioEffectEqualizerIsAvailable (_playerHandle, out available) != 0) {
- //throw Exception;
+ int ret = Interop.Player.AudioEffectEqualizerIsAvailable (_playerHandle, out available);
+ if ( ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get equalizer availability" + (PlayerError)ret);
}
return available;
}
}
}
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public BufferStatusEventArgs(StreamingBufferStatus status, StreamType type)
+ {
+ _status = status;
+ _streamType = type;
+ }
+
internal StreamingBufferStatus _status;
internal StreamType _streamType;
}
}
+ /// <summary>
+ /// constructor </summary>
+ public BufferingProgressEventArgs(int percent)
+ {
+ _percent = percent;
+ }
+
+
internal int _percent;
}
{
set
{
- if (Interop.PlayerInterop.SetDisplayMode (_playerHandle, (int)value) == 0) {
+ int ret = Interop.Player.SetDisplayMode (_playerHandle, (int)value);
+ if ( ret == (int)PlayerError.None)
+ {
_displayMode = value;
- } else {
- //throw Exception
+ }
+ else
+ {
+ Log.Error (PlayerLog.LogTag, "Setting display mode failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting display mode failed");
}
}
get
{
set
{
- if (Interop.PlayerInterop.SetDisplayVisible (_playerHandle, value) == 0) {
+ int ret = Interop.Player.SetDisplayVisible (_playerHandle, value);
+ if (ret == (int)PlayerError.None)
+ {
_isVisible = value;
- } else {
- //throw Exception
+ }
+ else
+ {
+ Log.Error (PlayerLog.LogTag, "Setting display visible failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting display visible failed");
}
}
get
{
set
{
- if (Interop.PlayerInterop.SetDisplayRotation (_playerHandle, (int)value) == 0) {
+ int ret = Interop.Player.SetDisplayRotation (_playerHandle, (int)value);
+ if (ret == (int)PlayerError.None)
+ {
_rotation = value;
- } else {
- //throw Exception
+ } else
+ {
+ Log.Error (PlayerLog.LogTag, "Setting display rotation failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting display rotation failed");
}
}
get
public class DownloadProgress
{
/// <summary>
- /// Get Start position in percentage.
+ /// Set/Get Start position in percentage.
/// </summary>
/// <value> 0 to 100 </value>
- public int Start;
+ public int Start
+ {
+ set
+ {
+ _start = value;
+ }
+ get
+ {
+ return _start;
+ }
+ }
/// <summary>
- /// Get Current position in percentage.
+ /// Set/Get Current position in percentage.
/// </summary>
/// <value> 0 to 100 </value>
- public int Current;
+ public int Current
+ {
+ set
+ {
+ _current = value;
+ }
+ get
+ {
+ return _current;
+ }
+ }
+
+ internal int _start;
+ internal int _current;
}
}
\ No newline at end of file
/// Set/Get new gain in decibel that is set to the given band [dB]
/// </summary>
/// <value> int level </value>
- public int Level { set; get;}
+ public int Level
+ {
+ set
+ {
+ _level = value;
+ }
+ get
+ {
+ return _level;
+ }
+ }
/// <summary>
/// Get frequency of the given band [dB] .
}
}
+ internal int _level;
internal int _frequency;
internal int _range;
}
{
public MediaBufferSource (byte[] buffer)
{
+ _buffer = buffer;
}
+
+ internal byte[] _buffer;
}
}
public class MediaStreamConfiguration
{
+ #if _MEDIA_FORMAT_
+ TODO: Uncomment this when MediaFormat is implemented.
+ private EventHandler<BufferStatusEventArgs> _bufferStatusChanged;
+ private Interop.Player.BufferStatusCallback _bufferStatusChangedCallback;
+
+ private EventHandler<SeekOffsetEventArgs> _seekOffsetChanged;
+ private Interop.Player.SeekOffsetChangedCallback _seekOffsetChangedCallback;
/// <summary>
/// BufferStatusChanged event is raised when buffer underrun or overflow occurs.
/// </summary>
- public event EventHandler<BufferStatusEventArgs> BufferStatusChanged;
+ public event EventHandler<BufferStatusEventArgs> BufferStatusChanged
+ {
+ add
+ {
+ if(_bufferStatusChanged == null) {
+ RegisterBufferStatusEvent();
+ }
+ _bufferStatusChanged += value;
+ }
+ remove
+ {
+ _bufferStatusChanged -= value;
+ if (_bufferStatusChanged == null) {
+ UnregisterBufferStatusEvent ();
+ }
+ }
+ }
+
+ private void RegisterBufferStatusEvent()
+ {
+ _bufferStatusChangedCallback = (int status, IntPtr userData) =>
+ {
+ BufferStatusEventArgs eventArgs = new BufferStatusEventArgs();
+ _bufferStatusChanged.Invoke(this, eventArgs);
+ };
+ Interop.Player.SetSubtitleUpdatedCb (_playerHandle, _bufferStatusChangedCallback, IntPtr.Zero);
+ }
+
+ private void UnregisterBufferStatusEvent()
+ {
+ Interop.Player.UnsetMediaStreamBufferStatusCb (_playerHandle);
+ }
+
/// <summary>
/// SeekOffsetChanged event is raised when seeking occurs.
/// </summary>
- public event EventHandler<SeekOffsetEventArgs> SeekOffsetChanged;
+ public event EventHandler<SeekOffsetEventArgs> SeekOffsetChanged
+ {
+ add
+ {
+ if(_seekOffsetChanged == null) {
+ RegisterSeekOffsetChangedEvent();
+ }
+ _seekOffsetChanged += value;
+ }
+ remove
+ {
+ _seekOffsetChanged -= value;
+ if (_seekOffsetChanged == null) {
+ UnregisterSeekOffsetChangedEvent ();
+ }
+ }
+ }
+
+ private void RegisterSeekOffsetChangedEvent()
+ {
+ _seekOffsetChangedCallback = (UInt64 offset, IntPtr userData) =>
+ {
+ SeekOffsetEventArgs eventArgs = new SeekOffsetEventArgs();
+ _seekOffsetChanged.Invoke(this, eventArgs);
+ };
+ Interop.Player.SetMediaStreamSeekCb (_playerHandle, _seekOffsetChangedCallback, IntPtr.Zero);
+ }
+ private void UnregisterSeekOffsetChangedEvent()
+ {
+ Interop.Player.UnsetMediaStreamSeekCb (_playerHandle);
+ }
+ #endif
/// <summary>
/// max size bytes of buffer </summary>
/// <value> Max size in bytes </value>
- public ulong BufferMaxSize { get; set; }
+ public ulong BufferMaxSize
+ {
+ get
+ {
+ return _maxSize;
+ }
+ set
+ {
+ _maxSize = value;
+ }
+ }
/// <summary>
/// Min threshold </summary>
/// <value> min threshold in bytes </value>
- public uint BufferMinThreshold { get; set; }
+ public uint BufferMinThreshold
+ {
+ set
+ {
+ _minThreshold = value;
+ }
+ get
+ {
+ return _minThreshold;
+ }
+ }
+
+ internal ulong _maxSize;
+ internal uint _minThreshold;
}
}
}
}
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public PlaybackErrorEventArgs(int errorCode)
+ {
+ _errorCode = errorCode;
+ }
+
internal int _errorCode;
}
}
}
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ public PlaybackInterruptedEventArgs(int interruptedCode)
+ {
+ _interruptedCode = interruptedCode;
+ }
+
internal int _interruptedCode;
}
}
\ No newline at end of file
namespace Tizen.Multimedia
{
+ static internal class PlayerLog
+ {
+ internal const string LogTag = "Tizen.Multimedia.Player";
+ }
/// <summary>
/// The Player class provides APIs required for playback.
/// </remarks>
public class Player
{
- /// <summary>
+ private EventHandler<PlaybackCompletedEventArgs> _playbackCompleted;
+ private Interop.Player.PlaybackCompletedCallback _playbackCompletedCallback;
+
+ private EventHandler<PlaybackInterruptedEventArgs> _playbackInterrupted;
+ private Interop.Player.PlaybackInterruptedCallback _playbackInterruptedCallback;
+
+ private EventHandler<PlaybackErrorEventArgs> _playbackError;
+ private Interop.Player.PlaybackErrorCallback _playbackErrorCallback;
+
+ //TODO: Uncomment this after MediaPacket is implemented.
+ //private EventHandler<VideoFrameDecodedEventArgs> _videoFrameDecoded;
+ //private Interop.Player.VideoFrameDecodedCallback _videoFrameDecodedCallback;
+
+ /// <summary>
/// PlaybackCompleted event is raised when playback of a media is finished
/// </summary>
- public event EventHandler<PlaybackCompletedEventArgs> PlaybackCompleted;
+ public event EventHandler<PlaybackCompletedEventArgs> PlaybackCompleted
+ {
+ add
+ {
+ if(_playbackCompleted == null) {
+ RegisterPlaybackCompletedEvent();
+ }
+ _playbackCompleted += value;
+
+ }
+ remove
+ {
+ _playbackCompleted -= value;
+ if (_playbackCompleted == null) {
+ UnregisterPlaybackCompletedEvent();
+ }
+ }
+ }
+
+ private void RegisterPlaybackCompletedEvent()
+ {
+ _playbackCompletedCallback = (IntPtr userData) =>
+ {
+ PlaybackCompletedEventArgs eventArgs = new PlaybackCompletedEventArgs();
+ _playbackCompleted.Invoke(this, eventArgs);
+ };
+ int ret = Interop.Player.SetCompletedCb (_playerHandle, _playbackCompletedCallback, IntPtr.Zero);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Setting PlaybackCompleted callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting PlaybackCompleted callback failed");
+ }
+
+ }
+
+ private void UnregisterPlaybackCompletedEvent()
+ {
+ int ret = Interop.Player.UnsetCompletedCb (_playerHandle);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Unsetting PlaybackCompleted callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Unsetting PlaybackCompleted callback failed");
+ }
+
+ }
/// <summary>
/// PlaybackInterruped event is raised when playback of a media is interrupted
/// </summary>
- public event EventHandler<PlaybackInterruptedEventArgs> PlaybackInterruped;
+ public event EventHandler<PlaybackInterruptedEventArgs> PlaybackInterruped
+ {
+ add
+ {
+ if(_playbackInterrupted == null) {
+ RegisterPlaybackInterruptedEvent();
+ }
+ _playbackInterrupted += value;
+ }
+ remove
+ {
+ _playbackInterrupted -= value;
+ if (_playbackInterrupted == null) {
+ UnregisterPlaybackInterruptedEvent();
+ }
+ }
+ }
+
+ private void RegisterPlaybackInterruptedEvent()
+ {
+ _playbackInterruptedCallback = (int code, IntPtr userData) =>
+ {
+ PlaybackInterruptedEventArgs eventArgs = new PlaybackInterruptedEventArgs(code);
+ _playbackInterrupted.Invoke(this, eventArgs);
+ };
+ int ret = Interop.Player.SetInterruptedCb (_playerHandle, _playbackInterruptedCallback, IntPtr.Zero);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Setting PlaybackInterrupted callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting PlaybackInterrupted callback failed");
+ }
+
+ }
+
+ private void UnregisterPlaybackInterruptedEvent()
+ {
+ int ret = Interop.Player.UnsetInterruptedCb (_playerHandle);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Unsetting PlaybackInterrupted callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Unsetting PlaybackInterrupted callback failed");
+ }
+ }
/// <summary>
/// PlaybackErrorOccured event is raised when any error occurs
/// </summary>
- public event EventHandler<PlaybackErrorEventArgs> PlaybackErrorOccured;
+ public event EventHandler<PlaybackErrorEventArgs> PlaybackErrorOccured
+ {
+ add
+ {
+ if(_playbackError == null) {
+ RegisterPlaybackErrorEvent();
+ }
+ _playbackError += value;
+ }
+ remove
+ {
+ _playbackError -= value;
+ if (_playbackError == null) {
+ UnregisterPlaybackErrorEvent ();
+ }
+ }
+ }
+ private void RegisterPlaybackErrorEvent()
+ {
+ _playbackErrorCallback = (int code, IntPtr userData) =>
+ {
+ PlaybackErrorEventArgs eventArgs = new PlaybackErrorEventArgs(code);
+ _playbackError.Invoke(this, eventArgs);
+ };
+ int ret = Interop.Player.SetErrorCb (_playerHandle, _playbackErrorCallback, IntPtr.Zero);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Setting PlaybackError callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting PlaybackError callback failed");
+ }
+
+ }
+
+ private void UnregisterPlaybackErrorEvent()
+ {
+ int ret = Interop.Player.UnsetErrorCb (_playerHandle);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Unsetting PlaybackError callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Unsetting PlaybackError callback failed");
+ }
+
+ }
+
+
+ #if _MEDIA_PACKET_
+ TODO: Uncomment this after MediaPacket is implemented.
/// <summary>
/// VideoFrameCaptured event is raised when a video frame is decoded
/// </summary>
- public event EventHandler<VideoFrameDecodedEventArgs> VideoFrameDecoded;
+ public event EventHandler<VideoFrameDecodedEventArgs> VideoFrameDecoded
+ {
+ add
+ {
+ if(_videoFrameDecoded == null) {
+ RegisterVideoFrameDecodedEvent ();
+ }
+ _videoFrameDecoded += value;
+ }
+ remove
+ {
+ _videoFrameDecoded -= value;
+ if (_videoFrameDecoded == null) {
+ UnregisterVideoFrameDecodedEvent ();
+ }
+ }
+ }
+
+ private void RegisterVideoFrameDecodedEvent()
+ {
+ _videoFrameDecoded = (MediaPacket packet, IntPtr userData) =>
+ {
+ VideoFrameDecodedEventArgs eventArgs = new VideoFrameDecodedEventArgs();
+ _videoFrameDecoded.Invoke(this, eventArgs);
+ };
+ Interop.Player.SetErrorCb (_playerHandle, _videoFrameDecodedCallback, IntPtr.Zero);
+ }
+
+ private void UnregisterVideoFrameDecodedEvent()
+ {
+ Interop.Player.UnsetMediaPacketVideoFrameDecodedCb (_playerHandle);
+ }
+ #endif
+
/// <summary>
/// Get Player state.
get
{
int state;
- if (Interop.PlayerInterop.GetState (_playerHandle, out state) != 0) {
- //throw Exception;
- }
+ int ret = Interop.Player.GetState (_playerHandle, out state);
+
+ if (ret != (int)PlayerError.None)
+ PlayerErrorFactory.ThrowException (ret, "Get player state failed");
+
return (PlayerState)state;
}
}
{
set
{
- if (Interop.PlayerInterop.SetVolume (_playerHandle, value, _rightVolume) == 0)
+ int ret = Interop.Player.SetVolume (_playerHandle, value, _rightVolume);
+
+ if (ret == (int)PlayerError.None)
+ {
_leftVolume = value;
- //else
- // throw Exception;
+ }
+ else
+ {
+ Log.Error (PlayerLog.LogTag, "Set volume failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "set volume failed");
+ }
}
get
{
- //Interop.PlayerInterop.GetVolume (_playerHandle, out _leftVolume, out _rightVolume);
+ //Interop.Player.GetVolume (_playerHandle, out _leftVolume, out _rightVolume);
return _leftVolume;
}
}
{
set
{
- if ( Interop.PlayerInterop.SetVolume (_playerHandle, _leftVolume, value) == 0 )
+ int ret = Interop.Player.SetVolume (_playerHandle, _leftVolume, value);
+
+ if (ret == (int)PlayerError.None)
+ {
_rightVolume = value;
- //else
- // throw Exception;
+ }
+ else
+ {
+ Log.Error (PlayerLog.LogTag, "Set volume failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "set volume failed");
+ }
}
get
{
- //Interop.PlayerInterop.GetVolume (_playerHandle, out _leftVolume, out _rightVolume);
+ //Interop.Player.GetVolume (_playerHandle, out _leftVolume, out _rightVolume);
return _rightVolume;
}
}
{
set
{
- if (_audioLatencyMode != (int)value && Interop.PlayerInterop.SetAudioLatencyMode (_playerHandle, (int)value) == 0)
- _audioLatencyMode = (int) value;
- //else
- // throw Exception;
+ if (_audioLatencyMode != (int)value)
+ {
+ int ret = Interop.Player.SetAudioLatencyMode (_playerHandle, (int)value);
+ if (ret != (int)PlayerError.None) {
+ Log.Error (PlayerLog.LogTag, "Set audio latency mode failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "set audio latency mode failed");
+ }
+ else
+ {
+ _audioLatencyMode = (int)value;
+ }
+ }
}
get
{
set
{
- if (_mute != value && Interop.PlayerInterop.SetMute (_playerHandle, value) == 0)
- _mute = value;
- //else
- // throw Exception;
+ if (_mute != value)
+ {
+ int ret = Interop.Player.SetMute (_playerHandle, value);
+ if (ret != (int)PlayerError.None) {
+ Log.Error (PlayerLog.LogTag, "Set mute failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "set mute failed");
+ }
+ else
+ {
+ _mute = value;
+ }
+ }
}
get
{
- //Interop.PlayerInterop.IsMuted (_playerHandle, out _mute);
+ //Interop.Player.IsMuted (_playerHandle, out _mute);
return _mute;
}
}
{
set
{
- if (_isLooping != value && Interop.PlayerInterop.SetLooping (_playerHandle, value) == 0)
- _isLooping = value;
- //else
- // throw Exception;
+ if (_isLooping != value)
+ {
+ int ret = Interop.Player.SetLooping (_playerHandle, value);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Set loop failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "set loop failed");
+ }
+ else
+ {
+ _isLooping = value;
+ }
+ }
}
get
{
- //Interop.PlayerInterop.IsLooping (_playerHandle, out _isLooping);
+ //Interop.Player.IsLooping (_playerHandle, out _isLooping);
return _isLooping;
}
}
{
set
{
- if (Interop.PlayerInterop.SetPlaybackRate (_playerHandle, value) != 0) {
- //throw Exception;
+ int ret = Interop.Player.SetPlaybackRate (_playerHandle, value);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Set playback rate failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "set playback rate failed");
}
}
}
/// Set/Get sound type.
/// </summary>
/// <value> System, Notification, Alarm, Ringtone, Media, Call, Voip, Voice </value>
- public SoundType PlayerSoundType
+ public AudioType PlayerAudioType
{
set
{
- if (_soundType != value && Interop.PlayerInterop.SetSoundType (_playerHandle, (int)value) != 0)
- _soundType = value;
- //else
- // throw Exception;
+ if (_audioType != value)
+ {
+ int ret = Interop.Player.SetSoundType (_playerHandle, (int)value);
+ if (ret != (int)PlayerError.None) {
+ Log.Error (PlayerLog.LogTag, "Set audio type failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "set audio type failed");
+ }
+ else
+ {
+ _audioType = value;
+ }
+ }
+
}
get
{
- return _soundType;
+ return _audioType;
}
}
get
{
int playPosition;
- if (Interop.PlayerInterop.GetPlayPosition (_playerHandle, out playPosition) != 0) {
- //throw Exception;
- }
+ int ret = Interop.Player.GetPlayPosition (_playerHandle, out playPosition);
+ if (ret != (int)PlayerError.None)
+ Log.Error (PlayerLog.LogTag, "Failed to get play position, " + (PlayerError)ret);
return playPosition;
}
}
/// Player constructor.</summary>
public Player()
{
- // Throw exception on error returns?
- Interop.PlayerInterop.Create (out _playerHandle);
+ int ret;
+
+ ret = Interop.Player.Create (out _playerHandle);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to create player" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Failed to create player");
+ }
// Initial get values
- Interop.PlayerInterop.GetVolume (_playerHandle, out _leftVolume, out _rightVolume);
- Interop.PlayerInterop.GetAudioLatencyMode (_playerHandle, out _audioLatencyMode);
- Interop.PlayerInterop.IsMuted (_playerHandle, out _mute);
- Interop.PlayerInterop.IsLooping (_playerHandle, out _isLooping);
-
+ Interop.Player.GetVolume (_playerHandle, out _leftVolume, out _rightVolume);
+ Interop.Player.GetAudioLatencyMode (_playerHandle, out _audioLatencyMode);
+ Interop.Player.IsMuted (_playerHandle, out _mute);
+ Interop.Player.IsLooping (_playerHandle, out _isLooping);
// AudioEffect
_audioEffect = new AudioEffect();
/// <summary>
/// Prepares the media player for playback. </summary>
- /// TODO: make async
- public /*Task<void>*/void PrepareAsync()
+ public void PrepareAsync()
{
- if ((Interop.PlayerInterop.Prepare (_playerHandle)) != 0) {
- //throw Exception;
- }
- }
+ int ret;
+ Task.Factory.StartNew (() => {
+ Interop.Player.PrepareCallback cb = (IntPtr userData) => {
+ };
+ ret = Interop.Player.PrepareAsync (_playerHandle, cb, IntPtr.Zero);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to prepare player" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Failed to prepare player");
+ }
+ });
+ }
/// <summary>
/// The most recently used media is reset and no longer associated with the player. Playback is no longer possible.
/// If you want to use the player again, you will have to set the data URI and call prepare() again. </summary>
public void Unrepare()
{
- if (Interop.PlayerInterop.Unprepare (_playerHandle) != 0) {
- //throw Exception;
+ int ret = Interop.Player.Unprepare (_playerHandle);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to unprepare player" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Failed to unprepare player");
}
}
/// Starts or resumes playback. </summary>
public void Start()
{
- if (Interop.PlayerInterop.Start (_playerHandle) != 0) {
- //throw Exception;
+ int ret = Interop.Player.Start (_playerHandle);
+ if ( ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to start player" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Failed to start player");
}
}
/// Stops playing media content. </summary>
public void Stop()
{
- if (Interop.PlayerInterop.Stop (_playerHandle) != 0) {
- //throw Exception;
+ int ret = Interop.Player.Stop (_playerHandle);
+ if ( ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to stop player" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Failed to stop player");
}
}
/// Pauses the player. </summary>
public void Pause()
{
- if (Interop.PlayerInterop.Pause (_playerHandle) != 0) {
- //throw Exception;
+ int ret = Interop.Player.Pause (_playerHandle);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to pause player" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Failed to pause player");
}
}
/// <summary>
/// sets media source for the player. </summary>
/// <param name="source"> Mediasource </param>
- /// TODO: implement memory buffer and packet stream
public void SetSource(MediaSource source)
{
- if (source.GetType() == typeof(MediaUriSource)) {
- if ( Interop.PlayerInterop.SetUri (_playerHandle, ((MediaUriSource)source)._uri) != 0) {
- // throw Exception
+ int ret;
+ if (source.GetType () == typeof(MediaUriSource))
+ {
+ ret = Interop.Player.SetUri (_playerHandle, ((MediaUriSource)source)._uri);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to seturi" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Failed to set uri");
}
+ }
+ else if (source.GetType () == typeof(MediaBufferSource))
+ {
+ //if(Interop.Player.SetMemoryBuffer(_playerHandle, ((MediaBufferSource)source)._buffer, ((MediaBufferSource)source)._buffer.Length) != 0) {
+ // throw Exception
+ //}
}
+ // TODO: Handle MediaStream source after implementing MediaPacket module
}
/// <summary>
/// Captures a video frame asynchronously. </summary>
- Task<VideoFrameCapture> CaptureVideoAsync()
+ public Task<VideoFrameCapture> CaptureVideoAsync()
{
- return null;
+ return Task.Factory.StartNew(() => CaptureVideoAsyncTask()).Result;
}
+ internal Task<VideoFrameCapture> CaptureVideoAsyncTask()
+ {
+ TaskCompletionSource<VideoFrameCapture> t = new TaskCompletionSource<VideoFrameCapture> ();
+ Interop.Player.VideoCaptureCallback cb = (byte[] data, int width, int height, uint size, IntPtr userData) => {
+ VideoFrameCapture v = new VideoFrameCapture(data, width, height, size);
+ t.SetResult(v);
+ };
+
+ int ret = Interop.Player.CaptureVideo (_playerHandle, cb, IntPtr.Zero);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to capture video" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Failed to capture video");
+ }
+ return t.Task;
+ }
+
/// <summary>
///Sets the seek position for playback, asynchronously. </summary>
/// <param name="milliseconds"> Position to be set in milliseconds</param>
/// <param name="accurate"> accurate seek or not</param>
- //public Task<void> SetPlayPositionAsync(int milliseconds, bool accurate)
- //{
- //}
+ public void SetPlayPositionAsync(int milliseconds, bool accurate)
+ {
+ Task.Factory.StartNew (() => {
+ Interop.Player.SeekCompletedCallback cb = (IntPtr userData) => {
+ };
+ int ret = Interop.Player.SetPlayPosition (_playerHandle, milliseconds, accurate, cb, IntPtr.Zero);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to set playposition" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Failed to set playposition");
+ }
+ });
+
+ }
internal PlayerState _state;
internal int _audioLatencyMode;
internal bool _mute;
internal bool _isLooping;
- internal SoundType _soundType;
+ internal AudioType _audioType;
internal Display _display;
internal Subtitle _subtitle;
get
{
string album;
- if (Interop.PlayerInterop.GetContentInfo (_playerHandle, (int)ContentInfoKey.Album, out album) != 0) {
- // throw Exception;
+ int ret = Interop.Player.GetContentInfo (_playerHandle, (int)ContentInfoKey.Album, out album);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get album info" + (PlayerError)ret);
}
return album;
}
get
{
string artist;
- if (Interop.PlayerInterop.GetContentInfo (_playerHandle, (int)ContentInfoKey.Artist, out artist) != 0) {
- // throw Exception;
+ int ret = Interop.Player.GetContentInfo (_playerHandle, (int)ContentInfoKey.Artist, out artist);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get artist info" + (PlayerError)ret);
}
+
return artist;
}
}
get
{
string author;
- if (Interop.PlayerInterop.GetContentInfo (_playerHandle, (int)ContentInfoKey.Author, out author) != 0) {
- // throw Exception;
+ int ret = Interop.Player.GetContentInfo (_playerHandle, (int)ContentInfoKey.Author, out author);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get author info" + (PlayerError)ret);
}
return author;
}
get
{
string genre;
- if (Interop.PlayerInterop.GetContentInfo (_playerHandle, (int)ContentInfoKey.Genre, out genre) != 0) {
- // throw Exception;
+ int ret = Interop.Player.GetContentInfo (_playerHandle, (int)ContentInfoKey.Genre, out genre);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get genre info" + (PlayerError)ret);
}
+
return genre;
}
}
get
{
string title;
- if (Interop.PlayerInterop.GetContentInfo (_playerHandle, (int)ContentInfoKey.Title, out title) != 0) {
- // throw Exception;
+ int ret = Interop.Player.GetContentInfo (_playerHandle, (int)ContentInfoKey.Title, out title);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get title info" + (PlayerError)ret);
}
return title;
}
get
{
string year;
- if (Interop.PlayerInterop.GetContentInfo (_playerHandle, (int)ContentInfoKey.Year, out year) != 0) {
- // throw Exception;
+ int ret = Interop.Player.GetContentInfo (_playerHandle, (int)ContentInfoKey.Year, out year);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get title info" + (PlayerError)ret);
}
return year;
}
-using System;\r
-\r
-namespace Tizen.Multimedia\r
-{\r
- /// <summary>\r
- /// Enumeration for player state\r
- /// </summary>\r
- public enum PlayerState\r
- {\r
- /// <summary>\r
- /// Player is not created \r
- /// </summary>\r
- None,\r
-\r
- /// <summary>\r
- /// Player is created, but not prepared \r
- /// </summary>\r
- Idle,\r
-\r
- /// <summary>\r
- /// Player is ready to play media \r
- /// </summary>\r
- Ready,\r
-\r
- /// <summary>\r
- /// Player is playing media \r
- /// </summary>\r
- Playing,\r
-\r
- /// <summary>\r
- /// Player is paused while playing media \r
- /// </summary>\r
- Paused,\r
- }\r
-\r
- /// <summary>\r
- /// Enumeration for player display type\r
- /// </summary>\r
- public enum DisplayType\r
- {\r
- /// <summary>\r
- /// Overlay surface display \r
- /// </summary>\r
- Overlay,\r
-\r
- /// <summary>\r
- /// Evas image object surface display \r
- /// </summary>\r
- Evas,\r
-\r
- /// <summary>\r
- /// This disposes off buffers \r
- /// </summary>\r
- None,\r
- }\r
-\r
-\r
- /// <summary>\r
- /// Enumeration for player audio latency mode\r
- /// </summary>\r
- public enum AudioLatencyMode\r
- {\r
- /// <summary>\r
- /// Low audio latency mode \r
- /// </summary>\r
- Low,\r
-\r
- /// <summary>\r
- /// Middle audio latency mode \r
- /// </summary>\r
- Mid,\r
-\r
- /// <summary>\r
- /// High audio latency mode \r
- /// </summary>\r
- High,\r
- }\r
-\r
-\r
- /// <summary>\r
- /// Enumeration for player display rotation\r
- /// </summary>\r
- public enum DisplayRotation\r
- {\r
- /// <summary>\r
- /// Display is not rotated \r
- /// </summary>\r
- RotationNone,\r
-\r
- /// <summary>\r
- /// Display is rotated 90 degrees \r
- /// </summary>\r
- Rotation90,\r
-\r
- /// <summary>\r
- /// Display is rotated 180 degrees \r
- /// </summary>\r
- Rotation180,\r
-\r
- /// <summary>\r
- /// Display is rotated 270 degrees \r
- /// </summary>\r
- Rotation270\r
- }\r
-\r
-\r
- /// <summary>\r
- /// Enumeration for player display mode\r
- /// </summary>\r
- public enum DisplayMode\r
- {\r
- /// <summary>\r
- /// Letter box \r
- /// </summary>\r
- LetterBox,\r
-\r
- /// <summary>\r
- /// Origin size\r
- /// </summary>\r
- OriginalSize,\r
-\r
- /// <summary>\r
- /// Full-screen \r
- /// </summary>\r
- FullScreen,\r
-\r
- /// <summary>\r
- /// Cropped full-screen \r
- /// </summary>\r
- CroppedFull,\r
-\r
- /// <summary>\r
- /// Origin size (if surface size is larger than video size(width/height)) or \r
- /// Letter box (if video size(width/height) is larger than surface size) \r
- /// </summary>\r
- OriginalOrFull,\r
-\r
- /// <summary>\r
- /// Dst ROI mode \r
- /// </summary>\r
- DstRoi\r
- }\r
-\r
-\r
- /// <summary>\r
- /// Enumeration for player stream type\r
- /// </summary>\r
- public enum StreamType\r
- {\r
- /// <summary>\r
- /// Container type \r
- /// </summary>\r
- Default,\r
-\r
- /// <summary>\r
- /// Audio element stream type \r
- /// </summary>\r
- Audio,\r
-\r
- /// <summary>\r
- /// Video element stream type \r
- /// </summary>\r
- Video,\r
-\r
- /// <summary>\r
- /// Text type \r
- /// </summary>\r
- Text\r
- }\r
-\r
-\r
-\r
- /// <summary>\r
- /// Enumeration for Progressive download message\r
- /// </summary>\r
- public enum ProgressiveDownloadMessage\r
- {\r
- /// <summary>\r
- /// Progressive download is started \r
- /// </summary>\r
- Started,\r
-\r
- /// <summary>\r
- /// Progressive download is completed \r
- /// </summary>\r
- Completed,\r
- }\r
-\r
- /// <summary>\r
- /// Streaming buffer status\r
- /// </summary>\r
- public enum StreamingBufferStatus\r
- {\r
- /// <summary>\r
- /// Underrun\r
- /// </summary>\r
- Underrun,\r
-\r
- /// <summary>\r
- /// Completed \r
- /// </summary>\r
- Overflow,\r
- }\r
-\r
- /// <summary>\r
- /// Enumeration for sound type\r
- /// </summary>\r
- public enum SoundType\r
- {\r
- /// <summary>\r
- /// Sound type for system \r
- /// </summary>\r
- System,\r
-\r
- /// <summary>\r
- /// Sound type for notifications \r
- /// </summary>\r
- Notification,\r
-\r
- /// <summary>\r
- /// Sound type for alarm \r
- /// </summary>\r
- Alarm,\r
-\r
- /// <summary>\r
- /// Sound type for ringtones \r
- /// </summary>\r
- Ringtone,\r
-\r
- /// <summary>\r
- /// Sound type for media \r
- /// </summary>\r
- Media,\r
-\r
- /// <summary>\r
- /// Sound type for call \r
- /// </summary>\r
- Call,\r
-\r
- /// <summary>\r
- /// Sound type for voip\r
- /// </summary>\r
- Voip,\r
-\r
- /// <summary>\r
- /// Sound type for voice \r
- /// </summary>\r
- Voice\r
- }\r
-\r
- /// <summary>\r
- /// Enumeration for source type\r
- /// </summary>\r
- public enum PlayerSourceType\r
- {\r
- /// <summary>\r
- /// Uri source \r
- /// </summary>\r
- Uri,\r
-\r
- /// <summary>\r
- /// memory buffer source \r
- /// </summary>\r
- Memory,\r
-\r
- /// <summary>\r
- /// stream source \r
- /// </summary>\r
- Stream,\r
- }\r
-\r
-}\r
+using System;
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// Enumeration for player state
+ /// </summary>
+ public enum PlayerState
+ {
+ /// <summary>
+ /// Player is not created
+ /// </summary>
+ None,
+
+ /// <summary>
+ /// Player is created, but not prepared
+ /// </summary>
+ Idle,
+
+ /// <summary>
+ /// Player is ready to play media
+ /// </summary>
+ Ready,
+
+ /// <summary>
+ /// Player is playing media
+ /// </summary>
+ Playing,
+
+ /// <summary>
+ /// Player is paused while playing media
+ /// </summary>
+ Paused,
+ }
+
+ /// <summary>
+ /// Enumeration for player display type
+ /// </summary>
+ public enum DisplayType
+ {
+ /// <summary>
+ /// Overlay surface display
+ /// </summary>
+ Overlay,
+
+ /// <summary>
+ /// Evas image object surface display
+ /// </summary>
+ Evas,
+
+ /// <summary>
+ /// This disposes off buffers
+ /// </summary>
+ None,
+ }
+
+
+ /// <summary>
+ /// Enumeration for player audio latency mode
+ /// </summary>
+ public enum AudioLatencyMode
+ {
+ /// <summary>
+ /// Low audio latency mode
+ /// </summary>
+ Low,
+
+ /// <summary>
+ /// Middle audio latency mode
+ /// </summary>
+ Mid,
+
+ /// <summary>
+ /// High audio latency mode
+ /// </summary>
+ High,
+ }
+
+
+ /// <summary>
+ /// Enumeration for player display rotation
+ /// </summary>
+ public enum DisplayRotation
+ {
+ /// <summary>
+ /// Display is not rotated
+ /// </summary>
+ RotationNone,
+
+ /// <summary>
+ /// Display is rotated 90 degrees
+ /// </summary>
+ Rotation90,
+
+ /// <summary>
+ /// Display is rotated 180 degrees
+ /// </summary>
+ Rotation180,
+
+ /// <summary>
+ /// Display is rotated 270 degrees
+ /// </summary>
+ Rotation270
+ }
+
+
+ /// <summary>
+ /// Enumeration for player display mode
+ /// </summary>
+ public enum DisplayMode
+ {
+ /// <summary>
+ /// Letter box
+ /// </summary>
+ LetterBox,
+
+ /// <summary>
+ /// Origin size
+ /// </summary>
+ OriginalSize,
+
+ /// <summary>
+ /// Full-screen
+ /// </summary>
+ FullScreen,
+
+ /// <summary>
+ /// Cropped full-screen
+ /// </summary>
+ CroppedFull,
+
+ /// <summary>
+ /// Origin size (if surface size is larger than video size(width/height)) or
+ /// Letter box (if video size(width/height) is larger than surface size)
+ /// </summary>
+ OriginalOrFull,
+
+ /// <summary>
+ /// Dst ROI mode
+ /// </summary>
+ DstRoi
+ }
+
+
+ /// <summary>
+ /// Enumeration for player stream type
+ /// </summary>
+ public enum StreamType
+ {
+ /// <summary>
+ /// Container type
+ /// </summary>
+ Default,
+
+ /// <summary>
+ /// Audio element stream type
+ /// </summary>
+ Audio,
+
+ /// <summary>
+ /// Video element stream type
+ /// </summary>
+ Video,
+
+ /// <summary>
+ /// Text type
+ /// </summary>
+ Text
+ }
+
+
+
+ /// <summary>
+ /// Enumeration for Progressive download message
+ /// </summary>
+ public enum ProgressiveDownloadMessage
+ {
+ /// <summary>
+ /// Progressive download is started
+ /// </summary>
+ Started,
+
+ /// <summary>
+ /// Progressive download is completed
+ /// </summary>
+ Completed,
+ }
+
+ /// <summary>
+ /// Streaming buffer status
+ /// </summary>
+ public enum StreamingBufferStatus
+ {
+ /// <summary>
+ /// Underrun
+ /// </summary>
+ Underrun,
+
+ /// <summary>
+ /// Completed
+ /// </summary>
+ Overflow,
+ }
+
+ /// <summary>
+ /// Enumeration for sound type
+ /// </summary>
+ public enum AudioType
+ {
+ /// <summary>
+ /// Sound type for system
+ /// </summary>
+ System,
+
+ /// <summary>
+ /// Sound type for notifications
+ /// </summary>
+ Notification,
+
+ /// <summary>
+ /// Sound type for alarm
+ /// </summary>
+ Alarm,
+
+ /// <summary>
+ /// Sound type for ringtones
+ /// </summary>
+ Ringtone,
+
+ /// <summary>
+ /// Sound type for media
+ /// </summary>
+ Media,
+
+ /// <summary>
+ /// Sound type for call
+ /// </summary>
+ Call,
+
+ /// <summary>
+ /// Sound type for voip
+ /// </summary>
+ Voip,
+
+ /// <summary>
+ /// Sound type for voice
+ /// </summary>
+ Voice
+ }
+
+ /// <summary>
+ /// Enumeration for source type
+ /// </summary>
+ public enum PlayerSourceType
+ {
+ /// <summary>
+ /// Uri source
+ /// </summary>
+ Uri,
+
+ /// <summary>
+ /// memory buffer source
+ /// </summary>
+ Memory,
+
+ /// <summary>
+ /// stream source
+ /// </summary>
+ Stream,
+ }
+
+}
--- /dev/null
+using System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Multimedia
+{
+ internal enum PlayerError
+ {
+ None = ErrorCode.None,
+ InvalidParameter = ErrorCode.InvalidParameter,
+ InvalidState,
+ OutOfMemory,
+ NoSuchFile,
+ InvalidOperation,
+ NoSpaceOnDevice,
+ FeatureNotSupported,
+ SeekFailed,
+ FileNotSupported,
+ InvalidUri,
+ SoundPolicyError,
+ ConnectionFailed,
+ VideoCaptureFailed,
+ DrmExpired,
+ DrmNoLicense,
+ DrmFutureUse,
+ DrmNotPermitted,
+ ResourceLimit,
+ PermissionDenied
+ };
+
+ internal static class PlayerErrorFactory
+ {
+ internal static void ThrowException (int errorCode, string errorMessage = null, string paramName = null)
+ {
+ PlayerError err = (PlayerError) errorCode;
+ if(string.IsNullOrEmpty(errorMessage))
+ {
+ errorMessage = err.ToString();
+ }
+ switch((PlayerError)errorCode)
+ {
+ case PlayerError.InvalidParameter:
+ throw new ArgumentException(errorMessage, paramName);
+
+ case PlayerError.InvalidState:
+ case PlayerError.OutOfMemory:
+ case PlayerError.NoSuchFile:
+ case PlayerError.InvalidOperation:
+ case PlayerError.NoSpaceOnDevice:
+ case PlayerError.FeatureNotSupported:
+ case PlayerError.SeekFailed:
+ case PlayerError.FileNotSupported:
+ case PlayerError.InvalidUri:
+ case PlayerError.SoundPolicyError:
+ case PlayerError.ConnectionFailed:
+ case PlayerError.VideoCaptureFailed:
+ case PlayerError.DrmExpired:
+ case PlayerError.DrmNoLicense:
+ case PlayerError.DrmFutureUse:
+ case PlayerError.DrmNotPermitted:
+ case PlayerError.ResourceLimit:
+ case PlayerError.PermissionDenied:
+ throw new InvalidOperationException(errorMessage);
+ }
+ }
+ }
+}
+
+++ /dev/null
-using System;\r
-\r
-\r
-namespace Tizen.Multimedia\r
-{\r
- abstract class PlayerSource\r
- {\r
- PlayerSourceType Type;\r
- }\r
-}\r
}
}
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ public ProgressiveDownloadMessageEventArgs(ProgressiveDownloadMessage message)
+ {
+ _message = message;
+ }
+
internal ProgressiveDownloadMessage _message;
}
/// Get current download position (bytes)
/// </summary>
/// <value> current download position </value>
- public ulong Current;
+ public ulong Current
+ {
+ set
+ {
+ _current = value;
+ }
+ get
+ {
+ return _current;
+ }
+ }
/// <summary>
/// Get total size of the file (bytes)
/// </summary>
/// <value> Total size of file (bytes) </value>
- public ulong TotalSize;
+ public ulong TotalSize
+ {
+ set
+ {
+ _totalSize = value;
+ }
+ get
+ {
+ return _totalSize;
+ }
+ }
+
+ internal ulong _current;
+ internal ulong _totalSize;
}
}
\ No newline at end of file
/// Get seek offset.
/// </summary>
/// <value> byte position to seek </value>
- public ulong Offset
+ public UInt64 Offset
{
get
{
}
}
- internal ulong _offset;
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public SeekOffsetEventArgs(UInt64 offset)
+ {
+ _offset = offset;
+ }
+
+ internal UInt64 _offset;
}
}
\ No newline at end of file
+++ /dev/null
-/// Source Factory\r
-///\r
-/// Copyright 2016 by Samsung Electronics, Inc.,\r
-///\r
-/// This software is the confidential and proprietary information\r
-/// of Samsung Electronics, Inc. ("Confidential Information"). You\r
-/// shall not disclose such Confidential Information and shall use\r
-/// it only in accordance with the terms of the license agreement\r
-/// you entered into with Samsung.\r
-\r
-using System;\r
-\r
-namespace Tizen.Multimedia\r
-{\r
- /// <summary>\r
- /// SourceFactory\r
- /// </summary>\r
- /// <remarks>\r
- /// Factory class for getting player source.\r
- /// </remarks>\r
-\r
- class SourceFactory\r
- {\r
- /// <summary>\r
- /// GetSource </summary>\r
- /// <param name="uri"> source uri string </param>\r
- /// <returns>PlayerSource</returns>\r
- public static PlayerSource GetSource(string uri)\r
- {\r
- return null;\r
- }\r
-\r
- /// <summary>\r
- /// GetSource </summary>\r
- /// <param name="buffer"> memory buffer </param>\r
- /// <returns>PlayerSource</returns>\r
- public static PlayerSource GetSource(byte[] buffer)\r
- {\r
- return null;\r
- }\r
-\r
- /// <summary>\r
- /// GetSource </summary>\r
- /// <param name="mediastream"> media stream</param>\r
- /// <returns>PlayerSource</returns>\r
- public static PlayerSource GetSource(MediaStream mediaStream)\r
- {\r
- return null;\r
- }\r
- }\r
-}\r
get
{
string audioCodec, videoCodec;
- if (Interop.PlayerInterop.GetCodecInfo (_playerHandle, out audioCodec, out videoCodec) != 0) {
- //throw Exception
+ int ret = Interop.Player.GetCodecInfo (_playerHandle, out audioCodec, out videoCodec);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get codec info" + (PlayerError)ret);
}
return audioCodec;
}
get
{
int duration;
- if (Interop.PlayerInterop.GetDuration (_playerHandle, out duration) != 0) {
- //throw Exception
+ int ret = Interop.Player.GetDuration (_playerHandle, out duration);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get duration info" + (PlayerError)ret);
}
return duration;
}
get
{
int sampleRate, channels, bitRate;
- if( Interop.PlayerInterop.GetAudioStreamInfo(_playerHandle, out sampleRate, out channels, out bitRate) != 0) {
- //throw Exception;
+ int ret = Interop.Player.GetAudioStreamInfo (_playerHandle, out sampleRate, out channels, out bitRate);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get audio stream info" + (PlayerError)ret);
}
return sampleRate;
}
get
{
int sampleRate, channels, bitRate;
- if( Interop.PlayerInterop.GetAudioStreamInfo(_playerHandle, out sampleRate, out channels, out bitRate) != 0) {
- //throw Exception;
+ int ret = Interop.Player.GetAudioStreamInfo (_playerHandle, out sampleRate, out channels, out bitRate);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get audio channels info" + (PlayerError)ret);
}
return channels;
}
get
{
int sampleRate, channels, bitRate;
- if( Interop.PlayerInterop.GetAudioStreamInfo(_playerHandle, out sampleRate, out channels, out bitRate) != 0) {
- //throw Exception;
+ int ret = Interop.Player.GetAudioStreamInfo (_playerHandle, out sampleRate, out channels, out bitRate);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get audio bitrate info" + (PlayerError)ret);
}
return bitRate;
}
get
{
string audioCodec, videoCodec;
- if (Interop.PlayerInterop.GetCodecInfo (_playerHandle, out audioCodec, out videoCodec) != 0) {
- //throw Exception
+ int ret = Interop.Player.GetCodecInfo (_playerHandle, out audioCodec, out videoCodec);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get video codec info" + (PlayerError)ret);
}
return videoCodec;
}
get
{
int fps, bitRate;
- if (Interop.PlayerInterop.GetVideoStreamInfo (_playerHandle, out fps, out bitRate) != 0) {
- //throw Exception;
+ int ret = Interop.Player.GetVideoStreamInfo (_playerHandle, out fps, out bitRate);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get video fps info" + (PlayerError)ret);
}
return fps;
}
get
{
int fps, bitRate;
- if (Interop.PlayerInterop.GetVideoStreamInfo (_playerHandle, out fps, out bitRate) != 0) {
- //throw Exception;
+ int ret = Interop.Player.GetVideoStreamInfo (_playerHandle, out fps, out bitRate);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get video bitrate info" + (PlayerError)ret);
}
return bitRate;
}
get
{
int height, width;
- if (Interop.PlayerInterop.GetVideoSize (_playerHandle, out width, out height) != 0) {
- //throw Exception;
+ int ret = Interop.Player.GetVideoSize (_playerHandle, out width, out height);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get video height" + (PlayerError)ret);
}
return height;
}
get
{
int height, width;
- if (Interop.PlayerInterop.GetVideoSize (_playerHandle, out width, out height) != 0) {
- //throw Exception;
+ int ret = Interop.Player.GetVideoSize (_playerHandle, out width, out height);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Failed to get video width" + (PlayerError)ret);
}
return width;
}
/// </remarks>
public class StreamingConfiguration
{
- /// <summary>
+ private EventHandler<BufferingProgressEventArgs> _bufferingProgress;
+ private Interop.Player.BufferingProgressCallback _bufferingProgressCallback;
+
+ private EventHandler<ProgressiveDownloadMessageEventArgs> _pdMessage;
+ private Interop.Player.ProgressiveDownloadMessageCallback _pdMessageCallback;
+
+ private EventHandler<VideoStreamEventArgs> _videoStreamChanged;
+ private Interop.Player.VideoStreamChangedCallback _videoStreamChangedCallback;
+
+ /// <summary>
/// BufferingProgressChanged event is raised when there is a change in the buffering status of a media stream
/// </summary>
- public event EventHandler<BufferingProgressEventArgs> BufferingProgressChanged;
+ public event EventHandler<BufferingProgressEventArgs> BufferingProgressChanged
+ {
+ add
+ {
+ if(_bufferingProgress == null) {
+ RegisterBufferingProgressEvent ();
+ }
+ _bufferingProgress += value;
+ }
+ remove
+ {
+ _bufferingProgress -= value;
+ if (_bufferingProgress == null) {
+ UnregisterBufferingProgressEvent ();
+ }
+ }
+ }
+
+ private void RegisterBufferingProgressEvent()
+ {
+ _bufferingProgressCallback = (int percent, IntPtr userData) =>
+ {
+ BufferingProgressEventArgs eventArgs = new BufferingProgressEventArgs(percent);
+ _bufferingProgress.Invoke(this, eventArgs);
+ };
+
+ int ret = Interop.Player.SetBufferingCb (_playerHandle, _bufferingProgressCallback, IntPtr.Zero);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Setting Buffering callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting Buffering callback failed");
+ }
+
+ }
+
+ private void UnregisterBufferingProgressEvent()
+ {
+ int ret = Interop.Player.UnsetBufferingCb (_playerHandle);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Unsetting Buffering callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Unsetting Buffering callback failed");
+ }
+
+ }
+
/// <summary>
/// ProgressiveDownloadMessageChanged event is raised when progressive download is started or completed.
/// </summary>
- public event EventHandler<ProgressiveDownloadMessageEventArgs> ProgressiveDownloadMessageChanged;
+ public event EventHandler<ProgressiveDownloadMessageEventArgs> ProgressiveDownloadMessageChanged
+ {
+ add
+ {
+ if(_pdMessage == null) {
+ RegisterProgressiveDownloadMessageEvent();
+ }
+ _pdMessage += value;
+ }
+ remove
+ {
+ _pdMessage -= value;
+ if (_pdMessage == null) {
+ UnregisterProgressiveDownloadMessageEvent ();
+ }
+ }
+ }
+
+ private void RegisterProgressiveDownloadMessageEvent()
+ {
+ _pdMessageCallback = (int type, IntPtr userData) =>
+ {
+ ProgressiveDownloadMessageEventArgs eventArgs = new ProgressiveDownloadMessageEventArgs((ProgressiveDownloadMessage)type);
+ _pdMessage.Invoke(this, eventArgs);
+ };
+ int ret = Interop.Player.SetProgressiveDownloadMessageCb (_playerHandle, _pdMessageCallback, IntPtr.Zero);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Setting progressive download callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting progressive download callback failed");
+ }
+ }
+
+ private void UnregisterProgressiveDownloadMessageEvent()
+ {
+ int ret = Interop.Player.UnsetProgressiveDownloadMessageCb (_playerHandle);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Unsetting progressive download callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Unsetting progressive download callback failed");
+ }
+
+ }
+
/// <summary>
/// Video stream changed event is raised to notify the video stream changed.
/// </summary>
- public event EventHandler<VideoStreamEventArgs> VideoStreamChanged;
+ public event EventHandler<VideoStreamEventArgs> VideoStreamChanged
+ {
+ add
+ {
+ if(_videoStreamChanged == null) {
+ RegisterVideoStreamChangedEvent();
+ }
+ _videoStreamChanged += value;
+ }
+ remove
+ {
+ _videoStreamChanged -= value;
+ if (_videoStreamChanged == null) {
+ UnregisterVideoStreamChanged ();
+ }
+ }
+ }
+
+ private void RegisterVideoStreamChangedEvent()
+ {
+ _videoStreamChangedCallback = (int width, int height, int fps, int bitrate, IntPtr userData) =>
+ {
+ VideoStreamEventArgs eventArgs = new VideoStreamEventArgs(height, width, fps, bitrate);
+ _videoStreamChanged.Invoke(this, eventArgs);
+ };
+ int ret = Interop.Player.SetVideoStreamChangedCb (_playerHandle, _videoStreamChangedCallback, IntPtr.Zero);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Setting video stream changed callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting video stream changed callback failed");
+ }
+ }
+ private void UnregisterVideoStreamChanged()
+ {
+ int ret = Interop.Player.UnsetVideoStreamChangedCb (_playerHandle);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Unsetting video stream changed callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Unsetting video stream changed callback failed");
+ }
+ }
/// <summary>
/// Set/Get Progressive download path.
{
set
{
- if (Interop.PlayerInterop.SetProgressiveDownloadPath (_playerHandle, value) != 0) {
- // throw Exception
+ int ret = Interop.Player.SetProgressiveDownloadPath (_playerHandle, value);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Setting progressive download path failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting progressive download path failed");
}
_progressiveDownloadPath = value;
}
get
{
DownloadProgress progress = new DownloadProgress();
- if (Interop.PlayerInterop.GetStreamingDownloadProgress (_playerHandle, out progress.Start, out progress.Current) != 0) {
- // throw Exception;
+ int start, current;
+ int ret = Interop.Player.GetStreamingDownloadProgress (_playerHandle, out start, out current);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Getting download progress failed" + (PlayerError)ret);
}
+
+ progress.Start = start;
+ progress.Current = current;
return progress;
}
}
{
set
{
- if (Interop.PlayerInterop.SetStreamingCookie (_playerHandle, value, value.Length + 1) != 0) {
- // throw Exception
+ int ret = Interop.Player.SetStreamingCookie (_playerHandle, value, value.Length + 1);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Setting cookie failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting cookie failed");
}
_cookie = value;
}
{
set
{
- if (Interop.PlayerInterop.SetStreamingUserAgent (_playerHandle, value, value.Length + 1) != 0) {
- // throw Exception
+ int ret = Interop.Player.SetStreamingUserAgent (_playerHandle, value, value.Length + 1);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Setting user agent failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting user agent failed");
}
_userAgent = value;
}
/// </remarks>
public class Subtitle
{
+
+ private EventHandler<SubtitleUpdatedEventArgs> _subtitleUpdated;
+ private Interop.Player.SubtitleUpdatedCallback _subtitleUpdatedCallback;
+
/// <summary>
/// Subtitle event is raised when the subtitle is updated
/// </summary>
- public event EventHandler<SubtitleUpdatedEventArgs> Updated;
+ public event EventHandler<SubtitleUpdatedEventArgs> Updated
+ {
+ add
+ {
+ if(_subtitleUpdated == null) {
+ RegisterSubtitleUpdatedEvent ();
+ }
+ _subtitleUpdated += value;
+ }
+ remove
+ {
+ _subtitleUpdated -= value;
+ if (_subtitleUpdated == null) {
+ UnregisterSubtitleUpdatedEvent ();
+ }
+ }
+ }
+
+ private void RegisterSubtitleUpdatedEvent()
+ {
+ _subtitleUpdatedCallback = (ulong duration, string text, IntPtr userData) =>
+ {
+ SubtitleUpdatedEventArgs eventArgs = new SubtitleUpdatedEventArgs(duration, text);
+ _subtitleUpdated.Invoke(this, eventArgs);
+ };
+ int ret = Interop.Player.SetSubtitleUpdatedCb (_playerHandle, _subtitleUpdatedCallback, IntPtr.Zero);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Setting subtitle updated callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting subtitle updated callback failed");
+ }
+
+ }
+
+ private void UnregisterSubtitleUpdatedEvent()
+ {
+ int ret = Interop.Player.UnsetSubtitleUpdatedCb (_playerHandle);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Unsetting subtitle updated callback failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Unsetting subtitle updated callback failed");
+ }
+ }
/// <summary>
{
set
{
- if (Interop.PlayerInterop.SetSubtitlePositionOffset (_playerHandle, value) != 0) {
- // throw Exception
+ int ret = Interop.Player.SetSubtitlePositionOffset (_playerHandle, value);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Setting position offset failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting position offset failed");
}
}
}
get
{
string langCode;
- foreach (SubtitleTrack t in _textTrack) {
- if (Interop.PlayerInterop.GetTrackLanguageCode (_playerHandle, (int)StreamType.Text, _textTrack.IndexOf (t), out langCode) != 0) {
- // throw Exception
+ int ret;
+ foreach (SubtitleTrack t in _textTrack)
+ {
+ ret = Interop.Player.GetTrackLanguageCode (_playerHandle, (int)StreamType.Text, _textTrack.IndexOf (t), out langCode);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Getting text track language code failed" + (PlayerError)ret);
}
t.LanguageCode = langCode;
}
get
{
string langCode;
- foreach (SubtitleTrack t in _audioTrack) {
- if (Interop.PlayerInterop.GetTrackLanguageCode (_playerHandle, (int)StreamType.Audio, _audioTrack.IndexOf (t), out langCode) != 0) {
- // throw Exception
+ foreach (SubtitleTrack t in _audioTrack)
+ {
+ int ret = Interop.Player.GetTrackLanguageCode (_playerHandle, (int)StreamType.Audio, _audioTrack.IndexOf (t), out langCode);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Getting audio track language code failed" + (PlayerError)ret);
}
t.LanguageCode = langCode;
}
get
{
string langCode;
- foreach (SubtitleTrack t in _videoTrack) {
- if (Interop.PlayerInterop.GetTrackLanguageCode (_playerHandle, (int)StreamType.Video, _videoTrack.IndexOf (t), out langCode) != 0) {
- // throw Exception
+ int ret;
+ foreach (SubtitleTrack t in _videoTrack)
+ {
+ ret = Interop.Player.GetTrackLanguageCode (_playerHandle, (int)StreamType.Video, _videoTrack.IndexOf (t), out langCode);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Getting video track language code failed" + (PlayerError)ret);
}
t.LanguageCode = langCode;
}
{
set
{
- if (Interop.PlayerInterop.SetSubtitlePath (_playerHandle, value) != 0) {
- // throw Exception
+ int ret = Interop.Player.SetSubtitlePath (_playerHandle, value);
+ if (ret != (int)PlayerError.None)
+ {
+ Log.Error (PlayerLog.LogTag, "Setting subtitle path failed" + (PlayerError)ret);
+ PlayerErrorFactory.ThrowException (ret, "Setting subtitle path failed");
}
}
}
/// Get/Set Language code.
/// </summary>
/// <value> language code string </value>
- public string LanguageCode { get; set; }
+ public string LanguageCode
+ {
+ set
+ {
+ _languageCode = value;
+ }
+ get
+ {
+ return _languageCode;
+ }
+ }
/// <summary>
/// Get/Set activation status.
/// </summary>
/// <value> true, false </value>
- public bool Activated { get; set; }
+ public bool Activated
+ {
+ set
+ {
+ _activated = value;
+ }
+ get
+ {
+ return _activated;
+ }
+ }
+
+ internal string _languageCode;
+ internal bool _activated;
}
}
}
}
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public SubtitleUpdatedEventArgs(ulong duration, string text)
+ {
+ _duration = duration;
+ _text = text;
+ }
+
internal ulong _duration;
internal string _text;
}
-/// VideoFrameCapture\r
-///\r
-/// Copyright 2016 by Samsung Electronics, Inc.,\r
-///\r
-/// This software is the confidential and proprietary information\r
-/// of Samsung Electronics, Inc. ("Confidential Information"). You\r
-/// shall not disclose such Confidential Information and shall use\r
-/// it only in accordance with the terms of the license agreement\r
-/// you entered into with Samsung.\r
-\r
-using System;\r
-\r
-namespace Tizen.Multimedia\r
-{\r
- /// <summary>\r
- /// VideoFrameCapture\r
- /// </summary>\r
- /// <remarks>\r
- /// VideoSize class provides properties of a captured video frame\r
- /// </remarks>\r
- class VideoFrameCapture\r
- {\r
-\r
- /// <summary>\r
- /// Get/Set ImageBuffer.\r
- /// </summary>\r
- /// <value> Image buffer </value>\r
- public byte[] ImageBuffer { set; get; }\r
-\r
- /// <summary>\r
- /// Get/Set width.\r
- /// </summary>\r
- /// <value> Image width </value>\r
- public int Width { set; get; }\r
-\r
- /// <summary>\r
- /// Get/Set height.\r
- /// </summary>\r
- /// <value> Image Height </value>\r
- public int Height { set; get; }\r
-\r
- /// <summary>\r
- /// Get/Set Size.\r
- /// </summary>\r
- /// <value> Size of the image </value>\r
- public uint Size { set; get; }\r
- }\r
-}\r
+/// VideoFrameCapture
+///
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+using System;
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// VideoFrameCapture
+ /// </summary>
+ /// <remarks>
+ /// VideoSize class provides properties of a captured video frame
+ /// </remarks>
+ public class VideoFrameCapture
+ {
+
+ /// <summary>
+ /// Get/Set ImageBuffer.
+ /// </summary>
+ /// <value> Image buffer </value>
+ public byte[] ImageBuffer
+ {
+ set
+ {
+ _imageBuffer = value;
+ }
+ get
+ {
+ return _imageBuffer;
+ }
+ }
+
+ /// <summary>
+ /// Get/Set width.
+ /// </summary>
+ /// <value> Image width </value>
+ public int Width
+ {
+ set
+ {
+ _width = value;
+ }
+ get
+ {
+ return _width;
+ }
+ }
+
+ /// <summary>
+ /// Get/Set height.
+ /// </summary>
+ /// <value> Image Height </value>
+ public int Height
+ {
+ set
+ {
+ _height = value;
+ }
+ get
+ {
+ return _height;
+ }
+ }
+
+ /// <summary>
+ /// Get/Set Size.
+ /// </summary>
+ /// <value> Size of the image </value>
+ public uint Size
+ {
+ set
+ {
+ _size = value;
+ }
+ get
+ {
+ return _size;
+ }
+ }
+
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ public VideoFrameCapture(byte[] imageBuffer, int width, int height, uint size)
+ {
+ _imageBuffer = imageBuffer;
+ _width = width;
+ _height = height;
+ _size = size;
+ }
+
+
+ internal byte[] _imageBuffer;
+ internal int _width;
+ internal int _height;
+ internal uint _size;
+ }
+}
/// </remarks>
public class VideoFrameDecodedEventArgs : EventArgs
{
+ // TODO: uncomment when MediaPacket is implemented.
/// <summary>
/// Get the Image buffer.
/// </summary>
}
}
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public VideoStreamEventArgs(int height, int width, int fps, int bitrate)
+ {
+ _height = height;
+ _width = width;
+ _fps = fps;
+ _bitrate = bitrate;
+ }
+
internal int _height;
internal int _width;
internal int _fps;
<AppDesignerFolder>Properties</AppDesignerFolder>\r
<RootNamespace>Tizen.Multimedia</RootNamespace>\r
<AssemblyName>Tizen.Multimedia</AssemblyName>\r
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>\r
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
<FileAlignment>512</FileAlignment>\r
<TargetFrameworkProfile />\r
- <ProductVersion>8.0.30703</ProductVersion>\r
- <SchemaVersion>2.0</SchemaVersion>\r
</PropertyGroup>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
<DebugSymbols>true</DebugSymbols>\r
<Compile Include="Player\PlayerEnums.cs" />\r
<Compile Include="Player\MediaStream.cs" />\r
<Compile Include="Player\MediaStreamConfiguration.cs" />\r
- <Compile Include="Player\PlayerSource.cs" />\r
- <Compile Include="Player\SourceFactory.cs" />\r
<Compile Include="Player\SubtitleTrack.cs" />\r
<Compile Include="Player\AudioEffect.cs" />\r
<Compile Include="Player\BufferingProgressChangedEventArgs.cs" />\r
<Compile Include="Player\MediaBufferSource.cs" />\r
<Compile Include="Player\MediaStreamSource.cs" />\r
<Compile Include="Interop\Interop.Libraries.cs" />\r
+ <Compile Include="Player\PlayerErrorFactory.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<None Include="Tizen.Multimedia.snk" />\r
<Target Name="AfterBuild">\r
</Target>\r
-->\r
+ <ItemGroup>\r
+ <ProjectReference Include="..\..\tizen\Tizen\Tizen.csproj">\r
+ <Project>{7659CA59-410D-41A1-9841-586E88BC78C9}</Project>\r
+ <Name>Tizen</Name>\r
+ </ProjectReference>\r
+ <ProjectReference Include="..\..\tizen\Tizen.Internals\Tizen.Internals.csproj">\r
+ <Project>{B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}</Project>\r
+ <Name>Tizen.Internals</Name>\r
+ </ProjectReference>\r
+ </ItemGroup>\r
</Project>
\ No newline at end of file
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
- <MonoDevelop.Ide.Workbench ActiveDocument="Player/Player.cs">
+ <MonoDevelop.Ide.Workbench ActiveDocument="Player/PlayerErrorFactory.cs">
<Files>
<File FileName="Player/Player.cs" Line="1" Column="1" />
+ <File FileName="Interop/Interop.Player.cs" Line="1" Column="1" />
+ <File FileName="Player/SubtitleUpdatedEventArgs.cs" Line="1" Column="1" />
+ <File FileName="Player/VideoFrameDecodedEventArgs.cs" Line="1" Column="1" />
+ <File FileName="Player/StreamingConfiguration.cs" Line="1" Column="1" />
+ <File FileName="Player/ProgressiveDownloadMessageEventArgs.cs" Line="1" Column="1" />
+ <File FileName="Player/Subtitle.cs" Line="1" Column="1" />
+ <File FileName="Player/PlayerEnums.cs" Line="1" Column="1" />
+ <File FileName="Player/PlayerErrorFactory.cs" Line="15" Column="29" />
+ <File FileName="Player/MediaStreamSource.cs" Line="1" Column="1" />
+ <File FileName="Player/MediaBufferSource.cs" Line="1" Column="1" />
+ <File FileName="Player/MediaUriSource.cs" Line="1" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
+ <DisabledProjects>
+ <String>../../tizen/Tizen.Internals/Tizen.Internals.csproj</String>
+ </DisabledProjects>
</Properties>
\ No newline at end of file