diff --git a/.github/workflows/build-pull-request.yml b/.github/workflows/build-pull-request.yml
index 05edec98fa0..1f71c11b340 100644
--- a/.github/workflows/build-pull-request.yml
+++ b/.github/workflows/build-pull-request.yml
@@ -55,7 +55,7 @@ jobs:
-- print --format=json --include-hidden \
-o Artifacts/api.json Artifacts/bin/public/
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: reports
@@ -72,7 +72,7 @@ jobs:
dotnet-version: 3.1.x
- name: Download Artifacts
- uses: actions/download-artifact@v2
+ uses: actions/download-artifact@v3
with:
name: reports
path: Artifacts
@@ -120,7 +120,7 @@ jobs:
base-file: Artifacts/base-api.json
output: Artifacts/api-comp.json
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@v3
with:
name: reports
path: Artifacts/api-comp.json
diff --git a/.github/workflows/deploy-documents-for-tizen-docs.yml b/.github/workflows/deploy-documents-for-tizen-docs.yml
index ff84dce4f77..67fe65a9cba 100644
--- a/.github/workflows/deploy-documents-for-tizen-docs.yml
+++ b/.github/workflows/deploy-documents-for-tizen-docs.yml
@@ -6,7 +6,6 @@ on:
workflow_dispatch:
env:
- DOCFX_FILE: docfx_tizen_docs.json
DEPLOY_BRANCH: tizen-docs-pages
CACHE_NAME: docfx-tizen-docs-pages-site
@@ -15,7 +14,7 @@ jobs:
build:
runs-on: ubuntu-20.04
container:
- image: tizendotnet/tizenfx-build-worker:2.4
+ image: tizendotnet/tizenfx-build-worker:2.5
options: --ulimit nofile=10240:10240
steps:
@@ -37,7 +36,6 @@ jobs:
- name: Build Documents
if: steps.cache-site.outputs.cache-hit != 'true'
run: |
- cp docfx_config/docfx.json docfx.json
./build.sh restore
./build.sh build
@@ -46,7 +44,7 @@ jobs:
cp .gitattributes _site/
tar cfz site.tar.gz _site/
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@v3
with:
name: documents
path: site.tar.gz
@@ -56,7 +54,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- - uses: actions/download-artifact@v2
+ - uses: actions/download-artifact@v3
with:
name: documents
diff --git a/.github/workflows/deploy-documents.yml b/.github/workflows/deploy-documents.yml
index ad7604338eb..017f9e0f6d2 100644
--- a/.github/workflows/deploy-documents.yml
+++ b/.github/workflows/deploy-documents.yml
@@ -10,7 +10,7 @@ jobs:
build:
runs-on: ubuntu-20.04
container:
- image: tizendotnet/tizenfx-build-worker:2.4
+ image: tizendotnet/tizenfx-build-worker:2.5
options: --ulimit nofile=10240:10240
steps:
@@ -31,14 +31,13 @@ jobs:
- name: Build Documents
if: steps.cache-site.outputs.cache-hit != 'true'
run: |
- cp docfx_config/docfx.json docfx.json
./build.sh restore
./build.sh build
./build.sh index
- name: Archive Artifacts
run: |
tar cfz site.tar.gz _site/
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@v3
with:
name: documents
path: site.tar.gz
@@ -48,7 +47,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- - uses: actions/download-artifact@v2
+ - uses: actions/download-artifact@v3
with:
name: documents
diff --git a/README.md b/README.md
index f834a32c41d..6f5b6f32479 100644
--- a/README.md
+++ b/README.md
@@ -9,8 +9,9 @@ TizenFX API, which allows you to access platform-specific features not covered b
| Branch | API Level | Target Framework | API Reference | Platform | myget.org | nuget.org |
|--------|:---------:|------------------|---------------|-------------------|-----------|------------|
-|master | 12 | net6.0-tizen9.0 | [Link](https://samsung.github.io/TizenFX/master/) | Tizen vNext | [![api12_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API12.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | |
-|API11 | 11 | net6.0-tizen8.0 | [Link](https://samsung.github.io/TizenFX/API11/) | Tizen 8.0 | [![api11_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API11.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | ![api11_nuget](https://img.shields.io/nuget/v/Tizen.NET.API11.svg)
+|master | 13 | | [Link](https://samsung.github.io/TizenFX/master/) | Tizen vNext | [![api12_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API12.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | |
+|API12 | 12 | net6.0-tizen9.0 | [Link](https://samsung.github.io/TizenFX/API12/) | Tizen 9.0 | [![api12_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API12.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | [![api12_nuget](https://img.shields.io/nuget/v/Tizen.NET.API12.svg)](https://www.nuget.org/packages/Tizen.NET/) |
+|API11 | 11 | net6.0-tizen8.0 | [Link](https://samsung.github.io/TizenFX/API11/) | Tizen 8.0 | [![api11_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API11.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | [![api11_nuget](https://img.shields.io/nuget/v/Tizen.NET.API11.svg)](https://www.nuget.org/packages/Tizen.NET/) |
|API10 | 10 | tizen10.0 | [Link](https://samsung.github.io/TizenFX/API10/) | Tizen 7.0 | [![api10_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API10.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | [![api10_nuget](https://img.shields.io/nuget/v/Tizen.NET.API10.svg)](https://www.nuget.org/packages/Tizen.NET/) |
|API9 | 9 | tizen90 | [Link](https://samsung.github.io/TizenFX/API9/) | Tizen 6.5 | [![api9_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API9.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | [![api9_nuget](https://img.shields.io/nuget/v/Tizen.NET.API9.svg)](https://www.nuget.org/packages/Tizen.NET/) |
|API8 | 8 | tizen80 | [Link](https://samsung.github.io/TizenFX/API8/) | Tizen 6.0 | [![api8_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API8.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | [![api8_nuget](https://img.shields.io/nuget/v/Tizen.NET.API8.svg)](https://www.nuget.org/packages/Tizen.NET/) |
@@ -20,7 +21,7 @@ TizenFX API, which allows you to access platform-specific features not covered b
|API4 | 4 | tizen40 | [Link](https://samsung.github.io/TizenFX/API4/) | Tizen 4.0 | [![api4_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API4.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | [![api4_nuget](https://img.shields.io/nuget/v/Tizen.NET.API4.svg)](https://www.nuget.org/packages/Tizen.NET/) |
### master
-The __master__ branch is the main development branch for the Tizen .NET __API Level 12__.
+The __master__ branch is the main development branch for the Tizen .NET __API Level 13__.
The following NuGet packages will be published to [Tizen MyGet Gallery](https://tizen.myget.org/gallery/dotnet) and [Github Packages Registry](https://github.com/orgs/Samsung/packages?tab=packages&q=Tizen.NET) every day if there are any changes. (Nightly Build)
@@ -28,13 +29,13 @@ The following NuGet packages will be published to [Tizen MyGet Gallery](https://
> - GitHub Packages Feed : ```https://nuget.pkg.github.com/Samsung/index.json```
> - GitHub Packages only supports authentication using a personal access token (classic). For more information, see [Working with the NuGet registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry) and [Managing your personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
-* Tizen.NET 12.0.0.#####
-* Tizen.NET.API12 12.0.0.#####
-* Tizen.NET.Internals 12.0.0.#####
+* Tizen.NET 13.0.0.#####
+* Tizen.NET.API13 13.0.0.#####
+* Tizen.NET.Internals 13.0.0.#####
And, This branch is pushed to the [tizen branch](https://git.tizen.org/cgit/platform/core/csapi/tizenfx/?h=tizen) in the tizen gerrit and submitted for the next Tizen platform.
-### API4 ~ API11 branches
+### API4 ~ API12 branches
The __API#__ branches are the release branch for Tizen .NET __API Level #__.
These release branches were __FROZEN__. No new public APIs can be added to these branches, only bug fixes and internal APIs can be added.
@@ -56,6 +57,7 @@ For more information, please see [Using Tizen.NET.Sdk as SDK-style](https://deve
### Minimum required versions of Tizen.NET.Sdk and Visual Studio
| API Level | Target Framework | Tizen.NET.Sdk | Visual Studio |
|:---------:|------------------|---------------|-------------------|
+| API13 | net6.0-tizen9.0 | [Tizen .NET Workloads](https://github.com/samsung/Tizen.NET) | 2022 |
| API12 | net6.0-tizen9.0 | [Tizen .NET Workloads](https://github.com/samsung/Tizen.NET) | 2022 |
| API11 | net6.0-tizen8.0 | [Tizen .NET Workloads](https://github.com/samsung/Tizen.NET) | 2022 |
| API10 | tizen10.0 | 1.1.9 | 2019 |
@@ -95,4 +97,5 @@ You can download the latest binaries with TizenFX from the link below :
| Tizen 6.5 | http://download.tizen.org/snapshots/TIZEN/Tizen-6.5/Tizen-6.5-Unified/latest/ |
| Tizen 7.0 | http://download.tizen.org/snapshots/TIZEN/Tizen-7.0/Tizen-7.0-Unified/latest/ |
| Tizen 8.0 | http://download.tizen.org/snapshots/TIZEN/Tizen-8.0/Tizen-8.0-Unified/latest/ |
-| Tizen 9.0 | http://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Unified/latest |
+| Tizen 9.0 | http://download.tizen.org/snapshots/TIZEN/Tizen-9.0/Tizen-9.0-Unified/latest/ |
+| Tizen 10.0 | http://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Unified/latest |
diff --git a/packaging/csapi-tizenfx.spec b/packaging/csapi-tizenfx.spec
index e17a246e84c..187764d8bf3 100644
--- a/packaging/csapi-tizenfx.spec
+++ b/packaging/csapi-tizenfx.spec
@@ -1,7 +1,7 @@
# Auto-generated from csapi-tizenfx.spec.in by makespec.sh
%define TIZEN_NET_API_VERSION 12
-%define TIZEN_NET_RPM_VERSION 12.0.0.999+nui22332
+%define TIZEN_NET_RPM_VERSION 12.0.0.999+nui22351
%define TIZEN_NET_NUGET_VERSION 12.0.0.99999
%define DOTNET_ASSEMBLY_PATH /usr/share/dotnet.tizen/framework
diff --git a/packaging/version.txt b/packaging/version.txt
index d89dc7054e8..f9b9c0bac20 100755
--- a/packaging/version.txt
+++ b/packaging/version.txt
@@ -6,4 +6,4 @@ RPM_VERSION=12.0.0.999
NUGET_VERSION=12.0.0.99999
# RPM Version Suffix
-RPM_VERSION_SUFFIX=nui22332
+RPM_VERSION_SUFFIX=nui22351
diff --git a/src/Tizen.AIAvatar/Tizen.AIAvatar.csproj b/src/Tizen.AIAvatar/Tizen.AIAvatar.csproj
index 68314141a71..63f5918ca9d 100644
--- a/src/Tizen.AIAvatar/Tizen.AIAvatar.csproj
+++ b/src/Tizen.AIAvatar/Tizen.AIAvatar.csproj
@@ -7,7 +7,6 @@
-
@@ -16,7 +15,6 @@
-
diff --git a/src/Tizen.AIAvatar/src/AIServices/BaseAIService.cs b/src/Tizen.AIAvatar/src/AIServices/BaseAIService.cs
new file mode 100644
index 00000000000..c9a18196cf9
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/AIServices/BaseAIService.cs
@@ -0,0 +1,82 @@
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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.ComponentModel;
+
+namespace Tizen.AIAvatar
+{
+ ///
+ /// Abstract base class for AI services, providing common functionalities.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public abstract class BaseAIService : IAIService, IDisposable
+ {
+ ///
+ /// Gets the name of the AI service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public abstract string ServiceName { get; }
+
+ ///
+ /// Gets the capabilities of the AI service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public abstract ServiceCapabilities Capabilities { get; }
+
+ ///
+ /// Gets the service client manager responsible for managing client operations.
+ ///
+ protected ServiceClientManager ClientManager { get; }
+
+ ///
+ /// Gets the configuration settings for the AI service.
+ ///
+ protected AIServiceConfiguration Configuration { get; }
+
+ ///
+ /// Initializes a new instance of the class with the specified configuration.
+ ///
+ /// The configuration settings for the AI service.
+ protected BaseAIService(AIServiceConfiguration config)
+ {
+ Configuration = config;
+ ClientManager = new ServiceClientManager(config);
+ }
+
+ ///
+ /// Releases all resources used by the AI service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ ///
+ /// Releases all resources used by the AI service.
+ ///
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposing && ClientManager != null)
+ {
+ ClientManager.Dispose();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Tizen.AIAvatar/src/AIServices/Core/AIServiceData.cs b/src/Tizen.AIAvatar/src/AIServices/Core/AIServiceData.cs
new file mode 100644
index 00000000000..c75e9d49026
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/AIServices/Core/AIServiceData.cs
@@ -0,0 +1,185 @@
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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.Collections.Generic;
+using System.ComponentModel;
+
+
+namespace Tizen.AIAvatar
+{
+ ///
+ /// Provides data for LLM response events.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class llmResponseEventArgs : EventArgs
+ {
+ ///
+ /// Gets or sets the task ID associated with the LLM response.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int TaskID { get; set; }
+
+ ///
+ /// Gets or sets the response text from the LLM.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Text { get; set; }
+
+ ///
+ /// Gets or sets the error message, if any, from the LLM response.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Error { get; set; }
+ }
+
+ ///
+ /// Provides data for TTS streaming events.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class ttsStreamingEventArgs : EventArgs
+ {
+ ///
+ /// Gets or sets the audio data of the current chunk.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public byte[] AudioData { get; set; }
+
+ ///
+ /// Gets or sets the sample rate of the audio data.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int SampleRate { get; set; }
+
+ ///
+ /// Gets or sets the text being converted to speech.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Text { get; set; }
+
+ ///
+ /// Gets or sets the voice used for the TTS conversion.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Voice { get; set; }
+
+ ///
+ /// Gets or sets the size of the current audio data chunk in bytes.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int AudioBytes { get; set; }
+
+ ///
+ /// Gets or sets the total number of bytes for the audio data.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int TotalBytes { get; set; }
+
+ ///
+ /// Gets or sets the number of bytes processed so far.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int ProcessedBytes { get; set; }
+
+ ///
+ /// Gets or sets the progress percentage of the TTS processing.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public double ProgressPercentage { get; set; }
+
+ ///
+ /// Gets or sets the error message, if any, during the TTS process.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Error { get; set; }
+ }
+
+ ///
+ /// Provides data for STT streaming events.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class sttStreamingEventArgs : EventArgs
+ {
+ ///
+ /// Gets or sets a value indicating whether the text is interim.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool Interim { get; set; }
+
+ ///
+ /// Gets or sets the transcribed text from the STT process.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Text { get; set; }
+
+ ///
+ /// Gets or sets the error message, if any, during the STT process.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Error { get; set; }
+ }
+
+ ///
+ /// Represents service endpoints for AI services.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class ServiceEndpoints
+ {
+ ///
+ /// Gets or sets the endpoint for the LLM service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string LLMEndpoint { get; set; }
+
+ ///
+ /// Gets or sets the endpoint for the Text-to-Speech service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string TextToSpeechEndpoint { get; set; }
+
+ ///
+ /// Gets or sets the endpoint for the Speech-to-Text service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string SpeechToTextEndpoint { get; set; }
+ }
+
+ ///
+ /// Represents the configuration for an AI service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public abstract class AIServiceConfiguration
+ {
+ ///
+ /// Gets or sets the API key for the AI service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string ApiKey { get; set; }
+
+ ///
+ /// Gets or sets the service endpoints.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ServiceEndpoints Endpoints { get; set; }
+
+ ///
+ /// Gets or sets additional settings for the AI service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Dictionary AdditionalSettings { get; set; } = new();
+ }
+}
diff --git a/src/Tizen.AIAvatar/src/Multimedia/Audio/AudioOptions.cs b/src/Tizen.AIAvatar/src/AIServices/Core/IAIService.cs
similarity index 50%
rename from src/Tizen.AIAvatar/src/Multimedia/Audio/AudioOptions.cs
rename to src/Tizen.AIAvatar/src/AIServices/Core/IAIService.cs
index 2ac9305159e..d82f4aac12a 100644
--- a/src/Tizen.AIAvatar/src/Multimedia/Audio/AudioOptions.cs
+++ b/src/Tizen.AIAvatar/src/AIServices/Core/IAIService.cs
@@ -15,51 +15,65 @@
*
*/
+using System;
using System.ComponentModel;
-using Tizen.Multimedia;
namespace Tizen.AIAvatar
{
///
- /// Provides the ability to audio
+ /// Defines the capabilities that an AI service can support.
///
+ [Flags]
[EditorBrowsable(EditorBrowsableState.Never)]
- internal class AudioOptions
+ public enum ServiceCapabilities
{
- private int sampleRate;
- private AudioChannel channel;
- private AudioSampleType sampleType;
+ ///
+ /// No capabilities.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ None = 0,
+
+ ///
+ /// Capability for Text-to-Speech service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ TextToSpeech = 1,
+
+ ///
+ /// Capability for Speech-to-Text service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ SpeechToText = 2,
///
- /// Initializes a new instance of the AudioOptions class with the specified sample rate, channel, and sampleType.
+ /// Capability for Large Language Model service.
///
- /// the audio sample rate (8000 ~ 192000Hz)
- /// the audio channel type.
- /// the audio sample type.
[EditorBrowsable(EditorBrowsableState.Never)]
- public AudioOptions(int sampleRate, AudioChannel channel, AudioSampleType sampleType)
- {
- this.sampleRate = sampleRate;
- this.channel = channel;
- this.sampleType = sampleType;
- }
+ LargeLanguageModel = 4,
///
- /// The audio sample rate (8000 ~ 192000Hz)
+ /// Capability for Vision-related service.
///
[EditorBrowsable(EditorBrowsableState.Never)]
- public int SampleRate { get => sampleRate; set => sampleRate = value; }
+ Vision = 8
+ }
+ ///
+ /// Represents a generic AI service interface.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public interface IAIService
+ {
///
- /// The audio channel type
+ /// Gets the name of the AI service.
///
[EditorBrowsable(EditorBrowsableState.Never)]
- public AudioChannel Channel { get => channel; set => channel = value; }
+ string ServiceName { get; }
///
- /// The audio sample type
+ /// Gets the capabilities of the AI service.
///
[EditorBrowsable(EditorBrowsableState.Never)]
- public AudioSampleType SampleType { get => sampleType; set => sampleType = value; }
+ ServiceCapabilities Capabilities { get; }
}
}
diff --git a/src/Tizen.AIAvatar/src/AIServices/Core/IAIServiceFeatures.cs b/src/Tizen.AIAvatar/src/AIServices/Core/IAIServiceFeatures.cs
new file mode 100644
index 00000000000..6df878534ce
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/AIServices/Core/IAIServiceFeatures.cs
@@ -0,0 +1,128 @@
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using System.Threading.Tasks;
+
+
+namespace Tizen.AIAvatar
+{
+ ///
+ /// Interface for a Text-to-Speech service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public interface ITextToSpeechService
+ {
+ ///
+ /// Occurs when the Text-to-Speech service starts processing.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ event EventHandler OnTtsStart;
+
+ ///
+ /// Occurs when the Text-to-Speech service is receiving data.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ event EventHandler OnTtsReceiving;
+
+ ///
+ /// Occurs when the Text-to-Speech service finishes processing.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ event EventHandler OnTtsFinish;
+
+ ///
+ /// Converts the given text to speech asynchronously and returns the audio data.
+ ///
+ /// The text to be converted to speech.
+ /// Optional parameter to specify the voice type.
+ /// Optional parameters for customizing speech output.
+ /// A task representing the asynchronous operation, with a byte array of the generated audio data.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Task TextToSpeechAsync(
+ string text,
+ string voice = null,
+ Dictionary options = null);
+
+ ///
+ /// Streams the given text as speech asynchronously.
+ ///
+ /// The text to be converted to speech.
+ /// Optional parameter to specify the voice type.
+ /// Optional parameters for customizing speech output.
+ /// A task representing the asynchronous operation.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Task TextToSpeechStreamAsync(
+ string text,
+ string voice = null,
+ Dictionary options = null);
+ }
+
+ ///
+ /// Interface for a Speech-to-Text service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public interface ISpeechToTextService
+ {
+ ///
+ /// Converts the given audio data to text asynchronously.
+ ///
+ /// The audio data to be converted to text.
+ /// Optional parameters for customizing the transcription.
+ /// A task representing the asynchronous operation, with the resulting transcribed text.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Task SpeechToTextAsync(
+ byte[] audioData,
+ Dictionary options = null);
+
+ ///
+ /// Streams the given audio data to text asynchronously.
+ ///
+ /// The audio stream to be converted to text.
+ /// Optional parameters for customizing the transcription.
+ /// A task representing the asynchronous operation.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Task StreamSpeechToTextAsync(
+ Stream audioStream,
+ Dictionary options = null);
+ }
+
+ ///
+ /// Interface for a Large Language Model (LLM) service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public interface ILLMService
+ {
+ ///
+ /// Occurs when a response is generated by the LLM service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ event EventHandler ResponseHandler;
+
+ ///
+ /// Generates a response to the given message asynchronously.
+ ///
+ /// The input message to be processed by the LLM.
+ /// Optional parameters for customizing the LLM output.
+ /// A task representing the asynchronous operation.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Task GenerateTextAsync(string message, Dictionary options = null);
+ }
+}
diff --git a/src/Tizen.AIAvatar/src/AIServices/Core/Prompt.cs b/src/Tizen.AIAvatar/src/AIServices/Core/Prompt.cs
new file mode 100644
index 00000000000..a3707d4ce5d
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/AIServices/Core/Prompt.cs
@@ -0,0 +1,18 @@
+using System.Collections.Generic;
+
+namespace Tizen.AIAvatar
+{
+ internal class Message
+ {
+ public string role { get; set; }
+ public string content { get; set; }
+ }
+
+ internal class Prompt
+ {
+ public string model { get; set; }
+ public List messages { get; set; }
+ public double temperature { get; set; }
+ public int seed { get; set; }
+ }
+}
diff --git a/src/Tizen.AIAvatar/src/AIServices/Core/RestClient/IRestClient.cs b/src/Tizen.AIAvatar/src/AIServices/Core/RestClient/IRestClient.cs
new file mode 100644
index 00000000000..f79415ccc6e
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/AIServices/Core/RestClient/IRestClient.cs
@@ -0,0 +1,78 @@
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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.ComponentModel;
+using System.Net;
+using System.Threading.Tasks;
+
+namespace Tizen.AIAvatar
+{
+
+ ///
+ /// Represents the response from a REST API call, containing information such as status, content, and potential error messages.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class RestResponse
+ {
+ ///
+ /// Indicates whether the request was successful.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool IsSuccessful { get; set; }
+
+ ///
+ /// The HTTP status code returned by the server, providing information about the response status.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public HttpStatusCode StatusCode { get; set; }
+
+ ///
+ /// The content of the response as a string, typically containing the body of the HTTP response.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Content { get; set; }
+
+ ///
+ /// The raw bytes of the response, which can be useful for handling non-text data or binary responses.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public byte[] RawBytes { get; set; }
+
+ ///
+ /// The error message if the request failed, providing details about what went wrong.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string ErrorMessage { get; set; }
+ }
+
+ ///
+ /// Interface for making REST API calls, providing functionality to execute HTTP requests and receive responses.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public interface IRestClient : IDisposable
+ {
+ ///
+ /// Executes a REST request asynchronously and returns the response from the server.
+ ///
+ /// The REST request to execute, containing information such as endpoint, headers, and parameters.
+ /// A task representing the asynchronous operation, which returns the REST response containing status, content, and any errors.
+ /// Thrown when the request parameter is null.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Task ExecuteAsync(RestRequest request);
+ }
+}
\ No newline at end of file
diff --git a/src/Tizen.AIAvatar/src/AIServices/Core/RestClient/RestClient.cs b/src/Tizen.AIAvatar/src/AIServices/Core/RestClient/RestClient.cs
new file mode 100644
index 00000000000..d7cf0560636
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/AIServices/Core/RestClient/RestClient.cs
@@ -0,0 +1,97 @@
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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.ComponentModel;
+using System.Net.Http;
+using System.Threading.Tasks;
+
+
+namespace Tizen.AIAvatar
+{
+ ///
+ /// A class that provides methods to execute REST requests and handle responses.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class RestClient : IRestClient
+ {
+ private readonly HttpClient _httpClient;
+
+ ///
+ /// Initializes a new instance of the RestClient class with the specified HttpClient.
+ ///
+ /// The HttpClient instance to use for sending HTTP requests.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public RestClient(HttpClient httpClient)
+ {
+ _httpClient = httpClient;
+ }
+
+ ///
+ /// Executes a REST request asynchronously and returns the response.
+ ///
+ /// The RestRequest object containing details of the request.
+ /// A RestResponse object representing the result of the request.
+ /// Thrown when an error occurs during the request execution.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public async Task ExecuteAsync(RestRequest request)
+ {
+ using var httpRequest = request?.CreateRequestMessage(_httpClient.BaseAddress);
+
+ try
+ {
+ using var httpResponse = await _httpClient.SendAsync(httpRequest);
+ var response = new RestResponse
+ {
+ StatusCode = httpResponse.StatusCode,
+ IsSuccessful = httpResponse.IsSuccessStatusCode
+ };
+
+ if (httpResponse.Content != null)
+ {
+ response.RawBytes = await httpResponse.Content.ReadAsByteArrayAsync();
+ response.Content = await httpResponse.Content.ReadAsStringAsync();
+ }
+
+ if (!httpResponse.IsSuccessStatusCode)
+
+ {
+ response.ErrorMessage = $"HTTP {(int)httpResponse.StatusCode} - {httpResponse.ReasonPhrase}";
+ }
+
+ return response;
+ }
+ catch (Exception ex)
+ {
+ return new RestResponse
+ {
+ IsSuccessful = false,
+ ErrorMessage = ex.Message
+ };
+ }
+ }
+
+ ///
+ /// Disposes of the resources used by the RestClient.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ _httpClient?.Dispose();
+ }
+ }
+}
diff --git a/src/Tizen.AIAvatar/src/AIServices/Core/RestClient/RestRequest.cs b/src/Tizen.AIAvatar/src/AIServices/Core/RestClient/RestRequest.cs
new file mode 100644
index 00000000000..4d6ca754319
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/AIServices/Core/RestClient/RestRequest.cs
@@ -0,0 +1,219 @@
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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.Text.Json;
+using System.Text;
+using System;
+using System.Net.Http;
+using System.Collections.Generic;
+using System.Text.Json.Serialization;
+using System.ComponentModel;
+
+namespace Tizen.AIAvatar
+{
+ ///
+ /// An enumeration representing various HTTP methods.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum Method
+ {
+ ///
+ /// Represents the HTTP GET method.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Get,
+
+ ///
+ /// Represents the HTTP POST method.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Post,
+
+ ///
+ /// Represents the HTTP PUT method.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Put,
+
+ ///
+ /// Represents the HTTP DELETE method.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Delete,
+
+ ///
+ /// Represents the HTTP PATCH method.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Patch
+ }
+
+ ///
+ /// Represents a RESTful API request.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class RestRequest
+ {
+ ///
+ /// Initializes a new instance of the RestRequest class with the specified HTTP method.
+ ///
+ /// The HTTP method to use for the request.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public RestRequest(Method method)
+ {
+ Resource = string.Empty;
+ Method = method;
+ _headers = new Dictionary();
+ }
+
+ ///
+ /// Initializes a new instance of the RestRequest class with the specified resource and HTTP method.
+ ///
+ /// The resource URI for the request.
+ /// The HTTP method to use for the request.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public RestRequest(string resource, Method method)
+ {
+ Resource = resource;
+ Method = method;
+ _headers = new Dictionary();
+ }
+
+ ///
+ /// Adds a header to the request.
+ ///
+ /// The name of the header.
+ /// The value of the header.
+ /// The current instance of RestRequest.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public RestRequest AddHeader(string name, string value)
+ {
+ _headers[name] = value;
+ return this;
+ }
+
+ ///
+ /// Adds a JSON body to the request.
+ ///
+ /// The object to serialize as JSON and include in the request body.
+ /// The current instance of RestRequest.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public RestRequest AddJsonBody(object body)
+ {
+ _body = body;
+ _jsonStringBody = null; // Clear json string if object body is set
+ if (!_headers.ContainsKey("Content-Type"))
+ {
+ _headers["Content-Type"] = "application/json";
+ }
+ return this;
+ }
+
+ ///
+ /// Adds a JSON string body to the request.
+ ///
+ /// The JSON string to include in the request body.
+ /// The current instance of RestRequest.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public RestRequest AddJsonStringBody(string jsonString)
+ {
+ _jsonStringBody = jsonString;
+ _body = null; // Clear object body if json string is set
+ if (!_headers.ContainsKey("Content-Type"))
+ {
+ _headers["Content-Type"] = "application/json";
+ }
+ return this;
+ }
+
+ ///
+ /// The resource URI for the request.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Resource { get; }
+
+ ///
+ /// The HTTP method to use for the request.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Method Method { get; }
+
+ ///
+ /// Creates an HttpRequestMessage based on the current RestRequest instance.
+ ///
+ /// The base address to use when constructing the request URI.
+ /// A new HttpRequestMessage representing the current RestRequest.
+ internal HttpRequestMessage CreateRequestMessage(Uri baseAddress)
+ {
+ // If Resource is empty, use only the baseAddress
+ var requestUri = string.IsNullOrEmpty(Resource) ? baseAddress : new Uri(baseAddress, Resource);
+
+ var request = new HttpRequestMessage(GetHttpMethod(), requestUri);
+
+ foreach (var header in _headers)
+ {
+ request.Headers.TryAddWithoutValidation(header.Key, header.Value);
+ }
+
+ if (_jsonStringBody != null)
+ {
+ request.Content = new StringContent(_jsonStringBody, Encoding.UTF8, "application/json");
+ }
+ else if (_body != null)
+ {
+ var jsonBody = JsonSerializer.Serialize(_body, new JsonSerializerOptions { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull });
+ request.Content = new StringContent(jsonBody, Encoding.UTF8, "application/json");
+ }
+
+ return request;
+ }
+
+ ///
+ /// Gets the appropriate HttpMethod for the specified Method enumeration value.
+ ///
+ /// The corresponding HttpMethod.
+ private HttpMethod GetHttpMethod()
+ {
+ return Method switch
+ {
+ Method.Get => HttpMethod.Get,
+ Method.Post => HttpMethod.Post,
+ Method.Put => HttpMethod.Put,
+ Method.Delete => HttpMethod.Delete,
+ Method.Patch => HttpMethod.Patch,
+ _ => throw new ArgumentException($"Unsupported HTTP method: {Method}")
+ };
+ }
+
+
+
+ ///
+ /// A dictionary containing the headers for the request.
+ ///
+ private readonly Dictionary _headers;
+
+ ///
+ /// The object to serialize as JSON and include in the request body.
+ ///
+ private object _body;
+
+ ///
+ /// The JSON string to include in the request body.
+ ///
+ private string _jsonStringBody;
+ }
+}
\ No newline at end of file
diff --git a/src/Tizen.AIAvatar/src/AIServices/Core/RestClient/ServiceClientManager.cs b/src/Tizen.AIAvatar/src/AIServices/Core/RestClient/ServiceClientManager.cs
new file mode 100644
index 00000000000..1aaf70e79fa
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/AIServices/Core/RestClient/ServiceClientManager.cs
@@ -0,0 +1,77 @@
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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.Collections.Generic;
+using System.ComponentModel;
+using System.Net.Http;
+
+namespace Tizen.AIAvatar
+{
+ ///
+ /// Manages REST clients for different endpoints based on the AI service configuration.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class ServiceClientManager : IDisposable
+ {
+ private readonly Dictionary _clients = new();
+ private readonly AIServiceConfiguration _config;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The AI service configuration.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ServiceClientManager(AIServiceConfiguration config)
+ {
+ _config = config;
+ }
+
+ ///
+ /// Retrieves or creates a REST client for the specified endpoint.
+ ///
+ /// The base URI of the endpoint.
+ /// The REST client for the specified endpoint.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public IRestClient GetClient(string endpoint)
+ {
+ if (!_clients.ContainsKey(endpoint))
+ {
+ var client = new RestClient(new HttpClient
+ {
+ BaseAddress = new Uri(endpoint)
+ });
+ _clients[endpoint] = client;
+ }
+ return _clients[endpoint];
+ }
+
+ ///
+ /// Releases all resources used by the .
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ foreach (var client in _clients.Values)
+ {
+ client?.Dispose();
+ }
+ _clients.Clear();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Tizen.AIAvatar/src/AIServices/OpenAIService.cs b/src/Tizen.AIAvatar/src/AIServices/OpenAIService.cs
new file mode 100644
index 00000000000..f6b231f9698
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/AIServices/OpenAIService.cs
@@ -0,0 +1,280 @@
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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.Collections.Generic;
+using System.ComponentModel;
+using System.Text.Json;
+using System.Threading.Tasks;
+
+namespace Tizen.AIAvatar
+{
+ ///
+ /// Configuration class for OpenAI services.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class OpenAIConfiguration : AIServiceConfiguration
+ {
+ ///
+ /// Initializes a new instance of the class with default endpoint settings.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public OpenAIConfiguration()
+ {
+ Endpoints = new ServiceEndpoints
+ {
+ LLMEndpoint = "https://api.openai.com/v1/chat/",
+ TextToSpeechEndpoint = "https://api.openai.com/v1/audio/"
+ };
+ }
+
+ ///
+ /// Gets or sets the default model to use for LLM services.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Model { get; set; } = "gpt-3.5-turbo";
+
+ ///
+ /// Gets or sets the OpenAI organization ID for accessing specific organizational resources.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Organization { get; set; }
+ }
+
+ ///
+ /// OpenAI Service implementation that provides Text-to-Speech and LLM services.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class OpenAIService : BaseAIService, ITextToSpeechService, ILLMService
+ {
+ private readonly OpenAIConfiguration config;
+
+ ///
+ /// Occurs when a response is generated by the LLM service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler ResponseHandler;
+
+ ///
+ /// Occurs when the Text-to-Speech service starts processing.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler OnTtsStart;
+
+ ///
+ /// Occurs when the Text-to-Speech service is receiving data.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler OnTtsReceiving;
+
+ ///
+ /// Occurs when the Text-to-Speech service finishes processing.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler OnTtsFinish;
+
+ ///
+ /// Gets the name of the AI service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override string ServiceName => "OpenAI";
+
+ ///
+ /// Gets the capabilities supported by this AI service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override ServiceCapabilities Capabilities =>
+ ServiceCapabilities.TextToSpeech | ServiceCapabilities.LargeLanguageModel;
+
+ ///
+ /// Initializes a new instance of the class with the specified configuration.
+ ///
+ /// The configuration for the OpenAI Service.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public OpenAIService(OpenAIConfiguration config) : base(config)
+ {
+ this.config = config;
+ }
+
+ ///
+ /// Generates a response from the LLM service asynchronously.
+ ///
+ /// The input message to be processed by the LLM.
+ /// Optional parameters for customizing the LLM output.
+ /// A task representing the asynchronous operation.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public async Task GenerateTextAsync(string message, Dictionary options = null)
+ {
+ var client = ClientManager.GetClient(config.Endpoints.LLMEndpoint);
+ var messages = new List
+ {
+ new { role = "user", content = message }
+ };
+
+ var request = new RestRequest("completions", Method.Post)
+ .AddHeader("Authorization", $"Bearer {config.ApiKey}")
+ .AddJsonBody(new
+ {
+ model = config.Model,
+ messages = messages,
+ temperature = options?.GetValueOrDefault("temperature", 0.7),
+ max_tokens = options?.GetValueOrDefault("max_tokens", 1000)
+ });
+
+ var response = await client.ExecuteAsync(request).ConfigureAwait(false);
+
+ if (!response.IsSuccessful)
+ {
+ ResponseHandler?.Invoke(this, new llmResponseEventArgs { Error = response.ErrorMessage });
+ return;
+ }
+
+ var jsonResponse = JsonSerializer.Deserialize(response.Content);
+ string content = jsonResponse
+ .GetProperty("choices")[0]
+ .GetProperty("message")
+ .GetProperty("content")
+ .GetString();
+
+ ResponseHandler?.Invoke(this, new llmResponseEventArgs { Text = content });
+ }
+
+ ///
+ /// Converts the given text to speech asynchronously and returns the audio data.
+ ///
+ /// The text to be converted to speech.
+ /// Optional parameter to specify the voice type.
+ /// Optional parameters for customizing speech output.
+ /// A task representing the asynchronous operation, with a byte array of the generated audio data.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public async Task TextToSpeechAsync(
+ string text,
+ string voice = null,
+ Dictionary options = null)
+ {
+ var client = ClientManager.GetClient(config.Endpoints.TextToSpeechEndpoint);
+
+ var request = new RestRequest("speech", Method.Post)
+ .AddHeader("Authorization", $"Bearer {config.ApiKey}")
+ .AddJsonBody(new
+ {
+ model = "tts-1",
+ input = text,
+ voice = voice ?? "alloy",
+ response_format = "mp3"
+ });
+
+ var response = await client.ExecuteAsync(request);
+ if (!response.IsSuccessful)
+ throw new Exception($"OpenAI TTS Error: {response.ErrorMessage}");
+
+ return response.RawBytes;
+ }
+
+ ///
+ /// Streams the given text as speech asynchronously.
+ ///
+ /// The text to be converted to speech.
+ /// Optional parameter to specify the voice type.
+ /// Optional parameters for customizing speech output.
+ /// A task representing the asynchronous operation.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public async Task TextToSpeechStreamAsync(string text, string voice = null, Dictionary options = null)
+ {
+ const int SAMPLE_RATE = 24000;
+ const int FRAME_DURATION_MS = 160;
+ const int TAIL_DURATION_MS = 15;
+ const int BYTES_PER_SAMPLE = 2;
+ const int CHUNK_SIZE = (SAMPLE_RATE * FRAME_DURATION_MS * BYTES_PER_SAMPLE) / 1000;
+ const int TAIL_CHUNK_SIZE = (SAMPLE_RATE * TAIL_DURATION_MS * BYTES_PER_SAMPLE) / 1000;
+
+ var client = ClientManager.GetClient(config.Endpoints.TextToSpeechEndpoint);
+ var request = new RestRequest("speech", Method.Post)
+ .AddHeader("Authorization", $"Bearer {config.ApiKey}")
+ .AddJsonBody(new
+ {
+ model = "tts-1",
+ input = text,
+ voice = voice ?? "alloy",
+ response_format = "pcm"
+ });
+
+ try
+ {
+ OnTtsStart?.Invoke(this, new ttsStreamingEventArgs
+ {
+ Text = text,
+ Voice = voice ?? "alloy",
+ SampleRate = SAMPLE_RATE,
+ TotalBytes = 0,
+ AudioData = Array.Empty()
+ });
+
+ var response = await client.ExecuteAsync(request).ConfigureAwait(false);
+ if (!response.IsSuccessful)
+ {
+ throw new Exception($"OpenAI TTS Error: {response.ErrorMessage}");
+ }
+
+ var audioData = response.RawBytes;
+ var totalBytes = audioData.Length;
+ var bytesProcessed = 0;
+
+ // Process the audio data in 160ms chunks
+ while (bytesProcessed < totalBytes)
+ {
+ var remainingBytes = totalBytes - bytesProcessed;
+ var currentChunkSize = Math.Min(CHUNK_SIZE + TAIL_CHUNK_SIZE, remainingBytes);
+ var chunk = new byte[currentChunkSize];
+ Array.Copy(audioData, bytesProcessed, chunk, 0, currentChunkSize);
+ bytesProcessed += Math.Min(CHUNK_SIZE, remainingBytes);
+
+ OnTtsReceiving?.Invoke(this, new ttsStreamingEventArgs
+ {
+ Text = text,
+ Voice = voice ?? "alloy",
+ TotalBytes = totalBytes,
+ ProcessedBytes = bytesProcessed,
+ ProgressPercentage = (double)bytesProcessed / totalBytes * 100,
+ AudioData = chunk
+ });
+ }
+
+ OnTtsFinish?.Invoke(this, new ttsStreamingEventArgs
+ {
+ Text = text,
+ Voice = voice ?? "alloy",
+ TotalBytes = totalBytes,
+ ProcessedBytes = totalBytes,
+ ProgressPercentage = 100,
+ AudioData = Array.Empty()
+ });
+ }
+ catch (Exception ex)
+ {
+ OnTtsFinish?.Invoke(this, new ttsStreamingEventArgs
+ {
+ Text = text,
+ Voice = voice ?? "alloy",
+ Error = ex.Message,
+ AudioData = Array.Empty()
+ });
+ throw;
+ }
+ }
+ }
+}
diff --git a/src/Tizen.AIAvatar/src/AIServices/SamsungAIService.cs b/src/Tizen.AIAvatar/src/AIServices/SamsungAIService.cs
new file mode 100644
index 00000000000..e032d61ebaa
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/AIServices/SamsungAIService.cs
@@ -0,0 +1,444 @@
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using System.Linq;
+using System.Text.Json;
+using System.Threading.Tasks;
+using Tizen.Uix.Tts;
+
+
+namespace Tizen.AIAvatar
+{
+ ///
+ /// Configuration class for Samsung AI services.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class SamsungAIConfiguration : AIServiceConfiguration
+ {
+ ///
+ /// Initializes a new instance of the class with default endpoint settings.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public SamsungAIConfiguration()
+ {
+ Endpoints = new ServiceEndpoints
+ {
+ LLMEndpoint = "https://playground-api.sec.samsung.net/api/v1/chat/completions",
+ TextToSpeechEndpoint = "OnDevice"
+ };
+ }
+
+ ///
+ /// Gets or sets the default model to use for LLM services.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Model { get; set; } = "chat-65b-32k-1.1.2";
+
+ ///
+ /// Gets or sets the small model version for LLM services.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string SmallModel { get; set; } = "Gauss.L-1B-0.1.1";
+ }
+
+ ///
+ /// Samsung AI Service implementation that provides Text-to-Speech and LLM services.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class SamsungAIService : BaseAIService, ITextToSpeechService, ILLMService
+ {
+ private readonly SamsungAIConfiguration config;
+ private readonly TtsClient ttsHandle;
+ private TaskCompletionSource ttsCompletionSource;
+
+ // Audio-related constants
+ private const float audioLengthFactor = 0.16f;
+ private const float audioTailLengthFactor = 0.015f;
+ private const float audioBufferMultiflier = 2f;
+
+
+ private int audioLength;
+ private int desiredBufferLength;
+ private int audioTailLength;
+ private byte[] recordedBuffer;
+ private byte[] audioMainBuffer;
+ private List audioSyncBuffer;
+ private float desiredBufferDuration = audioLengthFactor + audioTailLengthFactor;
+
+ ///
+ /// Occurs when a response is generated by the LLM service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler ResponseHandler;
+
+ ///
+ /// Occurs when the Text-to-Speech service starts processing.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler OnTtsStart;
+
+ ///
+ /// Occurs when the Text-to-Speech service is receiving data.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler OnTtsReceiving;
+
+ ///
+ /// Occurs when the Text-to-Speech service finishes processing.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler OnTtsFinish;
+
+ ///
+ /// Gets the name of the AI service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override string ServiceName => "SamsungResearch";
+
+ ///
+ /// Gets the capabilities supported by this AI service.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override ServiceCapabilities Capabilities =>
+ ServiceCapabilities.TextToSpeech | ServiceCapabilities.LargeLanguageModel;
+
+ ///
+ /// Initializes a new instance of the class with the specified configuration.
+ ///
+ /// The configuration for the Samsung AI Service.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public SamsungAIService(SamsungAIConfiguration config) : base(config)
+ {
+ this.config = config;
+
+ try
+ {
+ ttsHandle = new TtsClient();
+ ttsHandle.SynthesizedPcm += TtsSynthesizedPCM;
+ ttsHandle.PlayingMode = PlayingMode.ByClient;
+
+ ttsHandle.Prepare();
+
+ GetSupportedVoices();
+ }
+ catch (Exception e)
+ {
+ throw new Exception($"[ERROR] Failed to prepare TTS {e.Message}");
+ }
+ }
+
+ ///
+ /// Generates a response from the LLM service asynchronously.
+ ///
+ /// The input message to be processed by the LLM.
+ /// Optional parameters for customizing the LLM output.
+ /// A task representing the asynchronous operation.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public async Task GenerateTextAsync(string message, Dictionary options = null)
+ {
+ var client = ClientManager.GetClient(config.Endpoints.LLMEndpoint);
+
+ var request = new RestRequest(Method.Post)
+ .AddHeader("Authorization", $"Bearer {config.ApiKey}");
+
+ int taskID = (int)(options?.GetValueOrDefault("TaskID", 0) ?? 0);
+
+ if (options != null && options.TryGetValue("promptFilePath", out var jsonFilePathObj) && jsonFilePathObj is string jsonFilePath)
+ {
+ // Read JSON file content
+ if (File.Exists(jsonFilePath))
+ {
+ try
+ {
+ var jsonContent = await File.ReadAllTextAsync(jsonFilePath).ConfigureAwait(false);
+ Prompt prompt = JsonSerializer.Deserialize(jsonContent);
+ var msg = prompt.messages.Last();
+ msg.content = String.Format(msg.content, message);
+
+ request.AddJsonBody(prompt);
+ }
+ catch (Exception ex)
+ {
+ ResponseHandler?.Invoke(this, new llmResponseEventArgs { TaskID = taskID, Error = ex.Message });
+ return;
+ }
+ }
+ else
+ {
+ ResponseHandler?.Invoke(this, new llmResponseEventArgs { TaskID = taskID, Error = $"File not found: {jsonFilePath}" });
+ return;
+ }
+ }
+ else
+ {
+
+ var messages = new List
+ {
+ new { role = "user", content = message }
+ };
+ // Add the default body if no JSON file is provided
+ request.AddJsonBody(new
+ {
+ model = config.Model,
+ messages = messages,
+ temperature = options?.GetValueOrDefault("temperature", 0.5) ?? 0.5,
+ seed = options?.GetValueOrDefault("seed", 0)
+ });
+ }
+
+ var response = await client.ExecuteAsync(request).ConfigureAwait(false);
+ if (!response.IsSuccessful)
+ {
+ ResponseHandler?.Invoke(this, new llmResponseEventArgs { TaskID = taskID, Error = response.ErrorMessage });
+ return;
+ }
+
+ var jsonResponse = JsonSerializer.Deserialize(response.Content);
+ string content = jsonResponse.GetProperty("response").GetProperty("content").GetString();
+
+ ResponseHandler?.Invoke(this, new llmResponseEventArgs { TaskID = taskID, Text = content });
+ }
+
+ ///
+ /// Converts the given text to speech asynchronously and returns the audio data.
+ ///
+ /// The text to be converted to speech.
+ /// Optional parameter to specify the voice type.
+ /// Optional parameters for customizing speech output.
+ /// A task representing the asynchronous operation, with a byte array of the generated audio data.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public async Task TextToSpeechAsync(string text, string voice = null, Dictionary options = null)
+ {
+ audioSyncBuffer = new List();
+
+ await TextToSpeechStreamAsync(text,voice, options).ConfigureAwait(false);
+
+ return audioSyncBuffer.ToArray();
+ }
+
+ ///
+ /// Streams the given text as speech asynchronously.
+ ///
+ /// The text to be converted to speech.
+ /// The voice type to be used for the speech.
+ /// Optional parameters for customizing speech output.
+ /// A task representing the asynchronous operation.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public async Task TextToSpeechStreamAsync(string text, string voice, Dictionary options)
+ {
+ ttsCompletionSource = new TaskCompletionSource();
+ recordedBuffer = Array.Empty();
+
+ //Option 처리
+ SpeedRange speedRange = ttsHandle.GetSpeedRange();
+ int speed = speedRange.Normal;
+ int voiceType = (int)VoiceType.Auto;
+
+ if (options != null)
+ {
+ if (options.ContainsKey("speechRate"))
+ {
+ float speechRate = (float)(options["speechRate"]) / 2.0f;
+ speed = (int)(speedRange.Min + (speedRange.Max - speedRange.Min) * speechRate);
+ }
+
+ if (options.ContainsKey("voiceType"))
+ {
+ voiceType = (int)options["voiceType"];
+ }
+ }
+ /////////
+ try
+ {
+ ttsHandle.AddText(text, voice, voiceType, speed);
+
+ ttsHandle.Play();
+
+ await ttsCompletionSource.Task.ConfigureAwait(false);
+ }
+ catch (Exception ex)
+ {
+ OnTtsFinish?.Invoke(this, new ttsStreamingEventArgs
+ {
+ Text = text,
+ Voice = voice,
+ Error = ex.Message,
+ AudioData = Array.Empty()
+ });
+ }
+ }
+
+ ///
+ /// Releases all resources used by the AI service.
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ ttsHandle?.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ ///
+ /// Handles the PCM data synthesized by the TTS service.
+ ///
+ /// The sender of the event.
+ /// The event arguments containing PCM data and other information.
+ private void TtsSynthesizedPCM(object sender, SynthesizedPcmEventArgs e)
+ {
+ try
+ {
+ switch (e.EventType)
+ {
+ case SynthesizedPcmEvent.Start:
+ recordedBuffer = Array.Empty();
+
+ audioLength = (int)(audioLengthFactor * e.SampleRate * audioBufferMultiflier);
+ audioTailLength = (int)(audioTailLengthFactor * e.SampleRate * audioBufferMultiflier);
+ desiredBufferLength = (int)(desiredBufferDuration * e.SampleRate * audioBufferMultiflier);
+
+ audioMainBuffer = new byte[desiredBufferLength];
+
+ OnTtsStart?.Invoke(this, new ttsStreamingEventArgs
+ {
+ SampleRate = e.SampleRate,
+ AudioBytes = audioLength,
+ TotalBytes = 0,
+ AudioData = Array.Empty()
+ });
+
+ Log.Info("Tizen.AIAvatar", $"TTS Start: UtteranceId={e.UtteranceId}, SampleRate={e.SampleRate}");
+
+ break;
+
+ case SynthesizedPcmEvent.Continue:
+
+ audioSyncBuffer?.AddRange(e.Data);
+ recordedBuffer = recordedBuffer.Concat(e.Data).ToArray();
+
+ if (recordedBuffer.Length >= desiredBufferLength)
+ {
+ Buffer.BlockCopy(recordedBuffer, 0, audioMainBuffer, 0, desiredBufferLength);
+ OnTtsReceiving?.Invoke(this, new ttsStreamingEventArgs
+ {
+ AudioData = audioMainBuffer,
+ ProcessedBytes = audioMainBuffer.Length
+ });
+
+
+ int slicedBufferLength = recordedBuffer.Length - audioLength;
+ byte[] slicedBuffer = new byte[slicedBufferLength];
+ Buffer.BlockCopy(recordedBuffer, audioLength, slicedBuffer, 0, slicedBufferLength);
+
+ recordedBuffer = slicedBuffer;
+ }
+
+ break;
+
+ case SynthesizedPcmEvent.Finish:
+ Log.Info("Tizen.AIAvatar", $"TTS Finish: UtteranceId={e.UtteranceId}");
+
+ // Send any remaining audio data
+ if (recordedBuffer.Length > 0)
+ {
+ int minBufferSize = Math.Min(desiredBufferLength, recordedBuffer.Length);
+
+ Array.Clear(audioMainBuffer, 0, desiredBufferLength);
+ Buffer.BlockCopy(recordedBuffer, 0, audioMainBuffer, 0, minBufferSize);
+ OnTtsReceiving?.Invoke(this, new ttsStreamingEventArgs
+ {
+ AudioData = audioMainBuffer,
+ ProcessedBytes = minBufferSize,
+ ProgressPercentage = 100
+ });
+ }
+
+ OnTtsFinish?.Invoke(this, new ttsStreamingEventArgs
+ {
+ AudioData = Array.Empty(),
+ TotalBytes = recordedBuffer.Length,
+ ProgressPercentage = 100
+ });
+
+ ttsCompletionSource?.SetResult(true);
+ break;
+
+ case SynthesizedPcmEvent.Fail:
+ var error = "TTS synthesis failed";
+
+ OnTtsFinish?.Invoke(this, new ttsStreamingEventArgs
+ {
+ Error = error,
+ AudioData = Array.Empty()
+ });
+
+ ttsCompletionSource?.SetException(new Exception(error));
+
+ break;
+
+ }
+ }
+ catch (Exception ex)
+ {
+ Log.Error("Tizen.AIAvatar", $"Error in TtsSynthesizedPCM: {ex.Message}");
+ OnTtsFinish?.Invoke(this, new ttsStreamingEventArgs
+ {
+ Error = ex.Message,
+ AudioData = Array.Empty()
+ });
+ ttsCompletionSource?.SetException(ex);
+ }
+ }
+
+ ///
+ /// Retrieves the list of supported voices from the TTS client.
+ ///
+ /// A list of supported voice information.
+ private List GetSupportedVoices()
+ {
+ var voiceInfoList = new List();
+
+ if (ttsHandle == null)
+ {
+ Log.Error("Tizen.AIAvatar", $"ttsHandle is null");
+ return voiceInfoList;
+ }
+
+ var supportedVoices = ttsHandle.GetSupportedVoices();
+ foreach (var supportedVoice in supportedVoices)
+ {
+ Log.Info("Tizen.AIAvatar", $"{supportedVoice.Language} & {supportedVoice.VoiceType} is supported");
+ voiceInfoList.Add(new VoiceInfo() { Language = supportedVoice.Language, Type = (VoiceType)supportedVoice.VoiceType });
+ }
+ return voiceInfoList;
+ }
+
+ ///
+ /// Invokes the response handler event with the given event arguments.
+ ///
+ /// The response event arguments.
+ private void OnResponseHandler(llmResponseEventArgs e)
+ {
+ ResponseHandler?.Invoke(this, e);
+ }
+ }
+}
diff --git a/src/Tizen.AIAvatar/src/Animations/EyeBlinker.cs b/src/Tizen.AIAvatar/src/Animations/EyeBlinker.cs
deleted file mode 100644
index 14319028d91..00000000000
--- a/src/Tizen.AIAvatar/src/Animations/EyeBlinker.cs
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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 Tizen.NUI;
-
-using static Tizen.AIAvatar.AIAvatar;
-
-namespace Tizen.AIAvatar
-{
- internal class EyeBlinker : IBlendShapeModule, IDisposable
- {
- private AvatarMotionState currentMotionState = AvatarMotionState.Unavailable;
-
- private readonly Object motionChangedLock = new Object();
- private event EventHandler motionChanged;
-
- private const int blinkIntervalMinimum = 800;
- private const int blinkIntervalMaximum = 3000;
- private Animation eyeAnimation;
-
- private Timer blinkTimer;
-
- private bool isPlaying = false;
- private const int blinkDuration = 200;
-
- public AvatarMotionState CurrentMotionState
- {
- get
- {
- return currentMotionState;
- }
- set
- {
- if (currentMotionState == value)
- {
- return;
- }
- var preState = currentMotionState;
- currentMotionState = value;
- if (motionChanged != null)
- {
- motionChanged?.Invoke(this, new AvatarMotionChangedEventArgs(preState, currentMotionState));
- }
- }
- }
-
- public event EventHandler MotionStateChanged
- {
- add
- {
- lock (motionChangedLock)
- {
- motionChanged += value;
- }
-
- }
-
- remove
- {
- lock (motionChangedLock)
- {
- if (motionChanged == null)
- {
- Log.Error(LogTag, "Remove StateChanged Failed : motionChanged is null");
- return;
- }
- motionChanged -= value;
- }
- }
- }
-
- public EyeBlinker()
- {
-
- }
-
- public void Dispose()
- {
- DestroyAnimation();
- }
-
- public void Init(Animation eyeAnimation)
- {
- this.eyeAnimation = eyeAnimation;
- }
-
- public void Play()
- {
- //data
- StartEyeBlink();
- }
-
- public void Stop()
- {
- StopEyeBlink();
- }
-
- public void Pause()
- {
- eyeAnimation?.Pause();
- }
-
- public void Destroy()
- {
- DestroyAnimation();
- }
-
- private void StartEyeBlink()
- {
- DestroyBlinkTimer();
-
- blinkTimer = new Timer(blinkDuration);
- if (blinkTimer != null)
- {
- blinkTimer.Tick += OnBlinkTimer;
- blinkTimer?.Start();
- isPlaying = true;
- }
- }
-
- private void PauseEyeBlink()
- {
- blinkTimer?.Stop();
- isPlaying = false;
- }
-
- private void StopEyeBlink()
- {
- blinkTimer?.Stop();
- isPlaying = false;
- }
-
- private void DestroyAnimation()
- {
- DestroyBlinkTimer();
- if (eyeAnimation != null)
- {
- eyeAnimation.Stop();
- eyeAnimation.Dispose();
- eyeAnimation = null;
- }
- isPlaying = false;
- }
-
- private bool OnBlinkTimer(object source, Timer.TickEventArgs e)
- {
- if (eyeAnimation == null)
- {
- Log.Error(LogTag, "eye animation is not ready");
- return false;
- }
- eyeAnimation?.Play();
-
- var random = new Random();
- var fortimerinterval = (uint)random.Next(blinkIntervalMinimum, blinkIntervalMaximum);
- blinkTimer.Interval = fortimerinterval;
- return true;
- }
-
- private void DestroyBlinkTimer()
- {
- if (blinkTimer != null)
- {
- blinkTimer.Tick -= OnBlinkTimer;
- blinkTimer.Stop();
- blinkTimer.Dispose();
- blinkTimer = null;
- }
- }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Animations/IBlendShapeModule.cs b/src/Tizen.AIAvatar/src/Animations/IBlendShapeModule.cs
deleted file mode 100644
index 7f9daf667c4..00000000000
--- a/src/Tizen.AIAvatar/src/Animations/IBlendShapeModule.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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 Tizen.NUI;
-
-namespace Tizen.AIAvatar
-{
- internal interface IBlendShapeModule
- {
- public void Init(Animation animation);
-
- public void Play();
-
- public void Stop();
-
- public void Pause();
-
- public void Destroy();
- }
-
-}
diff --git a/src/Tizen.AIAvatar/src/Animations/MotionPlayer.cs b/src/Tizen.AIAvatar/src/Animations/MotionPlayer.cs
deleted file mode 100644
index a590ba9deae..00000000000
--- a/src/Tizen.AIAvatar/src/Animations/MotionPlayer.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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 Tizen.NUI;
-using Tizen.NUI.Scene3D;
-using static Tizen.AIAvatar.AIAvatar;
-
-namespace Tizen.AIAvatar
-{
- internal class MotionPlayer
- {
- private Animation motionAnimation;
- private EyeBlinker eyeBlinker;
-
- internal Animation MotionAnimation { get => motionAnimation; private set => motionAnimation = value; }
-
- internal MotionPlayer()
- {
- eyeBlinker = new EyeBlinker();
-
-
- }
-
- internal void PlayAnimation(Animation motionAnimation, int duration = 3000, bool isLooping = false, int loopCount = 1)
- {
- ResetAnimations();
- if (motionAnimation != null)
- {
- MotionAnimation = motionAnimation;
- MotionAnimation?.Play();
- }
- else
- {
- Tizen.Log.Error(LogTag, "motionAnimation is null");
- }
- }
-
- internal void PauseMotionAnimation()
- {
- MotionAnimation?.Pause();
- }
-
- internal void StopMotionAnimation()
- {
- MotionAnimation?.Stop();
- }
-
- internal void SetBlinkAnimation(Animation blinkerAnimation)
- {
- eyeBlinker?.Init(blinkerAnimation);
- }
-
- internal void StartEyeBlink()
- {
- eyeBlinker?.Play();
- }
-
- internal void PauseEyeBlink()
- {
- eyeBlinker?.Pause();
- }
-
-
- internal void StopEyeBlink()
- {
- eyeBlinker?.Stop();
- }
-
- internal void DestroyAnimations()
- {
- eyeBlinker?.Destroy();
- }
-
- private void ResetAnimations()
- {
- if (MotionAnimation != null)
- {
- MotionAnimation.Stop();
- MotionAnimation.Dispose();
- MotionAnimation = null;
- }
- }
-
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Common/Avatar.cs b/src/Tizen.AIAvatar/src/Common/Avatar.cs
deleted file mode 100644
index 8ff4306ebe3..00000000000
--- a/src/Tizen.AIAvatar/src/Common/Avatar.cs
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.ComponentModel;
-using Tizen.NUI.Scene3D;
-using Tizen.NUI;
-
-using static Tizen.AIAvatar.AIAvatar;
-
-namespace Tizen.AIAvatar
-{
- ///
- /// The Avatar class displays 3D avatars and provides easy access to their animations.
- /// This class is a sub-class of the Model class which allows us to easily control the Avatar's animations.
- /// Avatar also supports AR Emoji for humanoid-based 3D models.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class Avatar : Model
- {
- private AvatarProperties avatarProperties = new DefaultAvatarProperties();
-
- private MotionPlayer motionPlayer;
-
- ///
- /// The AvatarProperties property gets or sets the AvatarProperties object containing various information about the Avatar.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public AvatarProperties Properties
- {
- get => avatarProperties;
- set
- {
- avatarProperties = value;
- }
- }
-
- ///
- /// Create an initialized AvatarModel.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Avatar() : base()
- {
- InitAvatar();
- }
-
- ///
- /// Create an initialized AREmojiDefaultAvatar.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Avatar(AvatarInfo avatarInfo) : base(avatarInfo.ResourcePath)
- {
- InitAvatar();
- }
-
- ///
- /// Create an initialized Avatar.
- ///
- /// avatar file url.(e.g. glTF).
- /// The url to derectory containing resources: binary, image etc.
- ///
- /// If resourceDirectoryUrl is empty, the parent directory url of avatarUrl is used for resource url.
- ///
- /// http://tizen.org/privilege/mediastorage for local files in media storage.
- /// http://tizen.org/privilege/externalstorage for local files in external storage.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Avatar(string avatarUrl, string resourceDirectoryUrl = "") : base(avatarUrl, resourceDirectoryUrl)
- {
- InitAvatar();
- }
-
- ///
- /// Copy constructor.
- ///
- /// Source object to copy.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Avatar(Avatar avatar) : base(avatar)
- {
- InitAvatar();
- }
-
- #region Manage Animating
-
- ///
- /// Plays the specified avatar animation with an optional duration and loop count.
- ///
- /// The AnimationInfo object containing information about the desired avatar animation.
- /// The duration of the animation in milliseconds (default is 3000).
- /// A boolean indicating whether the animation should be looped or not.
- /// The number of times to repeat the animation if it's set to loop.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void PlayAnimation(AnimationInfo animationInfo, int duration = 3000, bool isLooping = false, int loopCount = 1)
- {
- if (animationInfo == null)
- {
- Tizen.Log.Error(LogTag, "animationInfo is null");
- return;
- }
- if (animationInfo.MotionData == null)
- {
- Tizen.Log.Error(LogTag, "animationInfo.MotionData is null");
- return;
- }
- motionAnimation = GenerateMotionDataAnimation(animationInfo.MotionData);
- if (motionAnimation != null)
- {
- motionAnimation.Duration = duration;
- motionAnimation.Looping = isLooping;
- motionAnimation.LoopCount = loopCount;
- motionAnimation.BlendPoint = 0.2f;
- motionPlayer.PlayAnimation(motionAnimation);
- }
- else
- {
- Tizen.Log.Error(LogTag, "motionAnimation is null");
- }
- }
-
- Animation motionAnimation;
-
- ///
- /// Plays the specified avatar animation with MotionData and an optional duration and loop count.
- ///
- /// The MotionData object containing information about the desired avatar animation.
- /// The duration of the animation in milliseconds (default is 3000).
- /// A boolean indicating whether the animation should be looped or not.
- /// The number of times to repeat the animation if it's set to loop.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void PlayAnimation(MotionData motionData, int duration = 3000, bool isLooping = false, int loopCount = 1)
- {
-
- if (motionData == null)
- {
- Tizen.Log.Error(LogTag, "motionData is null");
- return;
- }
- var motionAnimation = GenerateMotionDataAnimation(motionData);
- if (motionAnimation != null)
- {
- motionAnimation.Duration = duration;
- motionAnimation.Looping = isLooping;
- motionAnimation.LoopCount = loopCount;
- motionAnimation.BlendPoint = 0.2f;
- motionPlayer.PlayAnimation(motionAnimation);
- }
- else
- {
- Tizen.Log.Error(LogTag, "motionAnimation is null");
- }
- }
-
- ///
- /// Plays the specified avatar animation based on its index within the available animations and an optional duration and loop count.
- ///
- /// The zero-based index of the desired avatar animation within the list of available animations.
- /// The duration of the animation in milliseconds (default is 3000).
- /// A boolean indicating whether the animation should be looped or not.
- /// The number of times to repeat the animation if it's set to loop.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void PlayAnimation(int index, int duration = 3000, bool isLooping = false, int loopCount = 1)
- {
- //TODO by index
- //var motionAnimation = GenerateMotionDataAnimation(animationInfoList[index].MotionData);
- /*motionAnimation.Duration = duration;
- motionAnimation.Looping = isLooping;
- motionAnimation.LoopCount = loopCount;
- motionAnimation.BlendPoint = 0.2f;
-
- motionPlayer.PlayAnimation(motionAnimation);*/
- }
-
- ///
- /// Pauses the currently playing avatar animation.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void PauseMotionAnimation()
- {
- motionPlayer.PauseMotionAnimation();
- }
-
- ///
- /// Stops the currently playing avatar animation.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void StopMotionAnimation()
- {
- motionPlayer?.StopMotionAnimation();
- }
-
- ///
- /// Starts the eye blink animation for the current avatar.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void StartEyeBlink()
- {
- motionPlayer?.StartEyeBlink();
- }
-
- ///
- /// Pauses the eye blink animation for the current avatar.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void PauseEyeBlink()
- {
- motionPlayer?.PauseEyeBlink();
- }
-
- ///
- /// Stops the eye blink animation for the current avatar.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void StopEyeBlink()
- {
- motionPlayer?.StopEyeBlink();
- }
- #endregion
-
- private void InitAvatar()
- {
- motionPlayer = new MotionPlayer();
- var eyeMotionData = CreateEyeBlinkMotionData(200);
- if (eyeMotionData == null)
- {
- Tizen.Log.Info(LogTag, "Failed Loading eyeAnimation");
- }
-
- ResourcesLoaded += (s, e) =>
- {
- var eyeAnimation = GenerateMotionDataAnimation(eyeMotionData);
- if (eyeAnimation != null)
- {
- motionPlayer.SetBlinkAnimation(eyeAnimation);
- }
- };
- }
-
- private MotionData CreateEyeBlinkMotionData(int ms)
- {
- var keyFrames = new KeyFrames();
- keyFrames.Add(0.1f, 0.0f);
- keyFrames.Add(0.5f, 1.0f);
- keyFrames.Add(0.9f, 0.0f);
-
- var headBlendShapeEyeLeft = new AvatarBlendShapeIndex(avatarProperties.NodeMapper, NodeType.HeadGeo, avatarProperties.BlendShapeMapper, BlendShapeType.EyeBlinkLeft);
- var headBlendShapeEyeRight = new AvatarBlendShapeIndex(avatarProperties.NodeMapper, NodeType.HeadGeo, avatarProperties.BlendShapeMapper, BlendShapeType.EyeBlinkRight);
- var eyelashBlendShapeEyeLeft = new AvatarBlendShapeIndex(avatarProperties.NodeMapper, NodeType.EyelashGeo, avatarProperties.BlendShapeMapper, BlendShapeType.EyeBlinkLeft);
- var eyelashBlendShapeEyeRight = new AvatarBlendShapeIndex(avatarProperties.NodeMapper, NodeType.EyelashGeo, avatarProperties.BlendShapeMapper, BlendShapeType.EyeBlinkRight);
-
- var motionData = new MotionData(ms);
- motionData.Add(headBlendShapeEyeLeft, new MotionValue(keyFrames));
- motionData.Add(headBlendShapeEyeRight, new MotionValue(keyFrames));
- motionData.Add(eyelashBlendShapeEyeLeft, new MotionValue(keyFrames));
- motionData.Add(eyelashBlendShapeEyeRight, new MotionValue(keyFrames));
-
- return motionData;
- }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Emotion/EmotionAnalyzer.cs b/src/Tizen.AIAvatar/src/Emotion/EmotionAnalyzer.cs
deleted file mode 100644
index ec74d751e85..00000000000
--- a/src/Tizen.AIAvatar/src/Emotion/EmotionAnalyzer.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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 Newtonsoft.Json;
-using System.Net.Http;
-using System;
-using System.Threading.Tasks;
-
-namespace Tizen.AIAvatar
-{
- internal class EmotionAnalyzer
- {
- private LipSyncController avatarTTS;
- private IRestClient restClient;
- private const string playgroundURL = "https://playground-api.sec.samsung.net";
-
- internal EmotionAnalyzer()
- {
- }
-
- internal void InitAvatarLLM(LipSyncController avatarTTS)
- {
- this.avatarTTS = avatarTTS;
- // Setup RestClinet
- var restClientFactory = new RestClientFactory();
- restClient = restClientFactory.CreateClient(playgroundURL);
- }
-
- internal async Task StartTTSWithLLMAsync(string text, string token)
- {
- var bearerToken = token;
- var jsonData = "{\"messages\": [{\"role\": \"user\", \"content\": \"" + text + "\"}]}";
-
- try
- {
- var postResponse = await restClient.SendRequestAsync(HttpMethod.Post, "/api/v1/chat/completions", bearerToken, jsonData);
- var responseData = JsonConvert.DeserializeObject(postResponse);
- string content = responseData["response"]["content"];
- Log.Info("Tizen.AIAvatar", content);
-
- //TTS 호출
- var voiceInfo = new VoiceInfo()
- {
- Language = "en_US",
- Type = VoiceType.Female,
- };
-
- avatarTTS.PlayTTSAsync(content, voiceInfo, (o, e) =>
- {
-
- });
-
- }
- catch (Exception ex)
- {
- Log.Error("Tizen.AIAvatar", "에러 발생: " + ex.Message);
- }
- }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Emotion/EmotionController.cs b/src/Tizen.AIAvatar/src/Emotion/EmotionController.cs
deleted file mode 100644
index fd0bd421915..00000000000
--- a/src/Tizen.AIAvatar/src/Emotion/EmotionController.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.ComponentModel;
-
-namespace Tizen.AIAvatar
-{
- ///
- /// Manages facial expression control for avatars based on input text sentiment analysis results.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class EmotionController
- {
- ///
- /// Initializes a new instance of the class without an avatar reference.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public EmotionController()
- {
-
- }
-
- ///
- /// Initializes the EmotionController by setting up the necessary components for managing facial expressions in the avatar.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void Initialize()
- {
-
- }
- ///
- /// This method analyzes emotion the given text.
- ///
- /// The text to analyze
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void AnalizeEmotion(string text)
- {
-
- }
-
- ///
- /// This method starts playing the emotion facial.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void PlayEmotionFacial()
- {
-
- }
-
- ///
- /// This method pauses the emotion facial.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void PauseEmotionFacial()
- {
-
- }
-
- ///
- /// This method stops the emotion facial.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void StopEmotionFacial()
- {
-
- }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Internal/AIAvatar.cs b/src/Tizen.AIAvatar/src/Internal/AIAvatar.cs
deleted file mode 100644
index 847866ac90d..00000000000
--- a/src/Tizen.AIAvatar/src/Internal/AIAvatar.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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 Tizen.Multimedia;
-
-namespace Tizen.AIAvatar
-{
- internal static class AIAvatar
- {
- internal const string LogTag = "Tizen.AIAvatar";
- internal static readonly string ApplicationResourcePath = "/usr/apps/org.tizen.default-avatar-resource/shared/res/";
- internal static readonly string EmojiAvatarResourcePath = "/models/EmojiAvatar/";
- internal static readonly string DefaultModelResourcePath = "/models/DefaultAvatar/";
- internal static readonly string DefaultMotionResourcePath = "/animation/motion/";
-
- internal static readonly string VisemeInfo = $"{ApplicationResourcePath}/viseme/emoji_viseme_info.json";
- internal static readonly string DefaultModel = "DefaultAvatar.gltf";
-
- internal static readonly string AREmojiDefaultAvatarPath = $"{ApplicationResourcePath}{DefaultModelResourcePath}{DefaultModel}";
-
- internal static readonly string DefaultLowModelResourcePath = "/models/DefaultAvatar_Low/";
- internal static readonly string ExternalModel = "model_external.gltf";
- internal static readonly string AREmojiDefaultLowAvatarPath = $"{ApplicationResourcePath}{DefaultLowModelResourcePath}{ExternalModel}";
-
- internal static AudioOptions DefaultAudioOptions = new AudioOptions(24000, AudioChannel.Mono, AudioSampleType.S16Le);
- internal static AudioOptions CurrentAudioOptions = DefaultAudioOptions;
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Internal/Utils.cs b/src/Tizen.AIAvatar/src/Internal/Utils.cs
deleted file mode 100644
index e845a02f812..00000000000
--- a/src/Tizen.AIAvatar/src/Internal/Utils.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.IO;
-using Tizen.Security;
-using Newtonsoft.Json;
-using System.Collections.Generic;
-using static Tizen.AIAvatar.AIAvatar;
-
-namespace Tizen.AIAvatar
-{
- internal class Utils
- {
- internal static void ConvertAudioToFloat(in byte[] audioBytes, out float[] audioFloat)
- {
- audioFloat = new float[audioBytes.Length / 2];
-
- for (int i = 0, j = 0; i < audioBytes.Length; i += 2, j++)
- {
- short sample = BitConverter.ToInt16(audioBytes, i);
- audioFloat[j] = sample / 32768.0f;
- }
- }
-
- internal static byte[] ReadAllBytes(string path)
- {
- try
- {
- var bytes = File.ReadAllBytes(path);
- return bytes;
- }
- catch (Exception)
- {
- return null;
- }
- }
-
- internal static void SaveFile(string path, string filename, byte[] array)
- {
- try
- {
- var file = new FileStream($"{path}/{filename}", FileMode.Create);
- file.Write(array, 0, array.Length);
- file.Close();
- }
- catch (Exception)
- {
- return;
- }
- }
-
- internal static void CheckPrivilege(string privilege)
- {
- var result = PrivacyPrivilegeManager.CheckPermission(privilege);
-
- switch (result)
- {
- case CheckResult.Allow:
- Log.Info(LogTag, $"Privilege \"{privilege}\" : allowed.");
- break;
- case CheckResult.Deny:
- Log.Info(LogTag, $"Privilege \"{privilege}\" : denied.");
- /// Privilege can't be used
- break;
- case CheckResult.Ask:
- /// Request permission to user
- PrivacyPrivilegeManager.RequestPermission(privilege);
- break;
- }
- }
-
- internal static T ConvertJson(string jsonString)
- {
- return JsonConvert.DeserializeObject(jsonString);
- }
-
- internal int FindMaxValue(List list, Converter projection)
- {
- if (list.Count == 0)
- {
- throw new InvalidOperationException("Empty list");
- }
- int maxValue = int.MinValue;
- foreach (T item in list)
- {
- int value = projection(item);
- if (value > maxValue)
- {
- maxValue = value;
- }
- }
- return maxValue;
- }
- }
-}
-
-internal class SystemUtils
-{
- internal static string GetFileName(string path)
- {
- return System.IO.Path.GetFileName(path);
- }
- internal static string GetFileNameWithoutExtension(string path)
- {
- return System.IO.Path.GetFileNameWithoutExtension(path);
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Lipsync/AsyncLipSyncer.cs b/src/Tizen.AIAvatar/src/Lipsync/AsyncLipSyncer.cs
deleted file mode 100644
index 952c47c4980..00000000000
--- a/src/Tizen.AIAvatar/src/Lipsync/AsyncLipSyncer.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.Collections.Generic;
-using System.ComponentModel;
-using Tizen.NUI;
-
-using static Tizen.AIAvatar.AIAvatar;
-
-namespace Tizen.AIAvatar
-{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal class AsyncLipSyncer
- {
- private readonly uint AsyncPlayTime = 160;
- private Queue lipAnimations;
- private Queue lipAudios;
- private Timer asyncVowelTimer;
-
- private bool isAsyncInit = false;
- private bool isFinishAsyncLip = false;
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal AsyncLipSyncer()
- {
-
- }
-
- internal int SampleRate { get; set; }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal bool IsAsyncInit { get=>isAsyncInit; set=>isAsyncInit = value; }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal void SetFinishAsyncLip(bool finished)
- {
- isFinishAsyncLip = finished;
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected new void OnLipAnimationFinished(object sender, EventArgs e)
- {
- if (!isAsyncInit)
- {
- //TODO : State is Stop
- }
- else
- {
- Tizen.Log.Error(LogTag, "OnLipAnimationFinished---------------c");
- //Async State
- if (isFinishAsyncLip && lipAnimations.Count == 0)
- {
- Tizen.Log.Error(LogTag, "Finish vowel lip sync");
-
-
- //Audio Player is Stop, AudioPlayer.Stop();
- //TODO : State is Stop
- DestroyVowelTimer();
- isAsyncInit = false;
- }
- }
- }
-
- internal void InitAsyncLipsync()
- {
- if (lipAnimations == null)
- {
- lipAnimations = new Queue();
- }
- else
- {
- lipAnimations.Clear();
- }
-
- if (lipAudios == null)
- {
- lipAudios = new Queue();
- }
- else
- {
- lipAudios.Clear();
- }
- }
-
- private void EnqueueVowels(byte[] buffer, bool deleteLast = false)
- {
- /*
- var vowels = PredictVowels(buffer);
- if (vowels != null)
- {
- vowelPools.Enqueue(vowels);
- if (deleteLast)
- {
- var vowelList = new List(vowels);
- vowelList.RemoveAt(vowelList.Count - 1);
- vowels = vowelList.ToArray();
- }
- }*/
- }
-
- internal Animation CreateAsyncLipAnimation(byte[] buffer, int sampleRate)
- {
- EnqueueVowels(buffer, false);
- return null;
- //return CreateLipAnimationByVowelsQueue(sampleRate);
- }
-
- internal void EnqueueAnimation(byte[] recordBuffer, int sampleRate, int audioLength)
- {
- var createdAni = CreateAsyncLipAnimation(recordBuffer, sampleRate);
- if (createdAni != null)
- {
- lipAnimations.Enqueue(createdAni);
- }
-
- //Use Audio Full File
- ///var createdAni = avatarLipSyncer.CreateLipAnimation(recordBuffer, sampleRate);
- //lipAnimations.Enqueue(createdAni);
-
- var currentAudioBuffer = new byte[audioLength];
- Buffer.BlockCopy(recordBuffer, 0, currentAudioBuffer, 0, audioLength);
-
- lipAudios.Enqueue(currentAudioBuffer);
- }
-
- internal bool PlayAsyncLip(int sampleRate, bool isFinishAsyncLip)
- {
- try
- {
- if (lipAudios.Count <= 0 && lipAnimations.Count <= 0)
- {
- Tizen.Log.Info(LogTag, "Return lipaudio 0");
- if (isFinishAsyncLip)
- {
- Tizen.Log.Info(LogTag, "Finish Async lipsync");
- return false;
- }
- return true;
- }
- Tizen.Log.Info(LogTag, "Async timer tick lipAudios : " + lipAudios.Count);
- Tizen.Log.Info(LogTag, "Async timer tick lipAnimations : " + lipAnimations.Count);
-
- var lipAnimation = lipAnimations.Dequeue();
- lipAnimation.Finished += OnLipAnimationFinished;
-
- //ResetLipAnimation(lipAnimation);
- //PlayLipAnimation();
- var audioBuffer = lipAudios.Dequeue();
-
- //Audio Playe rAsync Play
- //AudioPlayer.PlayAsync(audioBuffer, sampleRate);
- return true;
-
- }
- catch (Exception ex)
- {
- Log.Error(LogTag, $"---Log Tick : {ex.StackTrace}");
-
- return false;
- }
- }
-
- internal void StartAsyncLipPlayTimer()
- {
- if (asyncVowelTimer == null)
- {
- Tizen.Log.Info(LogTag, "Start Async");
- asyncVowelTimer = new Timer(AsyncPlayTime);
- asyncVowelTimer.Tick += OnAsyncVowelTick;
- asyncVowelTimer.Start();
- }
- return;
- }
-
- private void DestroyVowelTimer()
- {
- if (asyncVowelTimer != null)
- {
-
- asyncVowelTimer.Tick -= OnAsyncVowelTick;
- asyncVowelTimer.Stop();
- asyncVowelTimer.Dispose();
- asyncVowelTimer = null;
- }
- }
-
- private bool OnAsyncVowelTick(object source, Tizen.NUI.Timer.TickEventArgs e)
- {
- return PlayAsyncLip(SampleRate, isFinishAsyncLip);
- }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Audio2Vowels.cs b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Audio2Vowels.cs
new file mode 100644
index 00000000000..c1cddee7027
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Audio2Vowels.cs
@@ -0,0 +1,108 @@
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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.Collections.Generic;
+using System.ComponentModel;
+
+
+namespace Tizen.AIAvatar
+{
+ ///
+ /// The Audio2Vowels class is responsible for predicting vowels from audio data using a pre-trained TensorFlow model.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class Audio2Vowels
+ {
+ ///
+ /// The sample rate of the audio data.
+ ///
+ private int sampleRate;
+
+ ///
+ /// The pre-trained TensorFlow model used for vowel prediction.
+ ///
+ private TFVowel6 model;
+
+ ///
+ /// A dictionary containing vowel classifiers indexed by their respective sample rates.
+ ///
+ private Dictionary classifiers;
+
+ ///
+ /// Initializes a new instance of the Audio2Vowels class with the specified TensorFlow model file path.
+ ///
+ /// The path to the pre-trained TensorFlow model file.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Audio2Vowels(string tensorflowFilePath)
+ {
+ classifiers = new Dictionary();
+ model = new TFVowel6(new int[4] { 12, 1, 1, 1 }, new int[4] { 7, 1, 1, 1 }, tensorflowFilePath);
+ }
+
+ ///
+ /// Predicts the vowels present in the given audio data.
+ ///
+ /// The audio data to analyze.
+ /// An array of predicted vowels.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string[] PredictVowels(byte[] audioData)
+ {
+ VowelClassifier classifier = GetVowelClassifier(sampleRate);
+ return classifier.Inference(audioData, model);
+ }
+
+ ///
+ /// Sets the sample rate of the audio data.
+ ///
+ /// The sample rate to set.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetSampleRate(int rate)
+ {
+ sampleRate = rate;
+ }
+
+ ///
+ /// Gets the current sample rate of the audio data.
+ ///
+ /// The current sample rate.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int GetSampleRate()
+ {
+ return sampleRate;
+ }
+
+ ///
+ /// Retrieves the vowel classifier corresponding to the specified sample rate.
+ /// If no classifier exists for the given sample rate, a new one is created.
+ ///
+ /// The sample rate for which to retrieve the classifier.
+ /// A VowelClassifier object.
+ private VowelClassifier GetVowelClassifier(int rate)
+ {
+ if (classifiers.ContainsKey(rate))
+ {
+ return classifiers[rate];
+ }
+ else
+ {
+ VowelClassifier classifier = new VowelClassifier(rate);
+ classifiers[rate] = classifier;
+ return classifier;
+ }
+ }
+ }
+}
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/ISingleShotModel.cs b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/ISingleShotModel.cs
similarity index 100%
rename from src/Tizen.AIAvatar/src/Lipsync/VowelConverter/ISingleShotModel.cs
rename to src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/ISingleShotModel.cs
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/CustomMfccExtractor.cs b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/CustomMfccExtractor.cs
similarity index 100%
rename from src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/CustomMfccExtractor.cs
rename to src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/CustomMfccExtractor.cs
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/DCT.cs b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/DCT.cs
similarity index 100%
rename from src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/DCT.cs
rename to src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/DCT.cs
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/FFT.cs b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/FFT.cs
similarity index 100%
rename from src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/FFT.cs
rename to src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/FFT.cs
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/FilterBank.cs b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/FilterBank.cs
similarity index 100%
rename from src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/FilterBank.cs
rename to src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/FilterBank.cs
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/IMFccExtractor.cs b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/IMFccExtractor.cs
similarity index 100%
rename from src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/IMFccExtractor.cs
rename to src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/IMFccExtractor.cs
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/PreEmphasis.cs b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/PreEmphasis.cs
similarity index 100%
rename from src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/PreEmphasis.cs
rename to src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/PreEmphasis.cs
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/Window.cs b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/Window.cs
similarity index 100%
rename from src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Audio2Vowel/inMFCC/Algorithm/Window.cs
rename to src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/MFCC/Algorithm/Window.cs
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/SoftmaxLinqExtension.cs b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/SoftmaxLinqExtension.cs
similarity index 100%
rename from src/Tizen.AIAvatar/src/Lipsync/VowelConverter/SoftmaxLinqExtension.cs
rename to src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/SoftmaxLinqExtension.cs
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/TFVowel6.cs b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/TFVowel6.cs
similarity index 96%
rename from src/Tizen.AIAvatar/src/Lipsync/VowelConverter/TFVowel6.cs
rename to src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/TFVowel6.cs
index fcafa674366..7d152b0a45b 100644
--- a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/TFVowel6.cs
+++ b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/TFVowel6.cs
@@ -29,10 +29,8 @@ internal class TFVowel6 : ISingleShotModel
private TensorsInfo outputInfo;
private TensorsData inputData;
private TensorsData outputData;
-
- private readonly string modelPath = ApplicationResourcePath + "audio2vowel_7.tflite";
-
- internal TFVowel6(int[] inputDimension, int[] outputDimension)
+
+ internal TFVowel6(int[] inputDimension, int[] outputDimension, string modelPath)
{
try
{
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/VowelClassifier.cs b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/VowelClassifier.cs
similarity index 86%
rename from src/Tizen.AIAvatar/src/Lipsync/VowelConverter/VowelClassifier.cs
rename to src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/VowelClassifier.cs
index 958b6f19647..c9771bb478d 100644
--- a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/VowelClassifier.cs
+++ b/src/Tizen.AIAvatar/src/Lipsync/Audio2Vowels/Core/VowelClassifier.cs
@@ -43,13 +43,13 @@ internal VowelClassifier(int sampleRate, float frameDuration = 0.025f, float hop
mfccExtractor = new CustomMfccExtractor(sampleRate, frameDuration, hopDuration, featureCount);
}
- public float GetStepTime()
+ internal float GetStepTime()
{
return stepTime;
}
- public string[] Inference(byte[] audio, ISingleShotModel model)
+ internal string[] Inference(byte[] audio, ISingleShotModel model)
{
int length = PreprocessInput(audio, out float[] features, out List audioEnergy);
var outputData = InferenceModel(features, length, model);
@@ -58,9 +58,9 @@ public string[] Inference(byte[] audio, ISingleShotModel model)
return result.ToArray();
}
- public int PreprocessInput(byte[] audioByte, out float[] flattenedArray, out List audioEnergy)
+ internal int PreprocessInput(byte[] audioByte, out float[] flattenedArray, out List audioEnergy)
{
- Utils.ConvertAudioToFloat(audioByte, out var audio);
+ ConvertAudioToFloat(audioByte, out var audio);
var mfccFeatures = mfccExtractor.ComputeFrom(audio, sampleRate);
@@ -78,7 +78,7 @@ public int PreprocessInput(byte[] audioByte, out float[] flattenedArray, out Lis
return featureLength;
}
- public List InferenceModel(float[] input, int length, ISingleShotModel model)
+ internal List InferenceModel(float[] input, int length, ISingleShotModel model)
{
byte[] inputBuffer = new byte[4 * 12 * 1 * 1];
byte[] outputBuffer;
@@ -108,6 +108,17 @@ public List InferenceModel(float[] input, int length, ISingleShotModel
return fullOutput;
}
+ private void ConvertAudioToFloat(in byte[] audioBytes, out float[] audioFloat)
+ {
+ audioFloat = new float[audioBytes.Length / 2];
+
+ for (int i = 0, j = 0; i < audioBytes.Length; i += 2, j++)
+ {
+ short sample = BitConverter.ToInt16(audioBytes, i);
+ audioFloat[j] = sample / 32768.0f;
+ }
+ }
+
private List ProcessOutput(List outputData, List audioEnergy)
{
var result = new List();
diff --git a/src/Tizen.AIAvatar/src/Lipsync/LipSyncController.cs b/src/Tizen.AIAvatar/src/Lipsync/LipSyncController.cs
deleted file mode 100644
index 45349f86cb0..00000000000
--- a/src/Tizen.AIAvatar/src/Lipsync/LipSyncController.cs
+++ /dev/null
@@ -1,668 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.Collections.Generic;
-using System.ComponentModel;
-using System;
-using Tizen.Uix.Tts;
-
-using static Tizen.AIAvatar.AIAvatar;
-using Tizen.Multimedia;
-using Tizen.NUI.Scene3D;
-using Tizen.NUI;
-
-namespace Tizen.AIAvatar
-{
- ///
- /// A controller class used to manage lip sync functionality for avatars.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class LipSyncController : IDisposable
- {
- private TTSController ttsController;
- private AudioRecorder audioRecorder;
- private LipSyncer lipSyncer;
-
- private Avatar avatar;
-
- private event EventHandler ttsReadyFinished;
- private readonly Object ttsReadyFinishedLock = new Object();
-
- ///
- /// Initializes a new instance of the class.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public LipSyncController(Avatar avatar)
- {
- this.avatar = avatar;
-
- audioRecorder = new AudioRecorder();
- lipSyncer = new LipSyncer();
-
- lipSyncer.CreatedKeyFrameAnimation += OnCreatedKeyFrameAnimation;
- }
-
- private Animation CreateLipAnimation(AnimationKeyFrame animationKeyFrames, bool isMic = false)
- {
- var animationTime = (int)(animationKeyFrames.AnimationTime * 1000f);
- var lipAnimation = new Animation(animationTime);
-
- var motionData = new MotionData(animationTime);
- for (var i = 0; i < animationKeyFrames.NodeNames.Length; i++)
- {
- var nodeName = animationKeyFrames.NodeNames[i];
- for (var j = 0; j < animationKeyFrames.BlendShapeCounts[i]; j++)
- {
- var blendShapeIndex = new BlendShapeIndex(new PropertyKey(nodeName), new PropertyKey(j));
- var keyFrameList = animationKeyFrames.GetKeyFrames(nodeName, j);
- if (keyFrameList.Count == 0)
- {
- continue;
- }
-
- var keyFrames = new KeyFrames();
- CreateKeyTimeFrames(ref keyFrames, keyFrameList, isMic);
-
- motionData.Add(blendShapeIndex, new MotionValue(keyFrames));
- lipAnimation = avatar.GenerateMotionDataAnimation(motionData);
- }
- }
- return lipAnimation;
- }
-
- private KeyFrames CreateKeyTimeFrames(ref KeyFrames keyFrames, List keyFrameList, bool isMic = false)
- {
- foreach (var key in keyFrameList)
- {
- keyFrames.Add(key.time, key.value);
- }
- if (!isMic) keyFrames.Add(1.0f, 0.0f);
-
- return keyFrames;
- }
-
- private Animation OnCreatedKeyFrameAnimation(AnimationKeyFrame animationKeyFrame, bool isMic)
- {
- if (animationKeyFrame == null)
- {
- Tizen.Log.Error(LogTag, "animtionKeyFrame is null");
- }
- var lipAnimation = CreateLipAnimation(animationKeyFrame, isMic);
- return lipAnimation;
- }
-
- ///
- /// Occurs when text-to-speech synthesis has finished and the audio data is ready to play.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public event EventHandler TTSReadyFinished
- {
- add
- {
- lock (ttsReadyFinishedLock)
- {
- ttsReadyFinished += value;
- }
-
- }
-
- remove
- {
- lock (ttsReadyFinishedLock)
- {
- if (ttsReadyFinished == null)
- {
- Log.Error(LogTag, "ttsReadyFinished is null");
- return;
- }
- ttsReadyFinished -= value;
- }
- }
- }
-
- ///
- /// Gets the current Text-To-Speech client associated with the Lip Sync Controller.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public TtsClient CurrentTTSClient => ttsController?.TtsHandle;
-
- ///
- /// Initializes the Text-To-Speech system for use with the Lip Sync Controller.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void InitializeTTS()
- {
- if (ttsController == null)
- {
- try
- {
- ttsController = new TTSController();
- //TODO : LipSync Event Connect
- ttsController.PreparedSyncText += OnPreparedSyncText;
- ttsController.StoppedTTS += OnStoppedTTS;
- ttsController.UpdatedBuffer += OnUpdatedBuffer;
- }
- catch (Exception e)
- {
- Log.Error(LogTag, $"error :{e.Message}");
- Log.Error(LogTag, $"{e.StackTrace}");
- }
- }
- }
-
- private void OnUpdatedBuffer(object sender, TTSControllerEventArgs e)
- {
- throw new NotImplementedException();
- if (lipSyncer != null)
- {
- Log.Error(LogTag, "OnTTSBufferChanged");
- /*
- lipSyncer.EnqueueAnimation(recordBuffer, sampleRate, audioLength);
- if (!isAsyncLipStarting)
- {
- lipSyncer.StartAsyncLipPlayTimer();
- isAsyncLipStarting = true;
- }*/
- }
- else
- {
- Log.Error(LogTag, "avatarLipSyncer is null");
- }
- }
-
- private void OnStoppedTTS(object sender, TTSControllerEventArgs e)
- {
- lipSyncer.Stop();
- }
-
- private void OnPreparedSyncText(object sender, TTSControllerEventArgs e)
- {
- var data = e.AudioData;
- var sampleRate = e.SampleRate;
-
- // Play Lipsync Animation by Audio
- lipSyncer.PlayAudio(data, sampleRate);
- }
-
- ///
- /// Deinitializes the Text-To-Speech system for use with the Lip Sync Controller.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void DeInitializeTTS()
- {
- if (ttsController != null)
- {
- try
- {
- ttsController.DeinitTts();
- ttsController = null;
- }
- catch (Exception e)
- {
- Log.Error(LogTag, $"error :{e.Message}");
- Log.Error(LogTag, $"{e.StackTrace}");
- }
- }
- }
-
- ///
- /// Returns a list of supported voices for the Text-To-Speech system.
- ///
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public List GetSupportedVoices()
- {
- return ttsController.GetSupportedVoices();
- }
-
- ///
- /// Plays the given audio with LipSync and returns whether it was successful or not.
- /// If the lip syncer is null, logs an error and returns false.
- /// The lipSyncer plays the audio using the provided byte array and sample rate.
- ///
- /// The audio data to be played in a byte array format.
- /// The sampling rate of the audio data, default value is 24000 Hz.
- public bool PlayLipSync(byte[] audio, int sampleRate = 24000)
- {
- if (lipSyncer == null)
- {
- Log.Error(LogTag, "lipSyncer is null");
- return false;
- }
- lipSyncer.PlayAudio(audio, sampleRate);
-
- return true;
- }
-
- ///
- /// Plays the given audio with LipSync and returns whether it was successful or not.
- /// If the lip syncer is null, logs an error and returns false.
- /// The lipSyncer plays the audio using the provided byte array and sample rate.
- ///
- /// The audio data to be played in a byte array format.
- /// The sampling rate of the audio data, default value is 16000 Hz.
- public bool PlayLipSync(string path, int sampleRate = 24000)
- {
- var audio = Utils.ReadAllBytes(path);
- if (audio == null)
- {
- Log.Error(LogTag, "audio data is null");
- return false;
- }
- lipSyncer.PlayAudio(audio, sampleRate);
-
- return true;
- }
-
- ///
- /// Prepares the Text-To-Speech engine to synthesize speech from the provided text and voice info.
- ///
- /// The text to convert into speech.
- /// The voice info to use for converting the text into speech.
- /// An optional callback that will be invoked when the TTS process is complete.
- /// True if preparation was successful, otherwise False .
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool PrepareTTS(string text, VoiceInfo voiceInfo, EventHandler ttsReadyFinishedCallback = null)
- {
- if (ttsController == null || ttsController.TtsHandle == null)
- {
- Log.Error(LogTag, "tts is null");
- return false;
- }
-
-
- if (!ttsController.IsSupportedVoice(voiceInfo))
- {
- Log.Info(LogTag, $"{voiceInfo.Language} & {voiceInfo.Type} is not supported");
- return false;
- }
-
- Log.Info(LogTag, "Current TTS State :" + ttsController.TtsHandle.CurrentState);
- if (ttsController.TtsHandle.CurrentState != Tizen.Uix.Tts.State.Ready)
- {
- Log.Info(LogTag, "TTS is not ready");
- return false;
- }
-
- try
- {
- ttsController.AddText(text, voiceInfo);
- ttsController.Prepare(ttsReadyFinishedCallback);
- }
- catch (Exception e)
- {
- Log.Error(LogTag, $"error :{e.Message}");
- Log.Error(LogTag, $"{e.StackTrace}");
- return false;
- }
- return true;
- }
-
- ///
- /// Prepares the Text-To-Speech engine to synthesize speech from the provided text and language code.
- ///
- /// The text to convert into speech.
- /// The two-letter ISO 639-1 language code to use for converting the text into speech (default is Korean - ko_KR).
- /// An optional callback that will be invoked when the TTS process is complete.
- /// True if preparation was successful, otherwise False .
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool PrepareTTS(string text, string lang = "ko_KR", EventHandler ttsReadyFinishedCallback = null)
- {
- if (ttsController == null || ttsController.TtsHandle == null)
- {
- Log.Error(LogTag, "tts is null");
- return false;
- }
-
- if (!ttsController.IsSupportedVoice(lang))
- {
- Log.Error(LogTag, $"{lang} is not supported");
- return false;
- }
-
- Log.Info(LogTag, "Current TTS State :" + ttsController.TtsHandle.CurrentState);
- if (ttsController.TtsHandle.CurrentState != Tizen.Uix.Tts.State.Ready)
- {
- Log.Error(LogTag, "TTS is not ready");
- return false;
- }
- try
- {
- ttsController.AddText(text, lang);
- ttsController.Prepare(ttsReadyFinishedCallback);
- }
- catch (Exception e)
- {
- Log.Error(LogTag, $"error :{e.Message}");
- Log.Error(LogTag, $"{e.StackTrace}");
- return false;
- }
- return true;
- }
-
- ///
- /// Plays the previously prepared Text-To-Speech audio data.
- ///
- /// True if playback started successfully, otherwise False .
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool PlayPreparedTTS()
- {
- if (ttsController == null || ttsController.TtsHandle == null)
- {
- Log.Error(LogTag, "tts is null");
- return false;
- }
-
- return ttsController.PlayPreparedText();
- }
-
- ///
- /// Converts the given text into speech using the specified voice info and plays the resulting audio immediately.
- ///
- /// The text to convert into speech.
- /// The voice info to use for converting the text into speech.
- /// True if playback started successfully, otherwise False .
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool PlayTTS(string text, VoiceInfo voiceInfo)
- {
- if (ttsController == null || ttsController.TtsHandle == null)
- {
- Log.Error(LogTag, "tts is null");
- return false;
- }
-
- if (!ttsController.IsSupportedVoice(voiceInfo))
- {
- Log.Info(LogTag, $"{voiceInfo.Language} & {voiceInfo.Type} is not supported");
- return false;
- }
-
- Log.Info(LogTag, "Current TTS State :" + ttsController.TtsHandle.CurrentState);
- if (ttsController.TtsHandle.CurrentState != Tizen.Uix.Tts.State.Ready)
- {
- Log.Info(LogTag, "TTS is not ready");
- return false;
- }
-
- try
- {
- ttsController.AddText(text, voiceInfo);
- ttsController.Play();
- }
- catch (Exception e)
- {
- Log.Error(LogTag, $"error :{e.Message}");
- Log.Error(LogTag, $"{e.StackTrace}");
- return false;
- }
- return true;
- }
-
- ///
- /// Converts the given text into speech using the specified language code and plays the resulting audio immediately.
- ///
- /// The text to convert into speech.
- /// The two-letter ISO 639-1 language code to use for converting the text into speech (default is Korean - ko_KR).
- /// True if playback started successfully, otherwise False .
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool PlayTTS(string text, string lang = "ko_KR")
- {
- if (ttsController == null || ttsController.TtsHandle == null)
- {
- Log.Error(LogTag, "tts is null");
- return false;
- }
-
- if (!ttsController.IsSupportedVoice(lang))
- {
- Log.Error(LogTag, $"{lang} is not supported");
- return false;
- }
-
- Log.Info(LogTag, "Current TTS State :" + ttsController.TtsHandle.CurrentState);
- if (ttsController.TtsHandle.CurrentState != Tizen.Uix.Tts.State.Ready)
- {
- Log.Error(LogTag, "TTS is not ready");
- return false;
- }
- try
- {
- ttsController.AddText(text, lang);
- ttsController.Play();
- }
- catch (Exception e)
- {
- Log.Error(LogTag, $"error :{e.Message}");
- Log.Error(LogTag, $"{e.StackTrace}");
- return false;
- }
- return true;
- }
-
- ///
- /// Asynchronously converts the given text into speech using the specified voice info and plays the resulting audio once it's ready.
- ///
- /// The text to convert into speech.
- /// The voice info to use for converting the text into speech.
- /// An optional callback that will be invoked when the TTS process is complete.
- /// True if asynchronous conversion was initiated successfully, otherwise False .
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool PlayTTSAsync(string text, VoiceInfo voiceInfo, EventHandler ttsReadyFinishedCallback = null)
- {
- if (ttsController == null || ttsController.TtsHandle == null)
- {
- Log.Error(LogTag, "tts is null");
- return false;
- }
-
- if (!ttsController.IsSupportedVoice(voiceInfo))
- {
- Log.Info(LogTag, $"{voiceInfo.Language} & {voiceInfo.Type} is not supported");
- return false;
- }
-
- Log.Info(LogTag, "Current TTS State :" + ttsController.TtsHandle.CurrentState);
- if (ttsController.TtsHandle.CurrentState != Tizen.Uix.Tts.State.Ready)
- {
- Log.Info(LogTag, "TTS is not ready");
- return false;
- }
-
- try
- {
- ttsController.AddText(text, voiceInfo);
- ttsController.PlayAsync(ttsReadyFinishedCallback);
- }
- catch (Exception e)
- {
- Log.Error(LogTag, $"error :{e.Message}");
- Log.Error(LogTag, $"{e.StackTrace}");
- return false;
- }
- return true;
- }
-
- ///
- /// Asynchronously converts the given text into speech using the specified language code and plays the resulting audio once it's ready.
- ///
- /// The text to convert into speech.
- /// The two-letter ISO 639-1 language code to use for converting the text into speech (default is Korean - ko_KR).
- /// An optional callback that will be invoked when the TTS process is complete.
- /// True if asynchronous conversion was initiated successfully, otherwise False .
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool PlayTTS(string text, string lang = "ko_KR", EventHandler ttsReadyFinishedCallback = null)
- {
- if (ttsController == null || ttsController.TtsHandle == null)
- {
- Log.Error(LogTag, "tts is null");
- return false;
- }
-
- if (!ttsController.IsSupportedVoice(lang))
- {
- Log.Error(LogTag, $"{lang} is not supported");
- return false;
- }
-
- Log.Info(LogTag, "Current TTS State :" + ttsController.TtsHandle.CurrentState);
- if (ttsController.TtsHandle.CurrentState != Tizen.Uix.Tts.State.Ready)
- {
- Log.Error(LogTag, "TTS is not ready");
- return false;
- }
- try
- {
- ttsController.AddText(text, lang);
- ttsController.PlayAsync(ttsReadyFinishedCallback);
- }
- catch (Exception e)
- {
- Log.Error(LogTag, $"error :{e.Message}");
- Log.Error(LogTag, $"{e.StackTrace}");
- return false;
- }
- return true;
- }
-
- ///
- /// Pauses the currently playing Text-To-Speech audio.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void PauseTTS()
- {
- if (ttsController == null || ttsController.TtsHandle == null)
- {
- Log.Error(LogTag, "tts is null");
- return;
- }
-
- try
- {
- Log.Info(LogTag, "Current TTS State :" + ttsController.TtsHandle.CurrentState);
- ttsController?.Pause();
- }
- catch (Exception e)
- {
- Log.Error(LogTag, $"error :{e.Message}");
- Log.Error(LogTag, $"{e.StackTrace}");
- }
- }
-
- ///
- /// Stops the currently playing Text-To-Speech audio.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void StopTTS()
- {
- if (ttsController == null || ttsController.TtsHandle == null)
- {
- Log.Error(LogTag, "tts is null");
- return;
- }
-
- try
- {
- Log.Info(LogTag, "Current TTS State :" + ttsController.TtsHandle.CurrentState);
- ttsController?.Stop();
- }
- catch (Exception e)
- {
- Log.Error(LogTag, $"error :{e.Message}");
- Log.Error(LogTag, $"{e.StackTrace}");
- }
- }
-
- public void InitializeMic()
- {
- if (audioRecorder == null)
- {
- Tizen.Log.Error(LogTag, "audio record is null");
- return;
- }
- audioRecorder.InitializeMic(lipSyncer, 160);
- }
-
- public void DeinitializeMic()
- {
- if (audioRecorder == null)
- {
- Tizen.Log.Error(LogTag, "audio record is null");
- return;
- }
- audioRecorder.StartRecording();
- }
-
- public void StartMic()
- {
- if (audioRecorder == null)
- {
- Tizen.Log.Error(LogTag, "audio record is null");
- return;
- }
- audioRecorder.StartRecording();
- }
-
- public void StopMic()
- {
- if (audioRecorder == null)
- {
- Tizen.Log.Error(LogTag, "audio record is null");
- return;
- }
- audioRecorder.StopRecording();
- }
-
- public void PauseMic()
- {
- if (audioRecorder == null)
- {
- Tizen.Log.Error(LogTag, "audio record is null");
- return;
- }
- audioRecorder.PauseRecording();
- }
-
- public void ResumeMic()
- {
- if(audioRecorder == null)
- {
- Tizen.Log.Error(LogTag, "audio record is null");
- return;
- }
- audioRecorder.ResumeRecording();
- }
-
- ///
- /// Releases unmanaged resources used by this instance.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void Dispose()
- {
- if (ttsController != null)
- {
- ttsController.Dispose();
- ttsController = null;
- }
-
- if (audioRecorder != null)
- {
- audioRecorder.Dispose();
- audioRecorder = null;
- }
- }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Lipsync/LipSyncer.cs b/src/Tizen.AIAvatar/src/Lipsync/LipSyncer.cs
deleted file mode 100644
index 8a5fc8fb47e..00000000000
--- a/src/Tizen.AIAvatar/src/Lipsync/LipSyncer.cs
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.Collections.Generic;
-using Tizen.NUI;
-using Tizen.NUI.Scene3D;
-using static Tizen.AIAvatar.AIAvatar;
-
-namespace Tizen.AIAvatar
-{
- internal class LipSyncer
- {
- private Animation lipAnimation = null;
-
- private VowelConverter vowelConverter;
- private AudioPlayer audioPlayer;
- private event Func TheEvent;
-
- internal Func CreatedKeyFrameAnimation;
-
- //Mic
- private Queue vowelPools = new Queue();
- private string prevVowel = "sil";
-
- internal LipSyncer()
- {
- vowelConverter = new VowelConverter();
- audioPlayer = new AudioPlayer();
- }
-
- internal AudioPlayer AudioPlayer { get { return audioPlayer; } }
-
- public void SetLipAnimation(Animation lipAnimation)
- {
- this.lipAnimation = lipAnimation;
- }
-
- public void PlayAudio(byte[] audio, int sampleRate)
- {
- if (audio != null)
- {
- PlayLipSync(audio, sampleRate);
- }
- }
-
- public void Stop()
- {
- StopLipSync();
- }
-
- public void Pause()
- {
- PauseLipSync();
- }
-
- public void Destroy()
- {
- DestroyLipAnimation();
- }
-
- //TODO : lipAnimation 자체를 Animator안에서 생성하고 관리될 수 있게 수정.
- protected void ResetLipAnimation(Animation lipAnimation)
- {
- DestroyLipAnimation();
- this.lipAnimation = lipAnimation;
- if (this.lipAnimation != null)
- {
- this.lipAnimation.Finished += OnLipAnimationFinished;
- }
- }
-
- protected void PlayLipAnimation()
- {
- if (lipAnimation == null)
- {
- Log.Error(LogTag, "Current Lip Animation is null");
- }
- lipAnimation?.Play();
- }
-
- protected void OnLipAnimationFinished(object sender, EventArgs e)
- {
- }
-
- private void PlayLipSync(byte[] audio)
- {
- if (audio == null)
- {
- Tizen.Log.Error(LogTag, "audi data is null");
- return;
- }
- DestroyLipAnimation();
-
- var lipKeyframes = CreateKeyFrame(audio, CurrentAudioOptions.SampleRate);
- if (lipKeyframes != null)
- {
- var lipAnimation = CreatedKeyFrameAnimation?.Invoke(lipKeyframes, false);
-
- if (lipAnimation != null)
- {
- ResetLipAnimation(lipAnimation);
- PlayLipAnimation();
- audioPlayer.Play(audio);
- }
- else
- {
- Tizen.Log.Error(LogTag, "lipAnimation is null");
- }
- }
- else
- {
- Tizen.Log.Error(LogTag, "lipKeyframes is null");
- }
- }
-
- private void PlayLipSync(byte[] audio, int sampleRate)
- {
- DestroyLipAnimation();
- var lipKeyFrames = CreateKeyFrame(audio, sampleRate);
- var lipAnimation = CreatedKeyFrameAnimation?.Invoke(lipKeyFrames, false);
- if (lipAnimation != null)
- {
- ResetLipAnimation(lipAnimation);
- PlayLipAnimation();
- }
- audioPlayer.Play(audio, sampleRate);
- }
-
- private void PlayLipSync(string path)
- {
- var bytes = Utils.ReadAllBytes(path);
- if (bytes != null)
- {
- PlayLipSync(bytes);
- }
- else
- {
- Log.Error(LogTag, "Failed to load audio file");
- }
- }
-
- private void PauseLipSync()
- {
- PauseLipAnimation();
- audioPlayer.Pause();
- }
-
- private void StopLipSync()
- {
- if (lipAnimation != null)
- {
- DestroyLipAnimation();
-
- var lipAnimation = ResetLipAnimation();
- if (lipAnimation != null)
- {
- ResetLipAnimation(lipAnimation);
- PlayLipAnimation();
- }
- else
- {
- Log.Error(LogTag, "Current Lip Animation is null");
- }
- }
- else
- {
- Log.Error(LogTag, "Current Lip Animation is null");
- }
- audioPlayer.Stop();
- }
-
- private void PauseLipAnimation()
- {
- if (lipAnimation != null)
- {
- lipAnimation?.Pause();
- }
- else
- {
- Log.Error(LogTag, "Current Lip Animation is null");
- }
- }
-
- private void DestroyLipAnimation()
- {
- if (lipAnimation != null)
- {
- lipAnimation.Stop();
- lipAnimation.Dispose();
- lipAnimation = null;
- }
- }
-
- private void EnqueueVowels(byte[] buffer, bool deleteLast = false)
- {
- var vowels = PredictVowels(buffer);
- if (vowels != null)
- {
- vowelPools.Enqueue(vowels);
- if (deleteLast)
- {
- var vowelList = new List(vowels);
- vowelList.RemoveAt(vowelList.Count - 1);
- vowels = vowelList.ToArray();
- }
- }
- }
-
- private Animation CreateLipAnimationByVowelsQueue(int sampleRate = 0)
- {
- if (sampleRate == 0)
- {
- sampleRate = CurrentAudioOptions.SampleRate;
- }
- if (vowelPools.Count > 0)
- {
- AttachPreviousVowel(vowelPools.Dequeue(), out var newVowels);
- Log.Info(LogTag, $"vowelRecognition: {String.Join(", ", newVowels)}");
-
- var lipKeyFrames = vowelConverter?.CreateKeyFrames(newVowels, sampleRate, true);
- var lipAnimation = CreatedKeyFrameAnimation?.Invoke(lipKeyFrames, true);
-
- return lipAnimation;
- }
- return null;
- }
-
- private Animation ResetLipAnimation()
- {
- vowelPools.Clear();
- var newVowels = new string[1];
- newVowels[0] = prevVowel = "sil";
- vowelPools.Enqueue(newVowels);
- return CreateLipAnimationByVowelsQueue();
- }
-
- private string[] PredictVowels(byte[] audioData)
- {
- string[] vowels = vowelConverter?.PredictVowels(audioData);
- return vowels;
- }
-
- private void AttachPreviousVowel(in string[] vowels, out string[] newVowels)
- {
- newVowels = new string[vowels.Length + 1];
- newVowels[0] = prevVowel;
- Array.Copy(vowels, 0, newVowels, 1, vowels.Length);
- prevVowel = vowels[vowels.Length - 1];
- }
-
- private AnimationKeyFrame CreateKeyFrame(byte[] audio, int sampleRate)
- {
- var keyFrames = vowelConverter?.CreateKeyFrames(audio, sampleRate);
- if (keyFrames == null)
- {
- Log.Error(LogTag, $"Failed to initialize KeyFrames");
- }
-
- return keyFrames;
- }
-
-
- internal void OnRecordBufferChanged(byte[] recordBuffer, int sampleRate)
- {
- EnqueueVowels(recordBuffer);
- }
-
- internal void OnRecodingTick()
- {
- var lipAnimation = CreateLipAnimationByVowelsQueue();
- if (lipAnimation != null)
- {
- ResetLipAnimation(lipAnimation);
- PlayLipAnimation();
- }
- else
- {
- Log.Error(LogTag, "Current Lip Animation is null");
- }
- }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Vowel2Animation/AnimationConverter.cs b/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Vowel2Animation/AnimationConverter.cs
deleted file mode 100644
index 2e2c6a4c06b..00000000000
--- a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Vowel2Animation/AnimationConverter.cs
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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 Newtonsoft.Json;
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-
-namespace Tizen.AIAvatar
-{
- internal enum Viseme
- {
- sil, AE, Ah, B_M_P, Ch_J, EE, Er, IH, Oh, W_OO, S_Z, F_V, TH,
- T_L_D_N, K_G_H_NG, R
- };
-
- internal class AnimationConverter
- {
- private Dictionary VowelToViseme
- = new Dictionary {
- { "A", "Ah" },
- { "E", "AE" },
- { "I", "EE" },
- { "O", "R" },
- { "ER", "R" },
- { "U", "W_OO" },
- { "HM", "B_M_P" },
- { "sil", "sil" }
- };
-
- private AnimationKeyFrame _animationKeyFrame;
- private BlendShapeInfo _visemBlendShapeInfo;
- private Dictionary _visemeMap;
-
- private bool _isInitialized;
-
- public AnimationConverter() { }
-
- public void InitializeVisemeInfo(string info_path)
- {
- try
- {
- StreamReader v = new StreamReader(info_path);
- var jsonString = v.ReadToEnd();
-
- _visemBlendShapeInfo = JsonConvert.DeserializeObject(jsonString);
- _visemeMap = _visemBlendShapeInfo.GetVisemeMap();
-
- var nodeNames = _visemBlendShapeInfo.GetNodeNames();
- var blendShapeCounts = _visemBlendShapeInfo.GetBlendShapeCounts();
- var blendShapeKeyFormat = _visemBlendShapeInfo.blendShape.keyFormat;
-
- _animationKeyFrame = new AnimationKeyFrame(nodeNames,
- blendShapeCounts,
- blendShapeKeyFormat);
- _isInitialized = true;
- v.Dispose();
- }
- catch (Exception)
- {
- throw new FailedPersonalizeException(info_path);
- }
- }
-
- public AnimationKeyFrame ConvertVowelsToAnimation(string[] vowels,
- float stepDuration)
- {
- if (!_isInitialized) throw new NotInitializedException();
-
- _animationKeyFrame.ClearAnimation();
- ConvertVowelsToVisemes(vowels, out var visemes);
- ConvertVisemesToAnimationKeyFrame(visemes, stepDuration);
-
- return _animationKeyFrame;
- }
-
- public AnimationKeyFrame ConvertVowelsToAnimationMic(string[] vowels,
- float stepDuration)
- {
- if (!_isInitialized) throw new NotInitializedException();
-
- _animationKeyFrame.ClearAnimation();
- ConvertVowelsToVisemes(vowels, out var visemes);
- ConvertVisemesToAnimationKeyFrameMic(visemes, stepDuration);
-
- return _animationKeyFrame;
- }
-
- private void ConvertVowelsToVisemes(in string[] vowels,
- out string[] visemes)
- {
- visemes = new string[vowels.Length];
-
- for (var i = 0; i < vowels.Length; i++)
- {
- if (!VowelToViseme.TryGetValue(vowels[i], out visemes[i]))
- {
- throw new InvalidVowelTypeException(vowels[i]);
- }
- }
- }
-
- private void ConvertVisemesToAnimationKeyFrame(in string[] visemes,
- float stepDuration)
- {
- float animationTime = visemes.Length * stepDuration;
- _animationKeyFrame.SetAnimationTime(animationTime);
-
- for (int i = 0; i < visemes.Length; i++)
- {
- float timeStamp = GetTimeStamp(i, stepDuration) / animationTime;
-
- foreach (var info in _visemeMap[visemes[i]])
- {
- _animationKeyFrame.AddKeyFrame(info.nodeName,
- info.blendIndex,
- timeStamp,
- info.blendValue);
- }
- }
- }
-
- private void ConvertVisemesToAnimationKeyFrameMic(in string[] visemes,
- float stepDuration)
- {
- float animationTime = (visemes.Length - 1) * stepDuration;
- _animationKeyFrame.SetAnimationTime(animationTime);
-
- for (int i = 0; i < visemes.Length; i++)
- {
- float timeStamp = GetTimeStamp(i, stepDuration) / animationTime;
-
- foreach (var info in _visemeMap[visemes[i]])
- {
- _animationKeyFrame.AddKeyFrame(info.nodeName,
- info.blendIndex,
- timeStamp,
- info.blendValue);
- }
- }
- }
-
- private float GetTimeStamp(int idx, float stepDuration)
- {
- if (idx > 0)
- return (idx * stepDuration) - (stepDuration / 2.0f);
- else
- return 0;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Vowel2Animation/DTO/AnimationKeyFrame.cs b/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Vowel2Animation/DTO/AnimationKeyFrame.cs
deleted file mode 100644
index 04f2a6ea832..00000000000
--- a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Vowel2Animation/DTO/AnimationKeyFrame.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.Collections.Generic;
-
-namespace Tizen.AIAvatar
-{
- internal class KeyFrame
- {
- public KeyFrame(float t, float v)
- {
- time = t;
- value = v;
- }
- public float time;
- public float value;
- }
-
- internal class AnimationKeyFrame
- {
- private Dictionary[]> _animationKeyFrames;
-
- public string[] NodeNames { get; private set; }
- public int[] BlendShapeCounts { get; private set; }
- public string BlendShapeKeyFormat { get; private set; }
- public float AnimationTime { get; private set; }
-
- public AnimationKeyFrame(string[] nodeNames,
- int[] blendShapeCounts,
- string blendShapeKeyFormat)
- {
- _animationKeyFrames = new Dictionary[]>();
- NodeNames = nodeNames;
- BlendShapeCounts = blendShapeCounts;
- BlendShapeKeyFormat = blendShapeKeyFormat;
-
- InitializeAnimation(nodeNames, blendShapeCounts);
- }
-
- public void SetAnimationTime(float animationTime)
- {
- AnimationTime = animationTime;
- }
-
- public List GetKeyFrames(string nodeName, int blendIndex)
- {
- return _animationKeyFrames[nodeName][blendIndex];
- }
-
- public void AddKeyFrame(string nodeName, int blendIndex, float time, float value)
- {
- _animationKeyFrames[nodeName][blendIndex].Add(new KeyFrame(time, value));
- }
-
- public void AddKeyFrame(string nodeName, int blendIndex, KeyFrame value)
- {
- _animationKeyFrames[nodeName][blendIndex].Add(value);
- }
-
- public void InitializeAnimation(string[] nodeNames, int[] blendShapeCounts)
- {
- ClearAnimation();
-
- for (int i = 0; i < nodeNames.Length; i++)
- {
- var nodeName = nodeNames[i];
- var blendShapeCount = blendShapeCounts[i];
-
- _animationKeyFrames.Add(nodeName, new List[blendShapeCount]);
-
- for (int j = 0; j < blendShapeCount; j++)
- {
- _animationKeyFrames[nodeName][j] = new List();
- }
- }
- }
-
- public void ClearAnimation()
- {
- foreach (KeyValuePair[]> kvp in _animationKeyFrames)
- {
- foreach (List kf in kvp.Value)
- {
- kf.Clear();
- }
- }
- }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Vowel2Animation/DTO/BlendShapeInfo.cs b/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Vowel2Animation/DTO/BlendShapeInfo.cs
deleted file mode 100644
index 8fb8163b146..00000000000
--- a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Vowel2Animation/DTO/BlendShapeInfo.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.Collections.Generic;
-
-namespace Tizen.AIAvatar
-{
- internal class BlendShapeInfo
- {
- public BlendShapeModelInfo blendShape;
- public BlendShapeVisemeInfo[] visemes;
-
- public BlendShapeInfo() { }
-
- public string[] GetNodeNames()
- {
- return blendShape.nodeNames;
- }
-
- public int[] GetBlendShapeCounts()
- {
- return blendShape.blendShapeCount;
- }
-
- public Dictionary GetVisemeMap()
- {
- Dictionary visemeMap
- = new Dictionary();
-
- foreach (var visemeInfo in this.visemes)
- {
- visemeMap.Add(visemeInfo.name, visemeInfo.values);
- }
-
- return visemeMap;
- }
- }
-
- internal class BlendShapeModelInfo
- {
- public string keyFormat;
- public string[] nodeNames;
- public int[] blendShapeCount;
-
- public BlendShapeModelInfo(string keyFormat, string[] nodeNames, int[] blendShapeCount)
- {
- this.keyFormat = keyFormat;
- this.nodeNames = nodeNames;
- this.blendShapeCount = blendShapeCount;
- }
- }
-
- internal class BlendShapeVisemeInfo
- {
- public string name;
- public BlendShapeValue[] values;
- }
-
- internal class BlendShapeValue
- {
- public string nodeName;
- public int blendIndex;
- public float blendValue;
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Vowel2Animation/Exception.cs b/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Vowel2Animation/Exception.cs
deleted file mode 100644
index da7b089053b..00000000000
--- a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/Vowel2Animation/Exception.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.AIAvatar
-{
- internal class InvalidVowelTypeException : Exception
- {
- public InvalidVowelTypeException() { }
-
- public InvalidVowelTypeException(string name)
- : base($"Not supported vowel type, {name}") { }
- }
-
- internal class FailedPersonalizeException : Exception
- {
- public FailedPersonalizeException() { }
-
- public FailedPersonalizeException(string name)
- : base($"Failed to personalize, file_path : {name}") { }
- }
-
- internal class NotInitializedException : Exception
- {
- public NotInitializedException()
- : base($"Animation Converter should be initialized with viseme_info") { }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/VowelConverter.cs b/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/VowelConverter.cs
deleted file mode 100644
index 0b65da25465..00000000000
--- a/src/Tizen.AIAvatar/src/Lipsync/VowelConverter/VowelConverter.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.Collections.Generic;
-
-using static Tizen.AIAvatar.AIAvatar;
-
-namespace Tizen.AIAvatar
-{
- internal class VowelConverter
- {
- private TFVowel6 vowelClassfierModel = null;
- private VowelClassifier vowelClassifier = null;
- private Dictionary vowelClassifiers;
- private AnimationConverter animationConverter = new AnimationConverter();
-
- internal VowelConverter()
- {
- vowelClassifiers = new Dictionary();
- vowelClassifier = GetVowelClassifier(CurrentAudioOptions.SampleRate);
- vowelClassfierModel = new TFVowel6(new int[4] { 12, 1, 1, 1 }, new int[4] { 7, 1, 1, 1 });
- animationConverter.InitializeVisemeInfo(VisemeInfo);
- }
-
- internal AnimationKeyFrame CreateKeyFrames(string[] vowels, int sampleRate, bool isMic = false)
- {
- vowelClassifier = GetVowelClassifier(sampleRate);
-
- if (isMic)
- {
- return animationConverter.ConvertVowelsToAnimationMic(vowels, vowelClassifier.GetStepTime());
- }
- else
- {
- return animationConverter.ConvertVowelsToAnimation(vowels, vowelClassifier.GetStepTime());
- }
- }
-
- internal AnimationKeyFrame CreateKeyFrames(byte[] audioData, int sampleRate, bool isMic = false)
- {
- vowelClassifier = GetVowelClassifier(sampleRate);
-
- if (vowelClassifier == null)
- {
- Log.Error(LogTag, "Failed to play Buffer");
- return null;
- }
- var vowels = PredictVowels(audioData);
- Log.Info(LogTag, $"vowelRecognition: {string.Join(", ", vowels)}");
-
- if (isMic) return animationConverter.ConvertVowelsToAnimationMic(vowels, vowelClassifier.GetStepTime());
- else return animationConverter.ConvertVowelsToAnimation(vowels, vowelClassifier.GetStepTime());
- }
-
- internal string[] PredictVowels(byte[] audioData)
- {
- var vowels = vowelClassifier.Inference(audioData, vowelClassfierModel);
- return vowels;
- }
-
- internal VowelClassifier GetVowelClassifier(int sampleRate)
- {
- if (vowelClassifiers.ContainsKey(sampleRate))
- {
- return vowelClassifiers[sampleRate];
- }
- else
- {
- vowelClassifiers[sampleRate] = new VowelClassifier(sampleRate);
- return vowelClassifiers[sampleRate];
- }
- }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Multimedia/Audio/AudioPlayer.cs b/src/Tizen.AIAvatar/src/Multimedia/Audio/AudioPlayer.cs
index bd04ec08502..8b13be57562 100644
--- a/src/Tizen.AIAvatar/src/Multimedia/Audio/AudioPlayer.cs
+++ b/src/Tizen.AIAvatar/src/Multimedia/Audio/AudioPlayer.cs
@@ -15,124 +15,460 @@
*
*/
-using Tizen.Multimedia;
-using System.IO;
+
using System;
+using System.IO;
+using System.Collections.Generic;
+using Tizen.NUI;
+using Tizen.Multimedia;
using static Tizen.AIAvatar.AIAvatar;
+using System.ComponentModel;
namespace Tizen.AIAvatar
{
- internal class AudioPlayer : IDisposable
+ ///
+ /// Represents an audio player capable of streaming and playing audio with support for audio ducking.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class AudioPlayer : IDisposable
{
- private AudioPlayback audioPlayback;
+
+ private int accLength = 0;
+ private int streamIndex = 0;
+
+ private bool isStreaming = false;
+
private MemoryStream audioStream;
+ private MemoryStream baseAudioStream;
+ private List streamList;
+
+ private AudioDucking audioDucking;
+ private AudioPlayback audioPlayback;
+ private AudioStreamPolicy audioStreamPolicy;
- internal AudioPlayer()
+ private Timer bufferChecker;
+
+ private AudioPlayerState currentAudioPlayerState = AudioPlayerState.Unavailable;
+ internal event EventHandler AudioPlayerStateChanged;
+
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Optional audio options for playback configuration.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public AudioPlayer(AudioOptions audioOptions = null)
{
+
+ if (audioOptions == null)
+ CurrentAudioOptions = DefaultAudioOptions;
+ else
+ CurrentAudioOptions = audioOptions;
+
+
+ baseAudioStream = new MemoryStream();
+ streamList = new List();
+
+ audioStreamPolicy = new AudioStreamPolicy(CurrentAudioOptions.StreamType);
+ InitAudio(CurrentAudioOptions.SampleRate);
+
+ bufferChecker = new Timer(100);
+ bufferChecker.Tick += OnBufferChecker;
+
+ audioDucking = new AudioDucking(CurrentAudioOptions.DuckingTargetStreamType);
+ audioDucking.DuckingStateChanged += (sender, arg) =>
+ {
+ if (arg.IsDucked)
+ {
+ CurrentAudioPlayerState = AudioPlayerState.Playing;
+ }
+ };
+
+ AudioPlayerStateChanged += OnStateChanged;
+ }
+
+ ///
+ /// Adds a new audio buffer to the stream list.
+ ///
+ /// The audio buffer to add.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void AddStream(byte[] buffer)
+ {
+ streamList.Add(new MemoryStream(buffer));
}
- internal void PlayAsync(byte[] buffer, int sampleRate = 0)
+ ///
+ /// Determines if the audio player is prepared with a valid stream.
+ ///
+ /// True if a valid stream is available; otherwise, false.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool IsPrepare()
{
- if (audioPlayback == null)
+ return streamList.Count > 0;
+ }
+
+ ///
+ /// Prepare the audio from the stream asynchronously.
+ ///
+ /// Optional sample rate for the audio playback.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void PrepareStreamAudio(int sampleRate = 0)
+ {
+ InitializeStream();
+
+ if (audioPlayback == null || audioPlayback.SampleRate != sampleRate)
{
- Play(buffer, sampleRate);
+ InitAudio(sampleRate);
}
- else
+
+
+ try
+ {
+ audioDucking.Activate(AIAvatar.CurrentAudioOptions.DuckingDuration, AIAvatar.CurrentAudioOptions.DuckingRatio);
+ }
+ catch (Exception e)
{
- audioPlayback.Write(buffer);
+ Log.Error(LogTag, $"Failed to PlayAsync AudioPlayback. {e.Message}");
+ CurrentAudioPlayerState = AudioPlayerState.Playing;
}
}
- internal void Play(byte[] audioBytes, int sampleRate = 0)
+ ///
+ /// Plays the provided audio buffer.
+ ///
+ /// The audio buffer to play.
+ /// Optional sample rate for the audio playback.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Play(byte[] audioBytes, int sampleRate = 0)
{
+ isStreaming = false;
+
if (audioBytes == null)
{
+ Log.Error(LogTag, $"Play AudioPlayBack null.");
return;
}
+ if (audioPlayback.SampleRate != sampleRate)
+ {
+ InitAudio(sampleRate);
+ }
+
+ InitializeStream();
+ streamList.Add(new MemoryStream(audioBytes));
+
try
{
+ audioDucking.Activate(CurrentAudioOptions.DuckingDuration, CurrentAudioOptions.DuckingRatio);
+ }
+ catch (Exception e)
+ {
+ Log.Error(LogTag, $"Failed to Play AudioPlayback. {e.Message}");
+ CurrentAudioPlayerState = AudioPlayerState.Playing;
+ }
+ }
+
+ ///
+ /// Pauses the current audio playback.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Pause()
+ {
+ CurrentAudioPlayerState = AudioPlayerState.Paused;
+
+ }
+
+ ///
+ /// Stops the current audio playback.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Stop()
+ {
+ CurrentAudioPlayerState = AudioPlayerState.Stopped;
+ }
+
+ ///
+ /// Destroys the audio player and clears all resources.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Destroy()
+ {
+ DestroyAudioPlayback();
+ streamList.Clear();
+ streamList = null;
+ }
+
+ ///
+ /// Releases all resources used by the AudioPlayer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ ///
+ /// Releases all resources used by the AudioPlayer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (bufferChecker != null)
+ {
+ bufferChecker.Stop();
+ bufferChecker.Dispose();
+ bufferChecker = null;
+ }
+
+ if (audioDucking != null)
+ {
+ audioDucking.DuckingStateChanged -= (sender, arg) =>
+ {
+ if (arg.IsDucked)
+ {
+ CurrentAudioPlayerState = AudioPlayerState.Playing;
+ }
+ };
+ audioDucking.Dispose();
+ audioDucking = null;
+ }
+
if (audioPlayback != null)
{
- Destroy();
+ Stop();
+ audioPlayback.BufferAvailable -= OnBufferAvailable;
+ audioPlayback.Dispose();
+ audioPlayback = null;
}
- if (sampleRate == 0)
+
+ if (audioStreamPolicy != null)
{
- sampleRate = CurrentAudioOptions.SampleRate;
+ audioStreamPolicy.Dispose();
+ audioStreamPolicy = null;
+ }
+
+ if (baseAudioStream != null)
+ {
+ baseAudioStream.Dispose();
+ baseAudioStream = null;
+ }
+
+ if (streamList != null)
+ {
+ foreach (var stream in streamList)
+ {
+ stream.Dispose();
+ }
+ streamList.Clear();
+ streamList = null;
}
- audioPlayback = new AudioPlayback(sampleRate, CurrentAudioOptions.Channel, CurrentAudioOptions.SampleType);
}
- catch (Exception e)
+ }
+
+ ///
+ /// Gets or sets the current state of the audio player.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public AudioPlayerState CurrentAudioPlayerState
+ {
+ get => currentAudioPlayerState;
+ protected set
{
- Log.Error(LogTag, $"Failed to create AudioPlayback. {e.Message}");
+ if (currentAudioPlayerState == value) return;
+
+ var preState = currentAudioPlayerState;
+ currentAudioPlayerState = value;
+
+ AudioPlayerStateChanged?.Invoke(this, new AudioPlayerChangedEventArgs(preState, currentAudioPlayerState));
}
+ }
- if (audioPlayback != null)
+
+ private bool OnBufferChecker(object source, Timer.TickEventArgs e)
+ {
+ if (isStreaming && streamList.Count == 0)
+ {
+ return true;
+ }
+
+ if (audioStream != null && audioStream.Position == audioStream.Length)
{
- audioPlayback.Prepare();
- audioPlayback.BufferAvailable += (sender, args) =>
+ if (streamIndex >= streamList.Count)
{
- if (audioStream.Position == audioStream.Length)
+ CurrentAudioPlayerState = AudioPlayerState.Finished;
+ Log.Debug(LogTag, $"Complete Play Audio Buffer.");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private void OnStateChanged(object sender, AudioPlayerChangedEventArgs state)
+ {
+
+ switch (state.Current)
+ {
+ case AudioPlayerState.Playing:
+ try
{
- return;
+ bufferChecker?.Start();
+ audioPlayback?.Prepare();
+ Log.Debug(LogTag, "Audio is playing.");
}
+ catch (NullReferenceException e)
+ {
+ Log.Error(LogTag, $"NullReferenceException in Playing state: {e.Message}");
+ }
+ catch (Exception e)
+ {
+ Log.Info(LogTag, $"PlayinnState: {e.Message}");
+ }
+
+ break;
+ case AudioPlayerState.Paused:
try
{
- var buffer = new byte[args.Length];
- audioStream.Read(buffer, 0, args.Length);
- audioPlayback.Write(buffer);
+ bufferChecker?.Stop();
+ audioPlayback?.Pause();
+ audioPlayback?.Unprepare();
+
+ if (audioDucking.IsDucked)
+ audioDucking?.Deactivate();
+
+ Log.Debug(LogTag, "Audio is paused.");
+ }
+ catch (NullReferenceException e)
+ {
+ Log.Error(LogTag, $"NullReferenceException in Paused state: {e.Message}");
}
catch (Exception e)
{
- Log.Error(LogTag, $"Failed to write. {e.Message}");
+ Log.Info(LogTag, $"PlayinnState: {e.Message}");
}
- };
+ break;
- audioStream = new MemoryStream(audioBytes);
+ case AudioPlayerState.Stopped:
+ case AudioPlayerState.Finished:
+
+ try
+ {
+ bufferChecker?.Stop();
+ audioPlayback?.Pause();
+ audioPlayback?.Unprepare();
+
+ if (audioDucking.IsDucked)
+ audioDucking?.Deactivate();
+
+ streamIndex = 0;
+ audioStream = baseAudioStream;
+
+ Log.Debug(LogTag, "Audio is stopped.");
+ }
+ catch (NullReferenceException e)
+ {
+ Log.Error(LogTag, $"NullReferenceException in Stopped/Finished state: {e.Message}");
+ }
+ catch (Exception e)
+ {
+ Log.Info(LogTag, $"PlayinnState: {e.Message}");
+ }
+
+ break;
}
+
}
- internal void Pause()
+ private void OnBufferAvailable(object sender, AudioPlaybackBufferAvailableEventArgs args)
{
- if (audioPlayback != null)
+ if (audioStream.Position == audioStream.Length)
{
- audioPlayback.Pause();
+
+ if (streamIndex < streamList.Count)
+ {
+ audioStream = streamList[streamIndex];
+ accLength = (int)audioStream.Length;
+
+ streamIndex++;
+ }
+ else
+ {
+ return;
+ }
}
- else
+
+ try
+ {
+ if (args.Length > 1024)
+ {
+ accLength -= args.Length;
+ int length = args.Length;
+ if (accLength < 0)
+ {
+ length += accLength;
+ }
+
+ var buffer = new byte[length];
+ audioStream.Read(buffer, 0, length);
+ audioPlayback.Write(buffer);
+ }
+ }
+ catch (Exception e)
{
- Log.Error(LogTag, $"audioPlayBack is null");
+ Log.Error(LogTag, $"Failed to write. {e.Message}");
}
}
- internal void Stop()
+ private void InitializeStream()
+ {
+ isStreaming = true;
+ streamIndex = 0;
+ streamList.Clear();
+ }
+
+ private void InitAudio(int sampleRate)
{
if (audioPlayback != null)
{
- audioPlayback.Pause();
- Destroy();
+ DestroyAudioPlayback();
}
- else
+ if (sampleRate == 0)
{
- Log.Error(LogTag, $"audioPlayBack is null");
+ sampleRate = CurrentAudioOptions.SampleRate;
}
- }
- public void Dispose()
- {
- Destroy();
+ try
+ {
+ audioPlayback = new AudioPlayback(sampleRate, CurrentAudioOptions.Channel, CurrentAudioOptions.SampleType);
+ audioPlayback.ApplyStreamPolicy(audioStreamPolicy);
+ audioPlayback.BufferAvailable += OnBufferAvailable;
+
+ audioStream = baseAudioStream;
+ }
+ catch (Exception e)
+ {
+ Log.Error(LogTag, $"Failed to create AudioPlayback. {e.Message}");
+ }
- audioStream?.Flush();
- audioStream?.Dispose();
- audioStream = null;
}
- private void Destroy()
+ private void DestroyAudioPlayback()
{
- audioPlayback?.Unprepare();
- audioPlayback?.Dispose();
+ if (audioPlayback != null)
+ {
+ Stop();
+ audioPlayback.BufferAvailable -= OnBufferAvailable;
+ audioPlayback.Dispose();
+ }
+
audioPlayback = null;
}
+
+
}
}
diff --git a/src/Tizen.AIAvatar/src/Multimedia/Audio/AudioRecorder.cs b/src/Tizen.AIAvatar/src/Multimedia/Audio/AudioRecorder.cs
deleted file mode 100644
index 406ce6d09de..00000000000
--- a/src/Tizen.AIAvatar/src/Multimedia/Audio/AudioRecorder.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright(c) 2023 Samsung Electronics Co., Ltd.
- *
- * 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.Linq;
-using Tizen.Multimedia;
-using Tizen.NUI;
-using static Tizen.AIAvatar.AIAvatar;
-
-namespace Tizen.AIAvatar
-{
- internal class AudioRecorder : IDisposable
- {
- private const string privilegeForRecording = "http://tizen.org/privilege/recorder";
-
- private AsyncAudioCapture asyncAudioCapture;
-
- private byte[] recordedBuffer;
- private float desiredBufferDuration = 0.16f;
- private int desiredBufferLength;
-
- private Timer audioRecordingTimer;
-
- private Action audioRecdingAction;
- private Action bufferAction;
-
- private static AudioRecorder instance;
-
- internal static AudioRecorder Instance
- {
- get
- {
- if (instance == null)
- {
- instance = new AudioRecorder();
- }
- return instance;
- }
- }
-
- internal event EventHandler BufferChanged;
-
- internal AudioRecorder()
- {
- Utils.CheckPrivilege(privilegeForRecording);
- desiredBufferLength = (int)(CurrentAudioOptions.SampleRate * desiredBufferDuration * 2);
- }
-
- internal void InitializeMic(LipSyncer lipSyncer, uint recordingTime = 160)
- {
- audioRecordingTimer = new Timer(recordingTime);
- if (lipSyncer != null)
- {
- Tizen.Log.Error(LogTag, "LipSyncer of animator is null");
- return;
- }
- this.audioRecdingAction = lipSyncer.OnRecodingTick;
- this.bufferAction = lipSyncer.OnRecordBufferChanged;
-
- BufferChanged += OnRecordBufferChanged;
- audioRecordingTimer.Tick += AudioRecordingTimerTick;
- }
-
-
- internal void DeinitializeMic()
- {
- StopRecording();
- BufferChanged -= OnRecordBufferChanged;
-
- if (audioRecordingTimer != null)
- {
- audioRecordingTimer.Stop();
- audioRecordingTimer.Tick -= AudioRecordingTimerTick;
-
- audioRecordingTimer.Dispose();
- audioRecordingTimer = null;
- }
- audioRecdingAction = null;
- }
-
- internal void StartRecording()
- {
- audioRecordingTimer?.Start();
- asyncAudioCapture = new AsyncAudioCapture(CurrentAudioOptions.SampleRate, CurrentAudioOptions.Channel, CurrentAudioOptions.SampleType);
-
- recordedBuffer = new byte[0];
- asyncAudioCapture.DataAvailable += (s, e) =>
- {
- recordedBuffer = recordedBuffer.Concat(e.Data).ToArray();
- if (recordedBuffer.Length >= desiredBufferLength)
- {
- var recordedBuffer = this.recordedBuffer;
- this.recordedBuffer = Array.Empty();
-
- BufferChanged?.Invoke(this, new RecordBufferChangedEventArgs(recordedBuffer, CurrentAudioOptions.SampleRate));
- }
- };
- asyncAudioCapture.Prepare();
- Log.Info(LogTag, "Start Recording - Preapre AsyncAudioCapture");
- }
-
- internal void StopRecording()
- {
- audioRecordingTimer?.Stop();
- asyncAudioCapture.Dispose();
- }
-
- internal void PauseRecording()
- {
- asyncAudioCapture.Pause();
- }
-
- internal void ResumeRecording()
- {
- asyncAudioCapture.Resume();
- }
-
- private void OnRecordBufferChanged(object sender, RecordBufferChangedEventArgs e)
- {
- bufferAction?.Invoke(e.RecordedBuffer, CurrentAudioOptions.SampleRate);
- }
-
- private bool AudioRecordingTimerTick(object source, Timer.TickEventArgs e)
- {
- Log.Info(LogTag, "TickTimer");
- audioRecdingAction?.Invoke();
- return true;
- }
-
- public void Dispose()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Multimedia/Audio/Core/AudioOptions.cs b/src/Tizen.AIAvatar/src/Multimedia/Audio/Core/AudioOptions.cs
new file mode 100644
index 00000000000..63b792db137
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/Multimedia/Audio/Core/AudioOptions.cs
@@ -0,0 +1,123 @@
+/*
+ * Copyright(c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * 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.ComponentModel;
+using Tizen.Multimedia;
+
+namespace Tizen.AIAvatar
+{
+ ///
+ /// Provides the ability to audio
+ ///
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class AudioOptions
+ {
+ private int sampleRate;
+ private AudioChannel channel;
+ private AudioSampleType sampleType;
+ private AudioStreamType streamType;
+
+ private double duckingRatio;
+ private uint duckingDuration;
+ private AudioStreamType duckingTargetStreamType;
+
+
+ ///
+ /// Initializes a new instance of the AudioOptions class with the specified sample rate, channel, sampleType and streamType.
+ ///
+ /// the audio sample rate (8000 ~ 192000Hz)
+ /// the audio channel type.
+ /// the audio sample type.
+ /// the audio Stream type.
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public AudioOptions(int sampleRate, AudioChannel channel, AudioSampleType sampleType, AudioStreamType streamType)
+ {
+ this.sampleRate = sampleRate;
+ this.channel = channel;
+ this.sampleType = sampleType;
+ this.streamType = streamType;
+
+ DuckingOptions(AudioStreamType.Media, 500, 0.2);
+ }
+
+ ///
+ /// Initialize the DuckingOption values of the AudioOptions class using the specified target StreamType, Duration, and Ratio.
+ ///
+ /// the audio Ducking target Stream type.
+ /// the ducking duration.
+ /// the ducking target volume ratio.
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DuckingOptions(AudioStreamType duckingTargetStreamType, uint duckingDuration, double duckingRatio)
+ {
+ this.duckingTargetStreamType = duckingTargetStreamType;
+ this.duckingDuration = duckingDuration;
+ this.duckingRatio = duckingRatio;
+ }
+
+ ///
+ /// The audio sample rate (8000 ~ 192000Hz)
+ ///
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int SampleRate { get => sampleRate; set => sampleRate = value; }
+
+ ///
+ /// The audio channel type
+ ///
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public AudioChannel Channel { get => channel; set => channel = value; }
+
+ ///
+ /// The audio sample type
+ ///
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public AudioSampleType SampleType { get => sampleType; set => sampleType = value; }
+
+ ///
+ /// The audio stream type
+ ///
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public AudioStreamType StreamType { get => streamType; set => streamType = value; }
+
+ ///
+ /// The audio ducking duration.
+ ///
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public uint DuckingDuration { get => duckingDuration; set => duckingDuration = value; }
+
+ ///
+ /// The audio ducking ratio.
+ ///
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public double DuckingRatio { get => duckingRatio; set => duckingRatio = value; }
+
+ ///
+ /// The audio ducking target stream type.
+ ///
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public AudioStreamType DuckingTargetStreamType { get => duckingTargetStreamType; }
+ }
+}
diff --git a/src/Tizen.AIAvatar/src/Multimedia/Audio/Core/AudioPlayerChangedEventArgs.cs b/src/Tizen.AIAvatar/src/Multimedia/Audio/Core/AudioPlayerChangedEventArgs.cs
new file mode 100644
index 00000000000..145f6cf1a73
--- /dev/null
+++ b/src/Tizen.AIAvatar/src/Multimedia/Audio/Core/AudioPlayerChangedEventArgs.cs
@@ -0,0 +1,63 @@
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * 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.ComponentModel;
+
+namespace Tizen.AIAvatar
+{
+ ///
+ /// This class provides arguments for handling Audio State change events.
+ /// The previous state of the audio.
+ /// The current state of the audio.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class AudioPlayerChangedEventArgs : EventArgs
+ {
+ ///
+ /// Initializes a new instance of the AudioChangedEventArgs class with the specified previous and current states.
+ ///
+ /// The previous state of the audio.
+ /// The current state of the audio.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public AudioPlayerChangedEventArgs(AudioPlayerState previous, AudioPlayerState current)
+ {
+ Previous = previous;
+ Current = current;
+ }
+
+ ///
+ /// The previous state.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public AudioPlayerState Previous
+ {
+ get;
+ internal set;
+ }
+
+ ///
+ /// The current state.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public AudioPlayerState Current
+ {
+ get;
+ internal set;
+ }
+ }
+}
diff --git a/src/Tizen.AIAvatar/src/Animations/AvatarMotionState.cs b/src/Tizen.AIAvatar/src/Multimedia/Audio/Core/AudioPlayerState.cs
similarity index 88%
rename from src/Tizen.AIAvatar/src/Animations/AvatarMotionState.cs
rename to src/Tizen.AIAvatar/src/Multimedia/Audio/Core/AudioPlayerState.cs
index aa62b0d4940..b4e37f779e1 100644
--- a/src/Tizen.AIAvatar/src/Animations/AvatarMotionState.cs
+++ b/src/Tizen.AIAvatar/src/Multimedia/Audio/Core/AudioPlayerState.cs
@@ -23,10 +23,10 @@ namespace Tizen.AIAvatar
/// Enumeration for the states.
///
[EditorBrowsable(EditorBrowsableState.Never)]
- public enum AvatarMotionState
+ public enum AudioPlayerState
{
///
- /// Created state.
+ /// Fail state.
///
[EditorBrowsable(EditorBrowsableState.Never)]
Failed = -1,
@@ -55,6 +55,12 @@ public enum AvatarMotionState
[EditorBrowsable(EditorBrowsableState.Never)]
Stopped = 5,
+ ///
+ /// Finished state.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Finished = 6,
+
///
/// Unavailable state.
///
diff --git a/src/Tizen.AIAvatar/src/Multimedia/TTS/TTSController.cs b/src/Tizen.AIAvatar/src/Multimedia/TTS/TTSController.cs
deleted file mode 100644
index f6cea3c405f..00000000000
--- a/src/Tizen.AIAvatar/src/Multimedia/TTS/TTSController.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.Collections.Generic;
-using System.Linq;
-using Tizen.Uix.Tts;
-
-using static Tizen.AIAvatar.AIAvatar;
-
-namespace Tizen.AIAvatar
-{
- internal class TTSControllerEventArgs : EventArgs
- {
- public TTSControllerEventArgs()
- {
- }
-
- public TTSControllerEventArgs(byte[] audioData, int sampleRate)
- {
- //AudioData = audioData;
- AudioData = new byte[audioData.Length];
- Buffer.BlockCopy(audioData, 0, AudioData, 0, audioData.Length);
- SampleRate = sampleRate;
- }
-
- public byte[] AudioData
- {
- get;
- internal set;
- }
-
- public int SampleRate
- {
- get;
- internal set;
- }
- }
-
- internal class TTSController : IDisposable
- {
- private List textList;
- private TtsClient ttsHandle;
- private VoiceInfo voiceInfo;
- private List byteList;
-
- private byte[] recordedBuffer;
- private byte[] audioTailBuffer;
-
- private int sampleRate;
- private float desiredBufferDuration = 0.175f;
- private float audioTailLengthFactor = 0.015f;
- private float audioBufferMultiflier = 2f;
-
- private int desiredBufferLength;
- private int audioTailLength;
-
- private bool isPrepared = false;
- private bool isAsync = false;
-
- private Action bufferChangedAction;
-
- private int audioLength;
- private bool isAsyncLipStarting;
-
- internal event EventHandler PlayReadyCallback;
-
- internal event EventHandler PreparedSyncText;
- internal event EventHandler StoppedTTS;
-
-
- internal event EventHandler UpdatedBuffer;
-
- internal TTSController()
- {
- InitTts();
- }
-
- ~TTSController()
- {
- DeinitTts();
- }
-
- internal TtsClient TtsHandle
- {
- get { return ttsHandle; }
- }
-
- internal VoiceInfo VoiceInfo
- {
- get { return voiceInfo; }
- set
- {
- voiceInfo = value;
- }
- }
-
- internal List GetSupportedVoices()
- {
- var voiceInfoList = new List();
-
- if (ttsHandle == null)
- {
- Log.Error(LogTag, $"ttsHandle is null");
- return voiceInfoList;
- }
-
- var supportedVoices = ttsHandle.GetSupportedVoices();
- foreach (var supportedVoice in supportedVoices)
- {
- Log.Info(LogTag, $"{supportedVoice.Language} & {supportedVoice.VoiceType} is supported");
- voiceInfoList.Add(new VoiceInfo() { Language = supportedVoice.Language, Type = (VoiceType)supportedVoice.VoiceType });
- }
- return voiceInfoList;
- }
-
- internal bool IsSupportedVoice(string lang)
- {
- if (ttsHandle == null)
- {
- Log.Error(LogTag, $"ttsHandle is null");
- return false;
- }
- var supportedVoices = ttsHandle.GetSupportedVoices();
-
- foreach (var supportedVoice in supportedVoices)
- {
- if (supportedVoice.Language.Equals(lang))
- {
- Log.Info(LogTag, $"{lang} is supported");
- return true;
- }
- }
- return false;
- }
-
- internal bool IsSupportedVoice(VoiceInfo voiceInfo)
- {
- if (ttsHandle == null)
- {
- Log.Error(LogTag, $"ttsHandle is null");
- return false;
- }
- var supportedVoices = ttsHandle.GetSupportedVoices();
- foreach (var supportedVoice in supportedVoices)
- {
- if (supportedVoice.Language.Equals(voiceInfo.Language) && ((VoiceType)supportedVoice.VoiceType == voiceInfo.Type))
- {
- Log.Info(LogTag, $"{voiceInfo.Language} & {voiceInfo.Type} is supported");
- return true;
- }
- }
- return false;
- }
-
-
- internal void AddText(string txt, VoiceInfo voiceInfo)
- {
- if (voiceInfo.Language == null)
- {
- Log.Error(LogTag, "VoiceInfo's value is null");
- }
- if (ttsHandle == null)
- {
- Log.Error(LogTag, $"ttsHandle is null");
- return;
- }
- var temp = new UtteranceText();
- temp.Text = txt;
- temp.UttID = ttsHandle.AddText(txt, voiceInfo.Language, (int)voiceInfo.Type, 0);
- try
- {
- textList.Add(temp);
- }
- catch (Exception e)
- {
- Log.Error(LogTag, $"Error AddText" + e.Message);
- }
- }
-
- internal void AddText(string txt, string lang)
- {
- if (ttsHandle == null)
- {
- Log.Error(LogTag, $"ttsHandle is null");
- return;
- }
- var temp = new UtteranceText();
- temp.Text = txt;
- temp.UttID = ttsHandle.AddText(txt, lang, (int)voiceInfo.Type, 0);
- try
- {
- textList.Add(temp);
- }
- catch (Exception e)
- {
- Log.Error(LogTag, $"Error AddText" + e.Message);
- }
- }
-
- internal void Prepare(EventHandler playReadyCallback)
- {
- if (ttsHandle == null)
- {
- Log.Error(LogTag, $"ttsHandle is null");
- return;
- }
- Log.Info(LogTag, "Prepare TTS");
- isPrepared = true;
- isAsync = false;
- PlayReadyCallback = playReadyCallback;
- Play(true);
- }
-
-
- internal bool PlayPreparedText()
- {
- if (byteList != null && byteList.Count != 0)
- {
- Log.Info(LogTag, "PlayPreparedText TTS");
-
- PreparedSyncText?.Invoke(this, new TTSControllerEventArgs(byteList.ToArray(), sampleRate));
- return true;
- }
- return false;
- }
-
- internal void Play(bool isPrepared = false)
- {
- if (ttsHandle == null)
- {
- Log.Error(LogTag, $"ttsHandle is null");
- return;
- }
-
- this.isPrepared = isPrepared;
- isAsync = false;
- ttsHandle.Play();
- }
-
- internal void PlayAsync(EventHandler playReadyCallback)
- {
- if (ttsHandle == null)
- {
- Log.Error(LogTag, $"ttsHandle is null");
- return;
- }
-
- isPrepared = false;
- isAsync = true;
- PlayReadyCallback = playReadyCallback;
- ttsHandle.Play();
- }
-
- public void Pause()
- {
- if (ttsHandle == null)
- {
- Log.Error(LogTag, $"ttsHandle is null");
- return;
- }
- ttsHandle.Pause();
- }
-
- internal void Stop()
- {
- if (ttsHandle == null)
- {
- Log.Error(LogTag, $"ttsHandle is null");
- return;
- }
- ttsHandle.Stop();
- StoppedTTS?.Invoke(this, new TTSControllerEventArgs());
- }
-
- internal void DeinitTts()
- {
- try
- {
- if (ttsHandle != null)
- {
- ttsHandle.Unprepare();
-
- // Unregister Callbacks
- ttsHandle.DefaultVoiceChanged -= TtsDefaultVoiceChangedCallback;
- ttsHandle.EngineChanged -= TtsEngineChangedCallback;
- ttsHandle.ErrorOccurred -= TtsErrorOccuredCallback;
- ttsHandle.StateChanged -= TtsStateChangedCallback;
- ttsHandle.UtteranceCompleted -= TtsUtteranceCompletedCallback;
- ttsHandle.UtteranceStarted -= TtsUtteranceStartedCallback;
-
- ttsHandle.Dispose();
- ttsHandle = null;
- }
-
- if (textList != null)
- {
- textList.Clear();
- textList = null;
- }
-
- if (byteList != null)
- {
- byteList.Clear();
- byteList = null;
- }
- }
- catch (Exception e)
- {
- Log.Error(LogTag, "[ERROR] Fail to unprepare Tts");
- Log.Error(LogTag, e.Message);
- }
- }
-
- private void InitTts()
- {
- try
- {
- ttsHandle = new TtsClient();
-
- // Register Callbacks
- ttsHandle.DefaultVoiceChanged += TtsDefaultVoiceChangedCallback;
- ttsHandle.EngineChanged += TtsEngineChangedCallback;
- ttsHandle.ErrorOccurred += TtsErrorOccuredCallback;
- ttsHandle.StateChanged += TtsStateChangedCallback;
- ttsHandle.UtteranceCompleted += TtsUtteranceCompletedCallback;
- ttsHandle.UtteranceStarted += TtsUtteranceStartedCallback;
-
- ttsHandle.SynthesizedPcm += TtsSyntheiszedPCM;
- ttsHandle.PlayingMode = PlayingMode.ByClient;
-
- ttsHandle.Prepare();
-
- voiceInfo = new VoiceInfo
- {
- Language = ttsHandle.DefaultVoice.Language,
- Type = (VoiceType)ttsHandle.DefaultVoice.VoiceType
- };
-
- textList = new List();
- Log.Info(LogTag, voiceInfo.Language + ", " + voiceInfo.Type.ToString());
-
- }
- catch (Exception e)
- {
- Log.Error(LogTag, "[ERROR] Fail to prepare Tts");
- Log.Error(LogTag, e.Message);
- }
- }
-
- private void TtsSyntheiszedPCM(object sender, SynthesizedPcmEventArgs e)
- {
- var dataSize = e.Data.Length;
- var audio = new byte[dataSize];
- sampleRate = e.SampleRate;
-
- //Marshal.Copy(e.Data, audio, 0, dataSize);
- switch (e.EventType) //START
- {
- case SynthesizedPcmEvent.Start://start
- Tizen.Log.Info(LogTag, "------------------Start : " + e.UtteranceId);
- Tizen.Log.Info(LogTag, "Output audio Size : " + dataSize);
- Tizen.Log.Info(LogTag, "SampleRate" + e.SampleRate);
- if (byteList == null)
- {
- byteList = new List();
- }
- if (recordedBuffer == null)
- {
- recordedBuffer = new byte[0];
- }
- byteList.Clear();
-
- if (isAsync)
- {
- recordedBuffer = Array.Empty();
-
- desiredBufferLength = (int)(e.SampleRate * desiredBufferDuration * audioBufferMultiflier);
- audioTailLength = (int)(sampleRate * audioTailLengthFactor * audioBufferMultiflier);
- audioTailBuffer = new byte[audioTailLength];
- PlayReadyCallback?.Invoke(null, EventArgs.Empty);
- //InitAsyncBuffer();
- }
- break;
- case SynthesizedPcmEvent.Continue://continue
- if (isAsync)
- {
- recordedBuffer = recordedBuffer.Concat(e.Data).ToArray();
- //PlayAsync
- if (recordedBuffer.Length >= desiredBufferLength)
- {
- Tizen.Log.Error(LogTag, "Current recordbuffer length :" + recordedBuffer.Length);
- //UpdateBuffer(recordedBuffer, sampleRate);
-
- Buffer.BlockCopy(recordedBuffer, recordedBuffer.Length - audioTailLength, audioTailBuffer, 0, audioTailLength);
-
- recordedBuffer = Array.Empty();
- recordedBuffer = recordedBuffer.Concat(audioTailBuffer).ToArray();
- Array.Clear(audioTailBuffer, 0, audioTailLength);
- }
- }
- else
- {
- byteList.AddRange(e.Data);
- }
- break;
- case SynthesizedPcmEvent.Finish://finish
- Tizen.Log.Info(LogTag, "------------------Finish : " + e.UtteranceId);
- if (!isAsync)
- {
- if (!isPrepared)
- {
- //Play voice immediately
- PlayPreparedText();
- }
- else
- {
- //Notify finished state
- Log.Info(LogTag, "Notify finished state");
- PlayReadyCallback?.Invoke(null, EventArgs.Empty);
- }
- }
- else
- {//async
- //FinishedSynthesizedPcm?.Invoke(null, EventArgs.Empty);
- //lipSyncer.SetFinishAsyncLip(true);
- }
- break;
- case SynthesizedPcmEvent.Fail: //fail
- break;
-
- }
- }
-
- private void TtsUtteranceStartedCallback(object sender, UtteranceEventArgs e)
- {
- Log.Debug(LogTag, "Utterance start now (" + e.UtteranceId + ")");
- }
-
- private void TtsUtteranceCompletedCallback(object sender, UtteranceEventArgs e)
- {
- Log.Debug(LogTag, "Utterance complete (" + e.UtteranceId + ")");
-
- foreach (UtteranceText item in textList)
- {
- if (item.UttID == e.UtteranceId)
- {
- textList.Remove(item);
- Log.Debug(LogTag, "TextList Count (" + textList.Count.ToString() + ")");
- break;
- }
- }
- }
-
- private void TtsStateChangedCallback(object sender, StateChangedEventArgs e)
- {
- Log.Debug(LogTag, "Current state is changed from (" + e.Previous + ") to (" + e.Current + ")");
- }
-
- private void TtsErrorOccuredCallback(object sender, ErrorOccurredEventArgs e)
- {
- Log.Error(LogTag, "Error is occured (" + e.ErrorMessage + ")");
- }
-
- private void TtsEngineChangedCallback(object sender, EngineChangedEventArgs e)
- {
- Log.Debug(LogTag, "Prefered engine is changed (" + e.EngineId + ") (" + e.VoiceType.Language + ")");
- }
-
- private void TtsDefaultVoiceChangedCallback(object sender, DefaultVoiceChangedEventArgs e)
- {
- Log.Debug(LogTag, "Default voice is changed from (" + e.Previous + ") to (" + e.Current + ")");
- }
-
- private void InitAsyncBuffer()
- {
- /*
- InitedAsyncBuffer?.Invoke(null, EventArgs.Empty);
- if (!lipSyncer.IsAsyncInit)
- {
- audioLength = (int)(sampleRate * 0.16f * 2f);
-
- lipSyncer.InitAsyncLipsync();
- lipSyncer.IsAsyncInit = true;
-
- lipSyncer.SetFinishAsyncLip(false);
- isAsyncLipStarting = false;
- }*/
- }
-
- private void UpdateBuffer(byte[] recordBuffer, int sampleRate)
- {
- UpdatedBuffer?.Invoke(this, new TTSControllerEventArgs(recordBuffer, sampleRate));
- /*
- if (lipSyncer != null)
- {
- Log.Error(LogTag, "OnTTSBufferChanged");
- lipSyncer.EnqueueAnimation(recordBuffer, sampleRate, audioLength);
- if (!isAsyncLipStarting)
- {
- lipSyncer.StartAsyncLipPlayTimer();
- isAsyncLipStarting = true;
- }
- }
- else
- {
- Log.Error(LogTag, "avatarLipSyncer is null");
- }*/
- }
-
- public void Dispose()
- {
- ttsHandle.Stop();
- ttsHandle.Dispose();
- ttsHandle = null;
- }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Multimedia/TTS/UtteranceText.cs b/src/Tizen.AIAvatar/src/Multimedia/TTS/UtteranceText.cs
deleted file mode 100644
index 2e69e1f97d6..00000000000
--- a/src/Tizen.AIAvatar/src/Multimedia/TTS/UtteranceText.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.AIAvatar
-{
- internal struct UtteranceText : IEquatable
- {
- private string text;
- private int uttID;
-
- public string Text { get => text; set => text = value; }
- public int UttID { get => uttID; set => uttID = value; }
-
- public override bool Equals(object obj) => obj is VoiceInfo other && this.Equals(other);
-
- public bool Equals(UtteranceText other) => Text == other.Text && UttID == other.UttID;
-
- public static bool operator ==(UtteranceText lhsUtternaceText, UtteranceText rhsUtternaceText) => lhsUtternaceText.Equals(rhsUtternaceText);
-
- public static bool operator !=(UtteranceText lhsUtternaceText, UtteranceText rhsVoiceInfo) => !lhsUtternaceText.Equals(rhsVoiceInfo);
-
- public override int GetHashCode() => (Text, UttID).GetHashCode();
- }
-}
diff --git a/src/Tizen.AIAvatar/src/RestClient/IRestClient.cs b/src/Tizen.AIAvatar/src/RestClient/IRestClient.cs
deleted file mode 100644
index 9a593b135b6..00000000000
--- a/src/Tizen.AIAvatar/src/RestClient/IRestClient.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.Net.Http;
-using System.Threading.Tasks;
-
-namespace Tizen.AIAvatar
-{
-
- internal interface IRestClient
- {
- Task SendRequestAsync(HttpMethod method, string endpoint, string bearerToken = null, string jsonData = null);
- }
-}
diff --git a/src/Tizen.AIAvatar/src/RestClient/RestClient.cs b/src/Tizen.AIAvatar/src/RestClient/RestClient.cs
deleted file mode 100644
index 0ee81ebb73b..00000000000
--- a/src/Tizen.AIAvatar/src/RestClient/RestClient.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.Net.Http.Headers;
-using System.Net.Http;
-using System.Text;
-using System.Threading.Tasks;
-using System.ComponentModel;
-
-namespace Tizen.AIAvatar
-{
- internal class RestClient : IRestClient, IDisposable
- {
- private readonly HttpClient client;
-
- internal RestClient(HttpClient httpClient)
- {
- client = httpClient;
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public async Task SendRequestAsync(HttpMethod method, string endpoint, string bearerToken = null, string jsonData = null)
- {
- AddBearerToken(bearerToken);
-
- HttpRequestMessage request = new HttpRequestMessage(method, endpoint);
-
- if (jsonData != null)
- {
- request.Content = new StringContent(jsonData, Encoding.UTF8, "application/json");
- }
-
- HttpResponseMessage response = await client.SendAsync(request);
- request?.Dispose();
- return await HandleResponse(response);
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void Dispose()
- {
- client.Dispose();
- }
-
- private void AddBearerToken(string bearerToken)
- {
- if (!string.IsNullOrEmpty(bearerToken))
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken);
- }
- }
-
- private async Task HandleResponse(HttpResponseMessage response)
- {
- if (response.IsSuccessStatusCode)
- {
- return await response.Content.ReadAsStringAsync();
- }
- else
- {
- throw new HttpRequestException($"HTTP request failed with status code {response.StatusCode}");
- }
- }
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Tracking/TrackingOptions.cs b/src/Tizen.AIAvatar/src/Tracking/TrackingOptions.cs
deleted file mode 100644
index a908e718b73..00000000000
--- a/src/Tizen.AIAvatar/src/Tracking/TrackingOptions.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
- *
- * 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.
- *
- */
-
-namespace Tizen.AIAvatar
-{
- internal class TrackingOptions
- {
- }
-}
diff --git a/src/Tizen.AIAvatar/src/Tracking/TrackingController.cs b/src/Tizen.AIAvatar/src/Utility/AIAvatar.cs
similarity index 65%
rename from src/Tizen.AIAvatar/src/Tracking/TrackingController.cs
rename to src/Tizen.AIAvatar/src/Utility/AIAvatar.cs
index 4ca0fbf9b03..79079cad032 100644
--- a/src/Tizen.AIAvatar/src/Tracking/TrackingController.cs
+++ b/src/Tizen.AIAvatar/src/Utility/AIAvatar.cs
@@ -15,26 +15,15 @@
*
*/
+using Tizen.Multimedia;
+
namespace Tizen.AIAvatar
{
- internal class TrackingController
+ internal static class AIAvatar
{
- internal TrackingController()
- {
- }
-
- internal void Initialize(TrackingOptions options)
- {
- }
-
- internal void StartMotionTracking()
- {
-
- }
-
- internal void StopMotionTracking()
- {
+ internal const string LogTag = "Tizen.AIAvatar";
- }
+ internal static AudioOptions DefaultAudioOptions = new AudioOptions(24000, AudioChannel.Mono, AudioSampleType.S16Le, AudioStreamType.System);
+ internal static AudioOptions CurrentAudioOptions = DefaultAudioOptions;
}
}
diff --git a/src/Tizen.AIAvatar/test/Test.cs b/src/Tizen.AIAvatar/test/Test.cs
index e8f0e11a86d..5d9c2cc9984 100644
--- a/src/Tizen.AIAvatar/test/Test.cs
+++ b/src/Tizen.AIAvatar/test/Test.cs
@@ -21,19 +21,7 @@ internal class Test
{
public void CreateTest()
{
- var avatar1 = new Avatar();
-
- var avatarInfo = new AvatarInfo("avatarName", "resourcePath");
- var avatar2 = new Avatar(avatarInfo);
-
- var avatar3 = new Avatar("resourcePath");
-
- var avatar4 = new Avatar(avatar1);
-
- avatar1.Dispose();
- avatar2.Dispose();
- avatar3.Dispose();
- avatar4.Dispose();
+
}
}
}
diff --git a/src/Tizen.Applications.Alarm/Interop/Interop.Alarm.cs b/src/Tizen.Applications.Alarm/Interop/Interop.Alarm.cs
index 85f7fb66c12..a7adbf724f6 100755
--- a/src/Tizen.Applications.Alarm/Interop/Interop.Alarm.cs
+++ b/src/Tizen.Applications.Alarm/Interop/Interop.Alarm.cs
@@ -54,6 +54,15 @@ internal struct DateTime
[DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_with_recurrence_week_flag")]
internal static extern int CreateAlarmRecurWeek(SafeAppControlHandle appControl, ref DateTime date, int week, out int alarmId);
+ [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_service_with_recurrence_seconds")]
+ internal static extern int CreateAlarmRecurForService(SafeAppControlHandle appControl, ref DateTime date, int period, out int alarmId);
+
+ [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_service_once_after_delay")]
+ internal static extern int CreateAlarmOnceAfterDelayForService(SafeAppControlHandle appControl, int delay, out int alarmId);
+
+ [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_service_once_at_date")]
+ internal static extern int CreateAlarmOnceAtDateForService(SafeAppControlHandle appControl, ref DateTime date, out int alarmId);
+
[DllImport(Libraries.Alarm, EntryPoint = "alarm_get_scheduled_recurrence_week_flag")]
internal static extern int GetAlarmWeekFlag(int alarmId, out int weekFlag);
diff --git a/src/Tizen.Applications.Alarm/Tizen.Applications/Alarm.cs b/src/Tizen.Applications.Alarm/Tizen.Applications/Alarm.cs
index 5110a58e63b..a5e5428ca5d 100755
--- a/src/Tizen.Applications.Alarm/Tizen.Applications/Alarm.cs
+++ b/src/Tizen.Applications.Alarm/Tizen.Applications/Alarm.cs
@@ -61,14 +61,17 @@ public int AlarmId
/// http://tizen.org/privilege/alarm.get
///
/// The setter for WeekFlag property is available since API Level 6.
- /// Weekflag can be a combination of the days of the week, for example Tuesday | Friday.
- /// If the period is already set, it will be removed and the week repetition flag will be set.
- /// If the week repetition flag is already set, it will be overwritten. If not, it will be set.
+ /// Weekflag can represent a combination of days of the week, such as Tuesday | Friday.
+ /// If the period is already set, it will be removed and the week repetition flag will be set instead.
+ /// If the week repetition flag is already set, it will be overwritten. Otherwise, it will be set.
/// If the Weekflag argument is 0 and the flag is already set,
- /// the flag will be cleared and the alarm will be changed to set once.
- /// If the Weekflag argument is 0, and the flag is not set or the period is set,
- /// the alarm won't be changed.
+ /// the flag will be cleared and the alarm will be changed to a single occurrence.
+ /// If the Weekflag argument is 0 and no flag is set or if the period is set,
+ /// the alarm will remain unchanged.
///
+ /// Thrown in case of an invalid parmaeter.
+ /// Thrown in case of a permission denied due to insufficient privileges.
+ /// Thrown in case of any internal error.
/// 3
public AlarmWeekFlag WeekFlag
{
@@ -103,6 +106,9 @@ public AlarmWeekFlag WeekFlag
///
/// The SchduleDate property setter is available since API Level 6.
///
+ /// Thrown in case of an invalid parmaeter.
+ /// Thrown in case of a permission denied due to insufficient privileges.
+ /// Thrown in case of any internal error.
/// 3
public DateTime ScheduledDate
{
@@ -141,19 +147,22 @@ public DateTime ScheduledDate
}
///
- /// Gets the period of time between the recurrent alarms.
+ /// Gets or sets the period of time between the recurrent alarms.
///
/// http://tizen.org/privilege/alarm.set
/// http://tizen.org/privilege/alarm.get
///
/// The Period property setter is available since API Level 6.
/// If the week recurrence flag was set before, it will be removed and the period will be set
- /// If the period was set before, it will be overwritten.If it was not, it will be set.
+ /// If the period was set before, it will be overwritten. If it was not, it will be set.
/// If the @a period argument is 0 and the period was previously set,
/// the period attribute will be cleared and the alarm will be changed to one-time.
/// If the @a period argument is 0 and the period was not set,
- /// or the week recurrence flag was set, the alarm will be unchanged.
+ /// or the week recurrence flag was set, the alarm will remain unchanged.
///
+ /// Thrown in case of an invalid parmaeter.
+ /// Thrown in case of a permission denied due to insufficient privileges.
+ /// Thrown in case of any internal error.
/// 3
public int Period
{
diff --git a/src/Tizen.Applications.Alarm/Tizen.Applications/AlarmManager.cs b/src/Tizen.Applications.Alarm/Tizen.Applications/AlarmManager.cs
index 0aaf4279051..007949e2f98 100755
--- a/src/Tizen.Applications.Alarm/Tizen.Applications/AlarmManager.cs
+++ b/src/Tizen.Applications.Alarm/Tizen.Applications/AlarmManager.cs
@@ -18,6 +18,7 @@ namespace Tizen.Applications
{
using System;
using System.Collections.Generic;
+ using System.ComponentModel;
using System.Runtime.InteropServices;
using Tizen.Applications.Notifications;
@@ -102,7 +103,7 @@ public enum AlarmStandardPeriod
}
///
- /// Mobile devices typically give constant access to information from various sources. Some of this information is best delivered through alarms.
+ /// Devices typically give constant access to information from various sources. Some of this information is best delivered through alarms.
/// The most obvious case is a calendar scheduling application, which lets you know when a meeting is about to start. Alarms are certainly better than actively waiting in a loop.
/// They are also better than putting an interface to sleep because they do not block your main UI thread.
/// Use of alarms helps build smooth user experiences and implements unattended data synchronization tasks.
@@ -149,7 +150,7 @@ internal static DateTime ConvertIntPtrToDateTime(Interop.Alarm.DateTime time)
/// Sets an alarm to be triggered after a specific time.
/// The alarm will first go off delay seconds later and then will go off every certain amount of time defined using period seconds.
///
- /// The amount of time before the first execution (in seconds).
+ /// The amount of time before the first execution (in seconds). Although this is inexact, the alarm will not fire before this time
/// The amount of time between subsequent alarms (in seconds). This value does not guarantee the accuracy.
/// The actual interval is calculated by the OS. The minimum value is 600sec.
/// The destination AppControl is used to perform a specific task when the alarm is triggered.
@@ -185,6 +186,7 @@ public static Alarm CreateAlarm(int delay, int period, AppControl appControl)
/// The amount of time before the execution (in seconds).
/// The destination AppControl to perform a specific task when the alarm is triggered.
/// An alarm instance is created with the set param values.
+ /// This operation is permitted with the UI application appcontrol only.
/// Thrown in case of an invalid parameter.
/// Thrown in case of a permission denied.
/// Thrown in case of any internal error.
@@ -330,7 +332,7 @@ public static Alarm CreateAlarm(DateTime dateTime, Notification notification)
/// Sets a notification alarm to be triggered after a specific time.
/// The alarm will first go off delay seconds later and then will go off every certain amount of time defined using period seconds.
///
- /// The amount of time before the first execution (in seconds).
+ /// The amount of time before the first execution (in seconds). Although this is inexact, the alarm will not fire before this time
/// The amount of time between subsequent alarms (in seconds). This value does not guarantee the accuracy.
/// The notification to be posted when the alarm is triggered.
/// An alarm instance is created with the set param values.
@@ -438,6 +440,119 @@ public static Alarm CreateAlarm(int delay, AlarmStandardPeriod standardPeriod, N
return CreateAlarm(delay, (int)standardPeriod, notification);
}
+ ///
+ /// Sets an alarm to be triggered after a specific time.
+ /// The alarm will go off delay seconds later.
+ ///
+ /// The amount of time before the execution (in seconds).
+ /// The destination AppControl to perform a specific task when the alarm is triggered.
+ /// An alarm instance is created with the set param values.
+ ///
+ /// This operation only allows service application which has Background Category to set an exact alarm.
+ ///
+ /// Thrown in case of an invalid parameter.
+ /// Thrown in case of a permission denied.
+ /// Thrown in case of any internal error.
+ /// http://tizen.org/privilege/alarm.set
+ /// http://tizen.org/privilege/appmanager.launch
+ /// 12
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Alarm CreateAlarmForServiceApp(int delay, AppControl appControl)
+ {
+ if (appControl == null)
+ {
+ throw AlarmErrorFactory.GetException(AlarmError.InvalidParameter, "AppControl should be not null");
+ }
+
+ Alarm alarm = null;
+ int alarmId;
+ AlarmError ret = (AlarmError)Interop.Alarm.CreateAlarmOnceAfterDelayForService(appControl.SafeAppControlHandle, delay, out alarmId);
+ alarm = new Alarm(alarmId);
+ if (ret != AlarmError.None)
+ {
+ throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+ }
+
+ return alarm;
+ }
+
+ ///
+ /// Sets an alarm to be triggered at a specific time.
+ /// The date describes the time of the first occurrence.
+ ///
+ /// The first active alarm time.
+ /// The destination AppControl to perform specific work when the alarm is triggered.
+ /// An alarm instance is created with the set param values.
+ ///
+ /// This operation only allows service application which has Background Category to set an exact alarm.
+ ///
+ /// Thrown in case of an invalid parameter.
+ /// Thrown in case of a permission denied.
+ /// Thrown in case of any internal error.
+ /// http://tizen.org/privilege/alarm.set
+ /// http://tizen.org/privilege/appmanager.launch
+ /// 12
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Alarm CreateAlarmForServiceApp(DateTime value, AppControl appControl)
+ {
+ if (appControl == null)
+ {
+ throw AlarmErrorFactory.GetException(AlarmError.InvalidParameter, "AppControl should be not null");
+ }
+
+ Alarm alarm = null;
+ int alarmId;
+ Interop.Alarm.DateTime time = ConvertDateTimeToStruct(value);
+ AlarmError ret = (AlarmError)Interop.Alarm.CreateAlarmOnceAtDateForService(appControl.SafeAppControlHandle, ref time, out alarmId);
+ alarm = new Alarm(alarmId);
+ if (ret != AlarmError.None)
+ {
+ throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+ }
+
+ return alarm;
+ }
+
+ ///
+ /// Sets an alarm to be triggered at a specific time.
+ /// The alarm will first go off at a specific time and then will go off every certain amount of time defined using period seconds.
+ ///
+ /// The first active alarm time.
+ /// The amount of time between subsequent alarms (in seconds).
+ /// The destination AppControl is used to perform a specific task when the alarm is triggered.
+ /// An alarm instance is created with the set param values.
+ ///
+ /// This operation only allows service application which has Background Category to set an exact alarm.
+ /// This API can have a significant impact on power usage when the device is in idle state, so apps that use it may greatly increase battery consumption.
+ /// Therefore, caution should be taken when using this API.
+ ///
+ /// Thrown in case of an invalid parameter.
+ /// Thrown in case of a permission denied.
+ /// Thrown in case of any internal error.
+ /// http://tizen.org/privilege/alarm.set
+ /// http://tizen.org/privilege/appmanager.launch
+ /// 12
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Alarm CreateAlarmForServiceApp(DateTime value, int period, AppControl appControl)
+ {
+ if (appControl == null)
+ {
+ throw AlarmErrorFactory.GetException(AlarmError.InvalidParameter, "AppControl should be not null");
+ }
+
+ Alarm alarm = null;
+ int alarmId;
+ Interop.Alarm.DateTime time = ConvertDateTimeToStruct(value);
+ AlarmError ret = (AlarmError)Interop.Alarm.CreateAlarmRecurForService(appControl.SafeAppControlHandle, ref time, period, out alarmId);
+ alarm = new Alarm(alarmId);
+ if (ret != AlarmError.None)
+ {
+ throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+ }
+
+ return alarm;
+ }
+
///
/// Cancels all scheduled alarms that are registered by the application that calls this API.
///
diff --git a/src/Tizen.Applications.Badge/Tizen.Applications/Badge.cs b/src/Tizen.Applications.Badge/Tizen.Applications/Badge.cs
index c7a4f1acabc..6378e4b5ba8 100644
--- a/src/Tizen.Applications.Badge/Tizen.Applications/Badge.cs
+++ b/src/Tizen.Applications.Badge/Tizen.Applications/Badge.cs
@@ -22,6 +22,7 @@ namespace Tizen.Applications
/// The class containing common properties of the Badge.
///
/// 3
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class Badge
{
private int count = 0;
@@ -34,6 +35,7 @@ public class Badge
/// Count value
/// True if it should be displayed
/// Thrown when failed because of invalid argument
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public Badge(string appId, int count = 1, bool visible = true)
{
if (IsNegativeNumber(count))
@@ -50,6 +52,7 @@ public Badge(string appId, int count = 1, bool visible = true)
///
/// 3
/// Thrown when set negative number
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int Count
{
get
@@ -71,12 +74,14 @@ public int Count
/// Property for the application ID of the badge.
///
/// 3
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string AppId { get; set; }
///
/// Property for display visibility. True if the badge display visible, otherwise false..
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public bool Visible{ get; set; }
private bool IsNegativeNumber(int number)
diff --git a/src/Tizen.Applications.Badge/Tizen.Applications/BadgeControl.cs b/src/Tizen.Applications.Badge/Tizen.Applications/BadgeControl.cs
index 093f40f65f8..7a2e4f11f5e 100755
--- a/src/Tizen.Applications.Badge/Tizen.Applications/BadgeControl.cs
+++ b/src/Tizen.Applications.Badge/Tizen.Applications/BadgeControl.cs
@@ -22,6 +22,7 @@ namespace Tizen.Applications
/// The class for badge operation.
///
/// 3
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static class BadgeControl
{
private static event EventHandler s_changed;
@@ -37,6 +38,7 @@ public static class BadgeControl
/// Thrown in case of failed conditions.
/// Thrown when an application does not have the privilege to access.
/// Thrown when Badge is not supported.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static event EventHandler Changed
{
add
@@ -88,6 +90,7 @@ public static event EventHandler Changed
/// Thrown when an application does not have the privilege to access.
/// Thrown in case of failed conditions.
/// Thrown when Badge is not supported.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static Badge Find(string appId)
{
uint count;
@@ -119,6 +122,7 @@ public static Badge Find(string appId)
/// Thrown when an application does not have the privilege to access.
/// Thrown in case of failed conditions.
/// Thrown when Badge is not supported.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static void Remove(string appId)
{
BadgeError err = Interop.Badge.Remove(appId);
@@ -139,6 +143,7 @@ public static void Remove(string appId)
/// Thrown when an application does not have the privilege to access.
/// Thrown in case of failed conditions.
/// Thrown when Badge is not supported.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static void Remove(Badge badge)
{
if (badge == null)
@@ -160,6 +165,7 @@ public static void Remove(Badge badge)
/// Thrown when an application does not have the privilege to access.
/// Thrown in case of failed conditions.
/// Thrown when Badge is not supported.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static void Add(Badge badge)
{
if (badge == null)
@@ -195,6 +201,7 @@ public static void Add(Badge badge)
/// Thrown when an application does not have the privilege to access.
/// Thrown in case of failed conditions.
/// Thrown when Badge is not supported.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static void Update(Badge badge)
{
if (badge == null)
@@ -225,6 +232,7 @@ public static void Update(Badge badge)
/// Thrown when an application does not have the privilege to access.
/// Thrown in case of failed conditions.
/// Thrown when Badge is not supported.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static IEnumerable GetBadges()
{
IList list = new List();
diff --git a/src/Tizen.Applications.Badge/Tizen.Applications/BadgeEventArgs.cs b/src/Tizen.Applications.Badge/Tizen.Applications/BadgeEventArgs.cs
index c0b8d0ff1da..c20c0add80a 100755
--- a/src/Tizen.Applications.Badge/Tizen.Applications/BadgeEventArgs.cs
+++ b/src/Tizen.Applications.Badge/Tizen.Applications/BadgeEventArgs.cs
@@ -22,6 +22,7 @@ namespace Tizen.Applications
/// The class for event arguments of the badge event.
///
/// 3
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class BadgeEventArgs : EventArgs
{
internal BadgeEventArgs()
@@ -32,6 +33,7 @@ internal BadgeEventArgs()
/// Enumeration for the badge action.
///
/// 3
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public enum Action : int
{
///
@@ -54,12 +56,14 @@ public enum Action : int
/// The property for the badge object.
///
/// 3
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public Badge Badge { get; internal set; }
///
/// The property for the action value.
///
/// 3
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public Action Reason { get; internal set; }
}
}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs
index 9923019a73a..ce0aada91db 100755
--- a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs
+++ b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs
@@ -156,10 +156,10 @@ public class Parcel : IDisposable
private ParcelHeader _header;
///
- /// Constructor for this class.
+ /// Constructs a new instance of the Parcel class.
///
- /// If it's false, the parcel object does not have the header.
- /// Thrown when an internal IO error occurs.
+ /// Determines whether the created parcel object includes a header or not.
+ /// Thrown when an internal I/O error occurs during the construction process.
/// 11
public Parcel(bool withHeader)
{
@@ -188,10 +188,10 @@ public Parcel() : this(true)
}
///
- /// Constructor with port object.
+ /// Creates a new parcel object from a specified port object.
///
- /// Port object.
- /// Thrown when an internal IO error occurs.
+ /// The port object to create a parcel from.
+ /// An internal IO error occurred while creating the parcel.
/// 5
public Parcel(Port port)
{
@@ -203,10 +203,10 @@ public Parcel(Port port)
}
///
- /// Constructor with the raw bytes.
+ /// Constructs a new Parcel object from the specified raw bytes.
///
- /// The raw bytes.
- /// Thrown when an internal IO error occurs.
+ /// An array of bytes that represents the content of the parcel.
+ /// Thrown if an invalid argument is passed in or an internal I/O error occurs.
/// 9
public Parcel(byte[] bytes)
{
@@ -218,10 +218,10 @@ public Parcel(byte[] bytes)
}
///
- /// Gets the raw bytes of the parcel.
+ /// Converts the current parcel into its raw bytes representation.
///
- /// The raw bytes of the parcel.
- /// Thrown when an internal IO error occurs.
+ /// An array of bytes containing the contents of the parcel.
+ /// Thrown if an internal I/O error occurs during conversion.
/// 9
public byte[] ToBytes()
{
@@ -234,9 +234,9 @@ public byte[] ToBytes()
}
///
- /// Sends parcel data through the port.
+ /// Sends parcel data through the specified port.
///
- /// The RPC port object for writing data.
+ /// The RPC port object for writing data.
/// Thrown when an internal IO error occurs.
/// 5
public void Send(Port p)
@@ -249,9 +249,9 @@ public void Send(Port p)
}
///
- /// Writes a byte value into parcel object.
+ /// Writes a single byte value into the parcel object.
///
- /// byte data.
+ /// The byte value to be written into the parcel object.
/// 5
public void WriteByte(byte b)
{
@@ -261,7 +261,7 @@ public void WriteByte(byte b)
///
/// Writes a short value into parcel object.
///
- /// short data.
+ /// The short data to write.
/// 5
public void WriteShort(short b)
{
@@ -269,9 +269,23 @@ public void WriteShort(short b)
}
///
- /// Writes an int value into parcel object.
- ///
- /// int data.
+ /// Writes an integer value into the parcel object.
+ ///
+ /// The integer value to write.
+ ///
+ /// Here's an example showing how to write an integer value into a parcel object:
+ ///
+ ///
+ /// // Create a new parcel object
+ /// Parcel parcel = new Parcel();
+ ///
+ /// // Write an integer value into the parcel object
+ /// parcel.WriteInt(42);
+ ///
+ /// // Do something else with the parcel object...
+ /// ...
+ ///
+ ///
/// 5
public void WriteInt(int b)
{
@@ -279,9 +293,9 @@ public void WriteInt(int b)
}
///
- /// Writes a long value into parcel object.
+ /// Writes a long value into the parcel object.
///
- /// long data.
+ /// The long data to write.
/// 5
public void WriteLong(long b)
{
@@ -289,9 +303,9 @@ public void WriteLong(long b)
}
///
- /// Writes a float value into parcel object.
+ /// Writes a float value into the parcel object.
///
- /// float data.
+ /// The float data to write into the parcel object.
/// 5
public void WriteFloat(float b)
{
@@ -299,9 +313,9 @@ public void WriteFloat(float b)
}
///
- /// Writes a double value into parcel object.
+ /// Writes a double value into the parcel object.
///
- /// double data.
+ /// The double data to write.
/// 5
public void WriteDouble(double b)
{
@@ -309,9 +323,9 @@ public void WriteDouble(double b)
}
///
- /// Writes a string value into parcel object.
+ /// Writes a string value into the parcel object.
///
- /// string data.
+ /// The string data to be written into the parcel object.
/// 5
public void WriteString(string b)
{
@@ -319,9 +333,9 @@ public void WriteString(string b)
}
///
- /// Writes a bool value into parcel object.
+ /// Writes a boolean value into the parcel object.
///
- /// bool data.
+ /// The boolean value to write.
/// 5
public void WriteBool(bool b)
{
@@ -329,9 +343,9 @@ public void WriteBool(bool b)
}
///
- /// Writes a Bundle data into parcel object.
+ /// Writes a Bundle data into the parcel object.
///
- /// Bundle data.
+ /// The Bundle object to write.
/// 5
public void WriteBundle(Bundle b)
{
@@ -344,9 +358,9 @@ public void WriteBundle(Bundle b)
}
///
- /// Writes a count of an array into parcel object.
+ /// Writes a count of an array into the parcel object.
///
- /// Array count.
+ /// The number of elements in the array.
/// 5
public void WriteArrayCount(int cnt)
{
@@ -354,9 +368,9 @@ public void WriteArrayCount(int cnt)
}
///
- /// Reads a byte value from parcel object.
+ /// Reads a byte value from the parcel object.
///
- /// byte data.
+ /// The byte value.
/// 5
public byte ReadByte()
{
@@ -365,9 +379,9 @@ public byte ReadByte()
}
///
- /// Reads a short value from parcel object.
+ /// Reads a short value from the parcel object.
///
- /// short data.
+ /// The short data.
/// 5
public short ReadShort()
{
@@ -376,9 +390,9 @@ public short ReadShort()
}
///
- /// Reads an int value from parcel object.
+ /// Reads an integer value from the parcel object.
///
- /// int data.
+ /// The integer data.
/// 5
public int ReadInt()
{
@@ -387,9 +401,9 @@ public int ReadInt()
}
///
- /// Reads a long value from parcel object.
+ /// Reads a long value from the parcel object.
///
- /// long data.
+ /// The long data.
/// 5
public long ReadLong()
{
@@ -398,9 +412,9 @@ public long ReadLong()
}
///
- /// Reads a float value from parcel object.
+ /// Reads a float value from the parcel object.
///
- /// float data.
+ /// The float data.
/// 5
public float ReadFloat()
{
@@ -409,9 +423,9 @@ public float ReadFloat()
}
///
- /// Reads a double value from parcel object.
+ /// Reads a double value from the parcel object.
///
- /// double data.
+ /// The double data.
/// 5
public double ReadDouble()
{
@@ -420,9 +434,9 @@ public double ReadDouble()
}
///
- /// Reads a string value from parcel object.
+ /// Reads a string value from the parcel object.
///
- /// string data.
+ /// The string data.
/// 5
public string ReadString()
{
@@ -431,9 +445,9 @@ public string ReadString()
}
///
- /// Reads a bool value from parcel object.
+ /// Reads a boolean value from the parcel object.
///
- /// bool data.
+ /// The boolean data.
/// 5
public bool ReadBool()
{
@@ -442,9 +456,9 @@ public bool ReadBool()
}
///
- /// Reads a Bundle value from parcel object.
+ /// Reads a Bundle value from the parcel object.
///
- /// Bundle data.
+ /// The Bundle data.
/// 5
public Bundle ReadBundle()
{
@@ -460,9 +474,9 @@ public Bundle ReadBundle()
}
///
- /// Reads a count of an array from parcel object.
+ /// Reads a count of an array from a parcel object.
///
- /// Array count.
+ /// The number of elements in the array.
/// 5
public int ReadArrayCount()
{
@@ -471,9 +485,9 @@ public int ReadArrayCount()
}
///
- /// Writes bytes into parcel object.
+ /// Writes bytes into the parcel object.
///
- /// Array of bytes.
+ /// An array of bytes containing the data to be written.
/// 5
public void Write(byte[] bytes)
{
@@ -486,10 +500,10 @@ public void Write(byte[] bytes)
}
///
- /// Reads bytes from parcel object.
+ /// Reads bytes from the parcel object.
///
- /// Bytes to read.
- /// Array of bytes.
+ /// The number of bytes to read.
+ /// An array of bytes that were read from the parcel.
/// 5
public byte[] Read(int size)
{
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Port.cs b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Port.cs
index f8261902ae5..5518b86fae5 100755
--- a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Port.cs
+++ b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Port.cs
@@ -21,7 +21,7 @@
namespace Tizen.Applications.RPCPort
{
///
- /// The class that proxy and stub can use to communicate with each other.
+ /// A class used by proxies and stubs to communicate with each other.
///
/// 5
public class Port
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/ProxyBase.cs b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/ProxyBase.cs
index 3206c52f240..038dbdd1c3b 100755
--- a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/ProxyBase.cs
+++ b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/ProxyBase.cs
@@ -19,7 +19,7 @@
namespace Tizen.Applications.RPCPort
{
///
- /// Abstract class for creating a proxy class for RPC.
+ /// Base class for creating a proxy class for remote procedure calls.
///
/// 5
public abstract class ProxyBase : IDisposable
@@ -45,9 +45,9 @@ public abstract class ProxyBase : IDisposable
protected Port CallbackPort { get; private set; }
///
- /// Constructor for this class.
+ /// Creates a new instance of the ProxyBase class.
///
- /// Thrown when internal IO error occurs.
+ /// Thrown when an internal I/O error occurs during initialization.
/// 5
public ProxyBase()
{
@@ -64,13 +64,17 @@ public ProxyBase()
}
///
- /// Connects to port.
+ /// Establishes a connection to the specified application through the named remote procedure call (RPC) port.
///
- /// The target stub app ID.
- /// The name of the RPC port.
- /// Thrown when not available app ID is used.
- /// Thrown when an internal IO error occurs.
- /// Thrown when the permission is denied.
+ ///
+ /// By calling this method, you can establish a connection between two applications using the specified RPC port. It requires the target application ID and the name of the desired RPC port.
+ /// If the connection cannot be established due to invalid arguments or insufficient privileges, appropriate exceptions are thrown accordingly.
+ ///
+ /// The ID of the target application to connect to.
+ /// The name of the RPC port to use for the connection.
+ /// Thrown if the specified application ID does not exist.
+ /// Thrown in case of an internal input/output error during the connection process.
+ /// Thrown when the required privileges are missing or access is otherwise restricted.
/// http://tizen.org/privilege/datasharing
/// http://tizen.org/privilege/appmanager.launch
/// 5
@@ -89,13 +93,13 @@ protected void Connect(string appid, string port)
}
///
- /// Connects to port synchronously.
+ /// Establishes a connection to the specified application synchronously through the named remote procedure call (RPC) port.
///
- /// The target stub app ID.
- /// The name of the RPC port.
- /// Thrown when not available app ID is used.
- /// Thrown when an internal IO error occurs.
- /// Thrown when the permission is denied.
+ /// The ID of the target application to connect to.
+ /// The name of the RPC port to use for the connection.
+ /// Thrown if the specified application ID does not exist.
+ /// Thrown in case of an internal input/output error during the connection process.
+ /// Thrown when the required privileges are missing or access is otherwise restricted.
/// http://tizen.org/privilege/datasharing
/// http://tizen.org/privilege/appmanager.launch
/// 8
@@ -114,11 +118,17 @@ protected void ConnectSync(string appid, string port)
}
///
- /// Gets a port.
+ /// Retrieves a port based on its type.
///
- /// The type of port.
- /// Port object.
- /// Thrown when an internal IO error occurs.
+ /// The specific type of port to retrieve.
+ /// An object representing the requested port.
+ /// Thrown if an internal I/O error occurs while retrieving the port.
+ ///
+ /// To get a main port:
+ ///
+ /// Port mainPort = GetPort(Port.Type.Main);
+ ///
+ ///
/// 5
protected Port GetPort(Port.Type t)
{
@@ -137,8 +147,8 @@ protected Port GetPort(Port.Type t)
///
/// Abstract method for receiving connected event.
///
- /// The target stub app ID.
- /// The name of the RPC port.
+ /// The target stub application ID.
+ /// The name of the Remote Procedure Call (RPC) port.
/// Port object for reading and writing.
/// 5
protected abstract void OnConnectedEvent(string endPoint, string portName, Port port);
@@ -146,24 +156,24 @@ protected Port GetPort(Port.Type t)
///
/// Abstract method for receiving disconnected event.
///
- /// The target stub app ID.
- /// The name of the port.
+ /// The target stub application ID..
+ /// The name of the Remote Procedure Call (RPC) port.
/// 5
protected abstract void OnDisconnectedEvent(string endPoint, string portName);
///
/// Abstract method called when the proxy receives data from stub.
///
- /// The target stub app ID.
- /// The name of the RPC port.
+ /// The target stub application ID..
+ /// The name of the Remote Procedure Call (RPC) port.
/// 5
protected abstract void OnReceivedEvent(string endPoint, string portName);
///
/// Abstract method for receiving rejected event.
///
- /// The target stub app ID.
- /// The name of the RPC port.
+ /// The target stub application ID..
+ /// The name of the Remote Procedure Call (RPC) port.
/// 5
protected abstract void OnRejectedEvent(string endPoint, string portName);
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/StubBase.cs b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/StubBase.cs
index 8e9c13a80ca..43272dee33e 100755
--- a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/StubBase.cs
+++ b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/StubBase.cs
@@ -19,8 +19,13 @@
namespace Tizen.Applications.RPCPort
{
///
- /// Abstract class for creating a stub class for RPC.
+ /// Base class for creating stubs in RPC.
///
+ ///
+ /// This class provides a base implementation for creating stubs that are used in Remote Procedure Call (RPC). By extending this class, you can easily implement your own stubs for specific interfaces.
+ /// The StubBase class handles common functionality such as managing the connection state and handling incoming requests from clients. It also provides methods for sending responses back to the client after processing the request.
+ /// To create a stub for a specific interface, you need to extend the StubBase class and override its virtual methods according to the requirements of the interface.
+ ///
/// 5
public abstract class StubBase : IDisposable
{
@@ -36,10 +41,18 @@ public abstract class StubBase : IDisposable
public string PortName { get; }
///
- /// Constructor for this class.
+ /// Constructs a new instance of the StubBase class.
///
/// The name of the port that wants to listen.
/// Thrown when an internal IO error occurs.
+ ///
+ /// Here's an example showing how to construct a new instance of the StubBase class:
+ ///
+ ///
+ /// // Create a new instance of the StubBase class
+ /// var stubBase = new StubBase("MyPort");
+ ///
+ ///
/// 5
public StubBase(string portName)
{
@@ -55,9 +68,13 @@ public StubBase(string portName)
}
///
- /// Listens to the requests for connections.
+ /// Starts listening to incoming connection requests on the specified port.
///
- /// Thrown when an internal IO error occurs.
+ ///
+ /// This method enables your application to listen for incoming connection requests from other applications.
+ /// It is typically called after setting up the necessary network infrastructure such as creating a server socket and specifying a listening port.
+ ///
+ /// Thrown when an internal IO error occurs during the listening process.
/// 5
protected void Listen()
{
@@ -87,9 +104,9 @@ protected void AddPrivilege(string privilege)
}
///
- /// Sets a trusted proxy to the stub.
+ /// Sets whether the stub allows only trusted proxies or not.
///
- /// Whether stub allows only trusted proxy or not.
+ /// Indicates if the stub allows only trusted proxies or not.
/// 5
protected void SetTrusted(bool trusted)
{
@@ -97,13 +114,13 @@ protected void SetTrusted(bool trusted)
}
///
- /// Gets s port.
+ /// Retrieves a port based on its type and the connected instance.
///
- /// The type of port.
- /// The ID of the instance, which is connected.
- /// Port object.
- /// Thrown when invalid instance is used.
- /// Thrown when an internal IO error occurs.
+ /// The type of port to retrieve.
+ /// The ID of the instance that the port is connected to.
+ /// The requested port.
+ /// Thrown if an invalid instance ID is passed.
+ /// Thrown in case of an internal I/O error.
/// 5
protected Port GetPort(Port.Type t, string instance)
{
@@ -123,7 +140,7 @@ protected Port GetPort(Port.Type t, string instance)
///
/// Abstract method for receiving connected event.
///
- /// The target proxy app ID.
+ /// The target proxy applicstion ID.
/// The information about the request.
/// 5
protected abstract void OnConnectedEvent(string sender, string instance);
@@ -131,7 +148,7 @@ protected Port GetPort(Port.Type t, string instance)
///
/// Abstract method for receiving disconnected event.
///
- /// The target proxy app ID.
+ /// The target proxy applicstion ID.
/// The information about the request.
/// 5
protected abstract void OnDisconnectedEvent(string sender, string instance);
@@ -139,7 +156,7 @@ protected Port GetPort(Port.Type t, string instance)
///
/// Abstract method called when the stub receives data from proxy.
///
- /// The target proxy app ID.
+ /// The target proxy applicstion ID.
/// The information about the request.
/// Port object for reading and writing.
/// true to continue receiving data, otherwise false to disconnect from the port.
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs
index 6f341d899f8..043fa7edf2c 100755
--- a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs
+++ b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs
@@ -102,7 +102,7 @@ public AppControl(bool enableAppStartedResultEvent)
///
/// Initializes the instance of the AppControl class with the SafeAppControlHandle.
///
- ///
+ /// A reference to the SafeAppControlHandle object.
/// 3
public AppControl(SafeAppControlHandle handle)
{
@@ -169,6 +169,9 @@ private AppControl(IntPtr handle)
///
/// Gets the SafeAppControlHandle instance.
///
+ ///
+ /// This property returns a reference to the underlying SafeAppControlHandle object.
+ ///
/// 3
public SafeAppControlHandle SafeAppControlHandle
{
@@ -227,7 +230,8 @@ public string Operation
/// Gets and sets the explicit MIME type of the data.
///
///
- /// (if the mime is null for setter, it clears the previous value.)
+ /// This property returns the explicitly set MIME type of the data. If no explicit MIME type is set, it will return null.
+ /// (Setting this property to null will clear any previously set explicit MIME types.)
///
///
///
@@ -328,7 +332,8 @@ public string Uri
/// Gets and sets the explicit category.
///
///
- /// (if the category is null for setter, it clears the previous value.)
+ /// This property returns the explicitly set category. If no explicit category is set, it will return null.
+ /// (Setting this property to null will clear any previously set explicit categories.)
///
/// 3
public string Category
@@ -363,7 +368,8 @@ public string Category
/// Gets and sets the application ID to explicitly launch.
///
///
- /// (if the application ID is null for setter, it clears the previous value.)
+ /// This property returns the explicitly set application ID. If no explicit application ID is set, it will return null.
+ /// (Setting this property to null will clear any previously set explicit application IDs.)
///
///
///
@@ -446,7 +452,7 @@ public AppControlLaunchMode LaunchMode
/// Gets the collection of the extra data.
///
///
- /// Extra data for communication between AppControls.
+ /// The ExtraData property provides access to a collection of key-value pairs representing additional data associated with the application control.
///
///
///
@@ -1023,9 +1029,9 @@ public static IEnumerable GetDefaultApplicationIds()
}
///
- /// Sets the window position.
+ /// Sets the position and size of the window.
///
- /// The window position object.
+ /// A structure containing the coordinates and dimensions of the window.
/// Thrown when the argument is null.
/// Thrown when the argument is invalid.
/// Thrown when the invalid operation error occurs.
@@ -1054,7 +1060,7 @@ public void SetWindowPosition(WindowPosition windowPosition)
///
/// Gets the window position.
///
- /// The window position.
+ /// A structure containing the coordinates and dimensions of the window.
/// Thrown when the invalid operation error occurs.
/// 11
public WindowPosition GetWindowPosition()
@@ -1357,9 +1363,13 @@ public bool TryGet(string key, out IEnumerable value)
}
///
- /// Removes the extra data.
+ /// Deletes a particular piece of extra data from the collection.
///
- /// The name of the extra data.
+ /// Identifier of the data to remove.
+ ///
+ /// This method enables removal of individual items from the ExtraData collection.
+ /// It accepts only non-empty strings as valid input parameters.
+ ///
/// Thrown when the key is a zero-length string.
/// Thrown when the key is not found.
/// Thrown when the key is rejected.
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationComponentType.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationComponentType.cs
index c5e9838b2cb..015a3e99941 100755
--- a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationComponentType.cs
+++ b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationComponentType.cs
@@ -23,27 +23,27 @@ namespace Tizen.Applications
public enum ApplicationComponentType
{
///
- /// Component type is ui application.
+ /// The user interface (UI) application component type.
///
UIApplication = 0,
///
- /// Component type is service application.
+ /// The service application component type.
///
ServiceApplication,
///
- /// Component type is widget application.
+ /// The widget application component type.
///
WidgetApplication,
///
- /// Component type is watch application.
+ /// The watch application component type.
///
WatchApplication,
///
- /// Component type is component-based application.
+ /// The component-based application component type.
///
/// 7
ComponentBasedApplication,
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationLaunchedEventArgs.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationLaunchedEventArgs.cs
index b65c4412048..106d9b0ee90 100644
--- a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationLaunchedEventArgs.cs
+++ b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationLaunchedEventArgs.cs
@@ -25,7 +25,7 @@ namespace Tizen.Applications
public class ApplicationLaunchedEventArgs : EventArgs
{
///
- /// The information of the application.
+ /// Gets the current running context of the application.
///
/// 3
public ApplicationRunningContext ApplicationRunningContext { get; internal set; }
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs
index 21abc91d8c5..904594a832a 100755
--- a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs
+++ b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs
@@ -43,6 +43,9 @@ public static class ApplicationManager
///
/// Occurs whenever the installed application is enabled.
///
+ ///
+ /// This event is raised whenever the installed application is enabled. It provides information about the application that was enabled through the arguments passed in the event handler.
+ ///
/// 3
public static event EventHandler ApplicationEnabled
{
@@ -74,6 +77,10 @@ public static event EventHandler ApplicationEnabled
///
/// Occurs whenever the installed application is disabled.
///
+ ///
+ /// This event is raised whenever the user disables an installed application through the Settings menu.
+ /// The event handler receives an argument of type ApplicationDisabledEventArgs which contains information about the disabled application.
+ ///
/// 3
public static event EventHandler ApplicationDisabled
{
@@ -105,6 +112,10 @@ public static event EventHandler ApplicationDisabl
///
/// Occurs whenever the installed applications get launched.
///
+ ///
+ /// This event provides information about the application that was just launched, including its package ID, version, and other details.
+ /// It is useful for tracking and monitoring application launches in order to gather statistics or perform certain actions based on specific conditions.
+ ///
/// 3
public static event EventHandler ApplicationLaunched
{
@@ -133,9 +144,13 @@ public static event EventHandler ApplicationLaunch
}
}
+
///
/// Occurs whenever the installed applications get terminated.
///
+ ///
+ /// This event is raised whenever any application gets terminated on the device. It provides information about the terminated application through the arguments passed in the event handler.
+ ///
/// 3
public static event EventHandler ApplicationTerminated
{
@@ -165,9 +180,24 @@ public static event EventHandler ApplicationTerm
}
///
- /// Gets the information of the installed applications asynchronously.
+ /// Asynchronously retrieves information about the installed applications.
///
- /// The installed application info list.
+ /// An asynchronous task that returns a list containing information about the installed applications.
+ ///
+ /// By calling this method, you can retrieve details about all the applications currently installed on the device. The returned list contains ApplicationInfo objects, which provide various properties such as package ID, version, and icon.
+ ///
+ ///
+ /// To get the information of the installed applications, you can call the following code snippet:
+ ///
+ ///
+ /// var listApp = await ApplicationManager.GetInstalledApplicationsAsync();
+ /// Assert.IsNotEmpty(_listApp, "The list of installed app should not be empty.");
+ /// foreach (ApplicationInfo instapp in _listApp)
+ /// {
+ /// Console.WriteLine(instapp.ApplicationId);
+ /// }
+ ///
+ ///
/// 3
public static async Task> GetInstalledApplicationsAsync()
{
@@ -238,10 +268,25 @@ public static void TerminateBackgroundApplication(ApplicationRunningContext app)
}
///
- /// Gets the information of the installed applications with the ApplicationInfoFilter asynchronously.
+ /// Retrieves the information about installed applications that match the specified filter criteria in an asynchronous manner.
///
- /// Key-value pairs for filtering.
- /// The installed application info list.
+ ///
+ /// By specifying the desired filter criteria through the argument, you can retrieve only those applications that meet these conditions. The returned result will contain a list of ApplicationInfo objects representing the matched applications.
+ ///
+ /// An ApplicationInfoFilter containing the desired filter criteria.
+ /// An IEnumerable<ApplicationInfo> containing the information of the installed applications that match the specified filter.
+ ///
+ /// The following code snippet demonstrates how to obtain the information of all installed applications:
+ ///
+ /// var filter = new ApplicationInfoFilter();
+ /// filter.Filter.Add(ApplicationInfoFilter.Keys.Id, "org.exmaple.hello");
+ /// var apps = await GetInstalledApplicationsAsync(filter);
+ /// foreach (var app in apps)
+ /// {
+ /// Console.WriteLine(app.ApplicationId);
+ /// }
+ ///
+ ///
/// 3
public static async Task> GetInstalledApplicationsAsync(ApplicationInfoFilter filter)
{
@@ -285,10 +330,27 @@ public static async Task> GetInstalledApplicationsA
}
///
- /// Gets the information of the installed applications with the ApplicationInfoMetadataFilter asynchronously.
+ /// Asynchronously retrieves the information about installed applications filtered by the specified criteria in the form of ApplicationInfoMetadataFilter.
///
- /// Key-value pairs for filtering.
- /// The installed application info list.
+ ///
+ /// By providing the filter argument, you can specify various conditions such as package names, types, visibility status, etc., which will help narrow down the search results to only those that match the desired criteria.
+ /// The returned result is a list of ApplicationInfo objects containing detailed information about each matched application.
+ ///
+ /// A dictionary of key-value pairs used to define the specific filtering criteria.
+ /// An enumerable collection of ApplicationInfo objects representing the installed applications that meet the specified filtering criteria.
+ ///
+ /// To retrieve all visible applications:
+ ///
+ ///
+ /// var filter = new ApplicationInfoMetadataFilter();
+ /// filter.Filter.Add("http://tizen.org/metadata/test-id", "org.exmaple.hello");
+ /// var apps = await GetInstalledApplicationsAsync(filter);
+ /// foreach (var app in apps)
+ /// {
+ /// Console.WriteLine(app.ApplicationId);
+ /// }
+ ///
+ ///
/// 3
public static async Task> GetInstalledApplicationsAsync(ApplicationInfoMetadataFilter filter)
{
@@ -332,9 +394,22 @@ public static async Task> GetInstalledApplicationsA
}
///
- /// Gets the information of the running applications asynchronously.
+ /// Asynchronously retrieves the information about currently running applications.
///
- /// The application running context list.
+ /// An enumerable list containing details about the running applications.
+ ///
+ /// This method provides an efficient way to gather information about all the active apps on the device without blocking the current thread. It returns a task which can be awaited in order to obtain the desired result.
+ ///
+ ///
+ /// Here's an example demonstrating how to retrieve the running applications and display their IDs:
+ ///
+ /// await ApplicationManager.GetRunningApplicationsAsync().ContinueWith((task) => {
+ /// foreach (var app in task.Result) {
+ /// Console.WriteLine(app.ApplicationId);
+ /// }
+ /// });
+ ///
+ ///
/// 3
public static async Task> GetRunningApplicationsAsync()
{
@@ -371,9 +446,26 @@ public static async Task> GetRunningAppli
}
///
- /// Gets the information of the running applications including subapp asynchronously.
+ /// Asynchronously retrieves the information about all currently running applications, including subapps.
///
- /// The application running context list.
+ /// An enumerable list containing details about the running applications.
+ ///
+ /// This method provides access to the current state of all active applications on the device, allowing you to gather information such as their IDs, types, and states.
+ /// By utilizing this functionality, developers can gain insights into the overall system activity and make informed decisions based on the available data.
+ ///
+ ///
+ /// Here is an example that demonstrates how to utilize the GetAllRunningApplicationsAsync method in order to obtain information about the currently running applications:
+ ///
+ /// // Initiate the call to get all running applications
+ /// IEnumerable<ApplicationRunningContext> runningApps = await GetAllRunningApplicationsAsync();
+ ///
+ /// // Iterate through the obtained list of running apps
+ /// foreach (var app in runningApps)
+ /// {
+ /// Console.WriteLine($"Id: {app.ApplicationId}");
+ /// }
+ ///
+ ///
/// 3
public static async Task> GetAllRunningApplicationsAsync()
{
@@ -410,10 +502,25 @@ public static async Task> GetAllRunningAp
}
///
- /// Gets the information of the specified application with the application ID.
+ /// Retrieves the information of the specified application by its application ID.
///
- /// Application ID.
- /// The application info.
+ /// The ID of the target application.
+ /// An object containing detailed information about the requested application.
+ ///
+ /// This function enables you to obtain specific information about an application based on its application ID.
+ /// It returns an object that contains various attributes such as the package name, version, icon URL, etc., which are associated with the identified application.
+ /// If the specified application does not exist in the system, an error message will be thrown indicating that the requested application could not be found.
+ ///
+ ///
+ /// The following code snippet demonstrates how to retrieve the details of an application with the ID "org.example.app":
+ ///
+ /// // Retrieve the application details
+ /// ApplicationInfo appInfo = ApplicationManager.GetInstalledApplication("org.example.app");
+ ///
+ /// // Print the package ID of the retrieved application
+ /// Console.WriteLine($"Package ID: {appInfo.PackageId}");
+ ///
+ ///
/// 3
public static ApplicationInfo GetInstalledApplication(string applicationId)
{
@@ -428,11 +535,26 @@ public static ApplicationInfo GetInstalledApplication(string applicationId)
}
///
- /// Returns if the specified application is running or not.
+ /// Determines whether the specified application is currently running.
///
- /// The application ID.
- /// Returns true if the given application is running, otherwise false.
- /// Thrown when the given parameter is invalid.
+ /// The unique identifier of the application to check.
+ /// True if the application identified by the given ID is currently running, otherwise False.
+ /// Thrown when the provided argument is invalid or missing.
+ ///
+ /// The following code snippet demonstrates how to determine if a specific application is currently running:
+ ///
+ ///
+ /// string applicationId = "org.example.app";
+ /// if (ApplicationManager.IsRunning(applicationId))
+ /// {
+ /// Console.WriteLine("The application with ID '{0}' is currently running.", applicationId);
+ /// }
+ /// else
+ /// {
+ /// Console.WriteLine("The application with ID '{0}' is not currently running.", applicationId);
+ /// }
+ ///
+ ///
/// 3
public static bool IsRunning(string applicationId)
{
@@ -446,11 +568,24 @@ public static bool IsRunning(string applicationId)
}
///
- /// Returns the application id.
+ /// Retrieves the application ID based on the specified process ID.
///
- /// The application pid.
- /// Returns the application id.
- /// Thrown when the given parameter is invalid.
+ ///
+ /// By providing the process ID as input, this function enables you to obtain the corresponding application ID.
+ /// It ensures that the correct application is identified even if multiple applications are running simultaneously.
+ ///
+ /// The process ID of the target application.
+ /// The application ID associated with the given process ID.
+ /// If the argument passed in is not valid.
+ ///
+ /// The following code snippet demonstrates how to retrieve the application ID by calling the GetAppId() function:
+ ///
+ ///
+ /// int processId = 12345; // Replace with actual process ID
+ /// string appId = GetAppId(processId);
+ /// Console.WriteLine($"Application ID: {appId}");
+ ///
+ ///
/// 6
public static string GetAppId(int processId)
{
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs
index e93d5709368..80a8ae32f50 100755
--- a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs
+++ b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs
@@ -21,8 +21,12 @@
namespace Tizen.Applications
{
///
- /// This class provides methods and properties to get information of the application.
+ /// This class provides methods and properties to retrieve information about the currently running application context.
///
+ ///
+ /// The ApplicationRunningContext class enables you to obtain various details related to the current execution environment such as the application ID, process id, and user data directory.
+ /// It also offers functionality to check if the current application is in foreground or background mode.
+ ///
/// 3
public class ApplicationRunningContext : IDisposable
{
@@ -37,12 +41,24 @@ internal ApplicationRunningContext(IntPtr contextHandle)
}
///
- /// A constructor of ApplicationRunningContext that takes the application ID.
+ /// Constructs an ApplicationRunningContext object from the specified application ID.
///
- /// Application ID.
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the "application not exist" error or the system error.
- /// Thrown when failed because of out of memory.
+ /// The ID of the application.
+ ///
+ /// The constructor creates a new instance of the ApplicationRunningContext class by passing in the application ID.
+ /// It throws exceptions if any errors occur during initialization, such as invalid arguments, non-existent applications, system errors, or out of memory conditions.
+ ///
+ ///
+ /// Here's an example demonstrating how to construct an ApplicationRunningContext object using the constructor:
+ ///
+ ///
+ /// // Define the application ID
+ /// const string APP_ID = "org.example.app";
+ ///
+ /// // Instantiate the ApplicationRunningContext class with the application ID
+ /// var context = new ApplicationRunningContext(APP_ID);
+ ///
+ ///
/// 3
public ApplicationRunningContext(string applicationId)
{
@@ -99,7 +115,7 @@ public ApplicationRunningContext(string applicationId, string instanceId)
}
///
- /// Destructor of the class.
+ /// Destroys the current application running context.
///
~ApplicationRunningContext()
{
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/Bundle.cs b/src/Tizen.Applications.Common/Tizen.Applications/Bundle.cs
index 61960542db2..1bcfe009212 100644
--- a/src/Tizen.Applications.Common/Tizen.Applications/Bundle.cs
+++ b/src/Tizen.Applications.Common/Tizen.Applications/Bundle.cs
@@ -39,10 +39,15 @@ public class Bundle : IDisposable
private readonly HashSet _keys;
///
- /// The bundle constructor.
+ /// Creates a new instance of the Bundle class.
///
+ ///
+ /// This constructor initializes a new instance of the Bundle class. It does not perform any specific actions by itself but provides a starting point for creating and managing bundles of data.
+ ///
/// Thrown when out of memory.
///
+ /// Here's an example showing how to create a new instance of the Bundle class:
+ ///
///
/// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
///
@@ -56,10 +61,10 @@ public Bundle()
}
///
- /// The bundle constructor.
+ /// Creates a new instance of the Bundle class from the specified SafeBundleHandle.
///
- /// The SafeBundleHandle instance.
- /// Thrown when the handle is null or invalid.
+ /// The SafeBundleHandle instance that represents the bundle.
+ /// Thrown if the handle argument is null or invalid.
/// 3
public Bundle(SafeBundleHandle handle)
{
diff --git a/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs b/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs
index 916c7392a26..1e04fc155cc 100644
--- a/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs
+++ b/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs
@@ -28,8 +28,11 @@
namespace Tizen.Applications
{
///
- /// This class represents an application controlled lifecycles by the backend system.
+ /// The CoreApplication class provides functionality to manage application lifecycle events that are controlled by the backend system.
///
+ ///
+ /// By inheriting from the Application class, CoreApplication enables developers to handle various application states such as creating and terminating. It also allows them to define their own event handlers for these states.
+ ///
/// 3
public class CoreApplication : Application
{
@@ -38,9 +41,14 @@ public class CoreApplication : Application
private bool _disposedValue = false;
///
- /// Initializes the CoreApplication class.
+ /// Initializes the CoreApplication class by providing a specific implementation of the ICoreBackend interface.
///
- /// The backend instance implementing ICoreBacked interface.
+ /// An instance of the desired implementation of the ICoreBackend interface.
+ ///
+ /// The CoreApplication class provides access to various features and functionalities related to application management.
+ /// By initializing the CoreApplication class with a specific implementation of the ICoreBackend interface, developers can customize the behavior and functionality of their applications based on their requirements.
+ /// It enables them to extend the capabilities of the default CoreApplication class and tailor it according to their needs.
+ ///
/// 3
public CoreApplication(ICoreBackend backend)
{
@@ -169,8 +177,9 @@ public override void Exit()
}
///
- /// Overrides this method if want to handle behavior when the application is launched.
- /// If base.OnCreated() is not called, the event 'Created' will not be emitted.
+ /// Overrides this method if you want to handle specific behavior when the application is created.
+ /// Calling base.OnCreate() ensures that the default implementation is executed before any custom code in this method.
+ /// If base.OnCreate() is not called, the event 'Created' will not be emitted.
///
/// 3
protected virtual void OnCreate()
@@ -195,8 +204,8 @@ protected virtual void OnCreate()
}
///
- /// Overrides this method if want to handle behavior when the application is terminated.
- /// If base.OnTerminate() is not called, the event 'Terminated' will not be emitted.
+ /// Override this method to define specific actions that occur when the application terminates.
+ /// Calling base.OnTerminate() ensures that the default termination process takes place and the 'Terminated' event is emitted.
///
/// 3
protected virtual void OnTerminate()
@@ -205,10 +214,10 @@ protected virtual void OnTerminate()
}
///
- /// Overrides this method if want to handle behavior when the application receives the appcontrol message.
- /// If base.OnAppControlReceived() is not called, the event 'AppControlReceived' will not be emitted.
+ /// Override this method to customize the behavior when the application receives the appcontrol message.
+ /// If base.OnAppControlReceived() is not called, the event 'AppControlReceived' will not be triggered.
///
- ///
+ /// The arguments passed in the appcontrol message
/// 3
protected virtual void OnAppControlReceived(AppControlReceivedEventArgs e)
{
@@ -222,8 +231,8 @@ protected virtual void OnAppControlReceived(AppControlReceivedEventArgs e)
}
///
- /// Overrides this method if want to handle behavior when the system memory is low.
- /// If base.OnLowMemory() is not called, the event 'LowMemory' will not be emitted.
+ /// Override this method to handle behavior when the system memory is low.
+ /// Calling base.OnLowMemory() ensures that the 'LowMemory' event is emitted.
///
/// The low memory event argument
/// 3
@@ -243,10 +252,10 @@ protected virtual void OnLowMemory(LowMemoryEventArgs e)
}
///
- /// Overrides this method if want to handle behavior when the system battery is low.
- /// If base.OnLowBattery() is not called, the event 'LowBattery' will not be emitted.
+ /// Override this method to handle the behavior when the system battery level drops.
+ /// If base.OnLowBattery() is not called, the LowBattery event will not be raised.
///
- /// The low battery event argument
+ /// The arguments for the low battery event
/// 3
protected virtual void OnLowBattery(LowBatteryEventArgs e)
{
@@ -260,10 +269,10 @@ protected virtual void OnLowBattery(LowBatteryEventArgs e)
}
///
- /// Overrides this method if want to handle behavior when the system language is changed.
- /// If base.OnLocaleChanged() is not called, the event 'LocaleChanged' will not be emitted.
+ /// Override this method to handle changes in the system language.
+ /// If base.OnLocaleChanged() is not called, the LocaleChanged event will not be triggered.
///
- /// The locale changed event argument
+ /// The arguments passed with the LocaleChanged event
/// 3
protected virtual void OnLocaleChanged(LocaleChangedEventArgs e)
{
@@ -282,10 +291,10 @@ protected virtual void OnLocaleChanged(LocaleChangedEventArgs e)
}
///
- /// Overrides this method if want to handle behavior when the region format is changed.
- /// If base.OnRegionFormatChanged() is not called, the event 'RegionFormatChanged' will not be emitted.
+ /// Override this method to handle changes in the region format.
+ /// Make sure to call base.OnRegionFormatChanged() to ensure that the RegionFormatChanged event is raised.
///
- /// The region format changed event argument
+ /// The region format changed event arguments
/// 3
protected virtual void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
{
@@ -304,10 +313,10 @@ protected virtual void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
}
///
- /// Overrides this method if want to handle behavior when the device orientation is changed.
- /// If base.OnRegionFormatChanged() is not called, the event 'RegionFormatChanged' will not be emitted.
+ /// Override this method to define specific behavior when the device orientation changes.
+ /// If base.OnDeviceOrientationChanged() is not called, the 'DeviceOrientationChanged' event will not be raised.
///
- /// The device orientation changed event argument
+ /// The arguments for the device orientation change event
/// 3
protected virtual void OnDeviceOrientationChanged(DeviceOrientationEventArgs e)
{
@@ -315,10 +324,10 @@ protected virtual void OnDeviceOrientationChanged(DeviceOrientationEventArgs e)
}
///
- /// Override this method if you want to handle behavior when the time zone is changed.
- /// If base.OnTimeZoneChanged() is not called, the event "TimeZoneChanged" will not be emitted.
+ /// Override this method to handle changes in the current time zone.
+ /// Calling base.OnTimeZoneChanged() ensures that the TimeZoneChanged event is triggered.
///
- /// The time zone changed event argument
+ /// The arguments containing details about the time zone change
/// 11
protected virtual void OnTimeZoneChanged(TimeZoneChangedEventArgs e)
{
diff --git a/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentInfo.cs b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentInfo.cs
index 16805c4b013..f0b6ebfb90a 100755
--- a/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentInfo.cs
+++ b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentInfo.cs
@@ -20,7 +20,8 @@
namespace Tizen.Applications.ComponentBased
{
///
- /// This class provides methods and properties to get information of the component.
+ /// Provides methods and properties to retrieve information about a component in a Tizen application.
+ /// This class encapsulates details such as component ID, application ID, and other attributes.
///
/// 6
public class ComponentInfo : IDisposable
@@ -41,13 +42,13 @@ internal ComponentInfo(IntPtr infoHandle)
}
///
- /// A constructor of ComponentInfo that takes the component ID.
+ /// Initializes a new instance of the class with the specified component ID.
///
- /// Component ID.
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied. >
+ /// The ID of the component.
+ /// Thrown when the component ID is invalid.
+ /// Thrown when a system error occurs.
+ /// Thrown when memory allocation fails.
+ /// Thrown when permission is denied.
/// http://tizen.org/privilege/packagemanager.info
/// 6
public ComponentInfo(string componentId)
@@ -63,7 +64,7 @@ public ComponentInfo(string componentId)
}
///
- /// Destructor of the class.
+ /// Finalizes an instance of the class.
///
~ComponentInfo()
{
@@ -71,7 +72,7 @@ public ComponentInfo(string componentId)
}
///
- /// Gets the component ID.
+ /// Gets the ID of the component.
///
/// 6
public string ComponentId
@@ -94,7 +95,7 @@ public string ComponentId
}
///
- /// Gets the application ID of the component.
+ /// Gets the application ID associated with the component.
///
/// 6
public string ApplicationId
@@ -132,7 +133,7 @@ public ComponentType ComponentType
}
///
- /// Checks whether the icon of the component should be displayed or not.
+ /// Checks whether the icon of the component should be displayed.
///
/// 6
public bool IsIconDisplayed
@@ -151,7 +152,7 @@ public bool IsIconDisplayed
}
///
- /// Checks whether the component should be managed by task-manager or not.
+ /// Checks whether the component is managed by the task manager.
///
/// 6
public bool IsManagedByTaskManager
@@ -170,7 +171,7 @@ public bool IsManagedByTaskManager
}
///
- /// Gets the absolute path of the icon image.
+ /// Gets the absolute path of the component's icon image.
///
/// 6
public string IconPath
@@ -207,11 +208,11 @@ public string Label
}
///
- /// Gets the localized label of the component for the given locale.
+ /// Gets the localized label of the component for a specified locale.
///
- /// Locale.
- /// The format of locale is language and country code. (available value: "[2-letter lowercase language code (ISO 639-1)]-[2-letter lowercase country code (ISO 3166-alpha-2)]")
- /// The localized label.
+ /// The locale in the format of language and country code (e.g., "en-US").
+ /// Available values are in the format "[2-letter lowercase language code (ISO 639-1)]-[2-letter lowercase country code (ISO 3166-alpha-2)]".
+ /// The localized label corresponding to the specified locale.
/// 6
public string GetLocalizedLabel(string locale)
{
@@ -226,7 +227,7 @@ public string GetLocalizedLabel(string locale)
}
///
- /// Releases all resources used by the ComponentInfo class.
+ /// Releases all resources used by the class.
///
/// 6
public void Dispose()
@@ -236,7 +237,7 @@ public void Dispose()
}
///
- /// Releases all resources used by the ComponentInfo class.
+ /// Releases resources used by the class.
///
/// Disposing
/// 6
diff --git a/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentManager.cs b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentManager.cs
index 4824e6f4e4b..890c8080fc0 100755
--- a/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentManager.cs
+++ b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentManager.cs
@@ -29,15 +29,18 @@ namespace Tizen.Applications.ComponentBased
public static class ComponentManager
{
private const string LogTag = "Tizen.Applications";
-
+
///
- /// Gets the information of the installed components asynchronously.
+ /// Asynchronously retrieves a list of installed components.
///
- /// The installed component info list.
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the "component not exist" error or the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
+ ///
+ /// A task that represents the asynchronous operation.
+ /// The task result contains an of the installed component information.
+ ///
+ /// Thrown when an invalid argument is provided.
+ /// Thrown when the component does not exist or if a system error occurs.
+ /// Thrown when the system runs out of memory.
+ /// Thrown when permission is denied to access the component information.
/// http://tizen.org/privilege/packagemanager.info
/// 6
public static async Task> GetInstalledComponentsAsync()
@@ -74,13 +77,16 @@ public static async Task> GetInstalledComponentsAsync
}
///
- /// Gets the information of the running components asynchronously.
+ /// Asynchronously retrieves a list of currently running components.
///
- /// The component running context list.
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the "component not exist" error or the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
+ ///
+ /// A task that represents the asynchronous operation.
+ /// The task result contains an of the running components.
+ ///
+ /// Thrown when an invalid argument is provided.
+ /// Thrown when the component does not exist or if a system error occurs.
+ /// Thrown when the system runs out of memory.
+ /// Thrown when permission is denied to access the running components.
/// http://tizen.org/privilege/packagemanager.info
/// 6
public static async Task> GetRunningComponentsAsync()
@@ -117,14 +123,16 @@ public static async Task> GetRunningCompone
}
///
- /// Checks whether the component is running or not.
+ /// Checks if a specified component is currently running.
///
- /// Component ID.
- /// Returns true if the component is running, otherwise false.
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the "component not exist" error or the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
+ /// The unique identifier of the component.
+ ///
+ /// True if the component is running; otherwise, false.
+ ///
+ /// Thrown when an invalid argument is provided.
+ /// Thrown when the component does not exist or if a system error occurs.
+ /// Thrown when the system runs out of memory.
+ /// Thrown when permission is denied to access the component status.
/// http://tizen.org/privilege/packagemanager.info
/// 6
public static bool IsRunning(string componentId)
@@ -139,17 +147,17 @@ public static bool IsRunning(string componentId)
}
///
- /// Terminates the component if it is running in the background.
+ /// Requests to terminate a specified component that is running in the background.
///
- /// Component ID
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the "component not exist" error or the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
+ /// The context of the running component to terminate.
+ /// Thrown when an invalid argument is provided.
+ /// Thrown when the component does not exist or if a system error occurs.
+ /// Thrown when the system runs out of memory.
+ /// Thrown when permission is denied to terminate the component.
/// http://tizen.org/privilege/appmanager.kill.bgapp
///
- /// This function returns after it just sends a request for terminating a background component.
- /// Platform will decide if the target component could be terminated or not according to the state of the target component.
+ /// This method sends a request to terminate a background component.
+ /// The platform determines if the target component can be terminated based on its current state.
///
/// 6
public static void TerminateBackgroundComponent(ComponentRunningContext context)
diff --git a/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentRunningContext.cs b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentRunningContext.cs
index 4932922087c..0c366ec1c6e 100755
--- a/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentRunningContext.cs
+++ b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentRunningContext.cs
@@ -23,7 +23,8 @@
namespace Tizen.Applications.ComponentBased
{
///
- /// This class provides methods and properties to get information of the running component.
+ /// Represents the context of a running component, providing methods and properties
+ /// to retrieve information about the component's state and behavior.
///
/// 6
public class ComponentRunningContext : IDisposable
@@ -39,13 +40,14 @@ internal ComponentRunningContext(IntPtr contextHandle)
}
///
- /// A constructor of ComponentRunningContext that takes the component ID.
+ /// Initializes a new instance of the class
+ /// with a specified component ID, retrieving the context handle associated with it.
///
- /// Component ID.
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the "component not exist" error or the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
+ /// The ID of the component.
+ /// Thrown when the component ID is invalid.
+ /// Thrown when the component does not exist or a system error occurs.
+ /// Thrown when memory allocation fails.
+ /// Thrown when permission is denied to access the component.
/// http://tizen.org/privilege/packagemanager.info
/// 6
public ComponentRunningContext(string componentId)
@@ -61,7 +63,7 @@ public ComponentRunningContext(string componentId)
}
///
- /// Destructor of the class.
+ /// Finalizes an instance of the class.
///
~ComponentRunningContext()
{
@@ -69,7 +71,7 @@ public ComponentRunningContext(string componentId)
}
///
- /// Enumeration for the component state.
+ /// Represents the possible states of a component.
///
/// 6
public enum ComponentState
@@ -108,6 +110,7 @@ public enum ComponentState
///
/// Gets the ID of the component.
///
+ /// The component ID as a string.
/// 6
public string ComponentId
{
@@ -129,7 +132,7 @@ public string ComponentId
}
///
- /// Gets the application ID of the component.
+ /// Gets the application ID associated with the component.
///
/// 6
public string ApplicationId
@@ -146,7 +149,7 @@ public string ApplicationId
return appId;
}
}
-
+
///
/// Gets the instance ID of the component.
///
@@ -167,7 +170,7 @@ public string InstanceId
}
///
- /// Gets the state of the component.
+ /// Gets the current state of the component.
///
/// 6
public ComponentState State
@@ -186,8 +189,9 @@ public ComponentState State
}
///
- /// Checks whether the component is terminated or not.
+ /// Checks whether the component has been terminated.
///
+ /// true if the component is terminated; otherwise, false .
/// 6
public bool IsTerminated
{
@@ -205,8 +209,9 @@ public bool IsTerminated
}
///
- /// Checks whether the component is running as sub component of the group.
+ /// Checks whether the component is running as a sub-component of a group.
///
+ /// true if the component is a sub-component; otherwise, false .
/// 6
public bool IsSubComponent
{
@@ -224,12 +229,12 @@ public bool IsSubComponent
}
///
- /// Resumes the running component.
+ /// Resumes the execution of the running component.
///
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
+ /// Thrown when the argument is invalid.
+ /// Thrown when a system error occurs.
+ /// Thrown when memory allocation fails.
+ /// Thrown when permission is denied to resume the component.
/// http://tizen.org/privilege/appmanager.launch
/// 6
public void Resume()
@@ -237,17 +242,17 @@ public void Resume()
Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerResumeComponent(_contextHandle);
if (err != Interop.ComponentManager.ErrorCode.None)
{
- throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Failed to Send the resume request.");
+ throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Failed to send the resume request.");
}
}
///
- /// Pauses the running component.
+ /// Pauses the execution of the running component.
///
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
+ /// Thrown when the argument is invalid.
+ /// Thrown when a system error occurs.
+ /// Thrown when memory allocation fails.
+ /// Thrown when permission is denied to pause the component.
/// http://tizen.org/privilege/appmanager.launch
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
@@ -261,12 +266,12 @@ public void Pause()
}
///
- /// Terminates the running component.
+ /// Terminates the execution of the running component.
///
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
+ /// Thrown when the argument is invalid.
+ /// Thrown when a system error occurs.
+ /// Thrown when memory allocation fails.
+ /// Thrown when permission is denied to terminate the component.
/// http://tizen.org/privilege/appmanager.launch
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
@@ -280,7 +285,7 @@ public void Terminate()
}
///
- /// Releases all resources used by the ComponentInfo class.
+ /// Releases all resources used by the class.
///
/// 6
public void Dispose()
@@ -290,9 +295,9 @@ public void Dispose()
}
///
- /// Releases all resources used by the ComponentInfo class.
+ /// Releases all resources used by the class.
///
- /// Disposing
+ /// true to release managed resources; otherwise, false .
/// 6
private void Dispose(bool disposing)
{
diff --git a/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/ComponentPort.cs b/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/ComponentPort.cs
index e62d82f764f..a0f70d1dec6 100755
--- a/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/ComponentPort.cs
+++ b/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/ComponentPort.cs
@@ -43,12 +43,12 @@ public class ComponentPort : IDisposable
private static int _requestId = 0;
///
- /// Constructor for this class.
+ /// Constructs a new instance of this class.
///
/// Thrown when the argument is invalid.
/// Thrown when the memory is insufficient.
/// Thrown when because of I/O error.
- /// The name of the port.
+ /// The name of the port to connect to.
/// 9
public ComponentPort(string portName)
{
@@ -77,7 +77,7 @@ public string PortName
/// Adds a privilege to the port object.
///
/// Thrown when the argument is invalid.
- /// privilege data
+ /// Privilege data specifying the access rights to be granted.
/// 9
public void AddPrivilege(string privilege)
{
@@ -157,8 +157,8 @@ public static Task WaitForPort(string endpoint)
///
///
/// This method runs a main loop until Cancel() is called.
- /// The code in the next line will not run until Cancel() is called.
- /// To avoid blocking the main thread, it's recommended to use the ComponentTask class.
+ /// The code in the next line will not execute until Cancel() is called.
+ /// To prevent blocking the main thread, consider using the ComponentTask class instead.
///
///
///
@@ -182,15 +182,19 @@ public void Cancel()
}
///
- /// Sends the request data.
+ /// Sends the request data to the specified endpoint.
///
+ ///
+ /// This method sends the serialized request data to the specified endpoint.
+ /// If the timeout value is not set (-1), the default timeout will be used.
+ ///
/// Thrown when the argument is invalid.
/// Thrown when the memory is insufficient.
/// Thrown when permission is denied.
/// Thrown when because of I/O error.
- /// The name of the endpoint
- /// The timeout in milliseconds, -1 to use the default timeout
- /// The serializable data to send
+ /// The name of the endpoint to which the request is sent.
+ /// The timeout in milliseconds, -1 to use the default timeout.
+ /// The serializable data to send.
/// 9
public void Send(string endpoint, int timeout, object request)
{
@@ -222,10 +226,10 @@ public void Send(string endpoint, int timeout, object request)
/// Thrown when the memory is insufficient.
/// Thrown when permission is denied.
/// Thrown when because of I/O error.
- /// The name of the endpoint
- /// The timeout in milliseconds, -1 to use the default timeout
- /// The serializable data to send
- /// The received serializable data
+ /// The name of the endpoint to which the request is sent.
+ /// The timeout in milliseconds, -1 to use the default timeout.
+ /// The serializable data to send.
+ /// The received serializable data.
/// 9
public object SendAndReceive(string endpoint, int timeout, object request)
{
@@ -264,11 +268,11 @@ public object SendAndReceive(string endpoint, int timeout, object request)
/// Thrown when the memory is insufficient.
/// Thrown when permission is denied.
/// Thrown when because of I/O error.
- /// The name of the endpoint
- /// The timeout in milliseconds, -1 to use the default timeout
- /// The serializable data to send
- /// The received serializable data
- /// /// 9
+ /// The name of the endpoint to which the request is sent.
+ /// The timeout in milliseconds, -1 to use the default timeout.
+ /// The serializable data to send.
+ /// The received serializable data.
+ /// 9
public Task SendAndReceiveAsync(string endpoint, int timeout, object request)
{
try
@@ -285,7 +289,7 @@ public Task SendAndReceiveAsync(string endpoint, int timeout, object req
/// Occurs whenever the request is received.
///
///
- /// If the reply is requested, RequestEventArgs.Request should be set.
+ /// The event handler receives a RequestEventArgs argument that contains information about the request. If the reply is requested, RequestEventArgs.Request should be set.
///
/// 9
public event EventHandler RequestReceived;
@@ -422,7 +426,7 @@ protected virtual void Dispose(bool disposing)
}
///
- /// Finalizer of the class ComponentPort.
+ /// Finalizes an instance of the class ComponentPort.
///
/// 9
~ComponentPort()
@@ -433,7 +437,7 @@ protected virtual void Dispose(bool disposing)
///
/// Releases all the resources used by the class ComponentPort.
///
- /// 9 >
+ /// 9
public void Dispose()
{
Dispose(disposing: true);
diff --git a/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/ComponentTask.cs b/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/ComponentTask.cs
index 2134be10a4b..9d5bb6c1754 100755
--- a/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/ComponentTask.cs
+++ b/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/ComponentTask.cs
@@ -59,10 +59,10 @@ private void OnThread()
///
/// Starts the task.
- ///
- /// This method calls ComponentPort.WaitForEvent() in the thread.
- ///
///
+ ///
+ /// This method calls in the thread.
+ ///
/// 9
public void Start()
{
@@ -81,7 +81,7 @@ public void Start()
/// Stops the task.
///
///
- /// This method calls ComponentPort.Cancel() before stopping the thread.
+ /// This method calls before stopping the thread.
///
/// 9
public void Stop()
diff --git a/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/Parcel.cs b/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/Parcel.cs
index 4f2db8ac6a0..ac10b5e9ef3 100755
--- a/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/Parcel.cs
+++ b/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/Parcel.cs
@@ -86,7 +86,7 @@ protected virtual void Dispose(bool disposing)
}
///
- /// Finalizer of the class Parcel.
+ /// Finalizes an instance of the Parcel class.
///
/// 9
~Parcel()
@@ -97,7 +97,7 @@ protected virtual void Dispose(bool disposing)
///
/// Releases all the resources used by the class parcel.
///
- /// 9 >
+ /// 9
public void Dispose()
{
Dispose(disposing: true);
@@ -123,4 +123,4 @@ internal static Exception GetException(Interop.Parcel.ErrorCode err, string mess
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/RequestEventArgs.cs b/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/RequestEventArgs.cs
index 652c9b1577a..c93086ee17b 100755
--- a/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/RequestEventArgs.cs
+++ b/src/Tizen.Applications.ComponentBased.Port/Tizen.Applications.ComponentBased.Port/RequestEventArgs.cs
@@ -19,7 +19,7 @@
namespace Tizen.Applications.ComponentBased
{
///
- /// Arguments for the event raised when the request is received.
+ /// The arguments for the event raised when the request is received.
///
/// 9
public class RequestEventArgs : EventArgs
diff --git a/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/BaseComponent.cs b/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/BaseComponent.cs
index 1940a3ff776..52b9ecbdce3 100755
--- a/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/BaseComponent.cs
+++ b/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/BaseComponent.cs
@@ -21,11 +21,11 @@
namespace Tizen.Applications.ComponentBased.Common
{
///
- /// This is a base-component class.
- /// It provides common functions of FrameComponent and ServiceComponent.
+ /// Represents the base class for components, providing common functionalities for both FrameComponent and ServiceComponent.
///
///
- /// This class cannot be registered by ComponentBased applications.
+ /// This class cannot be registered directly by ComponentBased applications.
+ /// It serves as a base class to be inherited by other components.
///
/// 6
public abstract class BaseComponent
@@ -75,26 +75,26 @@ public abstract class BaseComponent
public event EventHandler TimeZoneChanged;
///
- /// A component instance ID.
+ /// Gets the unique instance ID of the component.
/// It will be created after OnCreate method is invoked.
///
/// 6
public string Id { get; private set; }
///
- /// A component ID
+ /// Gets the ID of the component.
///
/// 6
public string ComponentId { get; private set; }
///
- /// Parent object
+ /// Gets the parent application object to which the component belongs.
///
/// 6
public ComponentBasedApplication Parent { get; private set; }
///
- /// Finish current component
+ /// Finishes the current component.
///
/// 6
public void Finish()
@@ -128,18 +128,18 @@ internal void Bind(IntPtr handle, string compId, string instanceId, ComponentBas
}
///
- /// Overrides this method if want to handle behavior to restore the previous status.
+ /// Override this method to handle restoring the previous state of the component.
///
- /// Contents. It can be used only in the callback. To use outside, make a copy.
+ /// A bundle containing the saved state of the component. It can only be used within the callback. To use it outside, create a copy.
/// 6
public virtual void OnRestoreContents(Bundle c)
{
}
///
- /// Overrides this method if want to handle behavior to save current status.
+ /// Override this method to handle saving the current state of the component.
///
- /// Contents. It can be used only in the callback. To use outside, make a copy.
+ /// A bundle containing the current state of the component. It can only be used within the callback. To use it outside, create a copy.
/// 6
public virtual void OnSaveContent(Bundle c)
{
@@ -181,17 +181,18 @@ internal void OnTimeZoneChangedCallback(string timeZone, string timeZoneId)
}
///
- /// Sends the launch request asynchronously.
+ /// Sends a launch request asynchronously.
///
///
- /// To use group mode, you must use this function instead of SendLaunchRequestAsync().
+ /// Use this method to send a launch request with group mode enabled.
+ /// If group mode is not required, you can use SendLaunchRequestAsync() instead.
///
- /// appcontrol object
- /// The callback function to be called when the reply is delivered.
- /// A task with the result of the launch request.
+ /// The AppControl object representing the request details.
+ /// The callback function to be invoked when the reply is received.
+ /// A task representing the result of the launch request.
/// Thrown when failed because of the argument is invalid.
- /// Thrown when fail to set component information to the AppControl.
- /// Thrown when the application to run is not found.
+ /// Thrown when there is a failure in setting the component information in the AppControl.
+ /// Thrown when the target application is not found.
/// Thrown when the launch request is rejected.
/// http://tizen.org/privilege/appmanager.launch
/// 6
diff --git a/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/ComponentBasedApplication.cs b/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/ComponentBasedApplication.cs
index 8b6cf709f15..da36a7fad81 100755
--- a/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/ComponentBasedApplication.cs
+++ b/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/ComponentBasedApplication.cs
@@ -20,8 +20,13 @@
namespace Tizen.Applications.ComponentBased.Common
{
///
- /// The class for supporting multi-components based application model.
+ /// Represents the base class for a multi-component based application.
+ /// This class allows the creation and management of multiple application components, such as Frame, Service, and Widget components.
///
+ ///
+ /// This abstract class provides the core structure for applications that consist of multiple components.
+ /// Each component has its own lifecycle, and the framework handles these lifecycles independently.
+ ///
/// 6
public abstract class ComponentBasedApplication : Application
{
@@ -30,12 +35,24 @@ public abstract class ComponentBasedApplication : Application
private Interop.CBApplication.CBAppLifecycleCallbacks _callbacks;
///
- /// Initializes the ComponentBasedApplicationBase class.
+ /// Initializes a new instance of the class with the specified component type information.
///
- /// The component type information.
- /// The key should be a class type of FrameComponent or SubComponent subclass.
- /// The value should be a component id which is declared in tizen-manifest.xml.
- ///
+ /// A dictionary where the key is the component class type (FrameComponent, ServiceComponent or WidgetComponent subclass),
+ /// and the value is the component ID defined in the tizen-manifest.xml file.
+ ///
+ /// This constructor sets up the necessary callbacks for the application lifecycle and registers the provided components.
+ ///
+ ///
+ ///
+ /// IDictionary<Type, string> components = new Dictionary<Type, string>()
+ /// {
+ /// { typeof(MyFrameComponent), "frameComponentId" },
+ /// { typeof(MyServiceComponent), "serviceComponentId" }
+ /// };
+ /// ComponentBasedApplication app = new MyApplication(components);
+ /// app.Run(args);
+ ///
+ ///
/// 6
public ComponentBasedApplication(IDictionary typeInfo)
{
@@ -53,11 +70,19 @@ public ComponentBasedApplication(IDictionary typeInfo)
}
///
- /// Registers a component.
+ /// Registers a component with the specified type and ID.
///
- /// Class type
- /// Component ID
- /// Thrown when component type is already added or not sub-class of FrameComponent or ServiceComponent
+ /// The type of the component to register. Must be a subclass of FrameComponent, ServiceComponent, or WidgetComponent.
+ /// The ID of the component, defined in the tizen-manifest.xml file.
+ /// Thrown when the component type is already registered or not sub-class of FrameComponent, ServiceComponent or WidgetComponent.
+ ///
+ /// This method ensures that only valid component types are registered. The component ID must be unique.
+ ///
+ ///
+ ///
+ /// app.RegisterComponent(typeof(MyFrameComponent), "frameComponentId");
+ ///
+ ///
/// 6
public void RegisterComponent(Type compType, string compId)
{
@@ -98,8 +123,13 @@ public void RegisterComponent(Type compType, string compId)
///
/// Runs the application's main loop.
///
- /// Arguments from commandline.
+ /// The arguments passed from the command line.
/// Thrown when component type is already added to the component.
+ ///
+ ///
+ /// app.Run(args);
+ ///
+ ///
/// 6
public override void Run(string[] args)
{
@@ -121,7 +151,7 @@ public override void Run(string[] args)
}
///
- /// Exits the main loop of the application.
+ /// Exits the application's main loop.
///
/// 6
public override void Exit()
@@ -166,31 +196,43 @@ private void OnFinishedNative(IntPtr data)
}
///
- /// This method will be called before running main-loop
+ /// Called before the main loop starts.
///
- ///
+ /// The arguments passed from the command line.
+ ///
+ /// Override this method to handle any initialization logic before the application enters the main event loop.
+ ///
/// 6
protected virtual void OnInit(string[] args)
{
}
///
- /// This method will be called after exiting main-loop
+ /// Called after the main loop exits.
///
+ ///
+ /// Override this method to handle any cleanup logic after the application has finished running.
+ ///
/// 6
protected virtual void OnFinished()
{
}
///
- /// This method will be called to start main-loop
+ /// Called to start the main loop of the application.
///
+ ///
+ /// This is an abstract method that must be implemented by derived classes to define the behavior when the application starts.
+ ///
/// 6
protected abstract void OnRun();
///
- /// This method will be called to exit main-loop
+ /// Called to exit the main loop of the application.
///
+ ///
+ /// Override this method to handle any logic needed before the application exits.
+ ///
/// 6
protected virtual void OnExit()
{
diff --git a/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/FrameComponent.cs b/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/FrameComponent.cs
index d3b166492dd..5a378791aa5 100644
--- a/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/FrameComponent.cs
+++ b/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/FrameComponent.cs
@@ -19,15 +19,19 @@
namespace Tizen.Applications.ComponentBased.Common
{
///
- /// The class for showing UI module
+ /// Represents a base class for UI components in the component-based application model.
+ /// This class provides methods for handling the lifecycle and state of UI components.
///
/// 6
public abstract class FrameComponent : BaseComponent
{
///
- /// Gets the display status of a component.
+ /// Gets the current display status of the component.
///
- /// Thrown when component type is already added to the component.
+ ///
+ /// The current of the component.
+ ///
+ /// Thrown when the display status cannot be retrieved.
/// 6
public DisplayStatus DisplayStatus
{
@@ -43,31 +47,36 @@ public DisplayStatus DisplayStatus
}
///
- /// Overrides this method to handle behavior when the component is launched.
+ /// Called when the component is launched. Override this method to implement custom launch behavior.
///
- /// True if a service component is successfully created
+ ///
+ /// true if the service component is successfully created; otherwise, false .
+ ///
/// 6
public abstract bool OnCreate();
///
- /// Overrides this method to create window. It will be called before OnCreate method.
+ /// Called to create the window for the component. Override this method to provide a custom window.
+ /// This method will be called before method.
///
- /// Window object to use
+ ///
+ /// An object that represents the created window.
+ ///
/// 6
public abstract IWindowInfo CreateWindowInfo();
///
- /// Overrides this method if want to handle behavior when the component receives the appcontrol message.
+ /// Called when the component receives an app control message. Override this method to handle app control messages.
///
- /// appcontrol object
- /// True if it was restarted
+ /// The object containing the app control data.
+ /// true if the component was restarted; otherwise, false .
/// 6
public virtual void OnStart(AppControl appControl, bool restarted)
{
}
///
- /// Overrides this method if you want to handle the behavior when the component is resumed.
+ /// Called when the component is resumed. Override this method to handle resume behavior.
///
/// 6
public virtual void OnResume()
@@ -75,7 +84,7 @@ public virtual void OnResume()
}
///
- /// Overrides this method if you want to handle the behavior when the component is paused.
+ /// Called when the component is paused. Override this method to handle pause behavior.
///
/// 6
public virtual void OnPause()
@@ -83,7 +92,7 @@ public virtual void OnPause()
}
///
- /// Overrides this method if you want to handle the behavior when the component is stopped.
+ /// Called when the component is stopped. Override this method to handle stop behavior.
///
/// 6
public virtual void OnStop()
@@ -91,7 +100,7 @@ public virtual void OnStop()
}
///
- /// Overrides this method if want to handle behavior when the component is destroyed.
+ /// Called when the component is destroyed. Override this method to handle destruction behavior.
///
/// 6
public virtual void OnDestroy()
diff --git a/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/ServiceComponent.cs b/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/ServiceComponent.cs
index 6dc04f2c3b5..3d95badcdc5 100755
--- a/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/ServiceComponent.cs
+++ b/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/ServiceComponent.cs
@@ -19,29 +19,33 @@
namespace Tizen.Applications.ComponentBased.Common
{
///
- /// The class for showing service module
+ /// Represents a base class for service components in the component-based application model.
+ /// This class provides methods for handling the lifecycle and state of service components.
///
/// 6
public abstract class ServiceComponent : BaseComponent
{
///
- /// Overrides this method to handle behavior when the component is created.
+ /// Called when the service component is created. Override this method to implement custom creation behavior.
///
- /// True if a service component is successfully created
+ ///
+ /// true if the service component is successfully created; otherwise, false .
+ ///
+ /// 6
public abstract bool OnCreate();
///
- /// Overrides this method if want to handle behavior when the component receives the start command message.
+ /// Called when the service component receives a start command message. Override this method to handle start command behavior.
///
- /// appcontrol object
- /// True if it was restarted
+ /// The object containing the app control data.
+ /// true if the component was restarted; otherwise, false .
/// 6
public virtual void OnStartCommand(AppControl appControl, bool restarted)
{
}
///
- /// Overrides this method if want to handle behavior when the component is destroyed.
+ /// Called when the service component is destroyed. Override this method to handle destruction behavior.
///
/// 6
public virtual void OnDestroy()
@@ -49,3 +53,4 @@ public virtual void OnDestroy()
}
}
}
+
diff --git a/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/WidgetComponent.cs b/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/WidgetComponent.cs
index 6f69360135a..a4e83f00b2f 100644
--- a/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/WidgetComponent.cs
+++ b/src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.Common/WidgetComponent.cs
@@ -19,41 +19,47 @@
namespace Tizen.Applications.ComponentBased.Common
{
///
- /// The class for showing UI module
+ /// Represents a base class for widget components in the component-based application model.
+ /// This class provides methods for handling the lifecycle and state of widget components.
///
/// 9
public abstract class WidgetComponent : BaseComponent
{
-
///
- /// Override this method to handle behavior when the component is launched.
+ /// Called when the widget component is created. Override this method to implement custom creation behavior.
///
- /// The width of the widget component instance
- /// The height of the widget component instance
- /// True if a service component is successfully created
+ /// The width of the widget component instance.
+ /// The height of the widget component instance.
+ ///
+ /// true if the widget component is successfully created; otherwise, false .
+ ///
/// 9
public abstract bool OnCreate(int width, int height);
///
- /// Override this method to create window. It will be called before OnCreate method.
+ /// Called to create the window for the widget. This method will be called before the method.
///
- /// The width of the widget window
- /// The height of the widget window
- /// Window object to use
+ /// The width of the widget window.
+ /// The height of the widget window.
+ ///
+ /// An object representing the window to use.
+ ///
/// 9
public abstract IWindowProxy CreateWindowInfo(int width, int height);
///
- /// Overrid this method if want to handle behavior when the component is started.
+ /// Called when the widget component is started. Override this method to handle start behavior.
///
- /// True if it was restarted
+ ///
+ /// true if the component was restarted; otherwise, false .
+ ///
/// 9
public virtual void OnStart(bool restarted)
{
}
///
- /// Override this method if you want to handle the behavior when the component is resumed.
+ /// Called when the widget component is resumed. Override this method to handle resume behavior.
///
/// 9
public virtual void OnResume()
@@ -61,7 +67,7 @@ public virtual void OnResume()
}
///
- /// Override this method if you want to handle the behavior when the component is paused.
+ /// Called when the widget component is paused. Override this method to handle pause behavior.
///
/// 9
public virtual void OnPause()
@@ -69,7 +75,7 @@ public virtual void OnPause()
}
///
- /// Override this method if you want to handle the behavior when the component is stopped.
+ /// Called when the widget component is stopped. Override this method to handle stop behavior.
///
/// 9
public virtual void OnStop()
@@ -77,9 +83,11 @@ public virtual void OnStop()
}
///
- /// Override this method if want to handle behavior when the component is destroyed.
+ /// Called when the widget component is destroyed. Override this method to handle destruction behavior.
///
- /// True if the instance is permanent
+ ///
+ /// true if the instance is permanent; otherwise, false .
+ ///
/// 9
public virtual void OnDestroy(bool permanent)
{
diff --git a/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs b/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs
index 44e6f7e6e19..46988c4ce1d 100644
--- a/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs
+++ b/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs
@@ -238,6 +238,21 @@ internal static class Notification
[DllImport(Libraries.Notification, EntryPoint = "notification_get_check_box")]
internal static extern NotificationError GetCheckBox(NotificationSafeHandle handle, out bool flag, out bool checkedValue);
+ /* apis for do not disturb app */
+ internal delegate void DisturbCallback(IntPtr userData);
+
+ [DllImport(Libraries.Notification, EntryPoint = "notification_register_do_not_disturb_app")]
+ internal static extern NotificationError RegisterDndApp(DisturbCallback cb, IntPtr userData);
+
+ [DllImport(Libraries.Notification, EntryPoint = "notification_unregister_do_not_disturb_app")]
+ internal static extern NotificationError UnRegisterDndApp();
+
+ [DllImport(Libraries.Notification, EntryPoint = "notification_set_pairing_type")]
+ internal static extern NotificationError SetPairingType(NotificationSafeHandle handle, bool pairing);
+
+ [DllImport(Libraries.Notification, EntryPoint = "notification_get_pairing_type")]
+ internal static extern NotificationError GetPairingType(NotificationSafeHandle handle, out bool pairing);
+
internal static NotificationError GetText(NotificationSafeHandle handle, NotificationText type, out string text)
{
NotificationError ret;
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/Notification.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/Notification.cs
index 019ea0a9a7e..dbe43211294 100755
--- a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/Notification.cs
+++ b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/Notification.cs
@@ -212,6 +212,9 @@ public int Count
[EditorBrowsable(EditorBrowsableState.Never)]
public bool CheckedValue { get; set; } = false;
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool PairingType { get; set; } = false;
+
///
/// Gets or sets NotificationSafeHandle.
///
@@ -525,7 +528,7 @@ internal Notification Build()
Bundle bundle = new Bundle(new SafeBundleHandle(extension, false));
foreach (string key in bundle.Keys)
{
- if (key.StartsWith("_NOTIFICATION_EXTENSION_EVENT_"))
+ if (key.StartsWith("_NOTIFICATION_EXTENSION_EVENT_") || key.StartsWith("_NOTIFICATION_TYPE_PAIRING_"))
continue;
SafeBundleHandle sbh;
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationBinder.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationBinder.cs
index b847e6917a3..750914b164e 100755
--- a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationBinder.cs
+++ b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationBinder.cs
@@ -62,6 +62,11 @@ internal static void BindObject(Notification notification)
{
Interop.Notification.SetCheckBox(notification.Handle, notification.CheckBox, notification.CheckedValue);
}
+
+ if (notification.PairingType == true)
+ {
+ Interop.Notification.SetPairingType(notification.Handle, notification.PairingType);
+ }
}
internal static void BindSafeHandle(Notification notification)
@@ -91,6 +96,7 @@ internal static void BindSafeHandle(Notification notification)
BindSafeHandleTag(notification);
BindSafeHandleAction(notification);
BindSafeHandleCheckBox(notification);
+ BindSafeHandlePairingType(notification);
}
private static void BindNotificationSafeHandle(Notification notification)
@@ -250,5 +256,18 @@ private static void BindSafeHandleCheckBox(Notification notification)
notification.CheckBox = checkbox;
notification.CheckedValue = checkedValue;
}
+
+ private static void BindSafeHandlePairingType(Notification notification)
+ {
+ NotificationError ret;
+ bool pairingType= false;
+
+ ret = Interop.Notification.GetPairingType(notification.Handle, out pairingType);
+ if (ret != NotificationError.None) {
+ Log.Error(Notification.LogTag, "Failed to get paring type info");
+ }
+
+ notification.PairingType = pairingType;
+ }
}
}
diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationManager.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationManager.cs
index aadca4ec6b9..2474f7b97a0 100644
--- a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationManager.cs
+++ b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationManager.cs
@@ -29,6 +29,10 @@ public static class NotificationManager
private static Interop.Notification.ResponseEventCallback responseEventCallback;
+ // for disturb app
+ private static event EventHandler ResponseDisturbHandler;
+ private static Interop.Notification.DisturbCallback disturbCallback;
+
private static void ResponseEventCallback(IntPtr ptr, int type, IntPtr userData)
{
IntPtr cloned;
@@ -48,6 +52,12 @@ private static void ResponseEventCallback(IntPtr ptr, int type, IntPtr userData)
ResponseEventHandler?.Invoke(null, eventArgs);
}
+ // for disturb app
+ private static void DisturbCallback(IntPtr userData)
+ {
+ ResponseDisturbHandler?.Invoke(null, EventArgs.Empty);
+ }
+
///
/// The event handler for receiving a response event from the notification viewers
///
@@ -559,5 +569,56 @@ public static Notification MakeNotification(NotificationSafeHandle handle)
return notification;
}
+
+ ///
+ /// The event handler to get
+ ///
+ /// 12
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static event EventHandler DisturbReceived
+ {
+ add
+ {
+ if (disturbCallback == null)
+ {
+ disturbCallback = new Interop.Notification.DisturbCallback(DisturbCallback);
+ }
+
+ ResponseDisturbHandler += value;
+ }
+
+ remove
+ {
+ if (ResponseDisturbHandler != null && ResponseDisturbHandler.GetInvocationList().Length > 0)
+ {
+ NotificationError ret = Interop.Notification.UnRegisterDndApp();
+ if (ret != NotificationError.None)
+ {
+ throw NotificationErrorFactory.GetException(ret, "register do not disturb app failed");
+ }
+
+ ResponseDisturbHandler -= value;
+ }
+ }
+ }
+
+ ///
+ /// Register do not disturb app
+ ///
+ /// 12
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void RegisterDoNotDisturbApp()
+ {
+ if (ResponseDisturbHandler != null && ResponseDisturbHandler.GetInvocationList().Length > 0)
+ {
+ NotificationError ret = Interop.Notification.RegisterDndApp(disturbCallback, IntPtr.Zero);
+ if (ret != NotificationError.None)
+ {
+ throw NotificationErrorFactory.GetException(ret, "register do not disturb app failed");
+ }
+ } else {
+ throw NotificationErrorFactory.GetException(NotificationError.InvalidOperation, "Disturb callback not exist");
+ }
+ }
}
}
diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsBinder.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsBinder.cs
index 7fb9d7238cc..1156f866b10 100755
--- a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsBinder.cs
+++ b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsBinder.cs
@@ -172,7 +172,7 @@ internal static NotificationEventArgs BindObject(IntPtr notification, bool data)
Bundle bundle = new Bundle(new SafeBundleHandle(extension, false));
foreach (string key in bundle.Keys)
{
- if (key.StartsWith("_NOTIFICATION_EXTENSION_EVENT_"))
+ if (key.StartsWith("_NOTIFICATION_EXTENSION_EVENT_") || key.StartsWith("_NOTIFICATION_TYPE_PAIRING_"))
continue;
SafeBundleHandle sbh;
diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs
index 9f01052a4db..4c7f7932128 100755
--- a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs
+++ b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs
@@ -59,6 +59,30 @@ public static class PackageManager
/// Event type of the request.
/// Current event state of the request.
/// Progress for the request being processed by the package manager (in percent).
+ ///
+ /// The RequestEventCallback function provides information about the current status of a package request. It is called every time there is an update in the package request process. By monitoring the arguments passed to this function, you can keep track of the progress and events related to the package request.
+ ///
+ ///
+ ///
+ /// private static void OnRequestEventCallback(string type, string packageId, PackageEventType eventType, PackageEventState eventState, int progress)
+ /// {
+ /// switch (eventType)
+ /// {
+ /// case PackageEventType.Installing:
+ /// Console.WriteLine($"Package '{packageId}' is currently installing.");
+ /// break;
+ /// case PackageEventType.Updating:
+ /// Console.WriteLine($"Package '{packageId}' is currently updating.");
+ /// break;
+ /// case PackageEventType.Removing:
+ /// Console.WriteLine($"Package '{packageId}' is currently removing.");
+ /// break;
+ /// default:
+ /// throw new ArgumentException($"Unknown event type: {eventType}");
+ /// }
+ /// }
+ ///
+ ///
/// 3
public delegate void RequestEventCallback(string type, string packageId, PackageEventType eventType, PackageEventState eventState, int progress);
@@ -72,9 +96,9 @@ public static class PackageManager
private delegate Interop.PackageManager.ErrorCode InstallPackagesMethod(SafePackageManagerRequestHandle requestHandle, string[] pkgPaths, int pathsCount, out int requestID);
///
- /// InstallProgressChanged event. This event occurs when a package is getting installed and the progress of the request to the package manager is changed.
+ /// InstallProgressChanged event. Occurs when a package is being installed and the progress of the request to the package manager changes.
///
- /// Thrown when subscribing to package manager event failed.
+ /// Thrown when subscribing to package manager event fails.
/// 3
public static event EventHandler InstallProgressChanged
{
@@ -122,7 +146,7 @@ public static event EventHandler UninstallProgressChang
UnregisterPackageManagerEventIfNeeded();
UnsetPackageManagerEventStatus();
}
- }
+ }
}
///
@@ -286,8 +310,8 @@ private static SafePackageManagerHandle Handle
///
/// The ID of the application.
/// Returns the ID of the package.
- /// It returns null if the input is null.
- /// Thrown when input application ID does not exist.
+ /// If the input is null, it returns null.
+ /// Thrown when the input application ID does not exist.
/// Thrown when there is not enough memory to continue the execution of the method.
/// Thrown when an application does not have the privilege to access this method.
/// http://tizen.org/privilege/packagemanager.info
@@ -346,6 +370,10 @@ public static void ClearCacheDirectory(string packageId)
///
/// Clears all the application's internal and external cache directories.
///
+ ///
+ /// This method clears both the internal and external cache directories of the application. It ensures that any cached files are removed from the device storage.
+ /// By calling this method, you can free up valuable space on the device and improve its performance. However, note that this operation may take some time depending on the amount of cached data present in the directories.
+ ///
/// Thrown when there is not enough memory to continue the execution of the method.
/// Thrown when the method fails due to an internal IO error.
/// Thrown when an application does not have the privilege to access this method.
@@ -368,13 +396,13 @@ public static void ClearAllCacheDirectory()
///
///
/// All files under data, shared/data, and shared/trusted in the internal storage are removed.
- /// And, if the external storage exists, then all files under data and shared/trusted in the external storage are removed.
+ /// And, if the external storage exists, then all files under data and shared/trusted in the external storage are also removed.
///
/// ID of the package.
/// Thrown when there is not enough memory to continue the execution of the method.
- /// Thrown when the method failed due to an internal IO error.
- /// Thrown when an application does not have the privilege to access this method.
- /// Thrown when the method failed due to an internal system error.
+ /// Thrown when the method fails due to an internal IO error.
+ /// Thrown when an application does not have the required privileges to access this method.
+ /// Thrown when the method fails due to an internal system error.
/// http://tizen.org/privilege/packagemanager.admin
/// platform
/// 3
@@ -533,10 +561,9 @@ public static async Task GetTotalSizeInformationAsync()
///
/// Absolute path for the package to be installed.
/// Optional parameter to indicate special installation mode.
- /// Returns true if the installation request is successful, otherwise false.
+ /// True if the installation request is successful, otherwise false.
///
- /// The 'true' means that the request for installation is successful.
- /// To check the result of the installation, the caller should check the progress using the InstallProgressChanged event.
+ /// True indicates that the installation request was successful. However, to determine whether the actual installation was completed successfully, the caller must monitor the progress by subscribing to the InstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -554,8 +581,7 @@ public static bool Install(string packagePath, InstallationMode installMode = In
/// Optional parameter to indicate special installation mode.
/// Returns true if installation request is successful, false otherwise.
///
- /// The 'true' means that the request for installation is successful.
- /// To check the result of installation, the caller should check the progress using the InstallProgressChanged event or eventCallback.
+ /// True indicates that the installation request was successful. However, to determine whether the actual installation was completed successfully, the caller must monitor the progress by subscribing to the InstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -573,8 +599,7 @@ public static bool Install(string packagePath, RequestEventCallback eventCallbac
/// Optional parameter to indicate special installation mode.
/// Returns true if installation request is successful, false otherwise.
///
- /// The 'true' means that the request for installation is successful.
- /// To check the result of installation, the caller should check the progress using the InstallProgressChanged event.
+ /// True indicates that the installation request was successful. However, to determine whether the actual installation was completed successfully, the caller must monitor the progress by subscribing to the InstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -592,8 +617,7 @@ public static bool Install(string packagePath, PackageType type, InstallationMod
/// Optional parameter to indicate special installation mode.
/// Returns true if installation request is successful, false otherwise.
///
- /// The 'true' means that the request for installation is successful.
- /// To check the result of installation, the caller should check the progress using the InstallProgressChanged event.
+ /// True indicates that the installation request was successful. However, to determine whether the actual installation was completed successfully, the caller must monitor the progress by subscribing to the InstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -612,8 +636,7 @@ public static bool Install(string packagePath, string expansionPackagePath, Inst
/// Optional parameter to indicate special installation mode.
/// Returns true if installation request is successful, false otherwise.
///
- /// The 'true' means that the request for installation is successful.
- /// To check the result of installation, the caller should check the progress using the InstallProgressChanged event or eventCallback.
+ /// True indicates that the installation request was successful. However, to determine whether the actual installation was completed successfully, the caller must monitor the progress by subscribing to the InstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -632,8 +655,7 @@ public static bool Install(string packagePath, PackageType type, RequestEventCal
/// Optional parameter to indicate special installation mode.
/// Returns true if installation request is successful, false otherwise.
///
- /// The 'true' means that the request for installation is successful.
- /// To check the result of installation, the caller should check the progress using the InstallProgressChanged event or eventCallback.
+ /// True indicates that the installation request was successful. However, to determine whether the actual installation was completed successfully, the caller must monitor the progress by subscribing to the InstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -652,8 +674,7 @@ public static bool Install(string packagePath, string expansionPackagePath, Requ
/// Optional parameter to indicate special installation mode.
/// Returns true if installation request is successful, false otherwise.
///
- /// The 'true' means that the request for installation is successful.
- /// To check the result of installation, the caller should check the progress using the InstallProgressChanged event.
+ /// True indicates that the installation request was successful. However, to determine whether the actual installation was completed successfully, the caller must monitor the progress by subscribing to the InstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -673,8 +694,7 @@ public static bool Install(string packagePath, string expansionPackagePath, Pack
/// Optional parameter to indicate special installation mode.
/// Returns true if installation request is successful, false otherwise.
///
- /// The 'true' means that the request for installation is successful.
- /// To check the result of installation, the caller should check the progress using the InstallProgressChanged event or eventCallback.
+ /// True indicates that the installation request was successful. However, to determine whether the actual installation was completed successfully, the caller must monitor the progress by subscribing to the InstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -691,8 +711,7 @@ public static bool Install(string packagePath, string expansionPackagePath, Pack
/// Optional parameter to indicate special installation mode.
/// Returns true if installation request is successful, false otherwise.
///
- /// The 'true' means that the request for installation is successful.
- /// To check the result of installation, the caller should check the progress using the InstallProgressChanged event or eventCallback.
+ /// True indicates that the installation request was successful. However, to determine whether the actual installation was completed successfully, the caller must monitor the progress by subscribing to the InstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -710,8 +729,7 @@ public static bool Install(List packagePaths, InstallationMode installMo
/// Optional parameter to indicate special installation mode.
/// Returns true if installation request is successful, false otherwise.
///
- /// The 'true' means that the request for installation is successful.
- /// To check the result of installation, the caller should check the progress using the InstallProgressChanged event or eventCallback.
+ /// True indicates that the installation request was successful. However, to determine whether the actual installation was completed successfully, the caller must monitor the progress by subscribing to the InstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -878,8 +896,7 @@ private static bool InstallInternal(List packagePaths, string expansionP
/// ID of the package to be uninstalled.
/// Returns true if the uninstallation request is successful, false otherwise.
///
- /// The 'true' means that the request for uninstallation is successful.
- /// To check the result of uninstallation, the caller should check the progress using the UninstallProgressChanged event.
+ /// The return value 'true' indicates that the uninstallation request was successfully made. However, in order to determine whether the actual uninstallation process completed without any errors, the caller needs to monitor the progress through the UninstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -896,8 +913,7 @@ public static bool Uninstall(string packageId)
/// Optional - Package type for the package to be uninstalled.
/// Returns true if the uninstallation request is successful, false otherwise.
///
- /// The 'true' means that the request for uninstallation is successful.
- /// To check the result of uninstallation, the caller should check the progress using the UninstallProgressChanged event.
+ /// The return value 'true' indicates that the uninstallation request was successfully made. However, in order to determine whether the actual uninstallation process completed without any errors, the caller needs to monitor the progress through the UninstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -914,8 +930,7 @@ public static bool Uninstall(string packageId, PackageType type)
/// Optional - The event callback will be invoked only for the current request.
/// Returns true if the uninstallation request is successful, false otherwise.
///
- /// The 'true' means that the request for uninstallation is successful.
- /// To check the result of uninstallation, the caller should check the progress using the UninstallProgressChanged event or eventCallback.
+ /// The return value 'true' indicates that the uninstallation request was successfully made. However, in order to determine whether the actual uninstallation process completed without any errors, the caller needs to monitor the progress through the UninstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -933,8 +948,7 @@ public static bool Uninstall(string packageId, RequestEventCallback eventCallbac
/// Optional - The event callback will be invoked only for the current request.
/// Returns true if the uninstallation request is successful, false otherwise.
///
- /// The 'true' means that the request for uninstallation is successful.
- /// To check the result of uninstallation, the caller should check the progress using the UninstallProgressChanged event or eventCallback.
+ /// The return value 'true' indicates that the uninstallation request was successfully made. However, in order to determine whether the actual uninstallation process completed without any errors, the caller needs to monitor the progress through the UninstallProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -1005,8 +1019,8 @@ public static bool Uninstall(string packageId, PackageType type, RequestEventCal
/// Storage package should be moved to.
/// Returns true if the move request is successful, false otherwise.
///
- /// The 'true' means that the request for move is successful.
- /// To check the result of move, the caller should check the progress using the MoveProgressChanged event.
+ /// The return value 'true' indicates that the move request was successfully made.
+ /// To determine whether the actual move operation completed successfully, the caller needs to monitor the progress by handling the MoveProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -1024,8 +1038,8 @@ public static bool Move(string packageId, StorageType newStorage)
/// Storage package should be moved to.
/// Returns true if the move request is successful, false otherwise.
///
- /// The 'true' means that the request for move is successful.
- /// To check the result of move, the caller should check the progress using the MoveProgressChanged event.
+ /// The return value 'true' indicates that the move request was successfully made.
+ /// To determine whether the actual move operation completed successfully, the caller needs to monitor the progress by handling the MoveProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -1043,8 +1057,8 @@ public static bool Move(string packageId, PackageType type, StorageType newStora
/// Optional - The event callback will be invoked only for the current request.
/// Returns true if move request is successful, false otherwise.
///
- /// The 'true' means that the request for move is successful.
- /// To check the result of move, the caller should check the progress using the MoveProgressChanged event.
+ /// The return value 'true' indicates that the move request was successfully made.
+ /// To determine whether the actual move operation completed successfully, the caller needs to monitor the progress by handling the MoveProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
@@ -1063,8 +1077,8 @@ public static bool Move(string packageId, StorageType newStorage, RequestEventCa
/// Optional - The event callback will be invoked only for the current request.
/// Returns true if move request is successful, false otherwise.
///
- /// The 'true' means that the request for move is successful.
- /// To check the result of move, the caller should check the progress using the MoveProgressChanged event.
+ /// The return value 'true' indicates that the move request was successfully made.
+ /// To determine whether the actual move operation completed successfully, the caller needs to monitor the progress by handling the MoveProgressChanged event.
///
/// http://tizen.org/privilege/packagemanager.admin
/// platform
diff --git a/src/Tizen.Applications.Preference/Tizen.Applications/Preference.cs b/src/Tizen.Applications.Preference/Tizen.Applications/Preference.cs
index fd5bbc4ef61..99b9280fa22 100755
--- a/src/Tizen.Applications.Preference/Tizen.Applications/Preference.cs
+++ b/src/Tizen.Applications.Preference/Tizen.Applications/Preference.cs
@@ -21,8 +21,8 @@
namespace Tizen.Applications
{
///
- /// The preference class provides APIs to store and retrieve an application specific data/preference. A preference is saved in the form of a key-value pair.
- /// Keys are always text strings and the value can be any one of the four types: integer, double, string, and boolean.
+ /// The Preference class provides methods to store and retrieve application specific data/preferences. Preferences are stored in the form of key-value pairs.
+ /// Key names must be text strings while values can be integers, doubles, strings, or booleans.
///
/// 3
public static class Preference
@@ -136,6 +136,9 @@ public static WeakReference GetEventContext(string key)
/// True if the key exists in the preference, otherwise false.
/// Thrown if the key is an invalid parameter.
/// Thrown when the method failed due to an internal I/O error.
+ ///
+ /// This method checks if the specified key exists in the preferences. It returns true if the key exists, and false if not. The key argument should be a valid parameter. An ArgumentException will be thrown if the key is invalid. Additionally, an IOException may be thrown if the method fails due to an internal input/output error.
+ ///
///
///
/// Preference.Set("active_user", "Joe");
@@ -166,18 +169,18 @@ public static bool Contains(string key)
///
///
/// If the key already exists in the preference, the old value will be overwritten with a new value.
- /// Data types for supported values are: integer, double, string, and bool.
+ /// Supported value data types include integers, doubles, strings, and booleans.
///
/// The name of the key to create/modify.
/// The value corresponding to the key.
/// Thrown if the key is an invalid parameter.
- /// Thrown when the method failed due to an internal I/O error.
+ /// Thrown when the method fails due to an internal I/O error.
///
///
/// Preference.Set("Option_enabled", true);
/// Preference.Set("active_user", "Joe");
/// Preference.Set("default_volume", 10);
- /// Preference.Set("brightness", "0.6");
+ /// Preference.Set("brightness", 0.6);
///
///
/// 3
@@ -362,7 +365,7 @@ private static void DisallowChangeNotifications(string key)
}
///
- /// The class manages event handlers of the preference keys. The class enables having event handlers for individual preference keys.
+ /// The class manages event handlers of the preference keys. It provides functionality to have event handlers for individual preference keys.
///
/// 3
public class EventContext
@@ -377,14 +380,20 @@ internal EventContext(string key)
///
/// Occurs whenever there is a change in the value of a preference key.
///
+ ///
+ /// This event is raised whenever the value of a preference key changes. It provides information about the changed key through the PreferenceChangedEventArgs argument.
+ /// The Changed event can be used to keep track of any modifications made to preferences during runtime.
+ ///
/// Thrown when the key does not exist or when there is an invalid parameter.
/// Thrown when the bundle instance has been disposed.
///
+ /// In this example, we show how to handle the Changed event by printing out the key that was modified. We also demonstrate how to subscribe and unsubscribe from the event.
///
/// private static void Preference_PreferenceChanged(object sender, PreferenceChangedEventArgs e)
/// {
/// Console.WriteLine("key {0}", e.Key);
/// }
+ ///
/// Preference.EventContext context = null;
/// Preference.GetEventContext("active_user").TryGetTarget(out context);
/// if(context != null)
diff --git a/src/Tizen.Applications.Preference/Tizen.Applications/PreferenceChangedEventArgs.cs b/src/Tizen.Applications.Preference/Tizen.Applications/PreferenceChangedEventArgs.cs
index cb3db24bbfa..e4b12ded3f4 100755
--- a/src/Tizen.Applications.Preference/Tizen.Applications/PreferenceChangedEventArgs.cs
+++ b/src/Tizen.Applications.Preference/Tizen.Applications/PreferenceChangedEventArgs.cs
@@ -19,7 +19,7 @@
namespace Tizen.Applications
{
///
- /// This class is an event argument of the PreferenceChanged event.
+ /// This class represents the event arguments for the PreferenceChanged event.
///
/// 3
public class PreferenceChangedEventArgs : EventArgs
diff --git a/src/Tizen.Applications.Service/Tizen.Applications/ServiceApplication.cs b/src/Tizen.Applications.Service/Tizen.Applications/ServiceApplication.cs
index 91babc5fe9e..428225acd86 100755
--- a/src/Tizen.Applications.Service/Tizen.Applications/ServiceApplication.cs
+++ b/src/Tizen.Applications.Service/Tizen.Applications/ServiceApplication.cs
@@ -48,6 +48,9 @@ public override void Run(string[] args)
///
/// Exits the main loop of the application without restarting.
///
+ ///
+ /// This function terminates the current execution of the application by exiting its main loop. It does not trigger the app restart request.
+ ///
/// 10
[EditorBrowsable(EditorBrowsableState.Never)]
public void ExitWithoutRestarting()
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut.csproj b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut.csproj
old mode 100644
new mode 100755
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/HomeShortcutInfo.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/HomeShortcutInfo.cs
index 5a344c372ba..c4e52328b5e 100755
--- a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/HomeShortcutInfo.cs
+++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/HomeShortcutInfo.cs
@@ -16,16 +16,20 @@
namespace Tizen.Applications.Shortcut
{
+ using System;
+
///
/// A class that contains the shortcut information.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class HomeShortcutInfo : ShortcutInfo
{
///
/// Gets or sets the specific information delivered to the viewer for creating a shortcut.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string Uri { get; set; } = string.Empty;
}
}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutEnumerations.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutEnumerations.cs
index e735cfd1827..0fd5adfb431 100755
--- a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutEnumerations.cs
+++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutEnumerations.cs
@@ -16,10 +16,13 @@
namespace Tizen.Applications.Shortcut
{
+ using System;
+
///
/// Enumeration for the sizes of the shortcut widget.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public enum ShortcutWidgetSize
{
///
@@ -96,6 +99,7 @@ public enum ShortcutWidgetSize
///
/// Enumeration for the shortcut types.
///
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
internal enum ShortcutType
{
///
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutInfo.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutInfo.cs
index 5d95b2f4b87..3351c2224f1 100755
--- a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutInfo.cs
+++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutInfo.cs
@@ -16,28 +16,34 @@
namespace Tizen.Applications.Shortcut
{
+ using System;
+
///
/// A class to get the information of the shortcut.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class ShortcutInfo
{
///
/// Gets or sets the name of the created shortcut icon.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string ShortcutName { get; set; } = string.Empty;
///
/// Gets or sets the absolute path of an icon file for this shortcut.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string IconPath { get; set; } = string.Empty;
///
/// Gets or sets a value indicating whether to allow or not allow duplication.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public bool IsAllowDuplicate { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutManager.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutManager.cs
index 5d3fd7ba0ac..f2be8aa5338 100755
--- a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutManager.cs
+++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/ShortcutManager.cs
@@ -22,6 +22,7 @@ namespace Tizen.Applications.Shortcut
/// This class provides some functions to add or delete a shortcut.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static class ShortcutManager
{
private const string LogTag = "Tizen.Applications.Shortcut";
@@ -38,6 +39,7 @@ public static class ShortcutManager
/// Thrown when the shortcut is not supported.
/// Thrown in case of out of memory.
/// Thrown in case of any internal error.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static void Add(HomeShortcutInfo shortcut)
{
Interop.Shortcut.ErrorCode err = Interop.Shortcut.ErrorCode.None;
@@ -79,6 +81,7 @@ public static void Add(HomeShortcutInfo shortcut)
/// Thrown when the shortcut is not supported.
/// Thrown in case of out of memory.
/// Thrown in case of any internal error.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static void Add(WidgetShortcutInfo shortcut)
{
Interop.Shortcut.ErrorCode err = Interop.Shortcut.ErrorCode.None;
@@ -114,6 +117,7 @@ public static void Add(WidgetShortcutInfo shortcut)
/// Thrown when the shortcut is not supported.
/// Thrown in case of out of memory.
/// Thrown in case of any internal error.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static void Delete(string shortcutName)
{
Interop.Shortcut.ErrorCode err = Interop.Shortcut.ErrorCode.None;
@@ -149,6 +153,7 @@ public static void Delete(string shortcutName)
/// Thrown when the shortcut is not supported.
/// Thrown in case of out of memory.
/// Thrown in case of any internal error.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static void Delete(ShortcutInfo shortcut)
{
if (shortcut == null)
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/WidgetShortcutInfo.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/WidgetShortcutInfo.cs
index 1e0d6052574..549944844ea 100755
--- a/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/WidgetShortcutInfo.cs
+++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.Shortcut/WidgetShortcutInfo.cs
@@ -16,28 +16,34 @@
namespace Tizen.Applications.Shortcut
{
+ using System;
+
///
/// A class that contains the information about the widget.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class WidgetShortcutInfo : ShortcutInfo
{
///
/// Gets or sets the widget ID.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string WidgetId { get; set; } = string.Empty;
///
/// Gets or sets the size of the widget.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public ShortcutWidgetSize WidgetSize { get; set; }
///
/// Gets or sets the update period in seconds.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public double Period { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/HomeShortcutAddedInfo.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/HomeShortcutAddedInfo.cs
index df1fe96c846..0e41bd067a8 100755
--- a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/HomeShortcutAddedInfo.cs
+++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/HomeShortcutAddedInfo.cs
@@ -16,22 +16,27 @@
namespace Tizen.Applications.Shortcut
{
+ using System;
+
///
/// A class that contains the shortcut information.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class HomeShortcutAddedInfo : ShortcutAddedInfo
{
///
/// Gets the name of the application.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string AppId { get; internal set; }
///
/// Gets the specific information for creating a new shortcut.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string Uri { get; internal set; }
}
}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutAddedInfo.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutAddedInfo.cs
index 6eced613f5a..63955c6c881 100755
--- a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutAddedInfo.cs
+++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutAddedInfo.cs
@@ -16,28 +16,34 @@
namespace Tizen.Applications.Shortcut
{
+ using System;
+
///
/// A class for getting the information of the shortcut.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class ShortcutAddedInfo
{
///
/// Gets the name of the created shortcut icon.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string ShortcutName { get; internal set; }
///
/// Gets the absolute path of an icon file for this shortcut.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string IconPath { get; internal set; }
///
/// Gets a value indicating whether to allow or not to allow duplication.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public bool IsAllowDuplicate { get; internal set; }
}
}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutDeletedInfo.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutDeletedInfo.cs
index dec0ec750d7..aa4ddb675c8 100755
--- a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutDeletedInfo.cs
+++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutDeletedInfo.cs
@@ -16,22 +16,27 @@
namespace Tizen.Applications.Shortcut
{
+ using System;
+
///
/// A class for getting the information of the shortcut.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class ShortcutDeletedInfo
{
///
/// Gets the name of the package.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string AppId { get; internal set; }
///
/// Gets the name of the created shortcut icon.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string ShortcutName { get; internal set; }
}
}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutEventEnumerations.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutEventEnumerations.cs
index 34d72ef7497..a0a18eb32d2 100755
--- a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutEventEnumerations.cs
+++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutEventEnumerations.cs
@@ -16,10 +16,13 @@
namespace Tizen.Applications.Shortcut
{
+ using System;
+
///
/// Enumeration for values of the shortcut response types.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public enum ShortcutError
{
///
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutEventManager.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutEventManager.cs
index 7e6c57a16a7..7e3e16dfb40 100755
--- a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutEventManager.cs
+++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutEventManager.cs
@@ -26,6 +26,7 @@ namespace Tizen.Applications.Shortcut
/// Object that contains the shortcut information to add.
/// The result of handling a shortcut add request.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public delegate ShortcutError ShortcutAdded(ShortcutAddedInfo args);
///
@@ -34,12 +35,14 @@ namespace Tizen.Applications.Shortcut
/// Object that contains the shortcut information to delete.
/// The result of handling a shortcut delete request.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public delegate ShortcutError ShortcutDeleted(ShortcutDeletedInfo args);
///
/// This class provides a way to register the callback function for the shortcut add and delete events.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static class ShortcutEventManager
{
private static Interop.Shortcut.AddCallback shortcutAddCallback;
@@ -67,6 +70,7 @@ public static class ShortcutEventManager
/// Thrown when the shortcut is not supported.
/// Thrown in case of out of memory.
/// Thrown in case of any internal error.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static void RegisterEventHandler(ShortcutAdded addedEvent)
{
if (shortcutAddCallback == null)
@@ -103,6 +107,7 @@ public static void RegisterEventHandler(ShortcutAdded addedEvent)
/// Thrown when the shortcut is not supported.
/// Thrown in case of out of memory.
/// Thrown in case of any internal error.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static void RegisterEventHandler(ShortcutDeleted deletedEvent)
{
if (shortcutDeleteCallback == null)
@@ -134,6 +139,7 @@ public static void RegisterEventHandler(ShortcutDeleted deletedEvent)
/// Thrown when an argument is invalid.
/// Thrown in case the permission is denied.
/// Thrown when the shortcut is not supported.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static void UnregisterEventHandler(ShortcutAdded addedEvent)
{
if (shortcutAdded != null && shortcutAdded.Equals(addedEvent))
@@ -168,6 +174,7 @@ public static void UnregisterEventHandler(ShortcutAdded addedEvent)
/// Thrown when an argument is invalid.
/// Thrown in case the permission is denied.
/// Thrown when the shortcut is not supported.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static void UnregisterEventHandler(ShortcutDeleted deletedEvent)
{
if (shortcutDeleted != null && shortcutDeleted.Equals(deletedEvent))
@@ -205,6 +212,7 @@ public static void UnregisterEventHandler(ShortcutDeleted deletedEvent)
/// Thrown when the shortcut is not supported.
/// Thrown in case of out of memory.
/// Thrown in case of any internal error.
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static IEnumerable GetTemplateList(string appId)
{
shortcutTemplates.Clear();
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutTemplate.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutTemplate.cs
index 0645e1457be..1b073d33e84 100755
--- a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutTemplate.cs
+++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/ShortcutTemplate.cs
@@ -16,40 +16,48 @@
namespace Tizen.Applications.Shortcut
{
+ using System;
+
///
/// A class that contains the preset list of the shortcut template from the installed package.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class ShortcutTemplate
{
///
/// Gets the application ID.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string AppId { get; internal set; }
///
/// Gets the name of the created shortcut icon.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string ShortcutName { get; internal set; }
///
/// Gets the absolute path of an icon file for this shortcut.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string IconPath { get; internal set; }
///
/// Gets the user data. A property of the shortcut element in the manifest file.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string ExtraKey { get; internal set; }
///
/// Gets the user data. A property of the shortcut element in the manifest file.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string ExtraData { get; internal set; }
}
}
\ No newline at end of file
diff --git a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/WidgetShortcutAddedInfo.cs b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/WidgetShortcutAddedInfo.cs
index 39892e72178..06e58fb28a8 100755
--- a/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/WidgetShortcutAddedInfo.cs
+++ b/src/Tizen.Applications.Shortcut/Tizen.Applications.ShortcutEvent/WidgetShortcutAddedInfo.cs
@@ -16,28 +16,34 @@
namespace Tizen.Applications.Shortcut
{
+ using System;
+
///
/// A class that contains the information about the widget.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class WidgetShortcutAddedInfo : ShortcutAddedInfo
{
///
/// Gets the widget ID.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string WidgetId { get; internal set; }
///
/// Gets the size of the widget.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public ShortcutWidgetSize WidgetSize { get; internal set; }
///
/// Gets the update period in seconds.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public double Period { get; internal set; }
}
}
\ No newline at end of file
diff --git a/src/Tizen.Applications.UI/Tizen.Applications/CoreUIApplication.cs b/src/Tizen.Applications.UI/Tizen.Applications/CoreUIApplication.cs
index 7fb0608a95b..948096e9410 100755
--- a/src/Tizen.Applications.UI/Tizen.Applications/CoreUIApplication.cs
+++ b/src/Tizen.Applications.UI/Tizen.Applications/CoreUIApplication.cs
@@ -23,7 +23,7 @@
namespace Tizen.Applications
{
///
- /// Represents an application that has an UI screen. The events for resuming and pausing are provided.
+ /// Represents an application that has an UI screen. It provides events for handling resume and pause actions.
///
/// 3
public class CoreUIApplication : CoreApplication
@@ -32,7 +32,7 @@ public class CoreUIApplication : CoreApplication
/// Initializes the CoreUIApplication class.
///
///
- /// The default backend for the UI application will be used.
+ /// By calling this constructor, the default backend for the UI application will be used.
///
/// 3
#pragma warning disable CA2000
@@ -45,9 +45,9 @@ public CoreUIApplication() : base(new UICoreBackend())
/// Initializes the CoreUIApplication class.
///
///
- /// If you want to change the backend, use this constructor.
+ /// This constructor is called if you need to modify the default behavior by providing a custom implementation of the ICoreBackend interface. By passing in your own backend instance, you can customize the application's functionality according to your requirements.
///
- /// The backend instance implementing the ICoreBacked interface.
+ /// The custom implementation of the ICoreBackend interface that provides customized functionalities.
/// 3
public CoreUIApplication(ICoreBackend backend) : base(backend)
{
@@ -91,7 +91,7 @@ public override void Run(string[] args)
}
///
- /// Overrides this method if you want to handle the behavior before calling OnCreate().
+ /// Overrides this method if you want to handle any specific actions before calling the OnCreate() method.
///
/// 3
protected virtual void OnPreCreate()
@@ -99,8 +99,8 @@ protected virtual void OnPreCreate()
}
///
- /// Overrides this method if you want to handle the behavior when the application is resumed.
- /// If base.OnResume() is not called, the event 'Resumed' will not be emitted.
+ /// Override this method to define the behavior when the application is resumed.
+ /// Calling base.OnResume() is required in order for the Resumed event to be raised.
///
/// 3
protected virtual void OnResume()
@@ -109,8 +109,8 @@ protected virtual void OnResume()
}
///
- /// Overrides this method if you want to handle the behavior when the application is paused.
- /// If base.OnPause() is not called, the event 'Paused' will not be emitted.
+ /// Override this method to define the behavior when the application is paused.
+ /// Calling base.OnPause() is required in order for the Paused event to be raised.
///
/// 3
protected virtual void OnPause()
@@ -122,7 +122,7 @@ protected virtual void OnPause()
/// Gets the window position of the application.
///
/// The window position.
- /// Thrown when there is no window position.
+ /// Thrown if there is no valid window position available.
/// 11
public WindowPosition GetWindowPosition()
{
diff --git a/src/Tizen.Content.MediaContent/Interop/Interop.MediaInfo.cs b/src/Tizen.Content.MediaContent/Interop/Interop.MediaInfo.cs
index deed1a6eed5..f0f5edafafb 100644
--- a/src/Tizen.Content.MediaContent/Interop/Interop.MediaInfo.cs
+++ b/src/Tizen.Content.MediaContent/Interop/Interop.MediaInfo.cs
@@ -54,11 +54,11 @@ internal static extern MediaContentError ForeachTags(string mediaId, FilterHandl
Common.ItemCallback callback, IntPtr userData = default); // Deprecated since API12
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_bookmark_count_from_db")]
- internal static extern MediaContentError GetBookmarkCount(string mediaId, FilterHandle filter, out int bookmarkCount);
+ internal static extern MediaContentError GetBookmarkCount(string mediaId, FilterHandle filter, out int bookmarkCount); // Deprecated since API12
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_foreach_bookmark_from_db")]
internal static extern MediaContentError ForeachBookmarks(string mediaId, FilterHandle filter,
- Common.ItemCallback callback, IntPtr userData = default);
+ Common.ItemCallback callback, IntPtr userData = default); // Deprecated since API12
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_face_count_from_db")]
internal static extern MediaContentError GetFaceCount(string mediaId, FilterHandle filter, out int bookmarkCount); // Deprecated
diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Bookmark.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Bookmark.cs
index 2da1b7ee598..db9b8687477 100644
--- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Bookmark.cs
+++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Bookmark.cs
@@ -23,6 +23,7 @@ namespace Tizen.Content.MediaContent
/// in media (video and audio) to enable fast searching.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class Bookmark
{
internal Bookmark(IntPtr handle)
@@ -38,6 +39,7 @@ internal Bookmark(IntPtr handle)
///
/// The ID of the bookmark.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int Id { get; }
///
@@ -45,6 +47,7 @@ internal Bookmark(IntPtr handle)
///
/// The thumbnail path of the bookmark.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string ThumbnailPath { get; }
///
@@ -52,6 +55,7 @@ internal Bookmark(IntPtr handle)
///
/// The offset of the bookmark in media in milliseconds.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int Offset { get; }
///
@@ -59,6 +63,7 @@ internal Bookmark(IntPtr handle)
///
/// The name of the bookmark.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string Name { get; }
internal static Bookmark FromHandle(IntPtr handle) => new Bookmark(handle);
@@ -68,6 +73,7 @@ internal Bookmark(IntPtr handle)
///
/// A string representation of the current bookmark.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public override string ToString() =>
$"Id={Id}, Name={Name}, ThumbnailPath={ThumbnailPath}, Offset={Offset}";
}
diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/BookmarkCommand.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/BookmarkCommand.cs
index 7037acc6048..9fb80815981 100644
--- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/BookmarkCommand.cs
+++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/BookmarkCommand.cs
@@ -23,6 +23,7 @@ namespace Tizen.Content.MediaContent
///
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class BookmarkCommand : MediaCommand
{
///
@@ -32,6 +33,7 @@ public class BookmarkCommand : MediaCommand
/// is null.
/// has already been disposed.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public BookmarkCommand(MediaDatabase database) : base(database)
{
}
@@ -44,6 +46,7 @@ public BookmarkCommand(MediaDatabase database) : base(database)
/// The has already been disposed.
/// An error occurred while executing the command.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int Count()
{
return Count(null);
@@ -58,6 +61,7 @@ public int Count()
/// The has already been disposed.
/// An error occurred while executing the command.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int Count(CountArguments arguments)
{
ValidateDatabase();
@@ -79,6 +83,7 @@ public int Count(CountArguments arguments)
/// is a zero-length string, contains only white space.
/// The caller has no required privilege.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public Bookmark Insert(string mediaId, int offset)
{
return Insert(mediaId, offset, null);
@@ -99,6 +104,7 @@ public Bookmark Insert(string mediaId, int offset)
/// is a zero-length string, contains only white space.
/// The caller has no required privilege.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public Bookmark Insert(string mediaId, int offset, string name)
{
return Insert(mediaId, offset, name, null);
@@ -123,6 +129,7 @@ public Bookmark Insert(string mediaId, int offset, string name)
/// is a zero-length string, contains only white space.
/// The caller has no required privilege.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public Bookmark Insert(string mediaId, int offset, string name, string thumbnailPath)
{
ValidateDatabase();
@@ -163,6 +170,7 @@ public Bookmark Insert(string mediaId, int offset, string name, string thumbnail
/// is less than zero.
/// The caller has no required privilege.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public bool Delete(int bookmarkId)
{
ValidateDatabase();
@@ -192,6 +200,7 @@ public bool Delete(int bookmarkId)
/// The has already been disposed.
/// An error occurred while executing the command.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public MediaDataReader Select()
{
return Select(null);
@@ -206,6 +215,7 @@ public MediaDataReader Select()
/// The has already been disposed.
/// An error occurred while executing the command.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public MediaDataReader Select(SelectArguments filter)
{
ValidateDatabase();
diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Columns.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Columns.cs
index 0baea5630c4..40036e5bad8 100644
--- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Columns.cs
+++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Columns.cs
@@ -465,6 +465,7 @@ public static class FolderColumns
///
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static class PlaylistColumns
{
///
@@ -476,6 +477,7 @@ public static class PlaylistColumns
///
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static string Name => "PLAYLIST_NAME";
///
@@ -487,6 +489,7 @@ public static class PlaylistColumns
///
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static string Id => "PLAYLIST_ID";
///
@@ -498,6 +501,7 @@ public static class PlaylistColumns
///
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static string MemberOrder => "PLAYLIST_MEMBER_ORDER";
///
@@ -510,6 +514,7 @@ public static class PlaylistColumns
///
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static string Count => "PLAYLIST_MEDIA_COUNT";
}
@@ -579,6 +584,7 @@ public static class TagColumns
///
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static class BookmarkColumns
{
///
@@ -590,6 +596,7 @@ public static class BookmarkColumns
///
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static string Offset => "BOOKMARK_MARKED_TIME";
///
@@ -601,6 +608,7 @@ public static class BookmarkColumns
///
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static string Id => "BOOKMARK_ID";
///
@@ -612,6 +620,7 @@ public static class BookmarkColumns
///
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public static string Name => "BOOKMARK_NAME";
}
diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs
index bafe885a953..6e470084b88 100644
--- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs
+++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs
@@ -53,6 +53,7 @@ public MediaInfoCommand(MediaDatabase database) : base(database)
/// is null.
/// is a zero-length string, contains only white space.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int CountBookmark(string mediaId)
{
return CountBookmark(mediaId, null);
@@ -70,6 +71,7 @@ public int CountBookmark(string mediaId)
/// is null.
/// is a zero-length string, contains only white space.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int CountBookmark(string mediaId, CountArguments arguments)
{
ValidateDatabase();
@@ -90,6 +92,7 @@ public int CountBookmark(string mediaId, CountArguments arguments)
/// is null.
/// is a zero-length string, contains only white space.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public MediaDataReader SelectBookmark(string mediaId)
{
return SelectBookmark(mediaId, null);
@@ -107,6 +110,7 @@ public MediaDataReader SelectBookmark(string mediaId)
/// is null.
/// is a zero-length string, contains only white space.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public MediaDataReader SelectBookmark(string mediaId, SelectArguments filter)
{
ValidateDatabase();
diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlayList.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlayList.cs
index a762611cd92..0bb39f454d4 100755
--- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlayList.cs
+++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlayList.cs
@@ -22,6 +22,7 @@ namespace Tizen.Content.MediaContent
/// Represents the playlist that is a group of media (usually songs).
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class Playlist
{
internal Playlist(IntPtr handle)
@@ -39,6 +40,7 @@ internal Playlist(IntPtr handle)
///
/// The unique ID of the playlist.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int Id { get; }
///
@@ -46,6 +48,7 @@ internal Playlist(IntPtr handle)
///
/// The name of the playlist.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string Name { get; }
///
@@ -53,6 +56,7 @@ internal Playlist(IntPtr handle)
///
/// The path to the thumbnail.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string ThumbnailPath { get; }
///
@@ -60,6 +64,7 @@ internal Playlist(IntPtr handle)
///
/// A string representation of the current playlist.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public override string ToString() =>
$"Id={Id}, Name={Name}, ThumbnailPath={ThumbnailPath}";
}
@@ -72,6 +77,7 @@ public override string ToString() =>
///
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class PlaylistUpdateValues
{
///
@@ -80,6 +86,7 @@ public class PlaylistUpdateValues
/// If the value is null, the update operation will have no effect on the field.
/// A string for name; the field will not be updated if null.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string Name { get; set; }
///
@@ -88,6 +95,7 @@ public class PlaylistUpdateValues
/// If the value is null, the update operation will have no effect on the field.
/// A string for the thumbnail path; the field will not be updated if null.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public string ThumbnailPath { get; set; }
}
@@ -95,6 +103,7 @@ public class PlaylistUpdateValues
/// Represents an order of a member of the playlist.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class PlayOrder
{
///
@@ -108,6 +117,7 @@ public class PlayOrder
/// is less than zero.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public PlayOrder(int memberId, int orderValue)
{
MemberId = memberId;
@@ -124,6 +134,7 @@ public PlayOrder(int memberId, int orderValue)
/// is less than or equal to zero.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int MemberId
{
get => _memberId;
@@ -148,6 +159,7 @@ public int MemberId
/// is less than zero.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int Value
{
get => _value;
diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlaylistCommand.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlaylistCommand.cs
index 226534d6f93..edf452efdba 100644
--- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlaylistCommand.cs
+++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlaylistCommand.cs
@@ -26,6 +26,7 @@ namespace Tizen.Content.MediaContent
///
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class PlaylistCommand : MediaCommand
{
///
@@ -35,6 +36,7 @@ public class PlaylistCommand : MediaCommand
/// is null.
/// has already been disposed.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public PlaylistCommand(MediaDatabase database) : base(database)
{
}
@@ -47,6 +49,7 @@ public PlaylistCommand(MediaDatabase database) : base(database)
/// The has already been disposed.
/// An error occurred while executing the command.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int Count()
{
return Count(null);
@@ -61,6 +64,7 @@ public int Count()
/// The has already been disposed.
/// An error occurred while executing the command.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int Count(CountArguments arguments)
{
ValidateDatabase();
@@ -83,6 +87,7 @@ public int Count(CountArguments arguments)
/// is less than or equal to zero.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int GetPlayOrder(int playlistId, int memberId)
{
ValidateDatabase();
@@ -116,6 +121,7 @@ public int GetPlayOrder(int playlistId, int memberId)
/// is less than or equal to zero.
/// The caller has no required privilege.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public bool Delete(int playlistId)
{
ValidateDatabase();
@@ -164,6 +170,7 @@ public bool Delete(int playlistId)
/// does not exists.
/// The caller has no required privilege.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public Playlist InsertFromFile(string name, string path)
{
ValidateDatabase();
@@ -222,6 +229,7 @@ public Playlist InsertFromFile(string name, string path)
/// No matching playlist exists.
/// The caller has no required privilege.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public void ExportToFile(int playlistId, string path)
{
ValidateDatabase();
@@ -268,6 +276,7 @@ public void ExportToFile(int playlistId, string path)
/// is a zero-length string.
/// The caller has no required privilege.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public Playlist Insert(string name)
{
return Insert(name, null);
@@ -287,6 +296,7 @@ public Playlist Insert(string name)
/// is a zero-length string.
/// The caller has no required privilege.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public Playlist Insert(string name, string thumbnailPath)
{
ValidateDatabase();
@@ -333,6 +343,7 @@ public Playlist Insert(string name, string thumbnailPath)
/// The has already been disposed.
/// An error occurred while executing the command.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public MediaDataReader Select()
{
return Select(null);
@@ -347,6 +358,7 @@ public MediaDataReader Select()
/// The has already been disposed.
/// An error occurred while executing the command.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public MediaDataReader Select(SelectArguments filter)
{
ValidateDatabase();
@@ -365,6 +377,7 @@ public MediaDataReader Select(SelectArguments filter)
/// An error occurred while executing the command.
/// is less than or equal to zero.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public Playlist Select(int playlistId)
{
ValidateDatabase();
@@ -407,6 +420,7 @@ public Playlist Select(int playlistId)
/// An error occurred while executing the command.
/// is less than or equal to zero.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int CountMember(int playlistId)
{
return CountMember(playlistId, null);
@@ -423,6 +437,7 @@ public int CountMember(int playlistId)
/// An error occurred while executing the command.
/// is less than or equal to zero.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int CountMember(int playlistId, CountArguments arguments)
{
ValidateDatabase();
@@ -481,6 +496,7 @@ private static List GetMembers(int playlistId, SelectArguments a
/// is null.
/// is a zero-length string, contains only white space.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int GetMemberId(int playlistId, string mediaId)
{
ValidateDatabase();
@@ -512,6 +528,7 @@ public int GetMemberId(int playlistId, string mediaId)
/// An error occurred while executing the command.
/// is less than or equal to zero.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public MediaDataReader SelectMember(int playlistId)
{
return SelectMember(playlistId, null);
@@ -528,6 +545,7 @@ public MediaDataReader SelectMember(int playlistId)
/// An error occurred while executing the command.
/// is less than or equal to zero.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public MediaDataReader SelectMember(int playlistId, SelectArguments filter)
{
ValidateDatabase();
@@ -556,6 +574,7 @@ public MediaDataReader SelectMember(int playlistId, SelectArgume
/// is less than or equal to zero.
/// The caller has no required privilege.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public bool Update(int playlistId, PlaylistUpdateValues values)
{
ValidateDatabase();
@@ -617,6 +636,7 @@ public bool Update(int playlistId, PlaylistUpdateValues values)
/// is a zero-length string, contains only white space.
/// is less than or equal to zero.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public bool AddMember(int playlistId, string mediaId)
{
ValidationUtil.ValidateNotNullOrEmpty(mediaId, nameof(mediaId));
@@ -644,6 +664,7 @@ public bool AddMember(int playlistId, string mediaId)
///
/// is less than or equal to zero.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public bool AddMembers(int playlistId, IEnumerable mediaIds)
{
ValidateDatabase();
@@ -718,6 +739,7 @@ public bool AddMembers(int playlistId, IEnumerable mediaIds)
/// is less than or equal to zero.
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public bool RemoveMember(int playlistId, int memberId)
{
if (memberId <= 0)
@@ -747,6 +769,7 @@ public bool RemoveMember(int playlistId, int memberId)
///
/// is less than or equal to zero.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public bool RemoveMembers(int playlistId, IEnumerable memberIds)
{
ValidateDatabase();
@@ -814,6 +837,7 @@ public bool RemoveMembers(int playlistId, IEnumerable memberIds)
/// is null.
/// is less than or equal to zero.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public bool UpdatePlayOrder(int playlistId, PlayOrder playOrder)
{
if (playOrder == null)
@@ -841,6 +865,7 @@ public bool UpdatePlayOrder(int playlistId, PlayOrder playOrder)
///
/// is less than or equal to zero.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public bool UpdatePlayOrders(int playlistId, IEnumerable orders)
{
ValidateDatabase();
diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlaylistMember.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlaylistMember.cs
index 8ebf307ec72..35495f7273a 100644
--- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlaylistMember.cs
+++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlaylistMember.cs
@@ -14,12 +14,15 @@
* limitations under the License.
*/
+using System;
+
namespace Tizen.Content.MediaContent
{
///
/// Represents a member of the .
///
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public class PlaylistMember
{
///
@@ -27,6 +30,7 @@ public class PlaylistMember
///
/// The member ID of the playlist.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public int MemberId { get; }
///
@@ -34,6 +38,7 @@ public class PlaylistMember
///
/// The of the member.
/// 4
+ [Obsolete("Deprecated since API12. Will be removed in API14.")]
public MediaInfo MediaInfo { get; }
internal PlaylistMember(int memberId, MediaInfo mediaInfo)
diff --git a/src/Tizen.Content.MimeType/Tizen.Content.MimeType/MimeUtil.cs b/src/Tizen.Content.MimeType/Tizen.Content.MimeType/MimeUtil.cs
index 02e45a37ab7..16d0a332501 100644
--- a/src/Tizen.Content.MimeType/Tizen.Content.MimeType/MimeUtil.cs
+++ b/src/Tizen.Content.MimeType/Tizen.Content.MimeType/MimeUtil.cs
@@ -32,10 +32,11 @@ namespace Tizen.Content.MimeType
public static class MimeUtil
{
///
- /// Gets the MIME type for the given file extension.
- /// The MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats.
+ /// Retrieves the MIME type for the specified file extension.
+ /// If no specific file format is associated with the given file extension, the default MIME type 'application/octet-stream' is returned.
///
- /// The file extension.
+ /// The file extension for which the MIME type needs to be retrieved.
+ /// The MIME type for the specified file extension.
///
///
/// string mimeType = MimeUtil.GetMimeType("png");
@@ -54,19 +55,22 @@ public static string GetMimeType(string fileExtension)
}
///
- /// Gets the file extensions for the given MIME type.
+ /// Retrieves the file extensions associated with the specified MIME type.
///
- ///
- /// If successful, returns the list of file extension strings for the given MIME type.
- /// The array of file extension is without the leading dot ('.').
- ///
- /// The MIME type.
+ ///
+ /// By calling this function with a specific MIME type argument, you can obtain a list of file extensions related to that MIME type.
+ /// These file extensions are returned without the leading period ('.') character.
+ ///
+ /// The MIME type for which you want to retrieve the associated file extensions.
+ /// An enumerable collection of file extension strings for the specified MIME type.
///
+ /// In the following code snippet, we demonstrate how to utilize the GetFileExtension method by retrieving the file extensions associated with the video/mpeg MIME type:
+ ///
///
- /// var extColl = MimeUtil.GetFileExtension("video/mpeg");
- /// foreach ( string obj in extColl )
+ /// var fileExtensions = MimeUtil.GetFileExtension("video/mpeg");
+ /// foreach (var extension in fileExtensions)
/// {
- /// Console.WriteLine(obj);
+ /// Console.WriteLine(extension);
/// }
///
///
diff --git a/src/Tizen.AIAvatar/src/Extensions/AvatarScene.cs b/src/Tizen.Core/Interop/Interop.Libraries.cs
similarity index 56%
rename from src/Tizen.AIAvatar/src/Extensions/AvatarScene.cs
rename to src/Tizen.Core/Interop/Interop.Libraries.cs
index 4f498b34e27..1280560ce0c 100644
--- a/src/Tizen.AIAvatar/src/Extensions/AvatarScene.cs
+++ b/src/Tizen.Core/Interop/Interop.Libraries.cs
@@ -1,25 +1,23 @@
/*
- * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
*
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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,
+ * 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 Tizen.NUI.Scene3D;
-
-namespace Tizen.AIAvatar
+internal static partial class Interop
{
- internal class AvatarScene : SceneView
+ internal static partial class Libraries
{
+ public const string TizenCore = "libtizen-core.so.0";
}
}
diff --git a/src/Tizen.Core/Interop/Interop.TizenCore.cs b/src/Tizen.Core/Interop/Interop.TizenCore.cs
new file mode 100644
index 00000000000..80a1fea238c
--- /dev/null
+++ b/src/Tizen.Core/Interop/Interop.TizenCore.cs
@@ -0,0 +1,331 @@
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+using Tizen;
+using Tizen.Internals.Errors;
+
+internal static partial class Interop
+{
+ internal static partial class LibTizenCore
+ {
+ internal enum ErrorCode
+ {
+ None = Tizen.Internals.Errors.ErrorCode.None,
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+ InvalidContext = -0x01100000 | 0x01,
+ }
+
+ internal enum Priority
+ {
+ High = -100,
+ Default = 0,
+ HighIdle = 100,
+ DefaultIdle = 200,
+ Low = 300,
+ }
+
+ internal enum PollEvent
+ {
+ In = 0x0001,
+ Pri = 0x0002,
+ Out = 0x0004,
+ Err = 0x0008,
+ Hup = 0x0010,
+ Nval = 0x0020,
+ }
+
+ internal static partial class TizenCore
+ {
+ // typedef void (*tizen_core_channel_receive_cb)(tizen_core_channel_object_h object, void *user_data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ChannelReceiveCallback(IntPtr channelObject, IntPtr userData);
+
+ // typedef bool (*tizen_core_task_cb)(void *user_data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool TaskCallback(IntPtr userData);
+
+ // typedef bool (*tizen_core_source_prepare_cb)(tizen_core_source_h source, int *timeout, void *user_data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool SourcePrepareCallback(IntPtr source, out int timeout, IntPtr userData);
+
+ // typedef bool (*tizen_core_source_check_cb)(tizen_core_source_h source, void *user_data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool SourceCheckCallback(IntPtr source, IntPtr userData);
+
+ // typedef bool (*tizen_core_source_dispatch_cb)(tizen_core_source_h source, void *user_data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool SourceDispatchCallback(IntPtr source, IntPtr userData);
+
+ // typedef void (*tizen_core_source_finalize_cb)(tizen_core_source_h source, void *user_data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void SourceFinalizeCallback(IntPtr source, IntPtr userData);
+
+ // void tizen_core_init(void);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_init")]
+ internal static extern void Init();
+
+ // void tizen_core_shutdown(void);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_shutdown")]
+ internal static extern void Shutdown();
+
+ // bool tizen_core_ready(void);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_ready")]
+ internal static extern bool Ready();
+
+ // int tizen_core_task_create(const char *name, bool use_thread, tizen_core_task_h task);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_task_create")]
+ internal static extern ErrorCode TaskCreate(string name, bool useThread, out IntPtr handle);
+
+ // int tizen_core_task_destroy(tizen_core_task_h task);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_task_destroy")]
+ internal static extern ErrorCode TaskDestroy(IntPtr handle);
+
+ // int tizen_core_task_run(tizen_core_task_h task);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_task_run")]
+ internal static extern ErrorCode TaskRun(IntPtr handle);
+
+ // int tizen_core_task_is_running(tizen_core_task_h task, bool *running);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_task_is_running")]
+ internal static extern ErrorCode TaskIsRunning(IntPtr handle, out bool running);
+
+ // int tizen_core_task_quit(tizen_core_task_h task);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_task_quit")]
+ internal static extern ErrorCode TaskQuit(IntPtr handle);
+
+ // int tizen_core_task_get_tizen_core(tizen_core_task_h task, tizen_core_h *core);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_task_get_tizen_core")]
+ internal static extern ErrorCode TaskGetTizenCore(IntPtr handle, out IntPtr coreHandle);
+
+ // int tizen_core_find(const char *name, tizen_core_h *core);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_find")]
+ internal static extern ErrorCode Find(string name, out IntPtr handle);
+
+ // int tizen_core_find_from_this_thread(tizen_core_h *core);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_find_from_this_thread")]
+ internal static extern ErrorCode FindFromThisThread(out IntPtr handle);
+
+ // int tizen_core_add_idle_job(tizen_core_h core, tizen_core_task_cb callback, void *user_data, tizen_core_source_h *source);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_add_idle_job")]
+ internal static extern ErrorCode AddIdleJob(IntPtr handle, TaskCallback callback, IntPtr userData, out IntPtr source);
+
+ // int tizen_core_add_timer(tizen_core_h core, unsigned int interval, tizen_core_task_cb callback, void *user_data, tizen_core_source_h *source);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_add_timer")]
+ internal static extern ErrorCode AddTimer(IntPtr handle, uint interval, TaskCallback callback, IntPtr userData, out IntPtr source);
+
+ // int tizen_core_add_channel(tizen_core_h core, tizen_core_channel_receiver_h receiver, tizen_core_channel_receive_cb callback, void *user_data, tizen_core_source_h *source);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_add_channel")]
+ internal static extern ErrorCode AddChannel(IntPtr handle, IntPtr channel, ChannelReceiveCallback callback, IntPtr userData, out IntPtr source);
+
+ // int tizen_core_add_event(tizen_core_h core, tizen_core_event_h event, tizen_core_source_h *source);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_add_event")]
+ internal static extern ErrorCode AddEvent(IntPtr handle, IntPtr eventHandle, out IntPtr source);
+
+ // int tizen_core_emit_event(tizen_core_h core, tizen_core_event_object_h object);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_emit_event")]
+ internal static extern ErrorCode EmitEvent(IntPtr handle, IntPtr eventObject);
+
+ // int tizen_core_add_source(tizen_core_h core, tizen_core_source_h source);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_add_source")]
+ internal static extern ErrorCode AddSource(IntPtr handle, IntPtr source);
+
+ // int tizen_core_remove_source(tizen_core_h core, tizen_core_source_h source);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_remove_source")]
+ internal static extern ErrorCode RemoveSource(IntPtr handle, IntPtr source);
+
+ // int tizen_core_source_create(tizen_core_source_h *source);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_source_create")]
+ internal static extern ErrorCode SourceCreate(out IntPtr source);
+
+ // int tizen_core_source_destroy(tizen_core_source_h source);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_source_destroy")]
+ internal static extern ErrorCode SourceDestroy(IntPtr source);
+
+ // int tizen_core_source_add_poll(tizen_core_source_h source, tizen_core_poll_fd_h poll_fd);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_source_add_poll")]
+ internal static extern ErrorCode SourceAddPoll(IntPtr source, IntPtr pollFd);
+
+ // int tizen_core_source_remove_poll(tizen_core_source_h source, tizen_core_poll_fd_h poll_fd);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_source_remove_poll")]
+ internal static extern ErrorCode SourceRemovePoll(IntPtr source, IntPtr pollFd);
+
+ // int tizen_core_source_set_prepare_cb(tizen_core_source_h source, tizen_core_source_prepare_cb callback, void *user_data);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_source_set_prepare_cb")]
+ internal static extern ErrorCode SourceSetPrepareCallback(IntPtr source, SourcePrepareCallback callback, IntPtr userData);
+
+ // int tizen_core_source_set_check_cb(tizen_core_source_h source, tizen_core_source_check_cb callback, void *user_data);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_source_set_check_cb")]
+ internal static extern ErrorCode SourceSetCheckCallback(IntPtr source, SourceCheckCallback callback, IntPtr userData);
+
+ // int tizen_core_source_set_dispatch_cb(tizen_core_source_h source, tizen_core_source_dispatch_cb callback, void *user_data);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_source_set_dispatch_cb")]
+ internal static extern ErrorCode SourceSetDispatchCallback(IntPtr source, SourceDispatchCallback callback, IntPtr userData);
+
+ // int tizen_core_source_set_finalize_cb(tizen_core_source_h source, tizen_core_source_finalize_cb callback, void *user_data);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_source_set_finalize_cb")]
+ internal static extern ErrorCode SourceSetFinalizeCallback(IntPtr source, SourceFinalizeCallback callback, IntPtr userData);
+
+ // int tizen_core_source_set_priority(tizen_core_source_h source, tizen_core_priority_e priority);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_source_set_priority")]
+ internal static extern ErrorCode SourceSetPriority(IntPtr source, int priority);
+
+ // int tizen_core_poll_fd_create(tizen_core_poll_fd_h *poll_fd);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_poll_fd_create")]
+ internal static extern ErrorCode PollFdCreate(out IntPtr handle);
+
+ // int tizen_core_poll_fd_destroy(tizen_core_poll_fd_h poll_fd);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_poll_fd_destroy")]
+ internal static extern ErrorCode PollFdDestroy(IntPtr handle);
+
+ // int tizen_core_poll_fd_set_fd(tizen_core_poll_fd_h poll_fd, int fd);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_poll_fd_set_fd")]
+ internal static extern ErrorCode PollFdSetFd(IntPtr handle, int fd);
+
+ // int tizen_core_poll_fd_get_fd(tizen_core_poll_fd_h poll_fd, int *fd);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_poll_fd_get_fd")]
+ internal static extern ErrorCode PollFdGetFd(IntPtr handle, out int fd);
+
+ // int tizen_core_poll_fd_set_events(tizen_core_poll_fd_h poll_fd, uint16_t events);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_poll_fd_set_events")]
+ internal static extern ErrorCode PollFdSetEvents(IntPtr handle, UInt16 events);
+
+ // int tizen_core_poll_fd_get_events(tizen_core_poll_fd_h poll_fd, uint16_t *events);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_poll_fd_get_events")]
+ internal static extern ErrorCode PollFdGetEvents(IntPtr handle, out UInt16 events);
+
+ // int tizen_core_poll_fd_set_returned_events(tizen_core_poll_fd_h poll_fd, uint16_t returned_events);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_poll_fd_set_returned_events")]
+ internal static extern ErrorCode PollFdSetReturnedEvents(IntPtr handle, UInt16 returnedEvents);
+
+ // int tizen_core_poll_fd_get_events(tizen_core_poll_fd_h poll_fd, uint16_t *returned_events);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_poll_fd_get_returned_events")]
+ internal static extern ErrorCode PollFdGetReturnedEvents(IntPtr handle, out UInt16 returnedEvents);
+ }
+
+ internal static partial class TizenCoreChannel
+ {
+ // int tizen_core_channel_make_pair(tizen_core_channel_sender_h *sender, tizen_core_channel_receiver_h *receiver);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_make_pair")]
+ internal static extern ErrorCode MakePair(out IntPtr sender, out IntPtr receiver);
+
+ // int tizen_core_channel_sender_send(tizen_core_channel_sender_h sender, tizen_core_channel_object_h object);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_sender_send")]
+ internal static extern ErrorCode SenderSend(IntPtr sender, IntPtr channelObject);
+
+ // int tizen_core_channel_sender_destroy(tizen_core_channel_sender_h sender);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_sender_destroy")]
+ internal static extern ErrorCode SenderDestroy(IntPtr sender);
+
+ // int tizen_core_channel_sender_clone(tizen_core_channel_sender_h sender, tizen_core_channel_sender_h *cloned_sender);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_sender_clone")]
+ internal static extern ErrorCode SenderClone(IntPtr sender, out IntPtr clonedHandle);
+
+ // int tizen_core_channel_receiver_receive(tizen_core_channel_receiver_h receiver, tizen_core_channel_object_h *object);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_receiver_receive")]
+ internal static extern ErrorCode ReceiverReceive(IntPtr receiver, out IntPtr channelObject);
+
+ // int tizen_core_channel_receiver_destroy(tizen_core_channel_receiver_h receiver);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_receiver_destroy")]
+ internal static extern ErrorCode ReceiverDestroy(IntPtr receiver);
+
+ // int tizen_core_channel_object_create(tizen_core_channel_object_h *object);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_object_create")]
+ internal static extern ErrorCode ObjectCreate(out IntPtr handle);
+
+ // int tizen_core_channel_object_destroy(tizen_core_channel_object_h object);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_object_destroy")]
+ internal static extern ErrorCode ObjectDestroy(IntPtr handle);
+
+ // int tizen_core_channel_object_set_id(tizen_core_channel_object_h object, int id);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_object_set_id")]
+ internal static extern ErrorCode ObjectSetId(IntPtr handle, int id);
+
+ // int tizen_core_channel_object_get_id(tizen_core_channel_object_h object, int *id);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_object_get_id")]
+ internal static extern ErrorCode ObjectGetId(IntPtr handle, out int id);
+
+ // int tizen_core_channel_object_set_data(tizen_core_channel_object_h object, void *data);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_object_set_data")]
+ internal static extern ErrorCode ObjectSetData(IntPtr handle, IntPtr data);
+
+ // int tizen_core_channel_object_get_data(tizen_core_channel_object_h object, void **data);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_object_get_data")]
+ internal static extern ErrorCode ObjectGetData(IntPtr handle, out IntPtr data);
+
+ // int tizen_core_channel_object_get_sender_task_name(tizen_core_channel_object_h object, const char **task_name);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_channel_object_get_sender_task_name")]
+ internal static extern ErrorCode ObjectGetSenderTaskName(IntPtr handle, out IntPtr taskName);
+ }
+
+ internal static partial class TizenCoreEvent
+ {
+ // typedef bool (*tizen_core_event_handler_cb)(tizen_core_event_object_h object, void *user_data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool EventHandlerCallback(IntPtr eventObject, IntPtr userData);
+
+ // typedef void (*tizen_core_event_object_destroy_cb)(void *event_data, void *user_data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void EventObjectDestroyCallback(IntPtr eventData, IntPtr userData);
+
+ // int tizen_core_event_create(tizen_core_event_h *event);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_event_create")]
+ internal static extern ErrorCode Create(out IntPtr handle);
+
+ // int tizen_core_event_destroy(tizen_core_event_h event);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_event_destroy")]
+ internal static extern ErrorCode Destroy(IntPtr handle);
+
+ // int tizen_core_event_add_handler(tizen_core_event_h event, tizen_core_event_handler_cb handler, void *user_data, tizen_core_event_handler_h *event_handler);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_event_add_handler")]
+ internal static extern ErrorCode AddHandler(IntPtr handle, EventHandlerCallback callback, IntPtr userData, out IntPtr eventHandler);
+
+ // int tizen_core_event_prepend_handler(tizen_core_event_h event, tizen_core_event_handler_cb handler, void *user_data, tizen_core_event_handler_h *event_handler);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_event_prepend_handler")]
+ internal static extern ErrorCode PrependHandler(IntPtr handle, EventHandlerCallback callback, IntPtr userData, out IntPtr eventHandler);
+
+ // int tizen_core_event_remove_handler(tizen_core_event_h event, tizen_core_event_handler_h event_handler);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_event_remove_handler")]
+ internal static extern ErrorCode RemoveHandler(IntPtr handle, IntPtr eventHandler);
+
+ // int tizen_core_event_emit(tizen_core_event_h event, tizen_core_event_object_h object);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_event_emit")]
+ internal static extern ErrorCode Emit(IntPtr handle, IntPtr eventObject);
+
+ // int tizen_core_event_object_create(tizen_core_event_object_h *object, int id, void *data);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_event_object_create")]
+ internal static extern ErrorCode ObjectCreate(out IntPtr handle, int id, IntPtr data);
+
+ // int tizen_core_event_object_destroy(tizen_core_event_object_h object);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_event_object_destroy")]
+ internal static extern ErrorCode ObjectDestroy(IntPtr handle);
+
+ // int tizen_core_event_object_set_destroy_cb(tizen_core_event_object_h object, tizen_core_event_object_destroy_cb callback, void *user_data);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_event_object_set_destroy_cb")]
+ internal static extern ErrorCode ObjectSetDestroyCallback(IntPtr handle, EventObjectDestroyCallback callback, IntPtr userData);
+
+ // int tizen_core_event_object_get_id(tizen_core_event_object_h object, int *id);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_event_object_get_id")]
+ internal static extern ErrorCode ObjectGetId(IntPtr handle, out int id);
+
+ // int tizen_core_event_object_get_data(tizen_core_event_object_h object, void *data);
+ [DllImport(Libraries.TizenCore, EntryPoint = "tizen_core_event_object_get_data")]
+ internal static extern ErrorCode ObjectGetData(IntPtr handle, out IntPtr data);
+ }
+ }
+}
diff --git a/src/Tizen.Core/Tizen.Core.csproj b/src/Tizen.Core/Tizen.Core.csproj
new file mode 100644
index 00000000000..37f8af30eec
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core.csproj
@@ -0,0 +1,12 @@
+
+
+
+ net6.0
+
+
+
+
+
+
+
+
diff --git a/src/Tizen.Core/Tizen.Core.sln b/src/Tizen.Core/Tizen.Core.sln
new file mode 100644
index 00000000000..7dd607db6ab
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core.sln
@@ -0,0 +1,37 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.31903.59
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Core", "Tizen.Core.csproj", "{1BA08908-7B2B-42D1-A124-092CB177BF4C}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen", "..\Tizen\Tizen.csproj", "{2E04FB0F-03F4-40B0-BB25-5ADFB08C8DF3}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Log", "..\Tizen.Log\Tizen.Log.csproj", "{8DA5B43B-63E9-460C-B64F-0B691539DC5D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {1BA08908-7B2B-42D1-A124-092CB177BF4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1BA08908-7B2B-42D1-A124-092CB177BF4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1BA08908-7B2B-42D1-A124-092CB177BF4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1BA08908-7B2B-42D1-A124-092CB177BF4C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2E04FB0F-03F4-40B0-BB25-5ADFB08C8DF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2E04FB0F-03F4-40B0-BB25-5ADFB08C8DF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2E04FB0F-03F4-40B0-BB25-5ADFB08C8DF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2E04FB0F-03F4-40B0-BB25-5ADFB08C8DF3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8DA5B43B-63E9-460C-B64F-0B691539DC5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8DA5B43B-63E9-460C-B64F-0B691539DC5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8DA5B43B-63E9-460C-B64F-0B691539DC5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8DA5B43B-63E9-460C-B64F-0B691539DC5D}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {E9B5E719-0EB7-430C-97DC-3FE2E50EE668}
+ EndGlobalSection
+EndGlobal
\ No newline at end of file
diff --git a/src/Tizen.Core/Tizen.Core/Channel.cs b/src/Tizen.Core/Tizen.Core/Channel.cs
new file mode 100644
index 00000000000..e1727a642cf
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core/Channel.cs
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2024 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.Core
+{
+ ///
+ /// The class for managing communication channels between tasks of Tizen Core.
+ ///
+ ///
+ /// Channels are essential in inter-task communications because they provide a reliable way to exchange messages and data.
+ /// By creating a channel, you can establish a connection between two tasks that need to communicate with each other.
+ /// Once created, both tasks can send and receive messages through the channel.
+ /// It's important to note that channels have a limited capacity, so make sure to handle message overflows appropriately.
+ /// Additionally, remember to close the channel once it's no longer needed to avoid resource leaks.
+ ///
+ /// 12
+ public class Channel : IDisposable
+ {
+ private bool _disposed = false;
+
+ ///
+ /// Creates a new channel with a sender and a receiver.
+ ///
+ ///
+ /// This constructor initializes a new channel that enables communication between a sender and a receiver.
+ /// It throws exceptions if any errors occur during initialization due to insufficient memory or invalid operations.
+ ///
+ /// Thrown when out of memory.
+ /// Thrown when failed because of an invalid operation.
+ ///
+ /// In the following code snippet, we attempt to initialize a new channel by calling the constructor.
+ /// However, if there is not enough memory available, an OutOfMemoryException is thrown. We handle this exception by displaying a message in the console.
+ ///
+ /// try
+ /// {
+ /// var channel = new Channel();
+ /// }
+ /// catch (OutOfMemoryException)
+ /// {
+ /// Console.WriteLine("Exception occurs");
+ /// }
+ ///
+ ///
+ /// 12
+ public Channel()
+ {
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCoreChannel.MakePair(out IntPtr sender, out IntPtr receiver);
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to make a channel pair");
+ Sender = new ChannelSender(sender);
+ Receiver = new ChannelReceiver(receiver);
+ }
+
+ ///
+ /// Finalizes an instance of the Channel class.
+ ///
+ ~Channel()
+ {
+ Dispose(false);
+ }
+
+ ///
+ /// Gets the channel sender instance.
+ ///
+ ///
+ /// This property provides access to the channel sender instance that can be used to send messages through the specified channel.
+ /// It ensures that only one sender instance per channel exists in order to avoid any conflicts during message transmission.
+ ///
+ /// 12
+ public ChannelSender Sender { get; private set; }
+
+ ///
+ /// Gets the channel receiver instance.
+ ///
+ ///
+ /// This property provides access to the channel receiver instance that handles incoming messages from other applications.
+ /// By utilizing this instance, you can subscribe to specific channels and receive notifications accordingly.
+ /// It is crucial to understand the concept of channels in order to effectively utilize this feature. For more details on channels, refer to the official documentation.
+ ///
+ /// 12
+ public ChannelReceiver Receiver { get; private set; }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// If true, disposes any disposable objects. If false, does not dispose disposable objects.
+ /// 12
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ Sender.Dispose();
+ Receiver.Dispose();
+ }
+
+ _disposed = true;
+ }
+ }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// 12
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ }
+}
diff --git a/src/Tizen.Core/Tizen.Core/ChannelObject.cs b/src/Tizen.Core/Tizen.Core/ChannelObject.cs
new file mode 100644
index 00000000000..eff18ba1fb7
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core/ChannelObject.cs
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2024 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.Collections.Concurrent;
+using System.Runtime.InteropServices;
+using System.Security.Cryptography;
+
+namespace Tizen.Core
+{
+ ///
+ /// Represents a channel object used for inter-task communication.
+ ///
+ ///
+ /// A channel object provides a mechanism for tasks to communicate with each other in a process. It allows sending messages between tasks without any race conditions.
+ /// To create a channel object, call the static method 'Create'. Once created, you can send and receive messages through the channel by calling the respective methods on the channel object.
+ /// When you are done using the channel object, remember to dispose it properly to avoid resource leaks.
+ ///
+ /// 12
+ public class ChannelObject : IDisposable
+ {
+ private IntPtr _handle = IntPtr.Zero;
+ private bool _disposed = false;
+ private static readonly ConcurrentDictionary _dataMap = new ConcurrentDictionary();
+ private static readonly object _dataLock = new object();
+ private static int _dataId = 1;
+
+ ///
+ /// Constructor for creating a new channel object with specified ID and data.
+ ///
+ /// The ID.
+ /// The data object.
+ /// Thrown when out of memory.
+ /// Thrown when failed because of an invalid operation.
+ ///
+ /// This constructor creates a new channel object with the specified ID and data. It throws an OutOfMemoryException if there isn't enough memory available to allocate the object.
+ /// Additionally, it may throw an InvalidOperationException if the operation fails due to an invalid condition.
+ ///
+ ///
+ ///
+ ///
+ /// int id = 0;
+ /// string message = "Test message";
+ /// var channelObject = new ChannelObject(id++, message);
+ ///
+ ///
+ ///
+ /// 12
+ public ChannelObject(int id, object data)
+ {
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCoreChannel.ObjectCreate(out _handle);
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to create channel object");
+ Id = id;
+ Data = data;
+ IsUsed = false;
+ IsDestroyable = true;
+ }
+
+ internal ChannelObject(IntPtr handle)
+ {
+ _handle = handle;
+ IsUsed = false;
+ IsDestroyable = true;
+ }
+
+ ///
+ /// Finalizes an instance of the ChannelObject class.
+ ///
+ ~ChannelObject()
+ {
+ Dispose(false);
+ }
+
+ ///
+ /// Gets and sets the ID.
+ ///
+ /// 12
+ public int Id
+ {
+ get
+ {
+ Interop.LibTizenCore.TizenCoreChannel.ObjectGetId(_handle, out int id);
+ return id;
+ }
+ set
+ {
+ Interop.LibTizenCore.TizenCoreChannel.ObjectSetId(_handle, value);
+ }
+ }
+
+ ///
+ /// Gets and sets the data object.
+ ///
+ /// 12
+ public object Data
+ {
+ get
+ {
+ Interop.LibTizenCore.TizenCoreChannel.ObjectGetData(_handle, out IntPtr handle);
+ int id = (int)handle;
+ if (_dataMap.TryGetValue(id, out var data))
+ {
+ return data;
+ }
+ return null;
+ }
+ set
+ {
+ int id;
+ Interop.LibTizenCore.TizenCoreChannel.ObjectGetData(_handle, out IntPtr handle);
+ if (handle != IntPtr.Zero)
+ {
+ id = (int)handle;
+ _dataMap.TryRemove(id, out var _);
+ }
+
+ lock (_dataLock)
+ {
+ if (_dataId + 1 < 0)
+ {
+ _dataId = 1;
+ }
+ id = _dataId++;
+ }
+ _dataMap[id] = value;
+ Interop.LibTizenCore.TizenCoreChannel.ObjectSetData(_handle, (IntPtr)id);
+ }
+ }
+
+ ///
+ /// Gets the name of the sender task.
+ ///
+ /// 12
+ public string Sender
+ {
+ get
+ {
+ Interop.LibTizenCore.TizenCoreChannel.ObjectGetSenderTaskName(_handle, out IntPtr taskName);
+ return Marshal.PtrToStringAnsi(taskName);
+ }
+ }
+
+ internal bool IsDestroyable { set; get; }
+
+ internal bool IsUsed { set; get; }
+
+ internal IntPtr Handle { get { return _handle; } }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// If true, disposes any disposable objects. If false, does not dispose disposable objects.
+ /// 12
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ if (_handle != IntPtr.Zero)
+ {
+ if (!IsUsed)
+ {
+ Interop.LibTizenCore.TizenCoreChannel.ObjectGetData(_handle, out IntPtr handle);
+ int id = (int)handle;
+ _dataMap.TryRemove(id, out var data);
+ }
+
+ if (IsDestroyable)
+ {
+ Interop.LibTizenCore.TizenCoreChannel.ObjectDestroy(_handle);
+ }
+ _handle = IntPtr.Zero;
+ }
+ }
+
+ _disposed = true;
+ }
+ }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// 12
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ }
+}
diff --git a/src/Tizen.Core/Tizen.Core/ChannelReceivedEventArgs.cs b/src/Tizen.Core/Tizen.Core/ChannelReceivedEventArgs.cs
new file mode 100644
index 00000000000..64bf33459ef
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core/ChannelReceivedEventArgs.cs
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2024 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.Core
+{
+ ///
+ /// Represents the arguments for the event raised when an object has been received through a channel.
+ ///
+ /// 12
+ public class ChannelReceivedEventArgs : System.EventArgs
+ {
+ internal ChannelReceivedEventArgs(ChannelObject channelObject)
+ {
+ if (channelObject == null)
+ {
+ throw new ArgumentNullException(nameof(channelObject));
+ }
+
+ Id = channelObject.Id;
+ Data = channelObject.Data;
+ Sender = channelObject.Sender;
+ }
+
+ ///
+ /// Gets the ID of the received object.
+ ///
+ /// 12
+ public int Id { get; private set; }
+
+ ///
+ /// Gets the Data of the received object.
+ ///
+ /// 12
+ public object Data { get; private set; }
+
+ ///
+ /// Gets the name of the sender task of the received object.
+ ///
+ /// 12
+ public string Sender { get; private set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Tizen.Core/Tizen.Core/ChannelReceiver.cs b/src/Tizen.Core/Tizen.Core/ChannelReceiver.cs
new file mode 100644
index 00000000000..0c6ae5c6b1b
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core/ChannelReceiver.cs
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2024 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.Threading.Tasks;
+
+namespace Tizen.Core
+{
+ ///
+ /// Represents the channel receiver used for inter-task communication.
+ ///
+ /// 12
+ public class ChannelReceiver : IDisposable
+ {
+ private bool _disposed = false;
+
+ internal ChannelReceiver(IntPtr handle)
+ {
+ Handle = handle;
+ Source = IntPtr.Zero;
+ Id = 0;
+ }
+
+ ///
+ /// Finalizes an instance of the ChannelReceiver class.
+ ///
+ ~ChannelReceiver()
+ {
+ Dispose(false);
+ }
+
+ ///
+ /// Occurs whenever a channel object is received in the main loop of the task.
+ ///
+ ///
+ /// The registered event handler will be invoked when the channel receiver is added to the specific task.
+ ///
+ ///
+ ///
+ ///
+ /// var channel = new Channel();
+ /// var receiver = channel.Receiver;
+ /// receiver.Received += (sender, args) => {
+ /// Console.WriteLine("OnChannelObjectReceived. Message = {0}", (string)args.Data);
+ /// };
+ ///
+ ///
+ ///
+ /// 12
+ public event EventHandler Received;
+
+ ///
+ /// Asynchronously receives the channel object from the sender.
+ ///
+ /// The received channel object.
+ /// Thrown when out of memory.
+ /// Thrown when failed due to an invalid operation.
+ ///
+ ///
+ ///
+ /// var channel = new Channel();
+ /// var task = TizenCore.Find("Test");
+ /// task.Send(async () => {
+ /// try {
+ /// var channelObject = await channel.Receiver.Receive();
+ /// Console.WriteLine("Message = {}", (string)channelObject.Data);
+ /// } catch (Exception e) {
+ /// Console.Error.WriteLine("Failed to receive message: {0}", e.ToString());
+ /// }
+ /// });
+ ///
+ ///
+ ///
+ /// 12
+ public async Task Receive()
+ {
+ return await System.Threading.Tasks.Task.Run(() =>
+ {
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCoreChannel.ReceiverReceive(Handle, out IntPtr channelObject);
+ if (error != Interop.LibTizenCore.ErrorCode.None)
+ {
+ if (error == Interop.LibTizenCore.ErrorCode.InvalidParameter)
+ {
+ error = Interop.LibTizenCore.ErrorCode.InvalidContext;
+ }
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to receive channel object");
+ }
+ return new ChannelObject(channelObject);
+ }).ConfigureAwait(false);
+ }
+
+ internal IntPtr Handle { get; set; }
+ internal IntPtr Source { get; set; }
+ internal int Id { get; set; }
+
+ internal void InvokeEventHandler(object sender, ChannelReceivedEventArgs e)
+ {
+ Received?.Invoke(sender, e);
+ }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// If true, disposes any disposable objects. If false, does not dispose disposable objects.
+ /// 12
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ if (Handle != IntPtr.Zero)
+ {
+ Interop.LibTizenCore.TizenCoreChannel.ReceiverDestroy(Handle);
+ Handle = IntPtr.Zero;
+ }
+ }
+
+ _disposed = true;
+ }
+ }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// 12
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ }
+}
diff --git a/src/Tizen.Core/Tizen.Core/ChannelSender.cs b/src/Tizen.Core/Tizen.Core/ChannelSender.cs
new file mode 100644
index 00000000000..1156d9ec49e
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core/ChannelSender.cs
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2024 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.Core
+{
+ ///
+ /// Represents the channel sender used for inter-task communication. It provides methods to send messages between tasks in order to facilitate task coordination.
+ ///
+ /// 12
+ public class ChannelSender : IDisposable
+ {
+ private bool _disposed = false;
+
+ internal ChannelSender(IntPtr handle)
+ {
+ Handle = handle;
+ }
+
+ ///
+ /// Finalizes an instance of the ChannelSender class.
+ ///
+ ~ChannelSender()
+ {
+ Dispose(false);
+ }
+
+ ///
+ /// Sends the channel object to the receiver.
+ ///
+ /// The channel object instance.
+ /// Thrown when the argument is null.
+ /// Thrown when the argument is invalid.
+ /// Thrown when failed because of an invalid operation.
+ ///
+ /// It's important to call the Dispose() method on the passed channel object to release resources.
+ ///
+ ///
+ ///
+ ///
+ /// var channel = new Channel();
+ /// var sender = channel.Sender;
+ /// string message = "Test";
+ /// using (var channelObject = new ChannelObject(1, message))
+ /// {
+ /// sender.Send(channelObject);
+ /// }
+ ///
+ ///
+ ///
+ /// 12
+ public void Send(ChannelObject channelObject)
+ {
+ if (channelObject == null)
+ {
+ throw new ArgumentNullException(nameof(channelObject));
+ }
+
+ if (channelObject.Handle == IntPtr.Zero)
+ {
+ throw new ArgumentException("Invalid argument");
+ }
+
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCoreChannel.SenderSend(Handle, channelObject.Handle);
+ if (error != Interop.LibTizenCore.ErrorCode.None)
+ {
+ throw new InvalidOperationException("Failed to send channel object");
+ }
+ channelObject.IsUsed = true;
+ }
+
+ ///
+ /// Creates and returns a copy of the channel sender object.
+ ///
+ /// A newly created channel sender instance.
+ /// Thrown when failed because of an invalid operation.
+ /// Thrown when out of memory.
+ ///
+ ///
+ ///
+ /// var channel = new Channel();
+ /// var sender = channel.Sender;
+ /// var clonedSender = sender.Clone();
+ ///
+ ///
+ ///
+ /// 12
+ public ChannelSender Clone()
+ {
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCoreChannel.SenderClone(Handle, out IntPtr clonedHandle);
+ if (error == Interop.LibTizenCore.ErrorCode.InvalidParameter)
+ {
+ error = Interop.LibTizenCore.ErrorCode.InvalidContext;
+ }
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to clone channel sender");
+
+ return new ChannelSender(clonedHandle);
+ }
+
+ internal IntPtr Handle { get; private set; }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// If true, disposes any disposable objects. If false, does not dispose disposable objects.
+ /// 12
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ if (Handle != IntPtr.Zero)
+ {
+ Interop.LibTizenCore.TizenCoreChannel.SenderDestroy(Handle);
+ Handle = IntPtr.Zero;
+ }
+ }
+
+ _disposed = true;
+ }
+ }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// 12
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ }
+}
diff --git a/src/Tizen.Core/Tizen.Core/Event.cs b/src/Tizen.Core/Tizen.Core/Event.cs
new file mode 100644
index 00000000000..f705845e561
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core/Event.cs
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2024 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.Core
+{
+ ///
+ /// Represents the event used for broadcasting events.
+ ///
+ ///
+ /// This class provides functionality for managing events that are broadcasted across multiple components in an application.
+ /// It enables communication between different parts of the code without resorting to direct references or global variables.
+ /// By implementing the IDisposable interface, it ensures proper resource management and prevents memory leaks.
+ ///
+ /// 12
+#pragma warning disable CA1716
+ public class Event : IDisposable
+#pragma warning restore CA1716
+ {
+ private IntPtr _handle = IntPtr.Zero;
+ private bool _disposed = false;
+ private Interop.LibTizenCore.TizenCoreEvent.EventHandlerCallback _callback = null;
+
+ ///
+ /// Constructor for creating a new event instance.
+ ///
+ ///
+ /// This constructor initializes a new event instance. It may throw exceptions if there are any issues during initialization such as running out of memory or performing an invalid operation.
+ ///
+ /// Thrown when out of memory.
+ /// Thrown when failed because of an invalid operation.
+ ///
+ /// Here's an example showing how to create a new event instance:
+ ///
+ /// Create a new event instance
+ /// var coreEvent = new Event();
+ ///
+ ///
+ /// 12
+ public Event()
+ {
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCoreEvent.Create(out _handle);
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to create event");
+
+ _callback = new Interop.LibTizenCore.TizenCoreEvent.EventHandlerCallback(EventHandlerCallback);
+ error = Interop.LibTizenCore.TizenCoreEvent.AddHandler(_handle, _callback, IntPtr.Zero, out IntPtr _);
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to add event handler");
+
+ Source = IntPtr.Zero;
+ Id = 0;
+ }
+
+ ///
+ /// Finalizes an instance of the Event class.
+ ///
+ ~Event()
+ {
+ Dispose(false);
+ }
+
+ private bool EventHandlerCallback(IntPtr eventData, IntPtr userData)
+ {
+ using (var eventObject = new EventObject(eventData))
+ {
+ EventReceived?.Invoke(this, new EventReceivedEventArgs(eventObject));
+ eventObject.Handle = IntPtr.Zero;
+ }
+ return true;
+ }
+
+ ///
+ /// Occurrs whenever the event is received in the main loop of the task.
+ ///
+ ///
+ /// The registered event handler will be invoked when the event is added to the specific task.
+ ///
+ ///
+ ///
+ ///
+ /// var coreEvent = new Event();
+ /// coreEvent.EventReceived += (s, e) => {
+ /// Console.WriteLine("OnEventReceived. Message = {}", (string)e.Data);
+ /// };
+ ///
+ ///
+ ///
+ /// 12
+ public event EventHandler EventReceived;
+
+ ///
+ /// Emits an event object to the event.
+ /// The emitted event object is queued and delivered to the registered EventHandlers on the main loop of the task.
+ ///
+ /// The event object instance.
+ /// Thrown when the argument is null.
+ /// Thrown when failed because of an invalid operation.
+ ///
+ /// If the event is not added to the task, the emitted event object will be pended until the event is added to the task.
+ ///
+ ///
+ ///
+ ///
+ /// var coreEvent = new Event();
+ /// coreEvent.EventReceived += (s, e) => {
+ /// Console.WriteLine("OnEventReceived. Message = {}", (string)e.Data);
+ /// };
+ ///
+ /// var task = TizenCore.Find("EventTask");
+ /// if (task != null)
+ /// {
+ /// task.AddEvent(coreEvent);
+ /// string message = "Test Event";
+ /// using (var eventObject = new EventObject(1, message))
+ /// {
+ /// coreEvent.Emit(eventObject);
+ /// }
+ /// }
+ ///
+ ///
+ ///
+ /// 12
+ public void Emit(EventObject eventObject)
+ {
+ if (eventObject == null)
+ {
+ throw new ArgumentNullException(nameof(eventObject));
+ }
+
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCoreEvent.Emit(_handle, eventObject.Handle);
+ if (error == Interop.LibTizenCore.ErrorCode.InvalidParameter)
+ {
+ error = Interop.LibTizenCore.ErrorCode.InvalidContext;
+ }
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to emit event object");
+ eventObject.Handle = IntPtr.Zero;
+ }
+
+ internal IntPtr Handle { get { return _handle; } }
+ internal IntPtr Source { get; set; }
+ internal int Id { get; set; }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// If true, disposes any disposable objects. If false, does not dispose disposable objects.
+ /// 12
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ if (_handle != IntPtr.Zero)
+ {
+ Interop.LibTizenCore.TizenCoreEvent.Destroy(_handle);
+ _handle = IntPtr.Zero;
+ }
+ }
+
+ _disposed = true;
+ }
+ }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// 12
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ }
+}
diff --git a/src/Tizen.Core/Tizen.Core/EventObject.cs b/src/Tizen.Core/Tizen.Core/EventObject.cs
new file mode 100644
index 00000000000..22d2ff5af07
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core/EventObject.cs
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2024 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.Collections.Concurrent;
+
+namespace Tizen.Core
+{
+ ///
+ /// Represents an event object used for broadcasting the event.
+ ///
+ /// 12
+ public class EventObject : IDisposable
+ {
+ private IntPtr _handle = IntPtr.Zero;
+ private bool _disposed = false;
+ private static readonly ConcurrentDictionary _dataMap = new ConcurrentDictionary();
+ private static readonly object _dataLock = new object();
+ private static int _dataId = 0;
+ private static Interop.LibTizenCore.TizenCoreEvent.EventObjectDestroyCallback _destroyCallback = new Interop.LibTizenCore.TizenCoreEvent.EventObjectDestroyCallback(NativeObjectDestroyCallback);
+
+ ///
+ /// Constructor for creating a new event object with specified ID and data.
+ ///
+ /// The ID.
+ /// The data object.
+ /// Thrown when out of memory.
+ /// Thrown when failed because of an invalid operation.
+ ///
+ ///
+ ///
+ /// int id = 0;
+ /// string message = "Test event";
+ /// var eventObject = new EventObject(id++, message);
+ ///
+ ///
+ ///
+ /// 12
+ public EventObject(int id, object data)
+ {
+ int dataId;
+ lock (_dataLock)
+ {
+ dataId = _dataId++;
+ }
+
+ _dataMap[dataId] = data;
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCoreEvent.ObjectCreate(out _handle, id, (IntPtr)dataId);
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to create channel object");
+
+ Interop.LibTizenCore.TizenCoreEvent.ObjectSetDestroyCallback(_handle, _destroyCallback, (IntPtr)dataId);
+ }
+
+ internal EventObject(IntPtr handle)
+ {
+ _handle = handle;
+ }
+
+ ///
+ /// Finalizes an instance of the EventObject class.
+ ///
+ ~EventObject()
+ {
+ Dispose(false);
+ }
+
+ ///
+ /// Gets the ID of the event object.
+ ///
+ public int Id
+ {
+ get
+ {
+ Interop.LibTizenCore.TizenCoreEvent.ObjectGetId(_handle, out int id);
+ return id;
+ }
+ }
+
+ ///
+ /// Gets the Data of the event object.
+ ///
+ public object Data
+ {
+ get
+ {
+ Interop.LibTizenCore.TizenCoreEvent.ObjectGetData(_handle, out IntPtr handle);
+ int id = (int)handle;
+ if (_dataMap.TryGetValue(id, out var data))
+ {
+ return data;
+ }
+ return null;
+ }
+ }
+
+ internal IntPtr Handle { get { return _handle; } set { _handle = value; } }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// If true, disposes any disposable objects. If false, does not dispose disposable objects.
+ /// 12
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ if (_handle != IntPtr.Zero)
+ {
+ Interop.LibTizenCore.TizenCoreEvent.ObjectDestroy(_handle);
+ _handle = IntPtr.Zero;
+ }
+ }
+
+ _disposed = true;
+ }
+ }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// 12
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private static void NativeObjectDestroyCallback(IntPtr eventData, IntPtr userData)
+ {
+ int dataId = (int)eventData;
+ _dataMap.TryRemove(dataId, out var _);
+ }
+ }
+}
diff --git a/src/Tizen.Core/Tizen.Core/EventReceivedEventArgs.cs b/src/Tizen.Core/Tizen.Core/EventReceivedEventArgs.cs
new file mode 100644
index 00000000000..93d91914d81
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core/EventReceivedEventArgs.cs
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2024 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.Core
+{
+ ///
+ /// Represents the arguments passed to the event handler when the event data is received.
+ ///
+ /// 12
+ public class EventReceivedEventArgs : System.EventArgs
+ {
+ internal EventReceivedEventArgs(EventObject eventObject)
+ {
+ if (eventObject == null)
+ {
+ throw new ArgumentNullException(nameof(eventObject));
+ }
+
+ Id = eventObject.Id;
+ Data = eventObject.Data;
+ }
+
+ ///
+ /// Gets the ID of the received object.
+ ///
+ /// 12
+ public int Id { get; private set; }
+
+ ///
+ /// Gets the Data of the received object.
+ ///
+ /// 12
+ public object Data { get; private set; }
+ }
+}
diff --git a/src/Tizen.Core/Tizen.Core/Log.cs b/src/Tizen.Core/Tizen.Core/Log.cs
new file mode 100644
index 00000000000..17d57a62df2
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core/Log.cs
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2024 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.Runtime.CompilerServices;
+
+namespace Tizen.Core
+{
+ internal class Log
+ {
+ private static string LogTag = "Tizen.Core";
+
+ public static void Error(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
+ {
+ Tizen.Log.Error(LogTag, message, file, func, line);
+ }
+
+ public static void Warn(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
+ {
+ Tizen.Log.Warn(LogTag, message, file, func, line);
+ }
+
+ public static void Info(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
+ {
+ Tizen.Log.Info(LogTag, message, file, func, line);
+ }
+
+ public static void Debug(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
+ {
+ Tizen.Log.Debug(LogTag, message, file, func, line);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Tizen.Core/Tizen.Core/Task.cs b/src/Tizen.Core/Tizen.Core/Task.cs
new file mode 100644
index 00000000000..a6796b368fb
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core/Task.cs
@@ -0,0 +1,783 @@
+/*
+ * Copyright (c) 2024 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.Collections.Concurrent;
+using System.Diagnostics.Tracing;
+using System.Threading.Channels;
+using System.Threading.Tasks;
+
+namespace Tizen.Core
+{
+ ///
+ /// Represents the task used for creating, running and terminating the thread with the main loop.
+ /// The state of the task can be changed as follows: Constructed -> Running -> Terminated.
+ /// To start the task, use 'Task.Run()' method. Once started, the task enters into 'Running' state. To terminate the task, use 'Task.Quit()' method.
+ /// After termination, the task returns back to 'Constructed' state.
+ ///
+ /// 12
+ public class Task : IDisposable
+ {
+ private IntPtr _handle = IntPtr.Zero;
+ private bool _disposed = false;
+ private static readonly ConcurrentDictionary _coreTaskMap = new ConcurrentDictionary();
+ private static readonly ConcurrentDictionary> _taskMap = new ConcurrentDictionary>();
+ private static readonly ConcurrentDictionary _actionkMap = new ConcurrentDictionary();
+ private static readonly ConcurrentDictionary _timerMap = new ConcurrentDictionary();
+ private static readonly ConcurrentDictionary _channelMap = new ConcurrentDictionary();
+ private static readonly ConcurrentDictionary _eventMap = new ConcurrentDictionary();
+ private static Object _idLock = new Object();
+ private static int _id = 1;
+
+ ///
+ /// Initializes the Task class with the specified ID.
+ ///
+ /// The unique identifier for the task.
+ /// Thrown when the is invalid or a Task with that ID already exists.
+ /// Thrown when out of memory.
+ /// Thrown when failed because of an invalid operation.
+ ///
+ /// The constructor throws an exception when the ID already exists.
+ /// By default, the task creates a separate thread. However, if the is set to "main", no separate thread is created.
+ /// In such case, the 'main' task will operate on the main application thread instead.
+ ///
+ ///
+ ///
+ ///
+ /// TizenCore.Initialize();
+ /// var task = new Task("Worker");
+ /// task.Run();
+ ///
+ ///
+ ///
+ /// 12
+ public Task(string id)
+ {
+ bool useThread = (id == "main") ? false : true;
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCore.TaskCreate(id, useThread, out _handle);
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to create task");
+ _coreTaskMap[id] = this;
+ }
+
+ internal Task(IntPtr handle)
+ {
+ _handle = handle;
+ _disposed = true;
+ }
+
+ ///
+ /// Finalizes the Task class.
+ ///
+ /// 12
+ ~Task()
+ {
+ Dispose(false);
+ }
+
+ ///
+ /// Posts an action to be executed later.
+ ///
+ /// The action callback to post.
+ /// Thrown when the action argument is null.
+ /// Thrown when failed because of an invalid operation.
+ /// Thrown when out of memory.
+ ///
+ /// The action callback will be executed by the main loop of the task.
+ /// If there was any error during this process, an appropriate exception will be thrown.
+ /// In order to prevent the from throwing an exception, you should add a try/catch block. If not, it may cause the application to crash or terminate.
+ ///
+ ///
+ ///
+ ///
+ /// var task = TizenCore.Find("Test") ?? TizenCore.Spawn("Test");
+ /// task.Post(() =>
+ /// {
+ /// Console.WriteLine("Test task");
+ /// });
+ ///
+ ///
+ ///
+ /// 12
+ public void Post(Action action)
+ {
+ if (action == null)
+ {
+ throw new ArgumentNullException(nameof(action));
+ }
+
+ int id;
+ lock (_idLock)
+ {
+ if (_id + 1 < 0) _id = 1;
+ id = _id++;
+ }
+ _actionkMap[id] = action;
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCore.AddIdleJob(_handle, NativeActionCallback, (IntPtr)id, out IntPtr handle);
+ if (error != Interop.LibTizenCore.ErrorCode.None)
+ {
+ if (error == Interop.LibTizenCore.ErrorCode.InvalidParameter)
+ {
+ error = Interop.LibTizenCore.ErrorCode.InvalidContext;
+ }
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to add idle job");
+ }
+ }
+
+ ///
+ /// Posts a task to be executed later.
+ ///
+ /// The task to post.
+ /// Thrown when the task argument is null.
+ /// Thrown when failed because of an invalid operation.
+ /// Thrown when out of memory.
+ ///
+ /// The task will be stored in the internal map using its unique identifier.
+ /// Then it will be added as an idle job to the main loop of the task.
+ /// If there was any error during this process, the task will be removed from the map and an appropriate exception will be thrown.
+ /// In order to prevent the from throwing an exception, you should add a try/catch block. If not, it may cause the application to crash or terminate.
+ ///
+ ///
+ ///
+ ///
+ /// var channel = new Channel();
+ /// var task = TizenCore.Find("Sender") ?? TizenCore.Spawn("Sender");
+ ///
+ /// int id = 0;
+ /// task.Post(async () =>
+ /// {
+ /// var channelObject = await channel.Receiver.Receive();
+ /// var message = (string)channelObject.Data;
+ /// Console.WriteLine("Received message = " + message);
+ /// });
+ ///
+ ///
+ ///
+ /// 12
+ public void Post(Func task)
+ {
+ if (task == null)
+ {
+ throw new ArgumentNullException(nameof(task));
+ }
+
+ int id;
+ lock (_idLock)
+ {
+ if (_id + 1 < 0) _id = 1;
+ id = _id++;
+ }
+ _taskMap[id] = task;
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCore.AddIdleJob(_handle, NativeTaskCallback, (IntPtr)id, out IntPtr handle);
+ if (error != Interop.LibTizenCore.ErrorCode.None)
+ {
+ _taskMap.TryRemove(id, out var _);
+ if (error == Interop.LibTizenCore.ErrorCode.InvalidParameter)
+ {
+ error = Interop.LibTizenCore.ErrorCode.InvalidContext;
+ }
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to add idle job");
+ }
+ }
+
+ ///
+ /// Adds a recurring timer to a main loop of the task.
+ ///
+ /// The interval of the timer in milliseconds.
+ /// The recurring timer callback function which returns whether or not to continue triggering the timer.
+ /// The registered timer ID to be used with .
+ /// Thrown when the callback argument is null.
+ /// Thrown when failed because of an invalid operation.
+ /// Thrown when out of memory.
+ ///
+ /// The callback function will be called every time the specified interval elapses. It should return true to keep the timer running, otherwise the timer will be stopped.
+ ///
+ ///
+ ///
+ ///
+ /// var task = TizenCore.Find("TimerTask") ?? TizenCore.Spawn("TimerTask");
+ /// var timerId = task.AddTimer(1000, () => {
+ /// Console.WriteLine("Timer callback is invoked");
+ /// return true;
+ /// });
+ ///
+ ///
+ ///
+ /// 12
+ public int AddTimer(uint interval, Func callback)
+ {
+ if (callback == null)
+ {
+ throw new ArgumentNullException(nameof(callback));
+ }
+
+ int id;
+ lock (_idLock)
+ {
+ if (_id + 1 < 0) _id = 1;
+ id = _id++;
+ }
+ var timerSource = new TimerSource(id, IntPtr.Zero, callback);
+ _timerMap[id] = timerSource;
+ lock (timerSource)
+ {
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCore.AddTimer(_handle, interval, NativeTimerCallback, (IntPtr)id, out IntPtr handle);
+ if (error != Interop.LibTizenCore.ErrorCode.None)
+ {
+ _timerMap.TryRemove(id, out var _);
+ throw new InvalidOperationException("Failed to add timer");
+ }
+
+ timerSource.Handle = handle;
+ }
+ return id;
+ }
+
+ ///
+ /// Removes the registered timer from the main loop of the task.
+ /// If the specified timer was already stopped, no action occurs.
+ ///
+ /// The registered timer ID.
+ ///
+ ///
+ ///
+ /// var task = TizenCore.Find("TimerTask") ?? TizenCore.Spawn("TimerTask");
+ /// var timerId = task.AddTimer(1000, () => {
+ /// Console.WriteLine("Timer handler is invoked");
+ /// return true;
+ /// });
+ /// ...
+ /// task.RemoveTimer(timerId);
+ ///
+ ///
+ ///
+ /// 12
+ public void RemoveTimer(int id)
+ {
+ if (_timerMap.TryRemove(id, out var timerSource))
+ {
+ lock (timerSource)
+ {
+ if (timerSource.Handle != IntPtr.Zero)
+ {
+ Interop.LibTizenCore.TizenCore.RemoveSource(_handle, timerSource.Handle);
+ timerSource.Handle = IntPtr.Zero;
+ }
+ }
+ }
+ }
+
+ ///
+ /// Adds a channel receiver to a main loop of the task.
+ ///
+ /// The channel receiver instance that needs to be added.
+ /// Thrown when the argument is null.
+ /// Thrown when the argument is invalid.
+ /// Thrown when failed because of an invalid operation.
+ /// Thrown when out of memory.
+ ///
+ /// In the following code snippet, we create a channel, find or spawn a task named "ReceivingTask", and then add the channel receiver to the task's main loop by calling the 'AddChannelReceiver' method.
+ ///
+ ///
+ ///
+ /// var channel = new Channel();
+ /// var task = TizenCore.Find("ReceivingTask") ?? TizenCore.Spawn("ReceivingTask");
+ /// var receiver = channel.Receiver;
+ /// receiver.Received += (sender, args) => {
+ /// Console.WriteLine("OnChannelMessageReceived. Message = " + (string)args.Data);
+ /// };
+ /// task.AddChannelReceiver(receiver);
+ ///
+ ///
+ ///
+ /// 12
+ public void AddChannelReceiver(ChannelReceiver receiver)
+ {
+ if (receiver == null) { throw new ArgumentNullException(nameof(receiver)); }
+
+ if (receiver.Handle == IntPtr.Zero)
+ {
+ if (receiver.Source != IntPtr.Zero)
+ {
+ throw new ArgumentException("The receiver is already added");
+ }
+
+ throw new ArgumentException("Invalid argument");
+ }
+
+ int id;
+ lock (_idLock)
+ {
+ if (_id + 1 < 0) _id = 1;
+ id = _id++;
+ }
+ receiver.Id = id;
+ _channelMap[id] = receiver;
+ lock (receiver)
+ {
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCore.AddChannel(_handle, receiver.Handle, NativeChannelReceiveCallback, (IntPtr)id, out IntPtr handle);
+ if (error != Interop.LibTizenCore.ErrorCode.None)
+ {
+ _channelMap.TryRemove(id, out var _);
+ if (error == Interop.LibTizenCore.ErrorCode.InvalidParameter)
+ {
+ error = Interop.LibTizenCore.ErrorCode.InvalidContext;
+ }
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to add a channel to the task");
+ }
+
+ receiver.Source = handle;
+ receiver.Handle = IntPtr.Zero;
+ }
+ }
+
+ ///
+ /// Removes the registered channel receiver from the main loop of the task.
+ ///
+ /// The channel receiver instance.
+ /// Thrown when the argument is null.
+ /// Thrown when the argument is invalid.
+ ///
+ ///
+ ///
+ /// var channel = new Channel();
+ /// var task = TizenCore.Find("ReceivingTask") ?? TizenCore.Spawn("ReceivingTask");
+ /// var receiver = channel.Receiver;
+ /// receiver.Received += (sender, args) => {
+ /// Console.WriteLine("OnChannelMessageReceived. Message = " + (string)args.Data);
+ /// };
+ ///
+ /// task.AddChannelReceiver(receiver);
+ /// task.RemoveChannelReceiver(receiver);
+ ///
+ ///
+ ///
+ /// 12
+ public void RemoveChannelReceiver(ChannelReceiver receiver)
+ {
+ if (receiver == null)
+ {
+ throw new ArgumentNullException(nameof(receiver));
+ }
+
+ if (receiver.Id == 0 || receiver.Source == IntPtr.Zero)
+ {
+ throw new ArgumentException("Invalid argument");
+ }
+
+ if (_channelMap.TryRemove(receiver.Id, out var _))
+ {
+ lock (receiver)
+ {
+ if (receiver.Source != IntPtr.Zero)
+ {
+ Interop.LibTizenCore.TizenCore.RemoveSource(_handle, receiver.Source);
+ receiver.Source = IntPtr.Zero;
+ receiver.Id = 0;
+ }
+ }
+ }
+ }
+
+ ///
+ /// Adds an event to a main loop of the task.
+ /// If the event is successfully added, its unique identifier is assigned to the event. The identifier can then be used later to identify the specific event among others.
+ ///
+ /// The event instance.
+ /// Thrown when the argument is null.
+ /// Thrown when the argument is invalid.
+ /// Thrown when failed because of an invalid operation.
+ /// Thrown when out of memory.
+ ///
+ /// This method allows you to associate an event with a specific task. By adding an event to a task's main loop, other threads can utilize this event to communicate with the task.
+ /// However, note that once an event is attached to a task, it cannot be reused or attached to another task.
+ /// If the argument passed to this method is null, an exception will be thrown. Additionally, if the event has been previously added, an argument exception will be raised.
+ ///
+ ///
+ ///
+ ///
+ /// var coreEvent = new Event();
+ /// coreEvent.EventReceived += (sender, args) => {
+ /// Console.WriteLine("OnEventReceived. ID = {}, Message = {}", args.Id, (string)args.Data);
+ /// };
+ ///
+ /// var task = TizenCore.Find("EventTask") ?? TizenCore.Spawn("EventTask");
+ /// task.AddEvent(coreEvent);
+ ///
+ ///
+ ///
+ /// 12
+ public void AddEvent(Event coreEvent)
+ {
+ if (coreEvent == null)
+ {
+ throw new ArgumentNullException(nameof(coreEvent));
+ }
+
+ if (coreEvent.Handle == IntPtr.Zero)
+ {
+ throw new ArgumentException("Invalid argument");
+ }
+
+ if (coreEvent.Source != IntPtr.Zero)
+ {
+ throw new ArgumentException("The event is already added");
+ }
+
+ int id;
+ lock (_idLock)
+ {
+ if (_id + 1 < 0)
+ {
+ _id = 1;
+ }
+ id = _id++;
+ }
+ coreEvent.Id = id;
+ _eventMap[id] = coreEvent;
+ lock (coreEvent)
+ {
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCore.AddEvent(_handle, coreEvent.Handle, out IntPtr handle);
+ if (error != Interop.LibTizenCore.ErrorCode.None)
+ {
+ _eventMap.TryRemove(id, out var _);
+ if (error == Interop.LibTizenCore.ErrorCode.InvalidParameter)
+ {
+ error = Interop.LibTizenCore.ErrorCode.InvalidContext;
+ }
+ TCoreErrorFactory.CheckAndThrownException(error, "Failed to add an event to the task");
+ }
+
+ coreEvent.Source = handle;
+ }
+ }
+
+ ///
+ /// Removes the registered event from the main loop of the task.
+ ///
+ /// The event instance.
+ /// Thrown when the argument is null.
+ /// Thrown when the argument is invalid.
+ ///
+ ///
+ ///
+ /// var coreEvent = new Event();
+ /// coreEvent.EventReceived += (sender, args) => {
+ /// Console.WriteLine("OnEventReceived. ID = {}, Message = {}", args.Id, (string)args.Data);
+ /// };
+ ///
+ /// var task = TizenCore.Find("EventTask") ?? TizenCore.Spawn("EventTask");
+ /// task.AddEvent(coreEvent);
+ /// task.RemoveEvent(coreEvent);
+ ///
+ ///
+ ///
+ /// 12
+ public void RemoveEvent(Event coreEvent)
+ {
+ if (coreEvent == null)
+ {
+ throw new ArgumentNullException(nameof(coreEvent));
+ }
+
+ if (coreEvent.Id == 0 || coreEvent.Source == IntPtr.Zero)
+ {
+ throw new ArgumentException("Invalid argument");
+ }
+
+ if (_eventMap.TryRemove(coreEvent.Id, out var _))
+ {
+ lock (coreEvent)
+ {
+ if (coreEvent.Source != IntPtr.Zero)
+ {
+ Interop.LibTizenCore.TizenCore.RemoveSource(_handle, coreEvent.Source);
+ coreEvent.Source = IntPtr.Zero;
+ coreEvent.Id = 0;
+ }
+ }
+ }
+ }
+
+ ///
+ /// Emits the event object to all registered event handlers of the task.
+ /// It's similar to Event.Emit(), but EmitAllEvent() sends the event object to every event handler of the task while Event.Emit() sends the event object only to the target event's event handler.
+ ///
+ /// The event object instance to be sent.
+ /// Thrown when the argument is null.
+ /// Thrown when the argument is invalid.
+ /// Thrown when failed because of an invalid operation.
+ ///
+ ///
+ ///
+ /// int id = 0;
+ /// string message = "Test Event";
+ /// using (var eventObject = new TCoreEventObject(id++, message))
+ /// {
+ /// var task = TizenCore.Find("EventTask") ?? TizenCore.Spawn("EventTask");
+ /// task.EmitEvent(eventObject);
+ /// }
+ ///
+ ///
+ ///
+ /// 12
+ public void EmitEvent(EventObject eventObject)
+ {
+ if (eventObject == null)
+ {
+ throw new ArgumentNullException(nameof(eventObject));
+ }
+
+ if (eventObject.Handle == IntPtr.Zero)
+ {
+ throw new ArgumentException("Invalid argument");
+ }
+
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCore.EmitEvent(_handle, eventObject.Handle);
+ if (error != Interop.LibTizenCore.ErrorCode.None)
+ {
+ throw new InvalidOperationException("Failed to emit event");
+ }
+
+ eventObject.Handle = IntPtr.Zero;
+ }
+
+ private static bool NativeTaskCallback(IntPtr userData)
+ {
+ int taskId = (int)userData;
+ if (_taskMap.TryRemove(taskId, out Func task))
+ {
+ task();
+ }
+ return false;
+ }
+
+ private static bool NativeActionCallback(IntPtr userData)
+ {
+ int actionId = (int)userData;
+ if (_actionkMap.TryRemove(actionId, out Action action))
+ {
+ action();
+ }
+ return false;
+ }
+
+ private static bool NativeTimerCallback(IntPtr userData)
+ {
+ int timerId = (int)userData;
+ if (_timerMap.TryGetValue(timerId, out TimerSource timerSource))
+ {
+ bool result = false;
+ lock (timerSource)
+ {
+ if (timerSource.Handle != IntPtr.Zero)
+ {
+ result = timerSource.Handler();
+ if (!result)
+ {
+ _timerMap.TryRemove(timerId, out TimerSource unusedSource);
+ }
+ }
+ }
+ return result;
+ }
+ return false;
+ }
+
+ private static void NativeChannelReceiveCallback(IntPtr nativeObject, IntPtr userData)
+ {
+ int channelId = (int)userData;
+ if (_channelMap.TryGetValue(channelId, out ChannelReceiver receiver))
+ {
+ lock (receiver)
+ {
+ if (receiver.Source != IntPtr.Zero)
+ {
+ using (var channelObject = new ChannelObject(nativeObject))
+ {
+ var eventArgs = new ChannelReceivedEventArgs(channelObject);
+ receiver.InvokeEventHandler(null, eventArgs);
+ channelObject.IsDestroyable = false;
+ }
+ }
+ }
+ }
+ }
+
+ internal static Task Find(string id)
+ {
+ if (_coreTaskMap.TryGetValue(id, out Task task)) { return task; }
+
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCore.Find(id, out IntPtr handle);
+ if (error == Interop.LibTizenCore.ErrorCode.None)
+ {
+ return new Task(handle);
+ }
+
+ return null;
+ }
+
+ internal static Task Spawn(string id)
+ {
+ if (id == "main")
+ {
+ Log.Error("Invalid argument. id = {}", id);
+ return null;
+ }
+
+ try
+ {
+ var task = new Task(id);
+ task.Run();
+ return task;
+ }
+ catch (ArgumentException)
+ {
+ Log.Error("ArgumentException occurs");
+ }
+ catch (OutOfMemoryException)
+ {
+ Log.Error("OutOfMemoryException occurs");
+ }
+ catch (InvalidOperationException)
+ {
+ Log.Error("InvalidOperationException occurs");
+ }
+
+ return null;
+ }
+
+ ///
+ /// Checks whether the task is running or not.
+ ///
+ /// 12
+ public bool Running {
+ get
+ {
+ Interop.LibTizenCore.TizenCore.TaskIsRunning(_handle, out bool running);
+ return running;
+ }
+ }
+
+ ///
+ /// Runs the main loop of the task.
+ ///
+ /// Thrown when failed because of an invalid operation.
+ ///
+ /// Here's an example that demonstrates how to create a Core Task and run its main loop:
+ ///
+ /// // Create a Core Task named "Runner"
+ /// var coreTask = new TCoreTask("Runner");
+ ///
+ /// // Start the main loop of the task
+ /// coreTask.Run();
+ ///
+ ///
+ /// 12
+ public void Run()
+ {
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCore.TaskRun(_handle);
+ if (error != Interop.LibTizenCore.ErrorCode.None)
+ {
+ throw new InvalidOperationException("Failed to run task");
+ }
+ }
+
+ ///
+ /// Quits the main loop of the task.
+ ///
+ /// Thrown when failed because of an invalid operation.
+ ///
+ /// This function can be called from any thread.
+ /// It requests the task to finish the current iteration of its loop and stop running.
+ /// All pending events in the event queue will be processed before quitting. Once the task quits, it's finished.
+ /// To start another task, you need to create a new one and call the method on it.
+ ///
+ ///
+ ///
+ ///
+ /// var coreTask = new TCoreTask("Runner");
+ /// coreTask.Run();
+ /// if (coreTask.Running)
+ /// {
+ /// coreTask.Quit();
+ /// }
+ ///
+ ///
+ ///
+ /// 12
+ public void Quit()
+ {
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCore.TaskQuit(_handle);
+ if (error != Interop.LibTizenCore.ErrorCode.None)
+ {
+ throw new InvalidOperationException("Failed to quit task");
+ }
+ }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// If true, disposes any disposable objects. If false, does not dispose disposable objects.
+ /// 12
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ if (_handle != IntPtr.Zero)
+ {
+ if (Running)
+ {
+ Quit();
+ }
+
+ Interop.LibTizenCore.TizenCore.TaskDestroy(_handle);
+ _handle = IntPtr.Zero;
+ }
+ }
+
+ _disposed = true;
+ }
+ }
+
+ ///
+ /// Release any unmanaged resources used by this object.
+ ///
+ /// 12
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ internal class TimerSource
+ {
+ public TimerSource(int id, IntPtr handle, Func handler)
+ {
+ Id = id;
+ Handle = handle;
+ Handler = handler;
+ }
+
+ public int Id { get; set; }
+
+ public IntPtr Handle { get; set; }
+
+ public Func Handler { get; set; }
+ }
+ }
+}
diff --git a/src/Tizen.Core/Tizen.Core/TizenCore.cs b/src/Tizen.Core/Tizen.Core/TizenCore.cs
new file mode 100644
index 00000000000..62057768979
--- /dev/null
+++ b/src/Tizen.Core/Tizen.Core/TizenCore.cs
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2024 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.Core
+{
+ ///
+ /// The class which provides functions related to the Tizen Core.
+ ///
+ public static class TizenCore
+ {
+ ///
+ /// Initializes Tizen Core.
+ /// This method should be called once per application before creating any Tasks.
+ /// Calling this method more than one time will increase internal reference counts which need to be matched by calling Shutdown().
+ /// Failing to call Shutdown() in corresponding number of calls may cause resource leakages.
+ ///
+ ///
+ ///
+ ///
+ /// TizenCore.Initialize();
+ /// var task = TizenCore.Spawn("Worker");
+ ///
+ ///
+ ///
+ /// 12
+ static public void Initialize()
+ {
+ Interop.LibTizenCore.TizenCore.Init();
+ }
+
+ ///
+ /// Shuts down Tizen Core.
+ ///
+ ///
+ ///
+ ///
+ /// TizenCore.Shutdown();
+ ///
+ ///
+ ///
+ /// 12
+ static public void Shutdown()
+ {
+ Interop.LibTizenCore.TizenCore.Shutdown();
+ }
+
+ ///
+ /// Finds the task instance.
+ ///
+ /// The ID of the task.
+ ///
+ ///
+ ///
+ /// TizenCore.Initialize();
+ /// var task = TizenCore.Find("Test") ?? TizenCore.Spawn("Test");
+ ///
+ ///
+ ///
+ /// On success the task instance, othwerwise null.
+ public static Task Find(string id)
+ {
+ return Task.Find(id);
+ }
+
+ ///
+ /// Finds the task instance running in the thread of the caller or the "main" task.
+ ///
+ /// On success the task instance, othwerwise null.
+ ///
+ ///
+ ///
+ /// TizenCore.Initialize();
+ /// var coreTask = TizenCore.FindFromThisThread();
+ /// if (coreTask != null)
+ /// {
+ /// coreTask.Post(() => {
+ /// Console.WriteLine("Idler invoked");
+ /// });
+ /// }
+ ///
+ ///
+ ///
+ /// 12
+ public static Task FindFromCurrentThread()
+ {
+ Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCore.FindFromThisThread(out IntPtr handle);
+ if (error == Interop.LibTizenCore.ErrorCode.None)
+ {
+ return new Task(handle);
+ }
+
+ return null;
+ }
+
+ ///
+ /// Creates and runs the task.
+ ///
+ /// The ID of the task.
+ /// On succes the created task instance, othwerwise null.
+ ///
+ ///
+ ///
+ /// TizenCore.Initialize();
+ /// var task = TizenCore.Spawn("Worker");
+ /// if (task != null)
+ /// {
+ /// task.AddTimer(5000, () => {
+ /// Console.WriteLine("Timer expired");
+ /// return true;
+ /// });
+ /// }
+ ///
+ ///
+ ///
+ /// 12
+ public static Task Spawn(string id)
+ {
+ return Task.Spawn(id);
+ }
+ }
+
+ internal static class TCoreErrorFactory
+ {
+ internal enum TCoreError
+ {
+ None = Interop.LibTizenCore.ErrorCode.None,
+ InvalidParameter = Interop.LibTizenCore.ErrorCode.InvalidParameter,
+ OutOfMemory = Interop.LibTizenCore.ErrorCode.OutOfMemory,
+ InvalidContext = Interop.LibTizenCore.ErrorCode.InvalidContext,
+ }
+
+ static internal void CheckAndThrownException(Interop.LibTizenCore.ErrorCode error, string message)
+ {
+ if ((TCoreError)error == TCoreError.None)
+ {
+ return;
+ }
+
+ if ((TCoreError)error == TCoreError.InvalidParameter)
+ {
+ throw new ArgumentException(message);
+ }
+ else if ((TCoreError)error == TCoreError.OutOfMemory)
+ {
+ throw new OutOfMemoryException(message);
+ }
+ else if ((TCoreError)error == TCoreError.InvalidContext)
+ {
+ throw new InvalidOperationException(message);
+ }
+ }
+ }
+}
diff --git a/src/Tizen.Core/doc/api/Tizen.Core.md b/src/Tizen.Core/doc/api/Tizen.Core.md
new file mode 100644
index 00000000000..2ec04f67c0a
--- /dev/null
+++ b/src/Tizen.Core/doc/api/Tizen.Core.md
@@ -0,0 +1,177 @@
+---
+# Copyright (c) 2024 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.
+
+uid: Tizen.Core
+summary: Tizen Core (TCore) is a new main loop model that provides per thread loops, message and event transmission, uniquely named threads.
+remarks: *content
+---
+## Overview
+Tizen Core (TCore) is a new main loop that improves the existing main loop model. It supports creating and running the main loop in multiple threads. Tizen Core provides an API that supports secure communication between threads.
+
+## Preparation
+To use the Tizen Core API, you must define `using Tizen.Core`, as shown below:
+```cs
+using Tizen.Core;
+```
+
+## Initializing Tizen Core
+Before using Tizen Core, Calls TizenCore.Initialize() as shown below:
+```cs
+TizenCore.Initialize();
+```
+
+## Shutting down Tizen Core
+When Tizen Core is no longer needed, shut down Tizen Core with the code below:
+```cs
+TizenCore.Shutdown();
+```
+
+## Managing Tizen Core tasks
+This section will cover creating, executing, and terminating the CoreTask objects, It will also cover adding idle jobs and timers to the main loop.
+
+### Creating a task
+Here` an example on how to create a Task object:
+```cs
+{
+ TizenCore.Initialize();
+ var task = new Task("task1");
+}
+```
+`task` was created with the name "task1" and configured to use its own thread. The created `task` instance should be removed using `Dispose()` method when it is no longer needed.
+
+### Running a task
+In this example, we'll cover the code to execute a previously created task:
+```cs
+{
+ task.Run();
+}
+```
+`task` creates and runs a thread named "task1". After calling `Run()` method, the thread is created and the loop starts running.
+
+### Checking if a task is running
+An example of checking if a task is running using `Running` property:
+```cs
+{
+ if (task.Running)
+ {
+ Log.Debug(LogTag, "task1 is running");
+ }
+ else
+ {
+ Log.Debug(LogTag, "task1 is not running");
+ }
+}
+```
+
+### Adding an timer job to Tizen Core
+Here's an example of registering a timer that calls the handler every 100 ms.
+```cs
+{
+ var timerId = task.AddTimer(100, () => {
+ Log.Debug(LogTag, "timer handler is invoked");
+ return true;
+ });
+}
+```
+
+### Adding an action to Tizen Core
+Let'w write an example that adds an action to `Task`.
+```cs
+{
+ var task = TizenCore.Find("Test") ?? TizenCore.Spawn("Test");
+ task.Post(() => {
+ Log.Debug(LogTag, "Action is invoked");
+ });
+}
+```
+
+## Managing Tizen Core channels
+Tizen Core channel Provides a communication channel that allows safe sending and receiving of data between threads. This channel can be used to exchange information in a synchronized state without data conflict. This section describes how to create a channel sender and receiver pair, send and receive data, and destroy the channel sender and receiver pair.
+
+### Creating a channel
+Here'a an example on how to create a Channel object:
+```cs
+{
+ try {
+ var channel = new Channel();
+ }
+ catch (OutOfMemoryException)
+ {
+ Log.Error(LogTag, "Exception occurs");
+ }
+}
+```
+
+### Creating and transmitting a channel object
+This example show how to create and transmit a channel object:
+```cs
+{
+ TizenCore.Initialize();
+ var channel = new Channel();
+ var receiver = channel.Receiver;
+ receiver.Received += (s, e) => {
+ Log.Debug(LogTag, "OnChannelObjectReceived. Message = {}", (string)e.Data);
+ };
+
+ var task = TizenCore.Find("ReceivingTask") ?? TizenCore.Spawn("ReceivingTask");
+ task.AddChannelReceiver(receiver);
+
+ var sender = channel.Sender;
+ string message = "Test message";
+ using (var channelObject = new ChannelObject(1, message))
+ {
+ sender.Send(channelObject);
+ }
+}
+```
+The example shows adding a receiver to a ReceivingTask and delivering a message using a ChannelSender.
+The channel event is passed to the main loop of the ReceivingTask, causing the event handler to be called.
+
+## Managing Tizen Core events
+A feature to deliver events to specific tasks, which can be used to wait for completion of tasks or send notifications to other threads. This section covers creating events, registering event handlers with them, attaching them to the main loop, and receiving events.
+
+### Creating an event and registering an event handler
+Here's an example of creating an event and registering an event handler:
+```cs
+{
+ var coreEvent = new Event();
+ coreEvent.EventReceived += (s, e) => {
+ Log.Debug(LogTag, "OnEventReceived. Message = {}", (string)e.Data);
+ }
+}
+```
+The example shows creating an event and registering an event handler for it. The created event is added to the EventTask.
+
+### Creating an event object and delivering it to the task.
+```cs
+{
+ TizenCore.Initialize();
+ var coreEvent = new Event();
+ coreEvent.EventReceived += (s, e) => {
+ Log.Debug(LogTag, "OnEventReceived. Message = {}", (string)e.Data);
+ }
+
+ var task = TizenCore.Find("EventTask") ?? TizenCore.Spawn("EventTask");
+ task.AddEvent(coreEvent);
+
+ string message = "Event message";
+ using (var eventObject = new EventObject(1, message))
+ {
+ task.EmitEvent(eventObject);
+ }
+}
+```
+The generated event is added to an EventTask, and a corresponding EventObject is passed to it.
+The event is then delivered to the main loop of the EventTask where the EventHandler is called.
diff --git a/src/Tizen.Data.Tdbc/Tizen.Data.Tdbc/DriverManager.cs b/src/Tizen.Data.Tdbc/Tizen.Data.Tdbc/DriverManager.cs
index d7c1e113e5c..690f6dbb74b 100644
--- a/src/Tizen.Data.Tdbc/Tizen.Data.Tdbc/DriverManager.cs
+++ b/src/Tizen.Data.Tdbc/Tizen.Data.Tdbc/DriverManager.cs
@@ -58,6 +58,11 @@ public static IConnection GetConnection(Uri uri)
throw new SystemException("Failed to open connection due to: " + ex);
}
+ if (conn == null)
+ {
+ throw new SystemException("Failed to open connection");
+ }
+
conn.Open(uri);
return conn;
}
@@ -90,6 +95,11 @@ public static IConnection GetConnection(String connectionString)
throw new SystemException("Failed to open connection due to: " + ex);
}
+ if (conn == null)
+ {
+ throw new SystemException("Failed to open connection");
+ }
+
conn.Open(connectionString);
return conn;
}
diff --git a/src/Tizen.Log/Tizen/Log.cs b/src/Tizen.Log/Tizen/Log.cs
index 1e1c645c1c1..eddd5ecb799 100755
--- a/src/Tizen.Log/Tizen/Log.cs
+++ b/src/Tizen.Log/Tizen/Log.cs
@@ -157,7 +157,7 @@ public class Log
{
private static char[] sep = { '\\', '/' };
///
- /// Prints a log message with the VERBOSE priority.
+ /// Prints a regular log message with the VERBOSE priority.
///
/// 3
/// The tag name of the log message.
@@ -171,7 +171,7 @@ public static void Verbose(string tag, string message, [CallerFilePath] string f
}
///
- /// Prints a log message with the DEBUG priority.
+ /// Prints a regular log message with the DEBUG priority.
///
/// 3
/// The tag name of the log message.
@@ -185,7 +185,7 @@ public static void Debug(string tag, string message, [CallerFilePath] string fil
}
///
- /// Prints a log message with the INFO priority.
+ /// Prints a regular log message with the INFO priority.
///
/// 3
/// The tag name of the log message.
@@ -199,7 +199,7 @@ public static void Info(string tag, string message, [CallerFilePath] string file
}
///
- /// Prints a log message with the WARNING priority.
+ /// Prints a regular log message with the WARNING priority.
///
/// 3
/// The tag name of the log message.
@@ -213,7 +213,7 @@ public static void Warn(string tag, string message, [CallerFilePath] string file
}
///
- /// Prints a log message with the ERROR priority.
+ /// Prints a regular log message with the ERROR priority.
///
/// 3
/// The tag name of the log message.
@@ -227,7 +227,7 @@ public static void Error(string tag, string message, [CallerFilePath] string fil
}
///
- /// Prints a log message with the FATAL priority.
+ /// Prints a regular log message with the FATAL priority.
///
/// 3
/// The tag name of the log message.
@@ -248,6 +248,7 @@ static unsafe void Print(Interop.Dlog.LogPriority priority, string tag, string m
///
/// Provides methods to print log messages to the Tizen logging system.
+ /// Sends "internal" logs, which end up in a different Dlog buffer than regular logs.
///
/// 3
[EditorBrowsable(EditorBrowsableState.Never)]
@@ -255,7 +256,7 @@ public class InternalLog
{
private static char[] sep = { '\\', '/' };
///
- /// Prints a log message with the VERBOSE priority.
+ /// Prints an internal log message with the VERBOSE priority.
///
/// 3
/// The tag name of the log message.
@@ -270,7 +271,7 @@ public static void Verbose(string tag, string message, [CallerFilePath] string f
}
///
- /// Prints a log message with the DEBUG priority.
+ /// Prints an internal log message with the DEBUG priority.
///
/// 3
/// The tag name of the log message.
@@ -284,7 +285,7 @@ public static void Debug(string tag, string message, [CallerFilePath] string fil
}
///
- /// Prints a log message with the INFO priority.
+ /// Prints an internal log message with the INFO priority.
///
/// 3
/// The tag name of the log message.
@@ -298,7 +299,7 @@ public static void Info(string tag, string message, [CallerFilePath] string file
}
///
- /// Prints a log message with the WARNING priority.
+ /// Prints an internal log message with the WARNING priority.
///
/// 3
/// The tag name of the log message.
@@ -312,7 +313,7 @@ public static void Warn(string tag, string message, [CallerFilePath] string file
}
///
- /// Prints a log message with the ERROR priority.
+ /// Prints an internal log message with the ERROR priority.
///
/// 3
/// The tag name of the log message.
@@ -326,7 +327,7 @@ public static void Error(string tag, string message, [CallerFilePath] string fil
}
///
- /// Prints a log message with the FATAL priority.
+ /// Prints an internal log message with the FATAL priority.
///
/// 3
/// The tag name of the log message.
@@ -347,6 +348,7 @@ static unsafe void Print(Interop.Dlog.LogID log_id, Interop.Dlog.LogPriority pri
///
/// Provides methods to print log messages to the Tizen logging system.
+ /// Sends "secure" logs, which have extra safety not to appear on release builds.
///
/// 3
[EditorBrowsable(EditorBrowsableState.Never)]
@@ -354,7 +356,7 @@ public class SecureLog
{
private static char[] sep = { '\\', '/' };
///
- /// Prints a log message with the VERBOSE priority.
+ /// Prints a secure log message with the VERBOSE priority.
///
/// 3
/// The tag name of the log message.
@@ -369,7 +371,7 @@ public static void Verbose(string tag, string message, [CallerFilePath] string f
}
///
- /// Prints a log message with the DEBUG priority.
+ /// Prints a secure log message with the DEBUG priority.
///
/// 3
/// The tag name of the log message.
@@ -383,7 +385,7 @@ public static void Debug(string tag, string message, [CallerFilePath] string fil
}
///
- /// Prints a log message with the INFO priority.
+ /// Prints a secure log message with the INFO priority.
///
/// 3
/// The tag name of the log message.
@@ -397,7 +399,7 @@ public static void Info(string tag, string message, [CallerFilePath] string file
}
///
- /// Prints a log message with the WARNING priority.
+ /// Prints a secure log message with the WARNING priority.
///
/// 3
/// The tag name of the log message.
@@ -411,7 +413,7 @@ public static void Warn(string tag, string message, [CallerFilePath] string file
}
///
- /// Prints a log message with the ERROR priority.
+ /// Prints a secure log message with the ERROR priority.
///
/// 3
/// The tag name of the log message.
@@ -425,7 +427,7 @@ public static void Error(string tag, string message, [CallerFilePath] string fil
}
///
- /// Prints a log message with the FATAL priority.
+ /// Prints a secure log message with the FATAL priority.
///
/// 3
/// The tag name of the log message.
diff --git a/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/Commons.cs b/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/Commons.cs
index 951ca333c56..ab655239b72 100755
--- a/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/Commons.cs
+++ b/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/Commons.cs
@@ -272,7 +272,7 @@ internal static class Tensor
///
/// The maximum number of other/tensor instances that other/tensors may have.
///
- internal const int SizeLimit = 16;
+ internal const int SizeLimit = 256;
///
/// Unknown Type of Tensor information. It is internally used for error check.
diff --git a/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsInfo.cs b/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsInfo.cs
index 094c044eca6..c9927c84755 100755
--- a/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsInfo.cs
+++ b/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsInfo.cs
@@ -60,10 +60,10 @@ public TensorsInfo()
}
///
- /// Add a Tensor information to the TensorsInfo instance. Note that we support up to 16 tensors in TensorsInfo.
+ /// Add a Tensor information to the TensorsInfo instance. Note that we support up to 256 tensors in TensorsInfo.
///
/// Data element type of Tensor.
- /// Dimension of Tensor. Note that we support up to 4th ranks.
+ /// Dimension of Tensor. Note that we support up to 16th ranks.
/// http://tizen.org/feature/machine_learning.inference
/// Thrown when the number of Tensor already exceeds the size limits (i.e. Tensor.SizeLimit)
/// Thrown when the method failed due to an invalid parameter.
diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Dataset.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Dataset.cs
index cfaf094c2a0..5658d4faa8e 100644
--- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Dataset.cs
+++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Dataset.cs
@@ -37,6 +37,9 @@ public class Dataset: IDisposable
private IntPtr handle = IntPtr.Zero;
private bool disposed = false;
+ /// if false, model will be destroy dataset handle
+ private bool hasOwnership = true;
+
///
/// Constructs the dataset.
///
@@ -44,6 +47,9 @@ public class Dataset: IDisposable
public Dataset()
{
NNTrainerError ret = Interop.Dataset.Create(out handle);
+ if (ret != NNTrainerError.None) {
+ handle = IntPtr.Zero;
+ }
NNTrainer.CheckException(ret, "Failed to create dataset instance");
Log.Info(NNTrainer.Tag, "Create Dataset");
}
@@ -82,6 +88,14 @@ protected virtual void Dispose(bool disposing)
{
// release managed object
}
+
+ disposed = true;
+
+ if (!hasOwnership){
+ Log.Info(NNTrainer.Tag, "Cannot destroy dataset already added in a Model. Model will destroy this dataset");
+ return;
+ }
+
// release unmanaged object
if (handle != IntPtr.Zero)
{
@@ -92,7 +106,6 @@ protected virtual void Dispose(bool disposing)
handle = IntPtr.Zero;
}
- disposed = true;
}
///
@@ -124,6 +137,11 @@ internal IntPtr GetHandle()
return handle;
}
+ internal void RemoveOwnership()
+ {
+ this.hasOwnership = false;
+ }
+
///
/// Sets the neural network dataset property.
///
diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs
index 8f66059aa7d..db19839f520 100644
--- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs
+++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs
@@ -49,6 +49,9 @@ public class Layer: IDisposable
public Layer(NNTrainerLayerType type)
{
NNTrainerError ret = Interop.Layer.Create(out handle, type);
+ if (ret != NNTrainerError.None) {
+ handle = IntPtr.Zero;
+ }
NNTrainer.CheckException(ret, "Failed to create model instance");
Log.Info(NNTrainer.Tag, $"Create layer with type:{type}");
}
@@ -98,7 +101,7 @@ protected virtual void Dispose(bool disposing)
disposed = true;
if (!hasOwnership){
- Log.Error(NNTrainer.Tag, "Cannot destroy layer already added in a Model. Model will destroy this layer");
+ Log.Info(NNTrainer.Tag, "Cannot destroy layer already added in a Model. Model will destroy this layer");
return;
}
diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs
index d92636e0f57..fa6a86fa44e 100644
--- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs
+++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs
@@ -65,6 +65,9 @@ public Model(string modelConf)
NNTrainer.CheckException(NNTrainerError.InvalidParameter, "modelConf is null");
NNTrainerError ret = Interop.Model.ConstructWithConf(modelConf, out handle);
+ if (ret != NNTrainerError.None) {
+ handle = IntPtr.Zero;
+ }
NNTrainer.CheckException(ret, "Failed to create model instance with modelConf");
Log.Info(NNTrainer.Tag, "Created Model with Conf path: "+ modelConf);
}
@@ -281,7 +284,7 @@ public void AddLayer(Layer layer)
public Layer GetLayer(string layerName)
{
IntPtr layerHandle = IntPtr.Zero;
- if (string.IsNullOrEmpty(layerName))
+ if (string.IsNullOrEmpty(layerName))
NNTrainer.CheckException(NNTrainerError.InvalidParameter, "layerName is null");
NNTrainerError ret = Interop.Model.GetLayer(handle, layerName, out layerHandle);
@@ -311,6 +314,7 @@ public void SetOptimizer(Optimizer optimizer)
NNTrainerError ret = Interop.Model.SetOptimizer(handle, optimizer.GetHandle());
NNTrainer.CheckException(ret, "Failed to set optimizer");
+ optimizer.RemoveOwnership();
}
///
@@ -335,6 +339,7 @@ public void SetDataset(Dataset dataset)
NNTrainerError ret = Interop.Model.SetDataset(handle, dataset.GetHandle());
NNTrainer.CheckException(ret, "Failed to set dataset");
+ dataset.RemoveOwnership();
}
internal static TensorsInfo CreateTensorsInfoFormHandle(IntPtr handle)
diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Optimizer.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Optimizer.cs
index de7bdf389c3..e10174e3d18 100644
--- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Optimizer.cs
+++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Optimizer.cs
@@ -37,6 +37,9 @@ public class Optimizer: IDisposable
private IntPtr handle = IntPtr.Zero;
private bool disposed = false;
+ /// if false, model will be destroy optimizer handle
+ private bool hasOwnership = true;
+
///
/// Creates a neural network optimizer.
///
@@ -45,6 +48,9 @@ public class Optimizer: IDisposable
public Optimizer(NNTrainerOptimizerType type)
{
NNTrainerError ret = Interop.Optimizer.Create(out handle, type);
+ if (ret != NNTrainerError.None) {
+ handle = IntPtr.Zero;
+ }
NNTrainer.CheckException(ret, "Failed to create optimizer instance");
Log.Info(NNTrainer.Tag, $"Create optimizer with type:{type}");
}
@@ -83,6 +89,14 @@ protected virtual void Dispose(bool disposing)
{
// release managed object
}
+
+ disposed = true;
+
+ if (!hasOwnership){
+ Log.Info(NNTrainer.Tag, "Cannot destroy optimizer already added in a Model. Model will destroy this optimizer");
+ return;
+ }
+
// release unmanaged object
if (handle != IntPtr.Zero)
{
@@ -93,7 +107,6 @@ protected virtual void Dispose(bool disposing)
handle = IntPtr.Zero;
}
- disposed = true;
}
///
@@ -122,5 +135,10 @@ internal IntPtr GetHandle()
{
return handle;
}
+
+ internal void RemoveOwnership()
+ {
+ this.hasOwnership = false;
+ }
}
}
diff --git a/src/Tizen.Multimedia.AudioIO/Interop/Interop.WavPlayer.cs b/src/Tizen.Multimedia.AudioIO/Interop/Interop.WavPlayer.cs
index 0712ee1c430..7c7299690e5 100644
--- a/src/Tizen.Multimedia.AudioIO/Interop/Interop.WavPlayer.cs
+++ b/src/Tizen.Multimedia.AudioIO/Interop/Interop.WavPlayer.cs
@@ -29,6 +29,10 @@ internal static partial class WavPlayer
internal static extern WavPlayerError Start(string filePath, AudioStreamPolicyHandle streamInfoHandle,
WavPlayerCompletedCallback completedCallback, IntPtr userData, out int id);
+ [DllImport(Libraries.WavPlayer, EntryPoint = "wav_player_start_loop")]
+ internal static extern WavPlayerError StartLoop(string filePath, AudioStreamPolicyHandle streamInfoHandle, uint count,
+ WavPlayerCompletedCallback completedCallback, IntPtr userData, out int id);
+
[DllImport(Libraries.WavPlayer, EntryPoint = "wav_player_stop")]
internal static extern WavPlayerError Stop(int id);
}
diff --git a/src/Tizen.Multimedia.AudioIO/WavPlayer/WavPlayer.cs b/src/Tizen.Multimedia.AudioIO/WavPlayer/WavPlayer.cs
index 5c159d5cbff..3dcfb24c26e 100644
--- a/src/Tizen.Multimedia.AudioIO/WavPlayer/WavPlayer.cs
+++ b/src/Tizen.Multimedia.AudioIO/WavPlayer/WavPlayer.cs
@@ -15,6 +15,7 @@
*/
using System;
+using System.ComponentModel;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -85,20 +86,62 @@ public static Task StartAsync(string path, AudioStreamPolicy streamPolicy,
}
return cancellationToken.IsCancellationRequested ? Task.FromCanceled(cancellationToken) :
- StartAsyncCore(path, streamPolicy, cancellationToken);
+ StartAsyncCore(path, streamPolicy, 1, cancellationToken);
}
- private static async Task StartAsyncCore(string path, AudioStreamPolicy streamPolicy,
+ ///
+ /// Plays a wav file based on the specified with given repetition number.
+ ///
+ /// If loopCount is 0, it means infinite loops
+ /// A task that represents the asynchronous operation.
+ /// A file path to play.
+ /// A .
+ /// A number of repetitions.
+ /// A cancellation token which can be used to stop.
+ ///
+ /// is null.
+ /// -or-
+ /// is null.
+ ///
+ /// An internal error occurs.
+ /// does not exists.
+ /// The format of is not supported.
+ /// has already been disposed of.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Task StartAsync(string path, AudioStreamPolicy streamPolicy, uint loopCount,
+ CancellationToken cancellationToken)
+ {
+ if (path == null)
+ {
+ throw new ArgumentNullException(nameof(path));
+ }
+
+ if (streamPolicy == null)
+ {
+ throw new ArgumentNullException(nameof(streamPolicy));
+ }
+
+ if (File.Exists(path) == false)
+ {
+ throw new FileNotFoundException("File does not exists.", path);
+ }
+
+ return cancellationToken.IsCancellationRequested ? Task.FromCanceled(cancellationToken) :
+ StartAsyncCore(path, streamPolicy, loopCount, cancellationToken);
+ }
+
+ private static async Task StartAsyncCore(string path, AudioStreamPolicy streamPolicy, uint loopCount,
CancellationToken cancellationToken)
{
+ int id = 0;
var tcs = new TaskCompletionSource();
Native.WavPlayerCompletedCallback cb = (id_, _) => tcs.TrySetResult(true);
using (var cbKeeper = ObjectKeeper.Get(cb))
{
- Native.Start(path, streamPolicy.Handle, cb, IntPtr.Zero, out var id).
- Validate("Failed to play.");
+ Native.StartLoop(path, streamPolicy.Handle, loopCount, cb, IntPtr.Zero, out id).
+ Validate("Failed to play with loop.");
using (RegisterCancellationAction(tcs, cancellationToken, id))
{
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/AdaptiveVariants.cs b/src/Tizen.Multimedia.MediaPlayer/Player/AdaptiveVariants.cs
index b24188e5788..aa66f1f0fa8 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/AdaptiveVariants.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/AdaptiveVariants.cs
@@ -93,7 +93,7 @@ internal AdaptiveVariants(Player player)
}
///
- /// Sets the maximum limit of the streaming variant.
+ /// Sets the maximum limit of adaptive streaming variants.
///
/// The has already been disposed of.
///
@@ -119,7 +119,7 @@ public void SetMaxLimit(int bandwidth, int width = -1, int height = -1)
}
///
- /// Gets the maximum limit of the streaming variant.
+ /// Gets the maximum limit of the adaptive streaming variant.
///
/// The containing the variant information.
/// The has already been disposed of.
@@ -136,7 +136,7 @@ public VariantInfo GetMaxLimit()
}
///
- /// Retrieves all the available adaptive variants.
+ /// Retrieves all the available adaptive streaming variants.
///
///
/// It returns a list contained all the available adaptive variants.
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/AudioDataDecodedEventArgs.cs b/src/Tizen.Multimedia.MediaPlayer/Player/AudioDataDecodedEventArgs.cs
index 17a00850c7e..1f0ac187777 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/AudioDataDecodedEventArgs.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/AudioDataDecodedEventArgs.cs
@@ -32,7 +32,7 @@ internal AudioDataDecodedEventArgs(MediaPacket packet)
}
///
- /// Gets the packet containing the decoded frame.
+ /// Gets the media packet containing the audio decoded frame.
///
/// 6
public MediaPacket Packet { get; }
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/AudioEffect.cs b/src/Tizen.Multimedia.MediaPlayer/Player/AudioEffect.cs
index 9815506a3b1..66b670207e4 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/AudioEffect.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/AudioEffect.cs
@@ -98,7 +98,7 @@ public void Clear()
}
///
- /// Gets the number of items.
+ /// Gets the number of equalizer bands available.
///
/// If audio offload is enabled by calling . (Since tizen 6.0)
/// -or-
@@ -148,7 +148,7 @@ public Range BandLevelRange
}
///
- /// Gets the value whether the AudioEffect is available or not.
+ /// Gets the value indicating whether the AudioEffect is available or not.
///
/// This function returns the availability of the .
/// It could be unavailable depending on the platform capabilities.
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/AudioOffload.cs b/src/Tizen.Multimedia.MediaPlayer/Player/AudioOffload.cs
index e25c20ea83a..cf474668a61 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/AudioOffload.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/AudioOffload.cs
@@ -50,7 +50,7 @@ internal void CheckDisabled()
}
///
- /// Enables or disables the audio offload.
+ /// Gets or sets whether the audio offload is enabled.
///
/// The value indicating whether or not audio offload is enabled. The default value is false.
/// The player lets the hardware decode and render the sound if the audio offload is enabled.
@@ -103,7 +103,7 @@ public bool IsEnabled
}
///
- /// Get a state whether or not the audio offload is activated.
+ /// Get a value indication whether or not the audio offload is activated.
///
/// The value indicating whether or not AudioOffload is activated.
///
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/EqualizerBand.cs b/src/Tizen.Multimedia.MediaPlayer/Player/EqualizerBand.cs
index d5c7e5406bb..b359aa05f49 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/EqualizerBand.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/EqualizerBand.cs
@@ -85,7 +85,7 @@ public int Level
///
- /// Gets the frequency in dB.
+ /// Gets the frequency in dB of the equalizer band.
///
///
/// If audio offload is enabled by calling . (Since tizen 6.0)
@@ -105,7 +105,7 @@ public int Frequency
}
///
- /// Gets the frequency range in dB.
+ /// Gets the frequency range in dB of the equalizer band.
///
///
/// If audio offload is enabled by calling . (Since tizen 6.0)
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/MediaBufferSource.cs b/src/Tizen.Multimedia.MediaPlayer/Player/MediaBufferSource.cs
index 0ad90e3ff76..c2d47dafdcb 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/MediaBufferSource.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/MediaBufferSource.cs
@@ -33,7 +33,7 @@ public sealed class MediaBufferSource : MediaSource
private byte[] _buffer;
///
- /// Initializes a new instance of the MediaBufferSource class with an allocated buffer.
+ /// Initializes a new instance of the MediaBufferSource class with the specified buffer length.
///
/// The value indicating the size of the buffer.
///
@@ -54,7 +54,7 @@ public MediaBufferSource(int length)
}
///
- /// Initializes a new instance of the MediaBufferSource class from the buffer.
+ /// Initializes a new instance of the MediaBufferSource class with the specified buffer.
///
/// The source array to be copied into the buffer.
/// is null.
@@ -65,7 +65,7 @@ public MediaBufferSource(byte[] buffer) : this(buffer, buffer == null ? 0 : buff
//TODO remove default parameter.
///
- /// Initializes a new instance of the MediaBufferSource class from the buffer
+ /// Initializes a new instance of the MediaBufferSource class with buffer, length, and optional offset.
/// with the specified length and the specified offset.
///
/// The source array to be copied into the buffer.
@@ -141,4 +141,3 @@ internal override void OnAttached(Player player)
}
}
}
-
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamBufferStatusChangedEventArgs.cs b/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamBufferStatusChangedEventArgs.cs
index dd48e886b80..468a41dfb67 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamBufferStatusChangedEventArgs.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamBufferStatusChangedEventArgs.cs
@@ -36,7 +36,7 @@ public MediaStreamBufferStatusChangedEventArgs(MediaStreamBufferStatus status)
}
///
- /// Gets the status.
+ /// Gets the current buffer status.
///
/// 3
public MediaStreamBufferStatus Status { get; }
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamConfiguration.cs b/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamConfiguration.cs
index c8d19defb14..602e7e9156e 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamConfiguration.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamConfiguration.cs
@@ -59,10 +59,10 @@ internal MediaStreamConfiguration(MediaStreamSource owner, StreamType streamType
public event EventHandler SeekingOccurred;
///
- /// Gets or sets the max size of the buffer.
+ /// Gets or sets the maximum size of the buffer for media stream.
///
- /// The max size of the buffer. The default is 200000.
- /// If the buffer level overflows the max size, will be raised with .
+ /// The maximum size of the buffer in bytes. The default is 200000.
+ /// If the buffer level overflows the maximum size, will be raised with .
/// The is not assigned to a player.
/// is zero.
///
@@ -95,7 +95,7 @@ public ulong BufferMaxSize
}
///
- /// Gets or sets the minimum threshold of the buffer.
+ /// Gets or sets the minimum threshold of the media stream buffer.
///
/// The minimum threshold of the buffer in percentage. The default is zero.
/// If the buffer level drops below the threshold value, will be raised with .
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamSeekingOccurredEventArgs.cs b/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamSeekingOccurredEventArgs.cs
index e033ed9f6e8..7de8cc98790 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamSeekingOccurredEventArgs.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamSeekingOccurredEventArgs.cs
@@ -35,8 +35,14 @@ public MediaStreamSeekingOccurredEventArgs(ulong offset)
}
///
- /// Gets the offset.
+ /// Gets the next new play position as a result of seeking operation.
///
+ ///
+ /// The next playback position after SetPlayPositionAsync could be a little bit different with its input position.
+ /// So user should push the next media data using this time offset in nanoseconds.
+ ///
+ ///
+ ///
/// 3
public ulong Offset { get; }
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamSource.cs b/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamSource.cs
index 0bee6d10c89..ea57faa6d78 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamSource.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/MediaStreamSource.cs
@@ -37,7 +37,7 @@ public sealed class MediaStreamSource : MediaSource
private static List _supportedVideoFormats;
///
- /// Gets all supported audio types.
+ /// Gets the supported audio types of the media stream source.
///
/// 3
public static IEnumerable SupportedAudioTypes
@@ -50,7 +50,7 @@ public static IEnumerable SupportedAudioTypes
}
///
- /// Gets all supported video types.
+ /// Gets the supported video types of the media stream source.
///
/// 3
public static IEnumerable SupportedVideoTypes
@@ -214,7 +214,7 @@ public MediaStreamSource(VideoMediaFormat videoMediaFormat)
public MediaStreamConfiguration VideoConfiguration { get; }
///
- /// Pushes elementary stream to decode audio or video.
+ /// Pushes elementary stream to decode audio or video packet.
///
/// This source must be set as a source to a player and the player must be in the ,
/// , or state.
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/MediaUriSource.cs b/src/Tizen.Multimedia.MediaPlayer/Player/MediaUriSource.cs
index 240b7a37f03..415a8f17f96 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/MediaUriSource.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/MediaUriSource.cs
@@ -20,7 +20,7 @@
namespace Tizen.Multimedia
{
///
- /// Represents a media source with a uri.
+ /// Represents a media source with a URI.
///
///
/// The internet privilege(http://tizen.org/privilege/internet) must be added if any URLs are used to play from a network.
@@ -31,9 +31,10 @@ namespace Tizen.Multimedia
/// 3
public sealed class MediaUriSource : MediaSource
{
- // TODO consider using Uri class.
+ // TODO consider using URI class.
///
- /// Initializes a new instance of the MediaUriSource class with the specified uri.
+ /// Initializes a new instance of the MediaUriSource class with the specified URI.
+ ///
/// The uri string.
/// For HTTP or RSTP, uri should start with "http://" or "rtsp://".
/// The default protocol is "file://".
@@ -57,4 +58,3 @@ internal override void OnAttached(Player player)
}
}
}
-
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/PlaybackInterruptedEventArgs.cs b/src/Tizen.Multimedia.MediaPlayer/Player/PlaybackInterruptedEventArgs.cs
index 47475e7a858..679ab19ddac 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/PlaybackInterruptedEventArgs.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/PlaybackInterruptedEventArgs.cs
@@ -35,7 +35,7 @@ public PlaybackInterruptedEventArgs(PlaybackInterruptionReason reason)
}
///
- /// Gets the reason.
+ /// Gets the reason for the playback interruption.
///
/// 3
public PlaybackInterruptionReason Reason { get; }
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs b/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
index 1b5d2f3939a..e60b994b413 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
@@ -193,7 +193,7 @@ public PlayerBufferingTime BufferingTime
#endregion
///
- /// Gets the state of the player.
+ /// Gets the current state of the player.
///
/// The current state of the player.
/// The player has already been disposed of.
@@ -258,7 +258,7 @@ public AudioLatencyMode AudioLatencyMode
}
///
- /// Gets or sets the looping state.
+ /// Gets or sets a value indicationg whether the media source is played in a loop.
///
/// true if the playback is looping; otherwise, false. The default value is false.
/// The player has already been disposed of.
@@ -286,7 +286,7 @@ public bool IsLooping
private PlayerDisplaySettings _displaySettings;
///
- /// Gets the display settings.
+ /// Gets the display settings of the player.
///
/// A that specifies the display settings.
/// 3
@@ -314,7 +314,7 @@ private void ReplaceDisplay(Display newDisplay)
}
///
- /// Gets or sets the display.
+ /// Gets or sets the display of the player.
///
/// A that specifies the display.
///
@@ -387,7 +387,7 @@ PlayerErrorCode IDisplayable.ApplyEcoreWindow(IntPtr windowHand
private PlayerTrackInfo _audioTrack;
///
- /// Gets the track info for the audio.
+ /// Gets the audio track information of the player.
///
/// A for audio.
/// 3
@@ -406,7 +406,7 @@ public PlayerTrackInfo AudioTrackInfo
private PlayerTrackInfo _subtitleTrackInfo;
///
- /// Gets the track info for the subtitle.
+ /// Gets the sutitle track information of the player.
///
/// A for the subtitle.
/// 3
@@ -425,7 +425,7 @@ public PlayerTrackInfo SubtitleTrackInfo
private StreamInfo _streamInfo;
///
- /// Gets the stream information.
+ /// Gets the stream information of the player.
///
/// A for this player.
/// 3
@@ -444,7 +444,7 @@ public StreamInfo StreamInfo
private AudioEffect _audioEffect;
///
- /// Gets the audio effect.
+ /// Gets the audio effect of the player.
///
/// http://tizen.org/feature/multimedia.custom_audio_effect
/// The required feature is not supported.
@@ -463,7 +463,7 @@ public AudioEffect AudioEffect
}
///
- /// Gets or sets the mute state.
+ /// Gets or sets a value indicationg whether the audio output of the player is muted.
///
/// true if the player is muted; otherwise, false.
/// The player has already been disposed of.
@@ -486,7 +486,7 @@ public bool Muted
}
///
- /// Gets or sets the current volume.
+ /// Gets or sets the current volume of the player.
///
/// Valid volume range is from 0 to 1.0, inclusive.
/// The player has already been disposed of.
@@ -520,7 +520,7 @@ public float Volume
}
///
- /// Gets or sets the audio-only state.
+ /// Gets or sets a value indicating whether the player is in audio only mode.
///
/// true if the playback is audio-only mode; otherwise, false. The default value is false.
/// The must be in the ,
@@ -547,7 +547,7 @@ public bool IsAudioOnly
}
///
- /// Gets or sets the player's replaygain state.
+ /// Gets or sets a value indicating whether the replay gain is enabled.
///
/// If the replaygain status is true, replaygain is applied (if contents has a replaygain tag);
/// otherwise, the replaygain is not affected by tag and properties.
@@ -585,8 +585,7 @@ public bool ReplayGain
}
///
- /// Enables or disables controlling the pitch of audio.
- /// Gets the status of controlling the pitch of audio.
+ /// Gets or sets a value indicating whether the audio pitch control is enabled.
///
/// The value indicating whether or not AudioPitch is enabled. The default is false.
/// This function is used for audio content only.
@@ -628,7 +627,7 @@ public bool AudioPitchEnabled
}
///
- /// Gets or sets the pitch of audio.
+ /// Gets or sets the pitch of the audio.
///
/// The audio stream pitch value. The default is 1.
/// Enabling pitch control could increase the CPU usage on some devices.
@@ -783,7 +782,7 @@ public CodecType VideoCodecType
private SphericalVideo _sphericalVideo;
///
- /// Gets the spherical video settings.
+ /// Gets the spherical video porperties of the player.
///
/// 5
public SphericalVideo SphericalVideo
@@ -802,7 +801,7 @@ public SphericalVideo SphericalVideo
private AdaptiveVariants _adaptiveVariants;
///
- /// Gets the adaptive variants settings.
+ /// Gets the adaptive variants of the player.
///
/// 5
public AdaptiveVariants AdaptiveVariants
@@ -821,7 +820,7 @@ public AdaptiveVariants AdaptiveVariants
private AudioOffload _audioOffload;
///
- /// Gets the setting for audio offload.
+ /// Gets the audio offload settings of the player.
///
/// 6
public AudioOffload AudioOffload
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/Player.cs b/src/Tizen.Multimedia.MediaPlayer/Player/Player.cs
index 3b3e2c2e105..0ec788b05e1 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/Player.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/Player.cs
@@ -184,7 +184,7 @@ internal void ValidateNotDisposed()
#region Methods
///
- /// Gets the streaming download progress.
+ /// Gets the download progress of the streaming contents.
///
/// The containing current download progress.
/// The player must be in the , ,
@@ -211,7 +211,7 @@ public DownloadProgress GetDownloadProgress()
}
///
- /// Sets the subtitle path for playback.
+ /// Sets the subtitle file path for playback.
///
/// The absolute path of the subtitle file, it can be NULL in the state.
/// Only MicroDVD/SubViewer(*.sub), SAMI(*.smi), and SubRip(*.srt) subtitle formats are supported.
@@ -247,7 +247,7 @@ public void SetSubtitle(string path)
}
///
- /// Removes the subtitle path.
+ /// Clears the the subtitle path of the media player.
///
/// The player must be in the state.
/// The player has already been disposed of.
@@ -262,7 +262,7 @@ public void ClearSubtitle()
}
///
- /// Sets the offset for the subtitle.
+ /// Sets the seek offset for the subtitle.
///
/// The value indicating a desired offset in milliseconds.
/// The player must be in the or state.
@@ -410,7 +410,7 @@ public virtual async Task PrepareAsync(CancellationToken cancellationToken)
}
///
- /// Unprepares the player.
+ /// Unprepares the media player.
///
///
/// The most recently used source is reset and is no longer associated with the player. Playback is no longer possible.
@@ -450,7 +450,7 @@ protected virtual void OnUnprepared()
}
///
- /// Starts or resumes playback.
+ /// Starts or resumes playing the media content.
///
///
/// Sound can be mixed with other sounds if you don't control the stream focus using .
@@ -505,7 +505,7 @@ public virtual void Stop()
}
///
- /// Pauses the player.
+ /// Pauses playing the media content.
///
///
/// The player must be in the state.
@@ -570,7 +570,7 @@ public void SetSource(MediaSource source)
}
///
- /// Captures a video frame, asynchronously.
+ /// Captures the current frame of the video being played, asynchronously.
///
/// A task that represents the asynchronous capture operation.
/// http://tizen.org/feature/multimedia.raw_video
@@ -607,7 +607,7 @@ public async Task CaptureVideoAsync()
}
///
- /// Gets the play position in milliseconds.
+ /// Gets the current playback position in milliseconds of the media.
///
/// The current position in milliseconds.
/// The player must be in the , ,
@@ -673,7 +673,7 @@ private async Task SetPlayPosition(long position, bool accurate, bool nanosecond
}
///
- /// Sets the seek position for playback, asynchronously.
+ /// Sets the playback position in milliseconds of the player, asynchronously.
///
/// The value indicating a desired position in milliseconds.
/// The value indicating whether the operation performs with accuracy.
@@ -701,7 +701,7 @@ public async Task SetPlayPositionAsync(int position, bool accurate)
}
///
- /// Gets the play position in nanoseconds.
+ /// Gets the current playback position in nanoseconds of the media.
///
/// The current position in nanoseconds.
/// The player must be in the , ,
@@ -725,7 +725,7 @@ public long GetPlayPositionNanoseconds()
}
///
- /// Sets the seek position in nanoseconds for playback, asynchronously.
+ /// Sets the playback position in nanoseconds of the player, asynchronously.
///
/// The value indicating a desired position in nanoseconds.
/// The value indicating whether the operation performs with accuracy.
@@ -753,7 +753,7 @@ public async Task SetPlayPositionNanosecondsAsync(long position, bool accurate)
}
///
- /// Sets the playback rate.
+ /// Sets the playback rate of the player.
///
/// The value for the playback rate. Valid range is -5.0 to 5.0, inclusive.
///
@@ -793,7 +793,7 @@ public void SetPlaybackRate(float rate)
}
///
- /// Applies the audio stream policy.
+ /// Applies the specified audio stream policy to the player.
///
/// The to apply.
///
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/PlayerDisplaySettings.cs b/src/Tizen.Multimedia.MediaPlayer/Player/PlayerDisplaySettings.cs
index 38b8a947a24..b8c889befc0 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/PlayerDisplaySettings.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/PlayerDisplaySettings.cs
@@ -53,7 +53,7 @@ protected PlayerDisplaySettings(Player player)
protected Player Player { get; }
///
- /// Gets or sets the .
+ /// Gets or sets the of the player.
///
///
/// Operation failed; internal error.
@@ -134,7 +134,7 @@ public Rotation Rotation
}
///
- /// Sets the roi(region of interest).
+ /// Sets the ROI(Region Of Interest) for the video display.
///
/// The region.
///
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/PlayerEnums.cs b/src/Tizen.Multimedia.MediaPlayer/Player/PlayerEnums.cs
index 137fc1a5865..27378e44466 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/PlayerEnums.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/PlayerEnums.cs
@@ -38,7 +38,7 @@ public enum PlayerError
InternalError = ErrorCode.InvalidOperation,
///
- /// No space.
+ /// No space on the device.
///
NoSpaceOnDevice = PlayerErrorCode.NoSpaceOnDevice,
@@ -269,32 +269,32 @@ public enum PlaybackInterruptionReason
public enum StreamMetadataKey
{
///
- /// Album.
+ /// The album name of the media content
///
Album,
///
- /// Artists.
+ /// The artist(s) of the media content.
///
Artist,
///
- /// Author.
+ /// The author(s) of the media content.
///
Author,
///
- /// Genre.
+ /// The genre(s) of the media content.
///
Genre,
///
- /// Title.
+ /// The title of the media content.
///
Title,
///
- /// Year.
+ /// The year of the media content.
///
Year
}
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/SubtitleUpdatedEventArgs.cs b/src/Tizen.Multimedia.MediaPlayer/Player/SubtitleUpdatedEventArgs.cs
index f3ee00a62ab..b46489e700f 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/SubtitleUpdatedEventArgs.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/SubtitleUpdatedEventArgs.cs
@@ -30,7 +30,7 @@ internal SubtitleUpdatedEventArgs(uint duration, string text)
}
///
- /// Gets the duration of the updated subtitle.
+ /// Gets the duration in milliseconds of the updated subtitle.
///
/// 3
public uint Duration { get; }
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/VideoFrameDecodedEventArgs.cs b/src/Tizen.Multimedia.MediaPlayer/Player/VideoFrameDecodedEventArgs.cs
index 89e97d2c5ca..cb978a69cc4 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/VideoFrameDecodedEventArgs.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/VideoFrameDecodedEventArgs.cs
@@ -32,7 +32,7 @@ internal VideoFrameDecodedEventArgs(MediaPacket packet)
}
///
- /// Gets the packet containing the decoded frame.
+ /// Gets the media packet containing the decoded frame.
///
/// 3
public MediaPacket Packet { get; }
diff --git a/src/Tizen.Multimedia.Metadata/MetadataExtractor/Metadata.cs b/src/Tizen.Multimedia.Metadata/MetadataExtractor/Metadata.cs
index d5ca764fefc..0d10a12f376 100644
--- a/src/Tizen.Multimedia.Metadata/MetadataExtractor/Metadata.cs
+++ b/src/Tizen.Multimedia.Metadata/MetadataExtractor/Metadata.cs
@@ -215,6 +215,8 @@ internal Metadata(MetadataExtractor extractor)
DateRecorded = extractor.GetMetadata(MetadataExtractorAttr.RecordingDate);
Rotation = extractor.GetMetadata(MetadataExtractorAttr.Rotate);
Content360 = extractor.GetMetadata(MetadataExtractorAttr.ContentFor360);
+ var stitched = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.StitchedContentFor360));
+ StitchedContent360 = stitched == 0 || stitched == null ? null : stitched;
_description = new Lazy(() => ObjectDescriptionBuilder.BuildWithProperties(this));
}
@@ -402,6 +404,13 @@ internal Metadata(MetadataExtractor extractor)
/// A string representing the information for 360 content, or null if the information does not exist.
public string Content360 { get; }
+ ///
+ /// Gets the information about 360 video content being stitched or not.
+ ///
+ /// 12
+ /// 1 : not stitched, 2 : stitched, or null if the information does not exist.
+ public int? StitchedContent360 { get; }
+
private Lazy _description;
///