Azure-Samples / communication-services-dotnet-quickstarts

Sample code for Azure Communication Services .Net quickstarts
MIT License
76 stars 104 forks source link

Unable to join call from .net core console application #145

Closed magnusdanielson closed 7 months ago

magnusdanielson commented 7 months ago
- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Create .net core console application. Target framework .Net 6.0 Target OS Windows Allow unsafe code Platform target x64 Target OS Version 10.0.22621.0 Supported OS version 10.0.22621.0

Below is the proj file

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0-windows10.0.22621.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <SupportedOSPlatformVersion>10.0.22621.0</SupportedOSPlatformVersion>
    <PlatformTarget>x64</PlatformTarget>
    <Platforms>x64</Platforms>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <WarningsAsErrors />
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <WarningsAsErrors />
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <WarningsAsErrors />
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <WarningsAsErrors />
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Azure.Communication.Calling.WindowsClient" Version="1.0.0" />
    <PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.6" />
  </ItemGroup>

</Project>

Update the Program.cs:

static async Task Main(string[] args)
        {
            var handler = new CallHandler();
            await handler.DoStuff();
        }

Add the CallHandler class:

internal class CallHandler
    {
        CallAgent callAgent;
        CommunicationCall call;
        RawIncomingAudioStream rawIncomingAudioStream;
        internal async Task DoStuff()
        {
            var callClient = new CallClient();

            var tokenCredential = new CallTokenCredential("token-from-az-cli-command-with-voip-scope");
            var callAgentOptions = new CallAgentOptions()
            {
                DisplayName = "Magnus"
            };

            this.callAgent = await callClient.CreateCallAgentAsync(tokenCredential, callAgentOptions);
            var startCallOptions = new StartCallOptions();

            var incomingVideoOptions = new IncomingVideoOptions
            {
                StreamKind = VideoStreamKind.RawIncoming,
                FrameKind = RawVideoFrameKind.Buffer
            };

            RawIncomingAudioStreamProperties properties = new RawIncomingAudioStreamProperties()
            {
                Format = AudioStreamFormat.Pcm16Bit,
                SampleRate = AudioStreamSampleRate.Hz_16000,
                ChannelMode = AudioStreamChannelMode.Mono
            };
            RawIncomingAudioStreamOptions options = new RawIncomingAudioStreamOptions()
            {
                Properties = properties
            };
            this.rawIncomingAudioStream = new RawIncomingAudioStream(options);
            IncomingAudioOptions incomingAudioOptions = new IncomingAudioOptions()
            {
                Stream = rawIncomingAudioStream
            };

            var joinCallOptions = new JoinCallOptions
            {
                IncomingVideoOptions = incomingVideoOptions,
                IncomingAudioOptions = incomingAudioOptions
            };

            var callees = new CallIdentifier[1]
            {
                new UserCallIdentifier("identifier-from-az-cli-command")

            };
            string MeetingLink = "https://teams.microsoft.com/l/meetup-join/19%3ameeting_NTUyMTRjMWQtOTlmZi00M2I5LTliNzAtNDBjNzhhNDliZjk4%40thread.v2/0?context=%7b%22Tid%22%3a%227ad8d35b-859c-482f-aceb-5d290f70e64b%22%2c%22Oid%22%3a%22e1619785-ecb0-434f-9ea8-dea76a43abab%22%7d";
            var locator = new TeamsMeetingLinkLocator(MeetingLink);

            this.call = await this.callAgent.JoinAsync(locator, joinCallOptions); // .StartCallAsync(callees, startCallOptions);
        }

    }

Start the app and after this.call = await this.callAgent.JoinAsync the this.call.EndCallReason == 410

According to this page: https://learn.microsoft.com/en-us/azure/communication-services/concepts/troubleshooting-info?tabs=csharp%2Cios%2Cdotnet#calling-sdk-error-codes

410 | Local media stack or media infrastructure error. | Ensure that you're using the latest SDK in a supported environment.

How can I ensure I use the correct SDK in a supported environment?

Any log messages given by the failure

image

Expected/desired behavior

The call is accepted and user is put in lobby.

OS and Version?

Windows, details above

Versions

Tested with Azure.Communication.Calling.WindowsClient 1.0.0 1.1.0 1.2.0 1.3.0

Other errors occurs on 1.4.0 and 1.5.0

Mention any other details that might be useful

It works if I do exactly the same in a UAP application.


Thanks! We'll be in touch soon.

magnusdanielson commented 7 months ago

Answered here: https://github.com/MicrosoftDocs/azure-docs/issues/119570