From: Hyunsoo, Park Date: Thu, 5 Jan 2017 05:20:51 +0000 (+0900) Subject: [Screen-mirroring] Apply latest changes of screen mirroring X-Git-Tag: submit/trunk/20170823.075128~94^2~145^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf0f0e8961749794731d5fe2ca078c68eebeb150;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Screen-mirroring] Apply latest changes of screen mirroring 1. Remove unused enums 2. Remove related with 'codec' apis which has same code but diffrent api name. 3. Remove ErrorOccurredEventArgs.cs file 4. Change 'SCMirroring' to 'ScreenMirroring' 5. Apply codes for robust testcase Change-Id: Ibd15e09dcc4370dd06e599f128f32c493d06b88e Signed-off-by: Hyunsoo, Park --- diff --git a/src/Tizen.Multimedia/Interop/Interop.ScreenMirroring.cs b/src/Tizen.Multimedia/Interop/Interop.ScreenMirroring.cs index 87d862f..cfda95c 100755 --- a/src/Tizen.Multimedia/Interop/Interop.ScreenMirroring.cs +++ b/src/Tizen.Multimedia/Interop/Interop.ScreenMirroring.cs @@ -1,20 +1,4 @@ -/* - * Copyright (c) 2016 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; using System.Runtime.InteropServices; internal static partial class Interop @@ -22,13 +6,13 @@ internal static partial class Interop internal static partial class ScreenMirroring { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - internal delegate void StateErrorCallback(IntPtr userData, int state, int error); + internal delegate void StateChangedCallback(IntPtr userData, int state, int error); [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_create")] internal static extern int Create(out IntPtr scmirroringSink); [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_set_state_changed_cb")] - internal static extern int SetStateErrorCb(IntPtr scmirroringSink, StateErrorCallback cb, IntPtr userData); + internal static extern int SetStateChangedCb(IntPtr scmirroringSink, StateChangedCallback cb, IntPtr userData); [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_set_ip_and_port")] internal static extern int SetIpAndPort(IntPtr scmirroringSink, string ip, string port); @@ -61,7 +45,7 @@ internal static partial class Interop internal static extern int Unprepare(IntPtr scmirroringSink); [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_unset_state_changed_cb")] - internal static extern int UnsetStateErrorCb(IntPtr scmirroringSink); + internal static extern int UnsetStateChangedCb(IntPtr scmirroringSink); [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_destroy")] internal static extern int Destroy(IntPtr scmirroringSink); diff --git a/src/Tizen.Multimedia/ScreenMirroring/AudioInformation.cs b/src/Tizen.Multimedia/ScreenMirroring/AudioInformation.cs index 447febf..dc3e716 100755 --- a/src/Tizen.Multimedia/ScreenMirroring/AudioInformation.cs +++ b/src/Tizen.Multimedia/ScreenMirroring/AudioInformation.cs @@ -48,9 +48,9 @@ namespace Tizen.Multimedia { int ret; ret = Interop.ScreenMirroring.GetNegotiatedAudioCodec(ref _handle, out _codec); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Failed to get audio codec" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Failed to get audio codec" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "failed to get audio codec"); } @@ -68,9 +68,9 @@ namespace Tizen.Multimedia { int ret; ret = Interop.ScreenMirroring.GetNegotiatedAudioChannel(ref _handle, out _channel); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Failed to get audio channel" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Failed to get audio channel" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "failed to get audio channel"); } @@ -88,9 +88,9 @@ namespace Tizen.Multimedia { int ret; ret = Interop.ScreenMirroring.GetNegotiatedAudioSampleRate(ref _handle, out _sampleRate); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Failed to get audio sample rate" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Failed to get audio sample rate" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "failed to get audio sample rate"); } @@ -108,9 +108,9 @@ namespace Tizen.Multimedia { int ret; ret = Interop.ScreenMirroring.GetNegotiatedAudioBitwidth(ref _handle, out _bitWidth); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Failed to get audio bitwidth" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Failed to get audio bitwidth" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "failed to get audio bitwidth"); } diff --git a/src/Tizen.Multimedia/ScreenMirroring/ErrorOccurredEventArgs.cs b/src/Tizen.Multimedia/ScreenMirroring/ErrorOccurredEventArgs.cs deleted file mode 100755 index a24d9f2..0000000 --- a/src/Tizen.Multimedia/ScreenMirroring/ErrorOccurredEventArgs.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2016 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; - -namespace Tizen.Multimedia -{ - /// - /// ErrorOccurred event arguments - /// - /// - /// ErrorOccurred event arguments - /// - public class ErrorOccurredEventArgs : EventArgs - { - internal int _error; - - /// - /// Constructor. - /// - /// Error Occurred - internal ErrorOccurredEventArgs(int error) - { - _error = error; - } - - /// - /// Get the error code. - /// - /// error code - public SCMirroringError Error - { - get - { - return (SCMirroringError)_error; - } - } - } -} \ No newline at end of file diff --git a/src/Tizen.Multimedia/ScreenMirroring/ScreenMirroring.cs b/src/Tizen.Multimedia/ScreenMirroring/ScreenMirroring.cs index 11b93b3..aafb29e 100755 --- a/src/Tizen.Multimedia/ScreenMirroring/ScreenMirroring.cs +++ b/src/Tizen.Multimedia/ScreenMirroring/ScreenMirroring.cs @@ -13,10 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - using System; using System.Threading.Tasks; -using System.Runtime.InteropServices; namespace Tizen.Multimedia { @@ -40,8 +38,7 @@ namespace Tizen.Multimedia private bool _disposed = false; private EventHandler _stateChanged; - private Interop.ScreenMirroring.StateErrorCallback _stateErrorCallback; - private EventHandler _errorOccurred; + private Interop.ScreenMirroring.StateChangedCallback _stateChangedCallback; /// /// Initializes a new instance of the ScreenMirroring class with parameters Ip, Port, Surface type and Display handle. @@ -57,7 +54,7 @@ namespace Tizen.Multimedia public ScreenMirroring(SurfaceType type, MediaView display, string ip, string port) { int ret = Interop.ScreenMirroring.Create(out _handle); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { ScreenMirroringErrorFactory.ThrowException(ret, "Failed to create Screen Mirroring Sink"); } @@ -70,17 +67,17 @@ namespace Tizen.Multimedia // Set ip and port int ret1 = Interop.ScreenMirroring.SetIpAndPort(_handle, _ip, _port); - if (ret1 != (int)SCMirroringError.None) + if (ret1 != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Set ip and port failed" + (SCMirroringError)ret1); + Log.Error(ScreenMirroringLog.LogTag, "Set ip and port failed" + (ScreenMirroringError)ret1); ScreenMirroringErrorFactory.ThrowException(ret, "set ip and port failed"); } // Set display int ret2 = Interop.ScreenMirroring.SetDisplay(_handle, (int)_type, _display); - if (ret2 != (int)SCMirroringError.None) + if (ret2 != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Set display failed" + (SCMirroringError)ret2); + Log.Error(ScreenMirroringLog.LogTag, "Set display failed" + (ScreenMirroringError)ret2); ScreenMirroringErrorFactory.ThrowException(ret, "set display failed"); } @@ -129,32 +126,6 @@ namespace Tizen.Multimedia } /// - /// ErrorOccurred event is raised when error is occured in screen mirroring sink. - /// Must be called after Create() API. - /// - public event EventHandler ErrorOccurred - { - add - { - if (_errorOccurred == null) - { - RegisterErrorOccurredEvent(); - } - - _errorOccurred += value; - } - - remove - { - _errorOccurred -= value; - if (_errorOccurred == null) - { - UnregisterErrorOccurredEvent(); - } - } - } - - /// /// Sets the server ip and port. /// This must be called before connect() and after create(). /// @@ -168,9 +139,9 @@ namespace Tizen.Multimedia public void SetIpAndPort(string ip, string port) { int ret = Interop.ScreenMirroring.SetIpAndPort(_handle, ip, port); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Set ip and port failed" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Set ip and port failed" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "set ip and port failed"); } } @@ -185,9 +156,9 @@ namespace Tizen.Multimedia public void SetResolution(int resolution) { int ret = Interop.ScreenMirroring.SetResolution(_handle, resolution); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Set resolution failed" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Set resolution failed" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "set resolution failed"); } } @@ -201,15 +172,15 @@ namespace Tizen.Multimedia /// /// Type. /// Display. - /// Display Handle not clear + /// Display Handle creates using mediaview class /// Thrown when method fail due to an invalid parameter /// Thrown when method fail due to an internal error public void SetDisplay(SurfaceType type, MediaView display) { int ret = Interop.ScreenMirroring.SetDisplay(_handle, (int)type, display); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Set display failed" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Set display failed" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "set display failed"); } } @@ -221,20 +192,19 @@ namespace Tizen.Multimedia public void Prepare() { int ret = Interop.ScreenMirroring.Prepare(_handle); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { ScreenMirroringErrorFactory.ThrowException(ret, "Failed to prepare sink for screen mirroring"); } } /// - /// Creates connection and prepare for receiving data from SCMIRRORING source. + /// Creates connection and prepare for receiving data from ScreenMirroring source. /// This must be called after prepare(). /// /// It will not give the current state. Need to subscribe for event to get the current state /// bool value /// http://tizen.org/privilege/internet - /// Thrown when method fail due to an invalid parameter /// Thrown when method fail due to an internal error public Task ConnectAsync() { @@ -242,18 +212,19 @@ namespace Tizen.Multimedia var task = new TaskCompletionSource(); Task.Factory.StartNew(() => - { - if (ret == (int)SCMirroringError.None) { - task.SetResult(true); - } - - else if (ret != (int)SCMirroringError.None) - { - task.SetResult(false); - ScreenMirroringErrorFactory.ThrowException(ret, "Failed to connect the screen mirroring source"); - } - }); + if (ret == (int)ScreenMirroringError.None) + { + task.SetResult(true); + } + + else if (ret != (int)ScreenMirroringError.None) + { + Log.Error(ScreenMirroringLog.LogTag, "Failed to start screen mirroring" + (ScreenMirroringError)ret); + InvalidOperationException e = new InvalidOperationException("Operation Failed"); + task.TrySetException(e); + } + }); return task.Task; } @@ -291,13 +262,12 @@ namespace Tizen.Multimedia } /// - /// Start receiving data from the SCMIRRORING source and display it(Mirror). + /// Start receiving data from the ScreenMirroring source and display it(Mirror). /// This must be called after connectasync(). /// /// It will not give the current state. Need to subscribe for event to get the current state /// bool value /// http://tizen.org/privilege/internet - /// Thrown when method fail due to an invalid parameter /// Thrown when method fail due to an internal error public Task StartAsync() { @@ -305,30 +275,30 @@ namespace Tizen.Multimedia var task = new TaskCompletionSource(); Task.Factory.StartNew(() => - { - if (ret == (int)SCMirroringError.None) { - task.SetResult(true); - } - - else if (ret != (int)SCMirroringError.None) - { - task.SetResult(false); - ScreenMirroringErrorFactory.ThrowException(ret, "Failed to start the screen mirroring"); - } - }); + if (ret == (int)ScreenMirroringError.None) + { + task.SetResult(true); + } + + else if (ret != (int)ScreenMirroringError.None) + { + Log.Error(ScreenMirroringLog.LogTag, "Failed to start screen mirroring" + (ScreenMirroringError)ret); + InvalidOperationException e = new InvalidOperationException("Operation Failed"); + task.TrySetException(e); + } + }); return task.Task; } /// - /// Pauses receiving data from the SCMIRRORING source. + /// Pauses receiving data from the ScreenMirroring source. /// This must be called after startasync(). /// /// It will not give the current state. Need to subscribe for event to get the current state /// bool value /// http://tizen.org/privilege/internet - /// Thrown when method fail due to an invalid parameter /// Thrown when method fail due to an internal error public Task PauseAsync() { @@ -336,30 +306,30 @@ namespace Tizen.Multimedia var task = new TaskCompletionSource(); Task.Factory.StartNew(() => - { - if (ret == (int)SCMirroringError.None) - { - task.SetResult(true); - } - - else if (ret != (int)SCMirroringError.None) { - task.SetResult(false); - ScreenMirroringErrorFactory.ThrowException(ret, "Failed to pause the receiving data from screen mirroring source"); - } - }); + if (ret == (int)ScreenMirroringError.None) + { + task.SetResult(true); + } + + else if (ret != (int)ScreenMirroringError.None) + { + Log.Error(ScreenMirroringLog.LogTag, "Failed to start screen mirroring" + (ScreenMirroringError)ret); + InvalidOperationException e = new InvalidOperationException("Operation Failed"); + task.TrySetException(e); + } + }); return task.Task; } /// - /// Resumes receiving data from the SCMIRRORING source. + /// Resumes receiving data from the ScreenMirroring source. /// This must be called after pauseasync(). /// /// It will not give the current state. Need to subscribe for event to get the current state /// bool value /// http://tizen.org/privilege/internet - /// Thrown when method fail due to an invalid parameter /// Thrown when method fail due to an internal error public Task ResumeAsync() { @@ -367,18 +337,19 @@ namespace Tizen.Multimedia var task = new TaskCompletionSource(); Task.Factory.StartNew(() => - { - if (ret == (int)SCMirroringError.None) { - task.SetResult(true); - } - - else if (ret != (int)SCMirroringError.None) - { - task.SetResult(false); - ScreenMirroringErrorFactory.ThrowException(ret, "Failed to resume the receiving data from screen mirroring source"); - } - }); + if (ret == (int)ScreenMirroringError.None) + { + task.SetResult(true); + } + + else if (ret != (int)ScreenMirroringError.None) + { + Log.Error(ScreenMirroringLog.LogTag, "Failed to start screen mirroring" + (ScreenMirroringError)ret); + InvalidOperationException e = new InvalidOperationException("Operation Failed"); + task.TrySetException(e); + } + }); return task.Task; } @@ -388,12 +359,12 @@ namespace Tizen.Multimedia /// valid states: connected/playing/paused /// /// http://tizen.org/privilege/internet - /// Thrown when method fail due to an invalid parameter + /// Thrown when method fail due to no connection between devices /// Thrown when method fail due to an internal error public void Disconnect() { int ret = Interop.ScreenMirroring.Disconnect(_handle); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { ScreenMirroringErrorFactory.ThrowException(ret, "Failed to disconnect sink for screen mirroring"); } @@ -403,12 +374,11 @@ namespace Tizen.Multimedia /// Unprepare this instance. /// valid states: prepared/disconnected. /// - /// Thrown when method fail due to an invalid parameter /// Thrown when method fail due to an internal error public void Unprepare() { int ret = Interop.ScreenMirroring.Unprepare(_handle); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { ScreenMirroringErrorFactory.ThrowException(ret, "Failed to reset the screen mirroring sink"); } @@ -459,30 +429,25 @@ namespace Tizen.Multimedia private void StateError(int state, int error) { ///if _stateChanged is subscribe, this will be invoke. - StateChangedEventArgs eventArgsState = new StateChangedEventArgs(state); + StateChangedEventArgs eventArgsState = new StateChangedEventArgs(state, error); _stateChanged?.Invoke(this, eventArgsState); - - ///if _errorOccurred is subscribe, this will be invoke. - ErrorOccurredEventArgs eventArgsError = new ErrorOccurredEventArgs(error); - _errorOccurred?.Invoke(this, eventArgsError); } /// /// Registers the state changed event. /// - /// Thrown when method fail due to an invalid parameter /// Thrown when method fail due to an internal error private void RegisterStateChangedEvent() { - _stateErrorCallback = (IntPtr userData, int state, int error) => + _stateChangedCallback = (IntPtr userData, int state, int error) => { StateError(state, error); }; - int ret = Interop.ScreenMirroring.SetStateErrorCb(_handle, _stateErrorCallback, IntPtr.Zero); - if (ret != (int)SCMirroringError.None) + int ret = Interop.ScreenMirroring.SetStateChangedCb(_handle, _stateChangedCallback, IntPtr.Zero); + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Setting StateChanged callback failed" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Setting StateChanged callback failed" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "Setting StateChanged callback failed"); } } @@ -490,51 +455,15 @@ namespace Tizen.Multimedia /// /// Unregisters the state changed event. /// - /// Thrown when method fail due to an invalid parameter /// Thrown when method fail due to an internal error private void UnregisterStateChangedEvent() { - int ret = Interop.ScreenMirroring.UnsetStateErrorCb(_handle); - if (ret != (int)SCMirroringError.None) + int ret = Interop.ScreenMirroring.UnsetStateChangedCb(_handle); + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Unsetting StateChnaged callback failed" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Unsetting StateChnaged callback failed" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "Unsetting StateChanged callback failed"); } } - - /// - /// Registers the error occurred event. - /// - /// Thrown when method fail due to an invalid parameter - /// Thrown when method fail due to an internal error - private void RegisterErrorOccurredEvent() - { - _stateErrorCallback = (IntPtr userData, int state, int error) => - { - StateError(state, error); - }; - - int ret = Interop.ScreenMirroring.SetStateErrorCb(_handle, _stateErrorCallback, IntPtr.Zero); - if (ret != (int)SCMirroringError.None) - { - Log.Error(ScreenMirroringLog.LogTag, "Setting ErrorOccurred callback failed" + (SCMirroringError)ret); - ScreenMirroringErrorFactory.ThrowException(ret, "Setting ErrorOccurred callback failed"); - } - } - - /// - /// Unregisters the error occurred event. - /// - /// Thrown when method fail due to an invalid parameter - /// Thrown when method fail due to an internal error - private void UnregisterErrorOccurredEvent() - { - int ret = Interop.ScreenMirroring.UnsetStateErrorCb(_handle); - if (ret != (int)SCMirroringError.None) - { - Log.Error(ScreenMirroringLog.LogTag, "Unsetting ErrorOccurred callback failed" + (SCMirroringError)ret); - ScreenMirroringErrorFactory.ThrowException(ret, "Unsetting ErrorOccurred callback failed"); - } - } } -} \ No newline at end of file +} diff --git a/src/Tizen.Multimedia/ScreenMirroring/ScreenMirroringEnumerations.cs b/src/Tizen.Multimedia/ScreenMirroring/ScreenMirroringEnumerations.cs index 82cce54..b84cd5b 100755 --- a/src/Tizen.Multimedia/ScreenMirroring/ScreenMirroringEnumerations.cs +++ b/src/Tizen.Multimedia/ScreenMirroring/ScreenMirroringEnumerations.cs @@ -105,7 +105,7 @@ namespace Tizen.Multimedia /// /// Enumeration for screen mirroring sink state /// - public enum SCMirroringSinkState + public enum ScreenMirroringSinkState { /// /// Screen mirroring is not created yet @@ -140,19 +140,15 @@ namespace Tizen.Multimedia /// /// Enumeration for screen mirroring error. /// - public enum SCMirroringError + public enum ScreenMirroringErrorCode { /// /// Successful /// - None = SCMirroringErrorCode.None, - /// - /// Invalid parameter - /// - InvalidParameter = SCMirroringErrorCode.InvalidParameter, + None = ScreenMirroringError.None, /// /// Invalid operation /// - InvalidOperation = SCMirroringErrorCode.InvalidOperation + InvalidOperation = ScreenMirroringError.InvalidOperation } -} +} \ No newline at end of file diff --git a/src/Tizen.Multimedia/ScreenMirroring/ScreenMirroringErrorFactory.cs b/src/Tizen.Multimedia/ScreenMirroring/ScreenMirroringErrorFactory.cs index ed69588..6c23f75 100755 --- a/src/Tizen.Multimedia/ScreenMirroring/ScreenMirroringErrorFactory.cs +++ b/src/Tizen.Multimedia/ScreenMirroring/ScreenMirroringErrorFactory.cs @@ -14,11 +14,11 @@ * limitations under the License. */ -using System; +using System; using Tizen.Internals.Errors; namespace Tizen.Multimedia { - internal enum SCMirroringErrorCode + internal enum ScreenMirroringError { None = ErrorCode.None, InvalidParameter = ErrorCode.InvalidParameter, @@ -33,23 +33,23 @@ namespace Tizen.Multimedia { internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null) { - SCMirroringErrorCode err = (SCMirroringErrorCode)errorCode; + ScreenMirroringError err = (ScreenMirroringError)errorCode; if (string.IsNullOrEmpty(errorMessage)) { errorMessage = err.ToString(); } - switch ((SCMirroringErrorCode)errorCode) + switch ((ScreenMirroringError)errorCode) { - case SCMirroringErrorCode.InvalidParameter: + case ScreenMirroringError.InvalidParameter: throw new ArgumentException(errorMessage, paramName); - case SCMirroringErrorCode.OutOfMemory: - case SCMirroringErrorCode.InvalidOperation: - case SCMirroringErrorCode.ConnectionTimeOut: - case SCMirroringErrorCode.PermissionDenied: - case SCMirroringErrorCode.NotSupported: - case SCMirroringErrorCode.Unknown: + case ScreenMirroringError.OutOfMemory: + case ScreenMirroringError.InvalidOperation: + case ScreenMirroringError.ConnectionTimeOut: + case ScreenMirroringError.PermissionDenied: + case ScreenMirroringError.NotSupported: + case ScreenMirroringError.Unknown: throw new InvalidOperationException(errorMessage); } } diff --git a/src/Tizen.Multimedia/ScreenMirroring/StateChangedEventArgs.cs b/src/Tizen.Multimedia/ScreenMirroring/StateChangedEventArgs.cs index fe4a2ff..6db0132 100755 --- a/src/Tizen.Multimedia/ScreenMirroring/StateChangedEventArgs.cs +++ b/src/Tizen.Multimedia/ScreenMirroring/StateChangedEventArgs.cs @@ -27,25 +27,40 @@ namespace Tizen.Multimedia public class StateChangedEventArgs : EventArgs { internal int _state; + internal int _error; /// /// Constructor. /// /// State Changed - internal StateChangedEventArgs(int state) + /// Error Occurred + internal StateChangedEventArgs(int state, int error) { _state = state; + _error = error; + } + + /// + /// Get the error. + /// + /// error code + public ScreenMirroringErrorCode Error + { + get + { + return (ScreenMirroringErrorCode)_error; + } } /// /// Get the current state. /// /// current state - public SCMirroringSinkState State + public ScreenMirroringSinkState State { get { - return (SCMirroringSinkState)_state; + return (ScreenMirroringSinkState)_state; } } } diff --git a/src/Tizen.Multimedia/ScreenMirroring/VideoInformation.cs b/src/Tizen.Multimedia/ScreenMirroring/VideoInformation.cs index d462cb7..b3ec9a1 100755 --- a/src/Tizen.Multimedia/ScreenMirroring/VideoInformation.cs +++ b/src/Tizen.Multimedia/ScreenMirroring/VideoInformation.cs @@ -1,3 +1,4 @@ +/// Video Information /* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * @@ -48,9 +49,9 @@ namespace Tizen.Multimedia { int ret; ret = Interop.ScreenMirroring.GetNegotiatedVideoCodec(ref _handle, out _codec); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Failed to get video codec" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Failed to get video codec" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "failed to get video codec"); } @@ -68,9 +69,9 @@ namespace Tizen.Multimedia { int ret; ret = Interop.ScreenMirroring.GetNegotiatedVideoResolution(ref _handle, out _width, out _height); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Failed to get height" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Failed to get height" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "failed to get video height"); } @@ -88,9 +89,9 @@ namespace Tizen.Multimedia { int ret; ret = Interop.ScreenMirroring.GetNegotiatedVideoResolution(ref _handle, out _width, out _height); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Failed to get width" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Failed to get width" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "failed to get video width"); } @@ -108,9 +109,9 @@ namespace Tizen.Multimedia { int ret; ret = Interop.ScreenMirroring.GetNegotiatedVideoFrameRate(ref _handle, out _frameRate); - if (ret != (int)SCMirroringError.None) + if (ret != (int)ScreenMirroringError.None) { - Log.Error(ScreenMirroringLog.LogTag, "Failed to get frame rate" + (SCMirroringError)ret); + Log.Error(ScreenMirroringLog.LogTag, "Failed to get frame rate" + (ScreenMirroringError)ret); ScreenMirroringErrorFactory.ThrowException(ret, "failed to get video frame rate"); } diff --git a/src/Tizen.Multimedia/Tizen.Multimedia.Net45.csproj b/src/Tizen.Multimedia/Tizen.Multimedia.Net45.csproj index f37d66e..f25d92f 100755 --- a/src/Tizen.Multimedia/Tizen.Multimedia.Net45.csproj +++ b/src/Tizen.Multimedia/Tizen.Multimedia.Net45.csproj @@ -240,7 +240,6 @@ - diff --git a/src/Tizen.Multimedia/Tizen.Multimedia.csproj b/src/Tizen.Multimedia/Tizen.Multimedia.csproj index 157ed29..d73ee4c 100755 --- a/src/Tizen.Multimedia/Tizen.Multimedia.csproj +++ b/src/Tizen.Multimedia/Tizen.Multimedia.csproj @@ -237,7 +237,6 @@ - @@ -270,4 +269,4 @@ <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory) true - + \ No newline at end of file