From e2f425b96181a6c4c18369bd0d0d61e21beaf27a Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Sat, 25 Mar 2017 19:02:13 +0900 Subject: [PATCH] [Recorder] Add MuxedStream event Change-Id: Ia3b7a8d191a6040517b8350580f95fac0f4546c3 Signed-off-by: Haesu Gwon --- packaging/csapi-multimedia.spec | 2 +- src/Tizen.Multimedia/Camera/CameraErrorFactory.cs | 6 +- src/Tizen.Multimedia/Interop/Interop.Recorder.cs | 9 + .../Recorder/MuxedStreamEventArgs.cs | 50 ++ src/Tizen.Multimedia/Recorder/Recorder.cs | 17 + .../Recorder/RecorderErrorFactory.cs | 6 +- src/Tizen.Multimedia/Recorder/RecorderSettings.cs | 7 +- src/Tizen.Multimedia/Tizen.Multimedia.csproj | 647 +++++++++++---------- 8 files changed, 410 insertions(+), 334 deletions(-) mode change 100644 => 100755 src/Tizen.Multimedia/Interop/Interop.Recorder.cs create mode 100755 src/Tizen.Multimedia/Recorder/MuxedStreamEventArgs.cs mode change 100644 => 100755 src/Tizen.Multimedia/Tizen.Multimedia.csproj diff --git a/packaging/csapi-multimedia.spec b/packaging/csapi-multimedia.spec index 00fabe3..9e4458c 100755 --- a/packaging/csapi-multimedia.spec +++ b/packaging/csapi-multimedia.spec @@ -1,6 +1,6 @@ Name: csapi-multimedia Summary: Tizen Multimedia API for C# -Version: 1.0.47 +Version: 1.0.48 Release: 0 Group: Development/Libraries License: Apache-2.0 diff --git a/src/Tizen.Multimedia/Camera/CameraErrorFactory.cs b/src/Tizen.Multimedia/Camera/CameraErrorFactory.cs index bc99d4e..4d776fc 100755 --- a/src/Tizen.Multimedia/Camera/CameraErrorFactory.cs +++ b/src/Tizen.Multimedia/Camera/CameraErrorFactory.cs @@ -15,6 +15,7 @@ */ using System; +using System.Runtime.CompilerServices; using Tizen.Internals.Errors; namespace Tizen.Multimedia @@ -41,7 +42,8 @@ namespace Tizen.Multimedia internal static class CameraErrorFactory { - internal static void ThrowIfError(int errorCode, string errorMessage = null) + internal static void ThrowIfError(int errorCode, string errorMessage = null, + [CallerMemberName] string caller = null, [CallerLineNumber] int line = 0) { CameraError err = (CameraError)errorCode; if (err == CameraError.None) @@ -49,7 +51,7 @@ namespace Tizen.Multimedia return; } - Log.Info(CameraLog.Tag, "errorCode : " + err.ToString()); + Log.Info(CameraLog.Tag, "errorCode : " + err.ToString() + ", Caller : " + caller + ", line " + line.ToString()); switch (err) { diff --git a/src/Tizen.Multimedia/Interop/Interop.Recorder.cs b/src/Tizen.Multimedia/Interop/Interop.Recorder.cs old mode 100644 new mode 100755 index 10bca63..2f66bb6 --- a/src/Tizen.Multimedia/Interop/Interop.Recorder.cs +++ b/src/Tizen.Multimedia/Interop/Interop.Recorder.cs @@ -31,6 +31,9 @@ namespace Tizen.Multimedia [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void StatechangedCallback(RecorderState previous, RecorderState current, bool byPolicy, IntPtr userData); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void MuxedStreamCallback(IntPtr stream, int size, ulong offset, IntPtr userData); + [DllImport(Libraries.Recorder, EntryPoint = "recorder_create_audiorecorder")] internal static extern int Create(out IntPtr handle); @@ -99,6 +102,12 @@ namespace Tizen.Multimedia [DllImport(Libraries.Recorder, EntryPoint = "recorder_unset_recording_limit_reached_cb")] internal static extern int UnsetLimitReachedCallback(IntPtr handle); + + [DllImport(Libraries.Recorder, EntryPoint = "recorder_set_muxed_stream_cb")] + internal static extern int SetMuxedStreamCallback(IntPtr handle, MuxedStreamCallback callback, IntPtr userData); + + [DllImport(Libraries.Recorder, EntryPoint = "recorder_unset_muxed_stream_cb")] + internal static extern int UnsetMuxedStreamCallback(IntPtr handle); } } } \ No newline at end of file diff --git a/src/Tizen.Multimedia/Recorder/MuxedStreamEventArgs.cs b/src/Tizen.Multimedia/Recorder/MuxedStreamEventArgs.cs new file mode 100755 index 0000000..b38d5ca --- /dev/null +++ b/src/Tizen.Multimedia/Recorder/MuxedStreamEventArgs.cs @@ -0,0 +1,50 @@ +/* + * 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.Runtime.InteropServices; + +namespace Tizen.Multimedia +{ + /// + /// An extended EventArgs class containing details of muxed stream(Audio + Video). + /// + public class MuxedStreamDeliveredEventArgs : EventArgs + { + internal MuxedStreamDeliveredEventArgs(IntPtr stream, int streamLength, ulong offset) + { + Stream = new byte[streamLength]; + Marshal.Copy(stream, Stream, 0, streamLength); + StreamLength = streamLength; + Offset = offset; + } + + /// + /// The muexed stream data. + /// + public byte[] Stream { get; } + + /// + /// The length of muxed stream data. + /// + public int StreamLength { get; } + + /// + /// The offset of the stream data. + /// + public ulong Offset { get; } + } +} diff --git a/src/Tizen.Multimedia/Recorder/Recorder.cs b/src/Tizen.Multimedia/Recorder/Recorder.cs index 73d62b5..81558b9 100755 --- a/src/Tizen.Multimedia/Recorder/Recorder.cs +++ b/src/Tizen.Multimedia/Recorder/Recorder.cs @@ -180,6 +180,12 @@ namespace Tizen.Multimedia /// public event EventHandler RecordingLimitReached; private Interop.Recorder.RecordingLimitReachedCallback _recordingLimitReachedCallback; + + /// + /// Event that occurs when muxed stream data is being delivered. + /// + public event EventHandler MuxedStreamDelivered; + private Interop.Recorder.MuxedStreamCallback _muxedStreamCallback; #endregion EventHandlers #region Properties @@ -317,6 +323,7 @@ namespace Tizen.Multimedia RegisterRecordingProgressCallback(); RegisterAudioStreamDeliveredCallback(); RegisterRecordingLimitReachedEvent(); + RegisterMuxedStreamEvent(); } private void RegisterErrorCallback() @@ -378,6 +385,16 @@ namespace Tizen.Multimedia RecorderErrorFactory.ThrowIfError(Interop.Recorder.SetLimitReachedCallback(_handle, _recordingLimitReachedCallback, IntPtr.Zero), "Setting limit reached callback failed"); } + + private void RegisterMuxedStreamEvent() + { + _muxedStreamCallback = (IntPtr stream, int streamSize, ulong offset, IntPtr userData) => + { + MuxedStreamDelivered?.Invoke(this, new MuxedStreamDeliveredEventArgs(stream, streamSize, offset)); + }; + RecorderErrorFactory.ThrowIfError(Interop.Recorder.SetMuxedStreamCallback(_handle, _muxedStreamCallback, IntPtr.Zero), + "Setting muxed stream callback failed"); + } #endregion Callback registrations } } diff --git a/src/Tizen.Multimedia/Recorder/RecorderErrorFactory.cs b/src/Tizen.Multimedia/Recorder/RecorderErrorFactory.cs index c7ef1e6..7ca36b2 100755 --- a/src/Tizen.Multimedia/Recorder/RecorderErrorFactory.cs +++ b/src/Tizen.Multimedia/Recorder/RecorderErrorFactory.cs @@ -15,6 +15,7 @@ */ using System; +using System.Runtime.CompilerServices; using Tizen.Internals.Errors; namespace Tizen.Multimedia @@ -40,7 +41,8 @@ namespace Tizen.Multimedia internal static class RecorderErrorFactory { - internal static void ThrowIfError(int errorCode, string errorMessage = null) + internal static void ThrowIfError(int errorCode, string errorMessage = null, + [CallerMemberName] string caller = null, [CallerLineNumber] int line = 0) { RecorderError err = (RecorderError)errorCode; if (err == RecorderError.None) @@ -48,7 +50,7 @@ namespace Tizen.Multimedia return; } - Log.Info(RecorderLog.Tag, "errorCode : " + err.ToString()); + Log.Info(RecorderLog.Tag, "errorCode : " + err.ToString() + ", Caller : " + caller + ", line " + line.ToString()); switch (err) { diff --git a/src/Tizen.Multimedia/Recorder/RecorderSettings.cs b/src/Tizen.Multimedia/Recorder/RecorderSettings.cs index fb08e59..4dcaf2f 100755 --- a/src/Tizen.Multimedia/Recorder/RecorderSettings.cs +++ b/src/Tizen.Multimedia/Recorder/RecorderSettings.cs @@ -327,12 +327,7 @@ namespace Tizen.Multimedia { get { - bool ret = Interop.RecorderSettings.GetMute(_recorder.GetHandle()); - - RecorderErrorFactory.ThrowIfError(ErrorFacts.GetLastResult(), - "Failed to get the mute state of recorder"); - - return ret; + return Interop.RecorderSettings.GetMute(_recorder.GetHandle()); } set diff --git a/src/Tizen.Multimedia/Tizen.Multimedia.csproj b/src/Tizen.Multimedia/Tizen.Multimedia.csproj old mode 100644 new mode 100755 index 9e8bb4e..acba88c --- a/src/Tizen.Multimedia/Tizen.Multimedia.csproj +++ b/src/Tizen.Multimedia/Tizen.Multimedia.csproj @@ -1,335 +1,336 @@ - - - - Debug - AnyCPU - {0CE698B0-4849-4096-9D7F-30E611F50DAD} - Library - Properties - Tizen.Multimedia - Tizen.Multimedia - 512 - - - .NETStandard - v1.3 - .NETStandard,Version=v1.3 - false - true - $(NoWarn);1701;1702 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - - - Tizen.Multimedia.snk - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + Debug + AnyCPU + {0CE698B0-4849-4096-9D7F-30E611F50DAD} + Library + Properties + Tizen.Multimedia + Tizen.Multimedia + 512 + + + .NETStandard + v1.3 + .NETStandard,Version=v1.3 + false + true + $(NoWarn);1701;1702 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + + + Tizen.Multimedia.snk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + --> + + --> - <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory) - <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory) - true - + --> + <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory) + <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory) + true + \ No newline at end of file -- 2.7.4