From: Vivek Ellur Date: Thu, 28 Jul 2016 08:38:30 +0000 (+0530) Subject: Multimedia: Fixed svace warnings, spec issues X-Git-Tag: submit/trunk/20170823.075128~94^2~204 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8987f6c25ab74d784401eb3f08693e4de12144a8;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Multimedia: Fixed svace warnings, spec issues Fixed svace warning in AudioStreamPolicy.cs and various spec issues. Change-Id: I87b35ae47981ecc4b13cdb25879c6a5e6aa0ded4 Signed-off-by: Vivek Ellur --- diff --git a/src/Tizen.Multimedia/AudioManager/AudioManagerEnumerations.cs b/src/Tizen.Multimedia/AudioManager/AudioManagerEnumerations.cs index 754d4aa..6773a6b 100644 --- a/src/Tizen.Multimedia/AudioManager/AudioManagerEnumerations.cs +++ b/src/Tizen.Multimedia/AudioManager/AudioManagerEnumerations.cs @@ -3,284 +3,291 @@ /// /// Enumeration for audio device options. /// - public enum AudioDeviceOptions{ - /// + public enum AudioDeviceOptions + { + /// /// Mask for input devices - /// - Input = 0x0001, - /// - /// Mask for output devices - /// - Output = 0x0002, - /// - /// Mask for input/output devices (both directions are available) - /// - InputAndOutput = 0x0004, - /// - /// Mask for built-in devices - /// - Internal = 0x00010, - /// - /// Mask for external devices - /// - External = 0x0020, - /// - /// Mask for deactivated devices - /// - Deactivated = 0x1000, - /// - /// Mask for activated devices - /// - Activated = 0x2000, - /// - /// Mask for all devices - /// - All = 0xFFFF + /// + Input = 0x0001, + /// + /// Mask for output devices + /// + Output = 0x0002, + /// + /// Mask for input/output devices (both directions are available) + /// + InputAndOutput = 0x0004, + /// + /// Mask for built-in devices + /// + Internal = 0x00010, + /// + /// Mask for external devices + /// + External = 0x0020, + /// + /// Mask for deactivated devices + /// + Deactivated = 0x1000, + /// + /// Mask for activated devices + /// + Activated = 0x2000, + /// + /// Mask for all devices + /// + All = 0xFFFF } + /// /// Enumeration for audio device type. /// - public enum AudioDeviceType{ - /// - /// Built-in speaker - /// - BuiltinSpeaker, - /// - /// Built-in receiver - /// - BuiltinReceiver, - /// - /// Built-in mic - /// - BuiltinMic, - /// - /// Audio jack that can be connected to wired accessory such as headphones and headsets - /// - AudioJack, - /// - /// Bluetooth - /// - Bluetooth, - /// - /// HDMI - /// - Hdmi, - /// - /// Device for forwarding - /// - Forwarding, - /// - /// USB Audio - /// - UsbAudio + public enum AudioDeviceType + { + /// + /// Built-in speaker + /// + BuiltinSpeaker, + /// + /// Built-in receiver + /// + BuiltinReceiver, + /// + /// Built-in mic + /// + BuiltinMic, + /// + /// Audio jack that can be connected to wired accessory such as headphones and headsets + /// + AudioJack, + /// + /// Bluetooth + /// + Bluetooth, + /// + /// HDMI + /// + Hdmi, + /// + /// Device for forwarding + /// + Forwarding, + /// + /// USB Audio + /// + UsbAudio } + /// /// Enumeration for audio device direction. /// - public enum AudioDeviceIoDirection{ - /// - /// Input device - /// - Input, - /// - /// Output device - /// - Output, - /// - /// Input/output device (both directions are available) - /// - InputAndOutput + public enum AudioDeviceIoDirection + { + /// + /// Input device + /// + Input, + /// + /// Output device + /// + Output, + /// + /// Input/output device (both directions are available) + /// + InputAndOutput } /// /// Enumeration for audio device state. /// - public enum AudioDeviceState{ - /// + public enum AudioDeviceState + { + /// /// Deactivated state - /// - Deactivated, - /// - /// Activated state - /// - Activated + /// + Deactivated, + /// + /// Activated state + /// + Activated } /// /// Enumeration for changed property of audio device. /// - public enum AudioDeviceProperty{ - /// - /// State of the device was changed - /// - State, - /// - /// IO direction of the device was changed - /// - IoDirection + public enum AudioDeviceProperty + { + /// + /// State of the device was changed + /// + State, + /// + /// IO direction of the device was changed + /// + IoDirection } /// /// Enumeration for audio type. /// - public enum AudioVolumeType{ - /// - /// Audio type for system - /// - System, - /// - /// Audio type for notifications - /// - Notification, - /// - /// Audio type for alarm - /// - Alarm, - /// - /// Audio type for ringtones - /// - Ringtone, - /// - /// Audio type for media - /// - Media, - /// - /// Audio type for call - /// - Call, - /// - /// Audio type for voip - /// - Voip, - /// - /// Audio type for voice - /// - Voice, - /// - /// Audio Type None - /// - None + public enum AudioVolumeType + { + /// + /// Audio type for system + /// + System, + /// + /// Audio type for notifications + /// + Notification, + /// + /// Audio type for alarm + /// + Alarm, + /// + /// Audio type for ringtones + /// + Ringtone, + /// + /// Audio type for media + /// + Media, + Call, + /// + /// Audio type for voip + /// + Voip, + /// + /// Audio type for voice + /// + Voice } + /// /// Enumeration for audio stream type. /// - public enum AudioStreamType{ - /// - /// Audio stream type for media - /// - Media, - /// - /// Audio stream type for system - /// - System, - /// - /// Audio stream type for alarm - /// - Alarm, - /// - /// Audio stream type for notification - /// - Notification, - /// - /// Audio stream type for emergency - /// - Emergency, - /// - /// Audio stream type for voice information - /// - VoiceInformation, - /// - /// Audio stream type for voice recognition - /// - VoiceRecognition, - /// - /// Audio stream type for ringtone for VoIP - /// - RingtoneVoip, - /// - /// Audio stream type for VoIP - /// - Voip, - /// - /// Audio stream type for media only for external devices - /// - MediaExternalOnly + public enum AudioStreamType + { + /// + /// Audio stream type for media + /// + Media, + /// + /// Audio stream type for system + /// + System, + /// + /// Audio stream type for alarm + /// + Alarm, + /// + /// Audio stream type for notification + /// + Notification, + /// + /// Audio stream type for emergency + /// + Emergency, + /// + /// Audio stream type for voice information + /// + VoiceInformation, + /// + /// Audio stream type for voice recognition + /// + VoiceRecognition, + /// + /// Audio stream type for ringtone for VoIP + /// + RingtoneVoip, + /// + /// Audio stream type for VoIP + /// + Voip, + /// + /// Audio stream type for media only for external devices + /// + MediaExternalOnly } + /// /// Enumeration for change reason of audio stream focus state. /// - public enum AudioStreamFocusChangedReason{ - /// - /// Changed by the stream type for media - /// - Media, - /// - /// Changed by the stream type for system - /// - System, - /// - /// Changed by the stream type for alarm - /// - Alarm, - /// - /// Changed by the stream type for notification - /// - Notification, - /// - /// Changed by the stream type for emergency - /// - Emergency, - /// - /// Changed by the stream type for voice information - /// - VoiceInformation, - /// - /// Changed by the stream type for voice recognition - /// - VoiceRecognition, - /// - /// Changed by the stream type for ringtone - /// - RingtoneVoip, - /// - /// Changed by the stream type for VoIP - /// - Voip, - /// - /// Changed by the stream type for voice-call or video-call - /// - Call, - /// - /// Changed by the stream type for media only for external devices - /// - MediaExternalOnly + public enum AudioStreamFocusChangedReason + { + /// + /// Changed by the stream type for media + /// + Media, + /// + /// Changed by the stream type for system + /// + System, + /// + /// Changed by the stream type for alarm + /// + Alarm, + /// + /// Changed by the stream type for notification + /// + Notification, + /// + /// Changed by the stream type for emergency + /// + Emergency, + /// + /// Changed by the stream type for voice information + /// + VoiceInformation, + /// + /// Changed by the stream type for voice recognition + /// + VoiceRecognition, + /// + /// Changed by the stream type for ringtone + /// + RingtoneVoip, + /// + /// Changed by the stream type for VoIP + /// + Voip, + /// + /// Changed by the stream type for voice-call or video-call + /// + Call, + /// + /// Changed by the stream type for media only for external devices + /// + MediaExternalOnly } /// /// Enumeration for audio stream focus options. /// - public enum AudioStreamFocusOptions{ - /// - /// Mask for playback focus - /// - Playback = 0x0001, - /// - /// Mask for recording focus - /// - Recording = 0x0002 + public enum AudioStreamFocusOptions + { + /// + /// Mask for playback focus + /// + Playback = 0x0001, + /// + /// Mask for recording focus + /// + Recording = 0x0002 } /// /// Enumeration for audio stream focus state. /// - public enum AudioStreamFocusState{ - /// - /// Focus state for release - /// - Released, - /// - ///Focus state for acquisition - /// - Acquired + public enum AudioStreamFocusState + { + /// + /// Focus state for release + /// + Released, + /// + ///Focus state for acquisition + /// + Acquired } } \ No newline at end of file diff --git a/src/Tizen.Multimedia/AudioManager/AudioStreamPolicy.cs b/src/Tizen.Multimedia/AudioManager/AudioStreamPolicy.cs index 08bd7fb..b481019 100644 --- a/src/Tizen.Multimedia/AudioManager/AudioStreamPolicy.cs +++ b/src/Tizen.Multimedia/AudioManager/AudioStreamPolicy.cs @@ -1,347 +1,309 @@ -using System; - -namespace Tizen.Multimedia -{ - internal static class AudioStreamPolicyLog - { - internal const string Tag = "Tizen.Multimedia.AudioStreamPolicy"; - } - - /// - /// The Stream Policy API provides functions to control a sound stream. - /// - public class AudioStreamPolicy : IDisposable - { - private static int _focusStateWatchCounter = 0; - private static EventHandler _focusStateWatchForPlayback; - private static EventHandler _focusStateWatchForRecording; - private static Interop.SoundStreamFocusStateWatchCallback _focusStateWatchCallback; - - private IntPtr _streamInfo; - private AudioStreamType _streamType; - private bool _disposed = false; - private EventHandler _focusStateChanged; - private Interop.SoundStreamFocusStateChangedCallback _focusStateChangedCallback; - - /// - /// Creates and returns an AudioStreamPolicy object - /// - /// - /// To apply the stream policy according to this stream information, this object should be passed to other APIs - /// related to playback or recording. (e.g., player, wav-player, audio-io, etc.) - /// - /// Type of sound stream for which policy needs to be created - /// StreamPolicy object - public AudioStreamPolicy(AudioStreamType streamType) - { - _streamType = streamType; - _focusStateChangedCallback = (IntPtr streamInfo, int reason, string extraInfo, IntPtr userData) => - { - StreamFocusStateChangedEventArgs eventArgs = new StreamFocusStateChangedEventArgs((AudioStreamFocusChangedReason)reason, extraInfo); - _focusStateChanged?.Invoke(this, eventArgs); - }; - int ret = Interop.AudioStreamPolicy.CreateStreamInformation((int)streamType, _focusStateChangedCallback, IntPtr.Zero, out _streamInfo); - AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to create stream information"); - } - - ~AudioStreamPolicy() - { - Dispose(false); - } - - /// - /// Registers the watch function to be invoked when the focus state for each sound stream type is changed regardless of the process. - /// - /// Remarks: You can set this only once per process. - /// - /// - public static event EventHandler PlaybackFocusStateWatch - { - add - { - if (_focusStateWatchCounter == 0) - { - RegisterFocusStateWatchEvent(); - } - _focusStateWatchCounter++; - _focusStateWatchForPlayback += value; - } - remove - { - _focusStateWatchForPlayback -= value; - _focusStateWatchCounter--; - if (_focusStateWatchCounter == 0) - { - UnregisterFocusStateWatch(); - } - } - } - - /// - /// Registers the watch function to be invoked when the focus state for each sound stream type is changed regardless of the process. - /// - /// Remarks: You can set this only once per process. - /// - /// - public static event EventHandler RecordingFocusStateWatch - { - add - { - if (_focusStateWatchCounter == 0) - { - RegisterFocusStateWatchEvent(); - } - _focusStateWatchCounter++; - _focusStateWatchForRecording += value; - } - remove - { - _focusStateWatchForRecording -= value; - _focusStateWatchCounter--; - if (_focusStateWatchCounter == 0) - { - UnregisterFocusStateWatch(); - } - } - } - - /// - /// Registers function to be called when the state of focus that belongs to the stream_info is changed. - /// - /// - /// Remarks: This function is issued in the internal thread of the sound manager. Therefore it is recommended not to call UI update function in this function. - /// Postcondition : FocusStateForPlayback and FokcusStateForRecording in the registered event handler to figure out how the focus state of the StreamInfo has been changed. - /// - public event EventHandler StreamFocusStateChanged - { - add - { - _focusStateChanged += value; - } - remove - { - _focusStateChanged -= value; - } - } - - /// - /// The sound type of the stream information. - /// - public AudioVolumeType VolumeType - { - get - { - AudioVolumeType soundType; - int ret = Interop.AudioStreamPolicy.GetSoundType(_streamInfo, out soundType); - if (ret != 0) - { - Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get sound type:" + (AudioManagerError)ret); - return AudioVolumeType.None; - } - return soundType; - } - } - - /// - /// The state of focus for playback. - /// - public AudioStreamFocusState PlaybackFocusState - { - get - { - AudioStreamFocusState stateForPlayback; - AudioStreamFocusState stateForRecording; - int ret = Interop.AudioStreamPolicy.GetFocusState(_streamInfo, out stateForPlayback, out stateForRecording); - if (ret != 0) - { - Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus state" + (AudioManagerError)ret); - return AudioStreamFocusState.Released; - } - return stateForPlayback; - } - } - - /// - /// The state of focus for recording. - /// - public AudioStreamFocusState RecordingFocusState - { - get - { - AudioStreamFocusState stateForPlayback; - AudioStreamFocusState stateForRecording; - int ret = Interop.AudioStreamPolicy.GetFocusState(_streamInfo, out stateForPlayback, out stateForRecording); - if (ret != 0) - { - Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus state" + (AudioManagerError)ret); - return AudioStreamFocusState.Released; - } - return stateForRecording; - } - } - - /// - /// Auto focus reacquisition property - /// - /// - /// The focus reacquistion is set as default. If you don't want to reacquire the focus you've lost automatically, disable the focus reacqusition setting by using this API and vice versa. - /// - public bool FocusReacquisitionEnabled - { - get - { - bool enabled; - int ret = Interop.AudioStreamPolicy.GetFocusReacquisition(_streamInfo, out enabled); - AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get focus reacquisition"); - if (ret != 0) - { - Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus reacquisition" + (AudioManagerError)ret); - return true; - } - return enabled; - } - set - { - int ret = Interop.AudioStreamPolicy.SetFocusReacquisition(_streamInfo, value); - AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus reacquisition"); - } - } - - internal IntPtr Handle - { - get - { - return _streamInfo; - } - } - - /// - /// Acquires the stream focus. - /// - /// The focus mask that user wants to acquire - /// The Extra information for this request (optional, this can be null) - /// - /// Do not call this API within event handlers of FocuStateChanged and StreamFocusStateWatch else it will throw and exception - /// - public void AcquireFocus(AudioStreamFocusOptions options, string extraInformation) - { - int ret = Interop.AudioStreamPolicy.AcquireFocus(_streamInfo, options, extraInformation); - Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Acquire focus return: " + ret); - AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to acquire focus"); - } - - /// - /// Releases the acquired focus. - /// - /// The focus mask that user wants to release - /// he Extra information for this request (optional, this can be null) - /// - /// Do not call this API within event handlers of FocuStateChanged and StreamFocusStateWatch else it will throw and exception - /// - public void ReleaseFocus(AudioStreamFocusOptions options, string extraInformation) - { - int ret = Interop.AudioStreamPolicy.ReleaseFocus(_streamInfo, options, extraInformation); - Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Release focus return: " + ret); - AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to release focus"); - } - - /// - /// Applies the stream routing. - /// - /// - /// If the stream has not been made yet, this setting will be applied when the stream starts to play. - /// Precondition: Call AddDeviceForStreamRouting() before calling this function. - /// - public void ApplyStreamRouting() - { - int ret = Interop.AudioStreamPolicy.ApplyStreamRouting(_streamInfo); - Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Apply Routing: " + (AudioManagerError)ret); - AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to apply stream routing"); - } - - /// - /// Adds the device to the stream information for the stream routing. - /// - /// - /// Remarks: Use SoundManager.GetCurrentDeviceList() to get the device. - /// The available types of the StreamInfo for this API are SoundStreamTypeVoip and SoundStreamTypeMediaExternalOnly. - /// Postcondition: You can apply this setting by calling ApplyStreamRouting(). - /// - /// The device item from the current sound devices list. - public void AddDeviceForStreamRouting(AudioDevice soundDevice) - { - int ret = Interop.AudioStreamPolicy.AddDeviceForStreamRouting(_streamInfo, soundDevice.Handle); - Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Add stream routing: " + (AudioManagerError)ret); - - AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to add device for stream routing"); - } - - /// - /// Removes the device to the stream information for the stream routing. - /// - /// - /// Remarks: Use SoundManager.GetCurrentDeviceList() to get the device. - /// The available types of the StreamInfo for this API are SoundStreamTypeVoip and SoundStreamTypeMediaExternalOnly. - /// Postcondition: You can apply this setting by calling ApplyStreamRouting(). - /// - /// The device item from the current sound devices list. - public void RemoveDeviceForStreamRouting(AudioDevice soundDevice) - { - int ret = Interop.AudioStreamPolicy.RemoveDeviceForStreamRouting(_streamInfo, soundDevice.Handle); - Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Remove stream routing: " + (AudioManagerError)ret); - AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to remove device for stream routing"); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (!_disposed) - { - if (disposing) - { - // to be used if there are any other disposable objects - } - if (_streamInfo != IntPtr.Zero) - { - Interop.AudioStreamPolicy.DestroyStreamInformation(_streamInfo); // Destroy the handle - _streamInfo = IntPtr.Zero; - } - _disposed = true; - } - } - - private static void RegisterFocusStateWatchEvent() - { - _focusStateWatchCallback = (AudioStreamFocusOptions options, AudioStreamFocusState focusState, AudioStreamFocusChangedReason reason, string extraInfo, IntPtr userData) => - { - FocusStateChangedEventArgs eventArgs = new FocusStateChangedEventArgs(focusState, reason, extraInfo); - if (options == AudioStreamFocusOptions.Playback) - { - _focusStateWatchForPlayback?.Invoke(null, eventArgs); - } - else if (options == AudioStreamFocusOptions.Recording) - { - _focusStateWatchForRecording?.Invoke(null, eventArgs); - } - else if (options == (AudioStreamFocusOptions.Playback | AudioStreamFocusOptions.Recording)) - { - _focusStateWatchForPlayback?.Invoke(null, eventArgs); - _focusStateWatchForRecording?.Invoke(null, eventArgs); - } - }; - int ret = Interop.AudioStreamPolicy.SetFocusStateWatchCallback(AudioStreamFocusOptions.Playback | AudioStreamFocusOptions.Recording, _focusStateWatchCallback, IntPtr.Zero); - AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus state watch callback"); - } - - private static void UnregisterFocusStateWatch() - { - int ret = Interop.AudioStreamPolicy.UnsetFocusStateWatchCallback(); - AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to unset focus state watch callback"); - } - } -} +using System; + +namespace Tizen.Multimedia +{ + internal static class AudioStreamPolicyLog + { + internal const string Tag = "Tizen.Multimedia.AudioStreamPolicy"; + } + + /// + /// The Stream Policy API provides functions to control a sound stream. + /// + public class AudioStreamPolicy : IDisposable + { + private static int _focusStateWatchCounter = 0; + private static EventHandler _focusStateWatchForPlayback; + private static EventHandler _focusStateWatchForRecording; + private static Interop.SoundStreamFocusStateWatchCallback _focusStateWatchCallback; + + private IntPtr _streamInfo; + private AudioStreamType _streamType; + private bool _disposed = false; + private EventHandler _focusStateChanged; + private Interop.SoundStreamFocusStateChangedCallback _focusStateChangedCallback; + + /// + /// Creates and returns an AudioStreamPolicy object + /// + /// + /// To apply the stream policy according to this stream information, this object should be passed to other APIs + /// related to playback or recording. (e.g., player, wav-player, audio-io, etc.) + /// + /// Type of sound stream for which policy needs to be created + /// StreamPolicy object + public AudioStreamPolicy(AudioStreamType streamType) + { + _streamType = streamType; + _focusStateChangedCallback = (IntPtr streamInfo, int reason, string extraInfo, IntPtr userData) => { + StreamFocusStateChangedEventArgs eventArgs = new StreamFocusStateChangedEventArgs((AudioStreamFocusChangedReason)reason, extraInfo); + _focusStateChanged?.Invoke(this, eventArgs); + }; + int ret = Interop.AudioStreamPolicy.CreateStreamInformation((int)streamType, _focusStateChangedCallback, IntPtr.Zero, out _streamInfo); + AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to create stream information"); + } + + ~AudioStreamPolicy() + { + Dispose(false); + } + + /// + /// Registers the watch function to be invoked when the focus state for each sound stream type is changed regardless of the process. + /// + /// Remarks: You can set this only once per process. + /// + /// + public static event EventHandler PlaybackFocusStateWatch { + add { + if(_focusStateWatchCounter == 0) { + RegisterFocusStateWatchEvent(); + } + _focusStateWatchCounter++; + _focusStateWatchForPlayback += value; + } + remove { + _focusStateWatchForPlayback -= value; + _focusStateWatchCounter--; + if(_focusStateWatchCounter == 0) { + UnregisterFocusStateWatch(); + } + } + } + + /// + /// Registers the watch function to be invoked when the focus state for each sound stream type is changed regardless of the process. + /// + /// Remarks: You can set this only once per process. + /// + /// + public static event EventHandler RecordingFocusStateWatch { + add { + if(_focusStateWatchCounter == 0) { + RegisterFocusStateWatchEvent(); + } + _focusStateWatchCounter++; + _focusStateWatchForRecording += value; + } + remove { + _focusStateWatchForRecording -= value; + _focusStateWatchCounter--; + if(_focusStateWatchCounter == 0) { + UnregisterFocusStateWatch(); + } + } + } + + /// + /// Registers function to be called when the state of focus that belongs to the current + /// streamInfo is changed. + /// + /// + /// Remarks: This function is issued in the internal thread of the sound manager. Therefore it is recommended not to call UI update function in this function. + /// Postcondition : Check PlaybackFocusState and RecordingFocusState in the registered event handler to figure out how the focus state of the StreamInfo has been changed. + /// + public event EventHandler StreamFocusStateChanged { + add { + _focusStateChanged += value; + } + remove { + _focusStateChanged -= value; + } + } + + /// + /// The sound type of the stream information. + /// + public AudioVolumeType VolumeType { + get { + AudioVolumeType soundType; + int ret = Interop.AudioStreamPolicy.GetSoundType(_streamInfo, out soundType); + if(ret != 0) { + Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get sound type:" + (AudioManagerError)ret); + return AudioVolumeType.None; + } + return soundType; + } + } + + /// + /// The state of focus for playback. + /// + public AudioStreamFocusState PlaybackFocusState { + get { + AudioStreamFocusState stateForPlayback; + AudioStreamFocusState stateForRecording; + int ret = Interop.AudioStreamPolicy.GetFocusState(_streamInfo, out stateForPlayback, out stateForRecording); + if(ret != 0) { + Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus state" + (AudioManagerError)ret); + return AudioStreamFocusState.Released; + } + return stateForPlayback; + } + } + + /// + /// The state of focus for recording. + /// + public AudioStreamFocusState RecordingFocusState { + get { + AudioStreamFocusState stateForPlayback; + AudioStreamFocusState stateForRecording; + int ret = Interop.AudioStreamPolicy.GetFocusState(_streamInfo, out stateForPlayback, out stateForRecording); + if(ret != 0) { + Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus state" + (AudioManagerError)ret); + return AudioStreamFocusState.Released; + } + return stateForRecording; + } + } + + /// + /// Auto focus reacquisition property + /// + /// + /// The focus reacquistion is set as default. If you don't want to reacquire the focus you've lost automatically, disable the focus reacqusition setting by using this API and vice versa. + /// + public bool FocusReacquisitionEnabled { + get { + bool enabled; + int ret = Interop.AudioStreamPolicy.GetFocusReacquisition(_streamInfo, out enabled); + if(ret != 0) { + Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus reacquisition" + (AudioManagerError)ret); + return true; + } + return enabled; + } + set { + int ret = Interop.AudioStreamPolicy.SetFocusReacquisition(_streamInfo, value); + AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus reacquisition"); + } + } + + internal IntPtr Handle { + get { + return _streamInfo; + } + } + + /// + /// Acquires the stream focus. + /// + /// The focus mask that user wants to acquire + /// The Extra information for this request (optional, this can be null) + /// + /// Do not call this API within event handlers of FocuStateChanged and StreamFocusStateWatch else it will throw and exception + /// + public void AcquireFocus(AudioStreamFocusOptions options, string extraInformation) + { + int ret = Interop.AudioStreamPolicy.AcquireFocus(_streamInfo, options, extraInformation); + Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Acquire focus return: " + ret); + AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to acquire focus"); + } + + /// + /// Releases the acquired focus. + /// + /// The focus mask that user wants to release + /// he Extra information for this request (optional, this can be null) + /// + /// Do not call this API within event handlers of FocuStateChanged and StreamFocusStateWatch else it will throw and exception + /// + public void ReleaseFocus(AudioStreamFocusOptions options, string extraInformation) + { + int ret = Interop.AudioStreamPolicy.ReleaseFocus(_streamInfo, options, extraInformation); + Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Release focus return: " + ret); + AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to release focus"); + } + + /// + /// Applies the stream routing. + /// + /// + /// If the stream has not been made yet, this setting will be applied when the stream starts to play. + /// Precondition: Call AddDeviceForStreamRouting() before calling this function. + /// + public void ApplyStreamRouting() + { + int ret = Interop.AudioStreamPolicy.ApplyStreamRouting(_streamInfo); + Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Apply Routing: " + (AudioManagerError)ret); + AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to apply stream routing"); + } + + /// + /// Adds the device to the stream information for the stream routing. + /// + /// + /// Remarks: Use SoundManager.GetCurrentDeviceList() to get the device. + /// The available types of the StreamInfo for this API are SoundStreamTypeVoip and SoundStreamTypeMediaExternalOnly. + /// Postcondition: You can apply this setting by calling ApplyStreamRouting(). + /// + /// The device item from the current sound devices list. + public void AddDeviceForStreamRouting(AudioDevice soundDevice) + { + int ret = Interop.AudioStreamPolicy.AddDeviceForStreamRouting(_streamInfo, soundDevice.Handle); + Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Add stream routing: " + (AudioManagerError)ret); + + AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to add device for stream routing"); + } + + /// + /// Removes the device to the stream information for the stream routing. + /// + /// + /// Remarks: Use SoundManager.GetCurrentDeviceList() to get the device. + /// The available types of the StreamInfo for this API are SoundStreamTypeVoip and SoundStreamTypeMediaExternalOnly. + /// Postcondition: You can apply this setting by calling ApplyStreamRouting(). + /// + /// The device item from the current sound devices list. + public void RemoveDeviceForStreamRouting(AudioDevice soundDevice) + { + int ret = Interop.AudioStreamPolicy.RemoveDeviceForStreamRouting(_streamInfo, soundDevice.Handle); + Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Remove stream routing: " + (AudioManagerError)ret); + AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to remove device for stream routing"); + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if(!_disposed) { + if(disposing) { + // to be used if there are any other disposable objects + } + if(_streamInfo != IntPtr.Zero) { + Interop.AudioStreamPolicy.DestroyStreamInformation(_streamInfo); // Destroy the handle + _streamInfo = IntPtr.Zero; + } + _disposed = true; + } + } + + private static void RegisterFocusStateWatchEvent() + { + _focusStateWatchCallback = (AudioStreamFocusOptions options, AudioStreamFocusState focusState, AudioStreamFocusChangedReason reason, string extraInfo, IntPtr userData) => { + FocusStateChangedEventArgs eventArgs = new FocusStateChangedEventArgs(focusState, reason, extraInfo); + if(options == AudioStreamFocusOptions.Playback) { + _focusStateWatchForPlayback?.Invoke(null, eventArgs); + } else if(options == AudioStreamFocusOptions.Recording) { + _focusStateWatchForRecording?.Invoke(null, eventArgs); + } else if(options == (AudioStreamFocusOptions.Playback | AudioStreamFocusOptions.Recording)) { + _focusStateWatchForPlayback?.Invoke(null, eventArgs); + _focusStateWatchForRecording?.Invoke(null, eventArgs); + } + }; + int ret = Interop.AudioStreamPolicy.SetFocusStateWatchCallback(AudioStreamFocusOptions.Playback | AudioStreamFocusOptions.Recording, _focusStateWatchCallback, IntPtr.Zero); + AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus state watch callback"); + } + + private static void UnregisterFocusStateWatch() + { + int ret = Interop.AudioStreamPolicy.UnsetFocusStateWatchCallback(); + AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to unset focus state watch callback"); + } + } +} diff --git a/src/Tizen.Multimedia/AudioManager/AudioVolume.cs b/src/Tizen.Multimedia/AudioManager/AudioVolume.cs index b817260..07b0d43 100644 --- a/src/Tizen.Multimedia/AudioManager/AudioVolume.cs +++ b/src/Tizen.Multimedia/AudioManager/AudioVolume.cs @@ -24,23 +24,18 @@ namespace Tizen.Multimedia /// /// Registers a function to be invoked when the volume level is changed. /// - public event EventHandler Changed - { - add - { + public event EventHandler Changed { + add { Tizen.Log.Info(AudioVolumeLog.Tag, "VolumeController Changed Event added...."); - if (_volumeChanged == null) - { + if(_volumeChanged == null) { RegisterVolumeChangedEvent(); } _volumeChanged += value; } - remove - { + remove { Tizen.Log.Info(AudioVolumeLog.Tag, "VolumeController Changed Event removed...."); _volumeChanged -= value; - if (_volumeChanged == null) - { + if(_volumeChanged == null) { UnregisterVolumeChangedEvent(); } } @@ -50,26 +45,20 @@ namespace Tizen.Multimedia /// The Sound Manager has predefined types of sounds.(system, notification, alarm, ringtone, media, call, voip, voice). /// The type of the sound being currently played. /// - public AudioVolumeType CurrentType - { - get - { + public AudioVolumeType CurrentType { + get { AudioVolumeType currentType; int ret = Interop.AudioVolume.GetCurrentSoundType(out currentType); - if ( ret != 0) - { + if(ret != 0) { Tizen.Log.Info(AudioVolumeLog.Tag, "Unable to get current sound type" + (AudioManagerError)ret); return AudioVolumeType.None; } return currentType; } - set - { + set { int ret = Interop.AudioVolume.SetCurrentSoundType(value); - if (ret != 0) - { - if (value == AudioVolumeType.None) - { + if(ret != 0) { + if(value == AudioVolumeType.None) { ret = Interop.AudioVolume.UnsetCurrentType(); } } @@ -77,14 +66,19 @@ namespace Tizen.Multimedia } } + /// + /// The indexer class which is used to get/set volume level specified for a particular sound type. + /// public VolumeLevel Level; + /// + /// The indexer class which is used to get maximum volume level supported for a particular sound type. + /// public MaxVolumeLevel MaxLevel; private void RegisterVolumeChangedEvent() { - _volumeChangedCallback = (AudioVolumeType type, uint volume, IntPtr userData) => - { + _volumeChangedCallback = (AudioVolumeType type, uint volume, IntPtr userData) => { VolumeChangedEventArgs eventArgs = new VolumeChangedEventArgs(type, volume); _volumeChanged.Invoke(this, eventArgs); }; diff --git a/src/Tizen.Multimedia/AudioManager/MaxVolumeLevel.cs b/src/Tizen.Multimedia/AudioManager/MaxVolumeLevel.cs index f30290e..6737153 100644 --- a/src/Tizen.Multimedia/AudioManager/MaxVolumeLevel.cs +++ b/src/Tizen.Multimedia/AudioManager/MaxVolumeLevel.cs @@ -7,18 +7,19 @@ namespace Tizen.Multimedia internal const string Tag = "Tizen.Multimedia.MaxVolume"; } + /// + /// This is a indexer class which is used to get the maximum volume level + /// supported for a particular sound type. + /// public class MaxVolumeLevel { - public int this[AudioVolumeType type] - { - get - { - if (type == AudioVolumeType.None) + public int this [AudioVolumeType type] { + get { + if(type == AudioVolumeType.None) throw new ArgumentException("Wrong Audio volume type. Cannot get max volume level for AudioVolumeType.None"); int maxVolume; int ret = Interop.AudioVolume.GetMaxVolume(type, out maxVolume); - if (ret != 0) - { + if(ret != 0) { Tizen.Log.Info(MaxVolumeLog.Tag, "Max Level Error: " + (AudioManagerError)ret); return -1; } diff --git a/src/Tizen.Multimedia/AudioManager/VolumeLevel.cs b/src/Tizen.Multimedia/AudioManager/VolumeLevel.cs index e4e6074..df3ada9 100644 --- a/src/Tizen.Multimedia/AudioManager/VolumeLevel.cs +++ b/src/Tizen.Multimedia/AudioManager/VolumeLevel.cs @@ -7,30 +7,29 @@ namespace Tizen.Multimedia internal const string Tag = "Tizen.Multimedia.VolumeLevel"; } + /// + /// This is a indexer class which is used to get/set the volume level + /// specified for a particular sound type. + /// public class VolumeLevel { - public int this[AudioVolumeType type] - { - get - { - if (type == AudioVolumeType.None) + public int this [AudioVolumeType type] { + get { + if(type == AudioVolumeType.None) throw new ArgumentException("Wrong Audio volume type. Cannot get volume level for AudioVolumeType.None"); int volume; int ret = Interop.AudioVolume.GetVolume(type, out volume); - if (ret != 0) - { + if(ret != 0) { Tizen.Log.Info(VolumeLevelLog.Tag, "Get Level Error: " + (AudioManagerError)ret); return -1; } return volume; } - set - { - if (type == AudioVolumeType.None) + set { + if(type == AudioVolumeType.None) throw new ArgumentException("Wrong Audio volume type. Cannot set volume level for AudioVolumeType.None"); int ret = Interop.AudioVolume.SetVolume(type, value); - if (ret != 0) - { + if(ret != 0) { Tizen.Log.Info(VolumeLevelLog.Tag, "Set Level Error: " + (AudioManagerError)ret); AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set level"); } diff --git a/src/Tizen.Multimedia/Recorder/AudioStreamDeliveredEventArgs.cs b/src/Tizen.Multimedia/Recorder/AudioStreamDeliveredEventArgs.cs index acd495e..a50c3d0 100644 --- a/src/Tizen.Multimedia/Recorder/AudioStreamDeliveredEventArgs.cs +++ b/src/Tizen.Multimedia/Recorder/AudioStreamDeliveredEventArgs.cs @@ -7,61 +7,53 @@ namespace Tizen.Multimedia /// public class AudioStreamDeliveredEventArgs : EventArgs { - private byte[] _stream = null; - private AudioSampleType _type = AudioSampleType.S16Le; - private int _channel = 0; - private uint _recordingTime = 0; + private byte[] _stream = null; + private AudioSampleType _type = AudioSampleType.S16Le; + private int _channel = 0; + private uint _recordingTime = 0; - internal AudioStreamDeliveredEventArgs(byte[] stream, AudioSampleType type, int channel, uint recordingTime) - { - _stream = stream; - _type = type; - _channel = channel; - _recordingTime = recordingTime; - } + internal AudioStreamDeliveredEventArgs(byte[] stream, AudioSampleType type, int channel, uint recordingTime) + { + _stream = stream; + _type = type; + _channel = channel; + _recordingTime = recordingTime; + } /// /// The audio stream data. /// - public byte[] Stream - { - get - { - return _stream; - } + public byte[] Stream { + get { + return _stream; + } } /// /// The audio format type. /// - public AudioSampleType Type - { - get - { - return _type; - } + public AudioSampleType Type { + get { + return _type; + } } /// /// The number of channels. /// - public int Channel - { - get - { - return _channel; - } + public int Channel { + get { + return _channel; + } } /// /// The recording time of the stream buffer in milliseconds. /// - public uint RecordingTime - { - get - { - return _recordingTime; - } + public uint RecordingTime { + get { + return _recordingTime; + } } } } diff --git a/src/Tizen.Multimedia/Recorder/Camera.cs b/src/Tizen.Multimedia/Recorder/Camera.cs index 001fc1f..d17248b 100644 --- a/src/Tizen.Multimedia/Recorder/Camera.cs +++ b/src/Tizen.Multimedia/Recorder/Camera.cs @@ -2,11 +2,14 @@ namespace Tizen.Multimedia { - public class Camera - { - public Camera () - { - } - } + /// + /// The Camera API allows application developers to support using the camera + /// + public class Camera + { + public Camera() + { + } + } } diff --git a/src/Tizen.Multimedia/Recorder/Recorder.cs b/src/Tizen.Multimedia/Recorder/Recorder.cs index cce7719..0dab2ac 100644 --- a/src/Tizen.Multimedia/Recorder/Recorder.cs +++ b/src/Tizen.Multimedia/Recorder/Recorder.cs @@ -377,7 +377,7 @@ namespace Tizen.Multimedia } /// - /// The maximum size of a recording file in KB(kilobytes). If 0 means + /// The maximum size of a recording file in KB(kilobytes). If 0, means /// unlimited recording size. /// /// @@ -411,7 +411,7 @@ namespace Tizen.Multimedia } /// - /// The time limit of a recording file in Seconds. If 0 means unlimited recording + /// The time limit of a recording file in Seconds. If 0, means unlimited recording /// time. /// /// @@ -922,10 +922,7 @@ namespace Tizen.Multimedia Dispose(true); GC.SuppressFinalize(this); } - /// - /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects. - /// - /// If true, disposes any disposable objects. If false, does not dispose disposable objects. + protected virtual void Dispose(bool disposing) { if (!_disposed) diff --git a/src/Tizen.Multimedia/Recorder/RecorderEnums.cs b/src/Tizen.Multimedia/Recorder/RecorderEnums.cs index a44e7ed..5558fdf 100644 --- a/src/Tizen.Multimedia/Recorder/RecorderEnums.cs +++ b/src/Tizen.Multimedia/Recorder/RecorderEnums.cs @@ -2,203 +2,204 @@ using System; namespace Tizen.Multimedia { - /// - /// Enumeration for Audio Codec. - /// - public enum RecorderAudioCodec - { - /// - /// Disable Audio track. - /// - Disable = -1, - /// - /// AMR codec. - /// - Amr = 0, - /// - /// AAC codec. - /// - Aac, - /// - /// Vorbis codec. - /// - Vorbis, - /// - /// PCM codec. - /// - Pcm, - /// - /// The mp3 codec. - /// - Mp3 - } + /// + /// Enumeration for Audio Codec. + /// + public enum RecorderAudioCodec + { + /// + /// Disable Audio track. + /// + Disable = -1, + /// + /// AMR codec. + /// + Amr = 0, + /// + /// AAC codec. + /// + Aac, + /// + /// Vorbis codec. + /// + Vorbis, + /// + /// PCM codec. + /// + Pcm, + /// + /// The mp3 codec. + /// + Mp3 + } - /// - /// Enumeration for Audio capture devices. - /// - public enum RecorderAudioDevice - { - /// - /// Capture audio from Mic device. - /// - Mic, - /// - /// Capture audio from modem. - /// - Modem - } + /// + /// Enumeration for Audio capture devices. + /// + public enum RecorderAudioDevice + { + /// + /// Capture audio from Mic device. + /// + Mic, + /// + /// Capture audio from modem. + /// + Modem + } - /// - /// Enumeration for the file container format. - /// - public enum RecorderFileFormat - { - /// - /// 3GP file format. - /// - ThreeGp, - /// - /// MP4 file format. - /// - Mp4, - /// - /// AMR file format. - /// - Amr, - /// - /// ADTS file format. - /// - Adts, - /// - /// WAV file format. - /// - Wav, - /// - /// OGG file format. - /// - Ogg, - /// - /// M2TS file format. - /// - M2ts - } + /// + /// Enumeration for the file container format. + /// + public enum RecorderFileFormat + { + /// + /// 3GP file format. + /// + ThreeGp, + /// + /// MP4 file format. + /// + Mp4, + /// + /// AMR file format. + /// + Amr, + /// + /// ADTS file format. + /// + Adts, + /// + /// WAV file format. + /// + Wav, + /// + /// OGG file format. + /// + Ogg, + /// + /// M2TS file format. + /// + M2ts + } - /// - /// Enumeration for the recorder policy. - /// - public enum RecorderPolicy - { - /// - /// None. - /// - None = 0, - /// - /// Security policy. - /// - Security = 4, - /// - /// Resource conflict policy. - /// - ResourceConflict = 5 - } + /// + /// Enumeration for the recorder policy. + /// + public enum RecorderPolicy + { + /// + /// None. + /// + None = 0, + /// + /// Security policy. + /// + Security = 4, + /// + /// Resource conflict policy. + /// + ResourceConflict = 5 + } - /// - /// Enumeration for the recording limit. - /// - public enum RecordingLimitType - { - /// - /// Time limit in seconds of recording file - /// - Time, - /// - /// Size limit in KB(KiloBytes) of recording file. - /// - Size, - /// - /// No free space in storage. - /// - Space - } + /// + /// Enumeration for the recording limit. + /// + public enum RecordingLimitType + { + /// + /// Time limit in seconds of recording file + /// + Time, + /// + /// Size limit in KB(KiloBytes) of recording file. + /// + Size, + /// + /// No free space in storage. + /// + Space + } - /// - /// Enumeration for the recorder rotation type. - /// - public enum RecorderOrientation - { - /// - /// No rotation. - /// - RotationNone, - /// - /// 90 Degree rotation. - /// - Rotation90, - /// - /// 180 Degree rotation. - /// - Rotation180, - /// - /// 270 Degree rotation. - /// - Rotation270 - } + /// + /// Enumeration for the recorder rotation type. + /// + public enum RecorderOrientation + { + /// + /// No rotation. + /// + RotationNone, + /// + /// 90 Degree rotation. + /// + Rotation90, + /// + /// 180 Degree rotation. + /// + Rotation180, + /// + /// 270 Degree rotation. + /// + Rotation270 + } - /// - /// Enumeration for recorder states. - /// - public enum RecorderState - { - /// - /// Recorder is not created. - /// - None, - /// - /// Recorder is created, but not prepared. - /// - Created, - /// - /// Recorder is ready to record. In case of video recorder, - /// preview display will be shown. - /// - Ready, - /// - /// Recorder is recording media. - /// - Recording, - /// - /// Recorder is paused while recording media. - /// - Paused - } + /// + /// Enumeration for recorder states. + /// + public enum RecorderState + { + /// + /// Recorder is not created. + /// + None, + /// + /// Recorder is created, but not prepared. + /// + Created, + /// + /// Recorder is ready to record. In case of video recorder, + /// preview display will be shown. + /// + Ready, + /// + /// Recorder is recording media. + /// + Recording, + /// + /// Recorder is paused while recording media. + /// + Paused + } - /// - /// Enumeration for video codec. - /// - public enum RecorderVideoCodec - { - /// - /// H263 codec. - /// - H263, - /// - /// H264 codec. - /// - H264, - /// - /// MPEG4 codec. - /// - Mpeg4, - /// - /// Theora codec. - /// - Theora - } + /// + /// Enumeration for video codec. + /// + public enum RecorderVideoCodec + { + /// + /// H263 codec. + /// + H263, + /// + /// H264 codec. + /// + H264, + /// + /// MPEG4 codec. + /// + Mpeg4, + /// + /// Theora codec. + /// + Theora + } /// /// Enumeration for audio sample type. /// - public enum AudioSampleType { + public enum AudioSampleType + { /// /// Unsigned 8-bit audio samples. /// @@ -212,19 +213,20 @@ namespace Tizen.Multimedia /// /// Enumeration for recorder failure error. /// - public enum RecorderErrorCode { + public enum RecorderErrorCode + { /// /// Device Error. /// - DeviceError = RecorderError.ErrorDevice, + DeviceError = RecorderError.ErrorDevice, /// /// Internal error. /// - InvalidOperation = RecorderError.InvalidOperation, + InvalidOperation = RecorderError.InvalidOperation, /// /// Out of memory. /// - OutOfMemory = RecorderError.OutOfMemory + OutOfMemory = RecorderError.OutOfMemory } } diff --git a/src/Tizen.Multimedia/Recorder/RecorderErrorFactory.cs b/src/Tizen.Multimedia/Recorder/RecorderErrorFactory.cs index db2e593..e33a27a 100644 --- a/src/Tizen.Multimedia/Recorder/RecorderErrorFactory.cs +++ b/src/Tizen.Multimedia/Recorder/RecorderErrorFactory.cs @@ -3,57 +3,55 @@ using Tizen.Internals.Errors; namespace Tizen.Multimedia { - internal enum RecorderError - { - None = ErrorCode.None, - InvalidParameter = ErrorCode.InvalidParameter, - TizenErrorRecorder = -0x01950000, - RecorderErrorClass = TizenErrorRecorder | 0x10, - InvalidState = RecorderErrorClass | 0x02, - OutOfMemory = ErrorCode.OutOfMemory, - ErrorDevice = RecorderErrorClass | 0x04, - InvalidOperation = ErrorCode.InvalidOperation, - SoundPolicy = RecorderErrorClass | 0x06, - SecurityRestricted = RecorderErrorClass | 0x07, - SoundPolicyByCall = RecorderErrorClass | 0x08, - SoundPolicyByAlarm = RecorderErrorClass | 0x09, - Esd = RecorderErrorClass | 0x0a, - OutOfStorage = RecorderErrorClass | 0x0b, - PermissionDenied = ErrorCode.PermissionDenied, - NotSupported = ErrorCode.NotSupported, - ResourceConflict = RecorderErrorClass | 0x0c - } + internal enum RecorderError + { + None = ErrorCode.None, + InvalidParameter = ErrorCode.InvalidParameter, + TizenErrorRecorder = -0x01950000, + RecorderErrorClass = TizenErrorRecorder | 0x10, + InvalidState = RecorderErrorClass | 0x02, + OutOfMemory = ErrorCode.OutOfMemory, + ErrorDevice = RecorderErrorClass | 0x04, + InvalidOperation = ErrorCode.InvalidOperation, + SoundPolicy = RecorderErrorClass | 0x06, + SecurityRestricted = RecorderErrorClass | 0x07, + SoundPolicyByCall = RecorderErrorClass | 0x08, + SoundPolicyByAlarm = RecorderErrorClass | 0x09, + Esd = RecorderErrorClass | 0x0a, + OutOfStorage = RecorderErrorClass | 0x0b, + PermissionDenied = ErrorCode.PermissionDenied, + NotSupported = ErrorCode.NotSupported, + ResourceConflict = RecorderErrorClass | 0x0c + } - internal static class RecorderErrorFactory - { - internal static void ThrowException(int errorCode, string errorMessage = null, string paramName= null) - { - RecorderError err = (RecorderError)errorCode; - if (string.IsNullOrEmpty (errorMessage)) - { - errorMessage = err.ToString (); - } - switch ((RecorderError)errorCode) - { - case RecorderError.InvalidParameter: - throw new ArgumentException (errorMessage, paramName); + internal static class RecorderErrorFactory + { + internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null) + { + RecorderError err = (RecorderError)errorCode; + if(string.IsNullOrEmpty(errorMessage)) { + errorMessage = err.ToString(); + } + switch((RecorderError)errorCode) { + case RecorderError.InvalidParameter: + throw new ArgumentException(errorMessage, paramName); - case RecorderError.InvalidState: - case RecorderError.OutOfMemory: - case RecorderError.ErrorDevice: - case RecorderError.InvalidOperation: - case RecorderError.SoundPolicy: - case RecorderError.SecurityRestricted: - case RecorderError.SoundPolicyByCall: - case RecorderError.SoundPolicyByAlarm: - case RecorderError.Esd: - case RecorderError.OutOfStorage: - case RecorderError.PermissionDenied: - case RecorderError.NotSupported: - case RecorderError.ResourceConflict: - throw new InvalidOperationException (errorMessage); - } - } - } + case RecorderError.InvalidState: + case RecorderError.OutOfMemory: + case RecorderError.ErrorDevice: + case RecorderError.InvalidOperation: + case RecorderError.SoundPolicy: + case RecorderError.SecurityRestricted: + case RecorderError.SoundPolicyByCall: + case RecorderError.SoundPolicyByAlarm: + case RecorderError.Esd: + case RecorderError.OutOfStorage: + case RecorderError.PermissionDenied: + case RecorderError.NotSupported: + case RecorderError.ResourceConflict: + throw new InvalidOperationException(errorMessage); + } + } + } } diff --git a/src/Tizen.Multimedia/Recorder/RecorderInterruptedEventArgs.cs b/src/Tizen.Multimedia/Recorder/RecorderInterruptedEventArgs.cs index 64bf78f..7771d35 100644 --- a/src/Tizen.Multimedia/Recorder/RecorderInterruptedEventArgs.cs +++ b/src/Tizen.Multimedia/Recorder/RecorderInterruptedEventArgs.cs @@ -9,48 +9,42 @@ namespace Tizen.Multimedia /// public class RecorderInterruptedEventArgs : EventArgs { - private RecorderPolicy _policy = RecorderPolicy.None; - private RecorderState _previous = RecorderState.None; - private RecorderState _current = RecorderState.None; + private RecorderPolicy _policy = RecorderPolicy.None; + private RecorderState _previous = RecorderState.None; + private RecorderState _current = RecorderState.None; - internal RecorderInterruptedEventArgs(RecorderPolicy policy, RecorderState previous, RecorderState current) - { - _policy = policy; - _previous = previous; - _current = current; - } + internal RecorderInterruptedEventArgs(RecorderPolicy policy, RecorderState previous, RecorderState current) + { + _policy = policy; + _previous = previous; + _current = current; + } /// /// The policy that interrupted the recorder. /// - public RecorderPolicy Policy - { - get - { - return _policy; - } + public RecorderPolicy Policy { + get { + return _policy; + } } /// /// The previous state of the recorder. /// - public RecorderState Previous - { - get - { - return _previous; - } + public RecorderState Previous { + get { + return _previous; + } } /// /// The current state of the recorder. /// - public RecorderState Current - { - get - { - return _current; - } + public RecorderState Current { + get { + return _current; + } } } } diff --git a/src/Tizen.Multimedia/Recorder/RecorderStateChangedEventArgs.cs b/src/Tizen.Multimedia/Recorder/RecorderStateChangedEventArgs.cs index 5cdb53b..23e0f07 100644 --- a/src/Tizen.Multimedia/Recorder/RecorderStateChangedEventArgs.cs +++ b/src/Tizen.Multimedia/Recorder/RecorderStateChangedEventArgs.cs @@ -8,48 +8,43 @@ namespace Tizen.Multimedia /// public class RecorderStateChangedEventArgs : EventArgs { - private RecorderState _previous = RecorderState.None; - private RecorderState _current = RecorderState.None; - private bool _policy = false; + private RecorderState _previous = RecorderState.None; + private RecorderState _current = RecorderState.None; + private bool _policy = false; - internal RecorderStateChangedEventArgs(RecorderState previous, RecorderState current, bool policy) - { - _previous = previous; - _current = current; - _policy = policy; - } + internal RecorderStateChangedEventArgs(RecorderState previous, RecorderState current, bool policy) + { + _previous = previous; + _current = current; + _policy = policy; + } /// /// Previous state of the recorder. /// - public RecorderState Previous - { - get - { - return _previous; - } + public RecorderState Previous { + get { + return _previous; + } } /// /// Current state of the recorder. /// - public RecorderState Current - { - get - { - return _current; - } + public RecorderState Current { + get { + return _current; + } } /// - /// true if the state changed by policy, otherwise false. + /// true if the state changed by policy such as Resource Conflict or Security, otherwise false + /// in normal state change. /// - public bool ByPolicy - { - get - { - return _policy; - } + public bool ByPolicy { + get { + return _policy; + } } } } diff --git a/src/Tizen.Multimedia/Recorder/RecordingErrorOccurredEventArgs.cs b/src/Tizen.Multimedia/Recorder/RecordingErrorOccurredEventArgs.cs index 82f2253..1649a56 100644 --- a/src/Tizen.Multimedia/Recorder/RecordingErrorOccurredEventArgs.cs +++ b/src/Tizen.Multimedia/Recorder/RecordingErrorOccurredEventArgs.cs @@ -7,36 +7,32 @@ namespace Tizen.Multimedia /// state of the recorder when it failed. /// public class RecordingErrorOccurredEventArgs : EventArgs - { - private RecorderErrorCode _error = RecorderErrorCode.DeviceError; - private RecorderState _state = RecorderState.None; + { + private RecorderErrorCode _error = RecorderErrorCode.DeviceError; + private RecorderState _state = RecorderState.None; - internal RecordingErrorOccurredEventArgs(RecorderErrorCode error, RecorderState state) - { - _error = error; - _state = state; - } + internal RecordingErrorOccurredEventArgs(RecorderErrorCode error, RecorderState state) + { + _error = error; + _state = state; + } /// /// The error code. /// - public RecorderErrorCode Error - { - get - { - return _error; - } + public RecorderErrorCode Error { + get { + return _error; + } } /// /// The state of the recorder. /// - public RecorderState State - { - get - { - return _state; - } + public RecorderState State { + get { + return _state; + } } } diff --git a/src/Tizen.Multimedia/Recorder/RecordingLimitReachedEventArgs.cs b/src/Tizen.Multimedia/Recorder/RecordingLimitReachedEventArgs.cs index d42247b..0846568 100644 --- a/src/Tizen.Multimedia/Recorder/RecordingLimitReachedEventArgs.cs +++ b/src/Tizen.Multimedia/Recorder/RecordingLimitReachedEventArgs.cs @@ -7,22 +7,20 @@ namespace Tizen.Multimedia /// public class RecordingLimitReachedEventArgs : EventArgs { - private RecordingLimitType _type = RecordingLimitType.Size; + private RecordingLimitType _type = RecordingLimitType.Size; - internal RecordingLimitReachedEventArgs(RecordingLimitType type) - { - _type = type; - } + internal RecordingLimitReachedEventArgs(RecordingLimitType type) + { + _type = type; + } /// /// The limitation type. /// - public RecordingLimitType Type - { - get - { - return _type; - } + public RecordingLimitType Type { + get { + return _type; + } } } } diff --git a/src/Tizen.Multimedia/Recorder/RecordingStatusChangedEventArgs.cs b/src/Tizen.Multimedia/Recorder/RecordingStatusChangedEventArgs.cs index cc2b378..f8c9f2d 100644 --- a/src/Tizen.Multimedia/Recorder/RecordingStatusChangedEventArgs.cs +++ b/src/Tizen.Multimedia/Recorder/RecordingStatusChangedEventArgs.cs @@ -7,35 +7,31 @@ namespace Tizen.Multimedia /// public class RecordingStatusChangedEventArgs : EventArgs { - private ulong _time = 0; - private ulong _fileSize = 0; + private ulong _time = 0; + private ulong _fileSize = 0; - internal RecordingStatusChangedEventArgs(ulong time, ulong fileSize) - { - _time = time; - _fileSize = fileSize; - } + internal RecordingStatusChangedEventArgs(ulong time, ulong fileSize) + { + _time = time; + _fileSize = fileSize; + } /// /// The time of recording in milliseconds. /// - public ulong ElapsedTime - { - get - { - return _time; - } + public ulong ElapsedTime { + get { + return _time; + } } /// /// The size of the recording file in Kilobyte. /// - public ulong FileSize - { - get - { - return _fileSize; - } + public ulong FileSize { + get { + return _fileSize; + } } } } diff --git a/src/Tizen.Multimedia/Recorder/VideoResolution.cs b/src/Tizen.Multimedia/Recorder/VideoResolution.cs index 9e68f07..b43d8e7 100644 --- a/src/Tizen.Multimedia/Recorder/VideoResolution.cs +++ b/src/Tizen.Multimedia/Recorder/VideoResolution.cs @@ -2,78 +2,69 @@ namespace Tizen.Multimedia { - - /// - /// Resolution for video recording. - /// + /// + /// Resolution for video recording. + /// public class RecorderVideoResolution { - private int _width, _height; - private bool _interopFlag; - internal IntPtr _videoHandle; + private int _width, _height; + private bool _interopFlag; + internal IntPtr _videoHandle; - internal RecorderVideoResolution(IntPtr handle) - { - _videoHandle = handle; - _interopFlag = true; - int ret = Interop.Recorder.GetVideoResolution (_videoHandle, out _width, out _height); - RecorderError err = (RecorderError)ret; - Log.Info (RecorderLog.Tag, "width " + _width + " height " + _height + "return " + err.ToString()); - } + internal RecorderVideoResolution(IntPtr handle) + { + _videoHandle = handle; + _interopFlag = true; + int ret = Interop.Recorder.GetVideoResolution(_videoHandle, out _width, out _height); + RecorderError err = (RecorderError)ret; + Log.Info(RecorderLog.Tag, "width " + _width + " height " + _height + "return " + err.ToString()); + } - internal RecorderVideoResolution(int width, int height) - { - _interopFlag = false; - _width = width; - _height = height; - } + internal RecorderVideoResolution(int width, int height) + { + _interopFlag = false; + _width = width; + _height = height; + } - /// - /// The video width. - /// - /// The width. - public int Width - { - get - { - if (_interopFlag == true) - Interop.Recorder.GetVideoResolution (_videoHandle, out _width, out _height); - return _width; - } - set - { - _width = value; - if (_interopFlag == true) - { - int ret = Interop.Recorder.SetVideoResolution (_videoHandle, _width, _height); - RecorderError err = (RecorderError)ret; - Log.Info (RecorderLog.Tag, " set width " + _width + " height " + _height + "set return " + err.ToString ()); - } - } - } + /// + /// The video width. + /// + /// The width. + public int Width { + get { + if(_interopFlag == true) + Interop.Recorder.GetVideoResolution(_videoHandle, out _width, out _height); + return _width; + } + set { + _width = value; + if(_interopFlag == true) { + int ret = Interop.Recorder.SetVideoResolution(_videoHandle, _width, _height); + RecorderError err = (RecorderError)ret; + Log.Info(RecorderLog.Tag, " set width " + _width + " height " + _height + "set return " + err.ToString()); + } + } + } - /// - /// The video height. - /// - /// The height. - public int Height - { - get - { - if (_interopFlag == true) - Interop.Recorder.GetVideoResolution (_videoHandle, out _width, out _height); - return _height; - } - set - { - _height = value; - if (_interopFlag == true) - { - int ret = Interop.Recorder.SetVideoResolution (_videoHandle, _width, _height); - RecorderError err = (RecorderError)ret; - Log.Info (RecorderLog.Tag, " set width " + _width + " height " + _height + "set return " + err.ToString ()); - } - } - } + /// + /// The video height. + /// + /// The height. + public int Height { + get { + if(_interopFlag == true) + Interop.Recorder.GetVideoResolution(_videoHandle, out _width, out _height); + return _height; + } + set { + _height = value; + if(_interopFlag == true) { + int ret = Interop.Recorder.SetVideoResolution(_videoHandle, _width, _height); + RecorderError err = (RecorderError)ret; + Log.Info(RecorderLog.Tag, " set width " + _width + " height " + _height + "set return " + err.ToString()); + } + } + } } }