agoraio-extensions / agora-c_sharp-sdk Goto Github PK
View Code? Open in Web Editor NEWThe simple ways to use Agora RTC SDK with C#
The simple ways to use Agora RTC SDK with C#
When I am selecting the join channel option it is giving error that unable to find entry point for CreateIrisRtcEngine method and AgoraRtcWrapper is not loading
private AgoraRtcEngine(EngineType type = EngineType.kEngineTypeNormal)
{
_result = new CharAssistant();
_channelInstance = new Dictionary<string, AgoraRtcChannel>();
_irisRtcEngine = type == EngineType.kEngineTypeNormal
? AgoraRtcNative.CreateIrisRtcEngine()
: AgoraRtcNative.CreateIrisRtcEngine(EngineType.kEngineTypeSubProcess);
If I modify the project directly to .net 5.0 or framework 4.X, will there be any pitfalls when I run it?
如果直接修改工程为 .net 5.0 或者 framework 4.X ,运行的时候会有什么坑吗?
We are preparing a c# application which basically is supposed to live streaming Custom audio to multiple Agora Channels at the same time. Here is the code we are trying to run:
/// <summary>
/// Intialize agora and join channel.
/// </summary>
[Obsolete]
public int InitializeAgora(string token, uint uid)
{
this.agoraEngine = RtcEngine.CreateAgoraRtcEngineEx();
// Prepare engine context
RtcEngineContext rtc_engine_ctx = new RtcEngineContext(
this.agoraAppId,
0,
CHANNEL_PROFILE_TYPE.CHANNEL_PROFILE_LIVE_BROADCASTING,
AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_DEFAULT);
// RtcEngineContext rtc_engine_ctx = new RtcEngineContext();
rtc_engine_ctx.appId = this.agoraAppId;
// Initialize engine
this.agoraEngine.Initialize(rtc_engine_ctx);
// Join channel
this.agoraEngine.EnableAudio();
this.agoraEngine.EnableLocalAudio(false);
this.agoraEngine.SetAudioProfile(AUDIO_PROFILE_TYPE.AUDIO_PROFILE_MUSIC_STANDARD, AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_MEETING);
this.agoraEngine.SetEnableSpeakerphone(false);
this.agoraEngine.SetExternalAudioSource(true, 16000, 1);
// this.agoraEngine.SetExternalAudioSink(true, 16000, 1);
this.agoraEngine.SetClientRole(CLIENT_ROLE_TYPE.CLIENT_ROLE_BROADCASTER);
this.agoraEngine.SetChannelProfile(CHANNEL_PROFILE_TYPE.CHANNEL_PROFILE_LIVE_BROADCASTING);
int joinResult = this.agoraEngine.JoinChannel(token, this.channelName, string.Empty, uid);
return joinResult;
}
/// <summary>
/// Send the audio buffer to agora.
/// </summary>
/// <param name="audioData">Buffer data.</param>
public int SendAudioFrame(byte[] audioData)
{
int pushResult = 0;
try
{
long currentTimeMillis = (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
// Assuming you have the audio frame data in bytes, send it to Agora
AudioFrame audioFrame = new AudioFrame();
audioFrame.samplesPerSec = this.agoraSamplerate;
audioFrame.channels = this.agoraChannels;
audioFrame.RawBuffer = audioData;
audioFrame.renderTimeMs = currentTimeMillis;
audioFrame.samplesPerChannel = audioData.Length / 2;
audioFrame.type = AUDIO_FRAME_TYPE.FRAME_TYPE_PCM16;
// audioFrame.sam = (BYTES_PER_SAMPLE)(audioData.Length / (this.agoraChannels * 2));
pushResult = this.agoraEngine.PushAudioFrame(
audioFrame);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
return pushResult;
}
// <copyright file="AgoraAudioBroadcaster.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
// </copyright>
namespace TeamsBot.Agora
{
using System;
using global::Agora.Rtc;
using Newtonsoft.Json.Linq;
/// <summary>
/// Broadcaster for agora.
/// </summary>
public class AgoraAudioBroadcaster
{
private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
private readonly int agoraSamplerate = 16000;
private readonly int agoraChannels = 1;
private string agoraAppId;
private string agoraAppCert;
private string channelName;
private IRtcEngine agoraEngine;
// private string token = "007eJxTYNBW29y2Pmjr9qu6dSJbv29K+2zz7VdfkdCt0+//dSgd/f1HgcHCONnS3NAwJcUwLcXEODHFwsLILNUsyTTFxDAxKdHUvIXnWkpDICODMAcXMyMDBIL4Egx5mSWZeQ6ZeSWpOTmZxclFmQUlxXrJ+bkMDABdpyol";
/// <summary>
/// Constructor.
/// </summary>
/// <param name="agoraAppId"></param>
/// <param name="channelName"></param>
/// <param name="agoraAppCert"></param>
public AgoraAudioBroadcaster(string agoraAppId, string channelName, string agoraAppCert)
{
this.agoraAppId = agoraAppId;
this.channelName = channelName;
this.agoraAppCert = agoraAppCert;
}
/// <summary>
/// Intialize agora and join channel.
/// </summary>
[Obsolete]
public int InitializeAgora(string token, uint uid)
{
this.agoraEngine = RtcEngine.CreateAgoraRtcEngineEx();
// Prepare engine context
RtcEngineContext rtc_engine_ctx = new RtcEngineContext(
this.agoraAppId,
0,
CHANNEL_PROFILE_TYPE.CHANNEL_PROFILE_LIVE_BROADCASTING,
AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_DEFAULT);
// RtcEngineContext rtc_engine_ctx = new RtcEngineContext();
rtc_engine_ctx.appId = this.agoraAppId;
// Initialize engine
this.agoraEngine.Initialize(rtc_engine_ctx);
// Join channel
this.agoraEngine.EnableAudio();
this.agoraEngine.EnableLocalAudio(false);
this.agoraEngine.SetAudioProfile(AUDIO_PROFILE_TYPE.AUDIO_PROFILE_MUSIC_STANDARD, AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_MEETING);
this.agoraEngine.SetEnableSpeakerphone(false);
this.agoraEngine.SetExternalAudioSource(true, 16000, 1);
// this.agoraEngine.SetExternalAudioSink(true, 16000, 1);
this.agoraEngine.SetClientRole(CLIENT_ROLE_TYPE.CLIENT_ROLE_BROADCASTER);
this.agoraEngine.SetChannelProfile(CHANNEL_PROFILE_TYPE.CHANNEL_PROFILE_LIVE_BROADCASTING);
int joinResult = this.agoraEngine.JoinChannel(token, this.channelName, string.Empty, uid);
return joinResult;
}
/// <summary>
/// Returns the app ID.
/// </summary>
/// <returns>returns the agora app ID.</returns>
public string GetAgoraAppId()
{
return this.agoraAppId;
}
/// <summary>
/// Send the audio buffer to agora.
/// </summary>
/// <param name="audioData">Buffer data.</param>
public int SendAudioFrame(byte[] audioData)
{
int pushResult = 0;
try
{
long currentTimeMillis = (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
// Assuming you have the audio frame data in bytes, send it to Agora
AudioFrame audioFrame = new AudioFrame();
audioFrame.samplesPerSec = this.agoraSamplerate;
audioFrame.channels = this.agoraChannels;
audioFrame.RawBuffer = audioData;
audioFrame.renderTimeMs = currentTimeMillis;
audioFrame.samplesPerChannel = audioData.Length / 2;
audioFrame.type = AUDIO_FRAME_TYPE.FRAME_TYPE_PCM16;
// audioFrame.sam = (BYTES_PER_SAMPLE)(audioData.Length / (this.agoraChannels * 2));
pushResult = this.agoraEngine.PushAudioFrame(
audioFrame);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
return pushResult;
}
/// <summary>
/// Dispose the agora engine and leave the channel.
/// </summary>
private void LeaveChannel()
{
this.agoraEngine.LeaveChannel();
this.agoraEngine.Dispose();
this.agoraEngine = null;
}
}
}
We create instance of the class using below code
private AgoraAudioBroadcaster ConfigureAgoraChannel(CallParticipantAddBody callParticipantAddBody)
{
var agoraAppId = this.configuration["AgoraAppId"];
var agoraCert = this.configuration["AgoraCert"];
AgoraAudioBroadcaster agoraAudioBroadcaster = new AgoraAudioBroadcaster(agoraAppId, callParticipantAddBody.UserPrincipalName, agoraCert);
var response = agoraAudioBroadcaster.InitializeAgora(callParticipantAddBody.AgoraSenderToken, (uint)callParticipantAddBody.SenderUDI);
return agoraAudioBroadcaster;
}
Problem
This code works just fine when we are trying to publish to the first channel. However, when we try to join the second channel, we get error code –17.
The app ID and certificate being used is the same, we do not have different app id for different channels.
Question
How can we publish the same audio stream to multiple agora channels at the same time?
Hi, I'm trying to use this example using 32 bit development, but I've found that the remote video is not showing (rendering). Can anyone help? I need it to be working on 32 bit devices.
Thank you.
Hello,
If I run the solution and select "1v1" video for example, I am still getting "OnWarning 106" and "OnRejoinChannelSuccess" repeatedly.
I think the C# SDK does not work for me because when I join the same room in C# SDK and Web SDK, I am unable to see a strem from C# SDK on a web.
Am I missing something?
Thank you
看到这个C# SDK通过P/Invoke调iris.dll,请问这个iris.dll是什么呢?
Hello,
I would like to join a channel without media and use the SendMessage functionality only. Use media on request lately.
I want to mimic RTM product.
In our usecase we do not need the media every time.
If there is a way how to use RTM (not RTC) with c#, please let me know.
Getting following error
Uncaught (in promise) AgoraRTCException: AgoraRTCError CAN_NOT_GET_GATEWAY_SERVER: flag: 4096, message: AgoraRTCError CAN_NOT_GET_GATEWAY_SERVER: dynamic use static key
I did use new key but no effect.
hello,does it works on hololens2?
Hello, I added the Nuget to a new project, and it only runs if I set the target of my project to x86. If I set to x64, it doesn't run, giving me an exception:
An unhandled exception of type 'System.BadImageFormatException' occurred in Host_Test_1.dll
Could not load file or assembly 'agorartc, Version=3.6.2.0, Culture=neutral, PublicKeyToken=null'. Trying to load a program in incorret format.
Is there a Nuget version of the library that runs on x64 targets?
I fill out the app id and channel name for the demo, but after joining, the screen is not showing anything.
Also, I notice that we don't have to fill in any token ? The demo that you have here https://webdemo.agora.io/agora-web-showcase/examples/Agora-Web-Tutorial-1to1-Web/ does require it though.
Select tap "screen share" and press "join channel" and i got 110 error
also got 1042 warning
The message shows "join ok" but i don't think it's joined.
I think other function dosen't works either.
error api
it says I need token-based authentication and i can't understand what it is.
I remember agora screen share in unity worked fine without token setting.
Any suggestion what to do?
Thank you.
Hello!
If you do everything according to the instructions, after installing the package, building and running the project causes an exception.
System.DllNotFoundException
HResult=0x80131524
Message = Unable to load DLL 'iris.dll' or one of its dependencies: The specified module was not found. (0x8007007E)
C:\Agora-C_Sharp-SDK\OneToOneVideo\OneToOneVideo\bin\Debug\netcoreapp3.1>dotnet OneToOneVideo.dll
Unhandled exception. System.DllNotFoundException: Unable to load DLL 'iris.dll' or one of its dependencies: The specified module was not found. (0x8007007E)
at agorartc.AgorartcNative.CreateIrisEngine()
at agorartc.AgoraRtcEngine.CreateRtcEngine()
at OneToOneVideo.OneToOneVideoDemo..ctor() in C:\Agora-C_Sharp-SDK\OneToOneVideo\OneToOneVideo\OneToOneVideoDemo.cs:line 27
at OneToOneVideo.Program.Main() in C:\Agora-C_Sharp-SDK\OneToOneVideo\OneToOneVideo\Program.cs:line 20
27 string is that: "Rtc = AgoraRtcEngine.CreateRtcEngine();"
What is the problem and how can it be solved?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.