なんかいろいろしてみます

Jun 25, 2021 - 2 minute read - HoloLens

AzureCommunicationServices を HoloLens の Unity 上で利用してみる

HoloLens の Unity アプリに AzureCommunicationServices を組み込んでMRCビデオチャットをできるようにしてみました.

概要

できること

  • .NET ライブラリを利用することで Unity 上でも AzureCommunicationServices の機能を使うことができます.
  • 今回は Unity アプリ内からビデオ通話機能を利用できるようにしてみます.

  • HoloLens 上の Unity アプリ内で AzureCommunicationServices を利用するためのプロジェクトを公開しています.

  • https://github.com/akihiro0105/CommunicationServicesUnitySample

  • AzureCommunicationServices のライブラリを導入し設定することで利用することができます.

ライブラリ導入

  • .nupkg の拡張子を .zip に変更して解凍すると内部のライブラリを抜き出すことができます.

  • Unity プロジェクトを作成し Plugins フォルダにライブラリを配置していきます.

  • azure.communication.calling.1.0.0-beta.28\lib\uap10.0 の以下のファイルを Plugins\WSA に配置

    • Azure.Communication.Calling.winmd
    • Azure.Communication.winmd
    • Azure.Core.winmd
  • 配置後に画像のように設定を行い UWP 実行時に利用できるようにします.

  • azure.communication.calling.1.0.0-beta.28\runtimes\win10-arm64\native のdllを Plugin\WSA\ARM64 に配置
  • azure.communication.calling.1.0.0-beta.28\runtimes\win10-x64\native のdllを Plugin\WSA\x86_64 に配置
  • azure.communication.calling.1.0.0-beta.28\runtimes\win10-x86\native のdllを Plugin\WSA\x86 に配置

  • dll は以下をそれぞれのフォルダに配置

    • ACSCallingShared.dll
    • Azure.Communication.Calling.dll
    • Azure.Communication.dll
    • Azure.Core.dll
    • RtmCodecs.dll
    • RtmMediaManager.dll
    • RtmMvrUap.dll
    • RtmPal.dll
    • RTMPLTFM.dll
    • skypert.dll
    • ssScreenVVS2.dll
    • VideoN.dll
  • dll の設定を画像のように ARM64 , x86 , x64 にそれぞれ設定しておきます

プロジェクト設定

  • Azure への接続,ビデオ通話ができるように Project settings の Capability の許諾を以下のように設定します.

public class CommunicationServicesSample : MonoBehaviour
{
    private CommunicationServices communicationServices;

    // アクセストークン
    private string user_token_ = "";

    // 接続先
    private string call_text = "";

    // 表示名
    private string user_name = "ACS Unity User";

    // Start is called before the first frame update
    async void Start()
    {
        communicationServices = new CommunicationServices();
        await communicationServices.Init(user_token_, user_name);

        await Task.Delay(1000);

        await communicationServices.CallButton_ClickAsync(call_text);
    }
}

  • Teams 会議に参加する場合には接続用の関数を Teams 用に書き換えて Teams の参加URL を入力してください
  await communicationServices.CallButton_ClickAsync(call_text);
  以下に書き換え
  await communicationServices.TeamsButton_Click(call_text);

できないこと

  • ビデオチャットの映像は UWP の UI に依存しているため, Unity 空間での表示に非対応

まとめ

  • HoloLens の 3D の Unity 空間内から AzureCommunicationServices でビデオ会話が可能になった
  • Teams 会議にも参加して HoloLens 内の空間表示を共有できた
  • Unity 空間内にビデオ表示がしたい
  • Unity 用 AzureCommunicationServices ライブラリにビデオ通話機能をサポートしてほしい