public void DidAudioMuted(AgoraRtcEngineKit engine, bool muted, nuint uid) { var user = GetOrCreateUser(uid); user.IsAudioMuted = muted; RemoteVideosContainer.ReloadRows(new[] { NSIndexPath.FromRowSection(_userList.IndexOf(user), 0) }, UITableViewRowAnimation.Automatic); }
private void CheckPermissionAndRunAgoraEngine() { SetError(string.Empty); AVCaptureDevice.RequestAccessForMediaType(AVAuthorizationMediaType.Audio, (accessGranted) => { BeginInvokeOnMainThread(() => { if (accessGranted) { _agoraKit = AgoraRtcEngineKit.SharedEngineWithAppId(AgoraTestConstants.AgoraAPI, (error) => { SetError($"Could not init agora. {error}"); SetControlsVisible(false); }); JoinChannel(); SetControlsVisible(true); } else { SetError("Permission denied. Please allow access to microphone"); SetControlsVisible(false); } }); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); NavigationController.NavigationBarHidden = true; RoomNameLabel.Text = AgoraSettings.Current.RoomName; BackgroundTap.ShouldRequireFailureOfGestureRecognizer(BackgroundDoubleTap); AgoraDelegate = new AgoraRtcDelegate(this); AgoraKit = AgoraRtcEngineKit.SharedEngineWithAppIdAndDelegate(AgoraTestConstants.AgoraAPI, AgoraDelegate); AgoraKit.SetChannelProfile(ChannelProfile.Communication); AgoraKit.EnableVideo(); //var profile = AgoraSettings.Current.UseMySettings ? AgoraSettings.Current.Profile.ToAgoraRtcVideoProfile() : DT.Xamarin.Agora.VideoProfile.Default; //AgoraKit.SetVideoProfile(profile, false); //AgoraRtcVideoCanvas videoCanvas = new AgoraRtcVideoCanvas(); //videoCanvas.Uid = 0; //videoCanvas.View = LocalView; //LocalView.Hidden = false; //videoCanvas.RenderMode = VideoRenderMode.Adaptive; //AgoraKit.SetupLocalVideo(videoCanvas); if (!string.IsNullOrEmpty(AgoraSettings.Current.EncryptionPhrase)) { AgoraKit.SetEncryptionMode(AgoraSettings.Current.EncryptionType.GetModeString()); AgoraKit.SetEncryptionSecret(AgoraSettings.Current.EncryptionPhrase); } AgoraKit.StartPreview(); Join(); }
public void DidAudioMuted(AgoraRtcEngineKit engine, bool muted, nuint uid) { var index = _users.IndexOf(_users.First(u => u.Uid == (uint)uid)); _users[index].IsAudioMuted = muted; RemoteUsersTableView.ReloadData(); }
private void LeaveChannel() { _agoraKit.LeaveChannel(null); AgoraRtcEngineKit.Destroy(); RtmService.Instance.LeaveChannel(); _userList.Clear(); }
public async Task TokenPrivilegeWillExpire(AgoraRtcEngineKit engine, string token) { var newToken = await AgoraTokenService.GetRtcToken(AgoraSettings.Current.RoomName); if (!string.IsNullOrEmpty(newToken)) { _agoraKit.RenewToken(newToken); } }
public virtual void OnUserJoined(AgoraRtcEngineKit engine, nuint uid) { var id = (uint)uid; foreach (var holder in _containers.Where(a => a.StreamUID == id)) { holder.VideoView.IsOffline = false; } }
public virtual void OnUserEnabledVideo(AgoraRtcEngineKit engine, nuint uid, bool enabled) { var id = (uint)uid; foreach (var holder in _containers.Where(a => a.StreamUID == id)) { holder.VideoView.IsVideoEnabled = enabled; } }
/// <summary> /// Ons the user mute audio. /// </summary> /// <param name="engine">Engine.</param> /// <param name="uid">Uid.</param> /// <param name="muted">If set to <c>true</c> muted.</param> public virtual void OnUserMuteAudio(AgoraRtcEngineKit engine, nuint uid, bool muted) { var id = (uint)uid; foreach (var holder in _containers.Where(a => a.StreamUID == id)) { holder.VideoView.IsAudioMuted = muted; } }
public void LeaveChannel() { _agoraKit.LeaveChannel(null); _agoraKit.SetupLocalVideo(null); remoteVideo.RemoveFromSuperview(); localVideo.RemoveFromSuperview(); //delegate?.VideoChatNeedClose(self); _agoraKit = null; }
public void LeaveChannel() { _agoraKit.LeaveChannel(null); _agoraKit.SetupLocalVideo(null); AgoraRtcEngineKit.Destroy(); RtmService.Instance.LeaveChannel(); _users.Clear(); _agoraKit = null; }
void LeaveChannel() { agoraKit.LeaveChannel(null); HideControlButtons(); UIApplication.SharedApplication.IdleTimerDisabled = false; remoteVideo.RemoveFromSuperview(); localVideo.RemoveFromSuperview(); agoraKit = null; this.DismissViewController(true, null); }
public void SetRemoteVideo(AgoraRtcEngineKit engine, nuint uid, CoreGraphics.CGSize size, nint elapse) { AgoraRtcVideoCanvas videoCanvas = new AgoraRtcVideoCanvas { Uid = uid, View = ContainerView, RenderMode = VideoRenderMode.Adaptive }; _rtcEngine.SetupRemoteVideo(videoCanvas); }
public void FirstRemoteVideoDecodedOfUid(AgoraRtcEngineKit engine, nuint uid, CGSize size, nint elapsed) { if (_users.Any(u => u.Uid == uid)) { return; } _users.Add(new RemoteVideoInfo { Uid = (uint)uid }); RemoteUsersTableView.ReloadData(); }
public override void RtcEngine(AgoraRtcEngineKit engine, nuint uid, CoreGraphics.CGSize size, nint elapsed) { if (_viewController.remoteVideo.Hidden) { _viewController.remoteVideo.Hidden = false; } AgoraRtcVideoCanvas videoCanvas = new AgoraRtcVideoCanvas(); videoCanvas.Uid = uid; videoCanvas.View = _viewController.remoteVideo; videoCanvas.RenderMode = AgoraRtcRenderMode.Adaptive; _viewController.agoraKit.SetupRemoteVideo(videoCanvas); }
public void FirstRemoteVideoDecodedOfUid(AgoraRtcEngineKit engine, nuint uid, CoreGraphics.CGSize size, nint elapsed) { if (remoteVideo.Hidden) { remoteVideo.Hidden = false; } var videoCanvas = new AgoraRtcVideoCanvas(); videoCanvas.Uid = uid; videoCanvas.View = remoteVideo; videoCanvas.RenderMode = VideoRenderMode.Adaptive; agoraKit.SetupRemoteVideo(videoCanvas); }
/// <summary> /// Starts the session. /// </summary> /// <param name="sessionId">Session identifier.</param> /// <param name="agoraAPI">Agora API key.</param> public virtual void StartSession(string sessionId, string agoraAPI, string token, VideoAgoraProfile profile = VideoAgoraProfile.Portrait360P, bool swapWidthAndHeight = false, bool webSdkInteroperability = false) { _knownStreams.Add(_myId); _agoraDelegate = new AgoraRtcDelegate(this); _agoraEngine = AgoraRtcEngineKit.SharedEngineWithAppIdAndDelegate(agoraAPI, _agoraDelegate); _agoraEngine.EnableWebSdkInteroperability(webSdkInteroperability); _agoraEngine.SetChannelProfile(ChannelProfile.Communication); _agoraEngine.EnableLocalVideo(true); _agoraEngine.SwitchCamera(); _agoraEngine.EnableVideo(); _agoraEngine.SetVideoProfile(GetVideoProfile(profile), swapWidthAndHeight); // if you do not specify the uid, we will generate the uid for you _agoraEngine.JoinChannelByToken(token, sessionId, null, 0, JoiningCompleted); }
public void FirstRemoteVideoDecodedOfUid(AgoraRtcEngineKit engine, nuint uid, CGSize size, nint elapsed) { if (remoteVideo.Hidden) { remoteVideo.Hidden = false; } remoteVideoMutedIndicator.Hidden = true; var videoCanvas = new AgoraRtcVideoCanvas(); videoCanvas.Uid = uid; videoCanvas.View = remoteVideo; videoCanvas.RenderMode = AgoraVideoRenderMode.Adaptive; _agoraKit.SetupRemoteVideo(videoCanvas); }
/// <summary> /// Ends the session. /// </summary> public virtual void EndSession() { _containers.Clear(); _knownStreams.Clear(); _myId = 0; _agoraEngine.StopPreview(); _agoraEngine.SetupLocalVideo(null); _agoraEngine.StopAudioMixing(); _agoraEngine.StopAudioRecording(); _agoraEngine.LeaveChannel(null); _agoraEngine.Dispose(); AgoraRtcEngineKit.Destroy(); _agoraEngine = null; }
public override void ViewDidLoad() { base.ViewDidLoad(); AgoraDelegate = new AgoraRtcQualityDelegate(this); AgoraKit = AgoraRtcEngineKit.SharedEngineWithAppIdAndDelegate(AgoraTestConstants.AgoraAPI, AgoraDelegate); AgoraKit.EnableWebSdkInteroperability(true); ChannelNameEdit.Text = AgoraSettings.Current.RoomName; ChannelNameEdit.EditingDidBegin += TextField_EditingDidBegin; ChannelNameEdit.EditingDidEnd += TextField_EditingDidEnd; EncryptionKeyEdit.Text = AgoraSettings.Current.EncryptionPhrase; MakeTextFieldRounded(ChannelNameEdit); AgoraVersionLabel.Text = string.Format(AgoraVersion, AgoraRtcEngineKit.SdkVersion); NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIImage.FromBundle("ic_share"), UIBarButtonItemStyle.Plain, ShareButtonCliked); NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIImage.FromBundle("ic_settings"), UIBarButtonItemStyle.Plain, SettingsButtonCliked); SetupKeyboardHiding(); }
public override void ViewDidLoad() { base.ViewDidLoad(); AgoraDelegate = new AgoraRtcQualityDelegate(this); AgoraKit = AgoraRtcEngineKit.SharedEngineWithAppIdAndDelegate(AgoraTestConstants.AgoraAPI, AgoraDelegate); AgoraKit.EnableWebSdkInteroperability(true); ChannelNameEdit.Text = AgoraSettings.Current.RoomName; EncryptionKeyEdit.Text = AgoraSettings.Current.EncryptionPhrase; UserNameLabel.Text = RtmService.Instance.UserName; ChannelNameEdit.SetRoundCorners(); ChannelNameEdit.SetAttributedPlaceholder("Room Name"); AgoraVersionLabel.Text = string.Format(AgoraVersion, AgoraRtcEngineKit.SdkVersion); NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIImage.FromBundle("ic_share"), UIBarButtonItemStyle.Plain, ShareButtonCliked); NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIImage.FromBundle("ic_settings"), UIBarButtonItemStyle.Plain, SettingsButtonCliked); View.SetupKeyboardHiding(ChannelNameEdit); }
public override void ViewDidLoad() { base.ViewDidLoad(); _rtcEngineDeletegate = new RtcEngineDelegate(this); _rtcEngine = AgoraRtcEngineKit.SharedEngineWithAppIdAndDelegate("2cb3898040a64b88a9ca9763cc3d5667", _rtcEngineDeletegate); _rtcEngine.SetChannelProfile(ChannelProfile.Communication); _rtcEngine.EnableVideo(); AgoraRtcVideoCanvas videoCanvas = new AgoraRtcVideoCanvas { Uid = 0, View = LocalView, RenderMode = VideoRenderMode.Adaptive }; _rtcEngine.SetupLocalVideo(videoCanvas); _rtcEngine.JoinChannelByToken(string.Empty, "DEMOCHANNEL1", null, 0, JoinSuccessful); }
public void LastmileQuality(AgoraRtcEngineKit engine, NetworkQuality agoraQuality) { string quality = string.Empty; switch (agoraQuality) { case NetworkQuality.Excellent: quality = "Excellent"; ConnectionImage.Image = UIImage.FromBundle("connection_5"); break; case NetworkQuality.Good: quality = "Good"; ConnectionImage.Image = UIImage.FromBundle("connection_4"); break; case NetworkQuality.Poor: quality = "Poor"; ConnectionImage.Image = UIImage.FromBundle("connection_3"); break; case NetworkQuality.Bad: quality = "Bad"; ConnectionImage.Image = UIImage.FromBundle("connection_2"); break; case NetworkQuality.VBad: quality = "Very Bad"; ConnectionImage.Image = UIImage.FromBundle("connection_1"); break; case NetworkQuality.Down: quality = "Down"; ConnectionImage.Image = UIImage.FromBundle("connection_0"); break; default: quality = "Unknown"; ConnectionImage.Image = UIImage.FromBundle("connection_0"); break; } ConnectingLabel.Text = string.Format(QualityFormat, quality); }
public void FirstRemoteVideoDecodedOfUid(AgoraRtcEngineKit engine, nuint uid, CoreGraphics.CGSize size, nint elapsed) { _remoteId = (uint)uid; if (ContainerView.Hidden) { ContainerView.Hidden = false; } AgoraRtcVideoCanvas videoCanvas = new AgoraRtcVideoCanvas(); videoCanvas.Uid = uid; videoCanvas.View = ContainerView; videoCanvas.RenderMode = VideoRenderMode.Adaptive; AgoraKit.SetupRemoteVideo(videoCanvas); if (ContainerView.Hidden) { ContainerView.Hidden = false; } RefreshDebug(); }
/// <summary> /// Firsts the remote video decoded of uid. /// </summary> /// <param name="engine">Engine.</param> /// <param name="uid">Uid.</param> /// <param name="size">Size.</param> /// <param name="elapsed">Elapsed.</param> public virtual void FirstRemoteVideoDecodedOfUid(AgoraRtcEngineKit engine, nuint uid, CoreGraphics.CGSize size, nint elapsed) { var id = (uint)uid; _knownStreams.Add(id); if (!_containers.Any(a => a.StreamUID == id)) { if (_containers.Any(a => a.StreamUID == AgoraService.UnknownRemoteStreamId)) { var viewHolder = _containers.First(a => a.StreamUID == AgoraService.UnknownRemoteStreamId); viewHolder.StreamUID = id; viewHolder.VideoView.IsOffline = false; } else { OnNewStream(id, (int)size.Width, (int)size.Height); } } }
public void FirstLocalVideoFrameWithSize(AgoraRtcEngineKit engine, CoreGraphics.CGSize size, nint elapsed) { var fixedSize = size.FixedSize(ContainerView.Bounds.Size); nfloat ratio; if (fixedSize.Width > 0 && fixedSize.Height > 0) { ratio = fixedSize.Width / fixedSize.Height; } else { ratio = ContainerView.Bounds.Width / ContainerView.Bounds.Height; } var viewWidth = NSLayoutConstraint.Create(LocalView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Width, 0.249999f, 0f); var viewRatio = NSLayoutConstraint.Create(LocalView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, LocalView, NSLayoutAttribute.Height, ratio, 0f); NSLayoutConstraint.DeactivateConstraints(new NSLayoutConstraint[] { LocalVideoWidth, LocalVideoHeight }); NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { viewWidth, viewRatio }); }
internal void OnUserOffline(AgoraRtcEngineKit engine, nuint uid, UserOfflineReason reason) { var id = (uint)uid; _knownStreams.Remove(id); var toClear = _containers.Where(a => a.StreamUID == id && a.IsStatic).ToList(); var toRemove = _containers.Where(a => a.StreamUID == id && !a.IsStatic).ToList(); foreach (var container in toRemove) { container.NativeView.RemoveFromSuperview(); _containers.Remove(container); } foreach (var container in toClear) { container.VideoView.IsOffline = true; container.VideoView.IsAudioMuted = false; container.VideoView.IsVideoMuted = false; container.VideoView.StreamUID = container.VideoView.StreamUID == Consts.UnknownLocalStreamId ? Consts.UnknownLocalStreamId : Consts.UnknownRemoteStreamId; } OnDisconnected(id); }
private void InitAgoraRtc() { AudioMuted = VideoMuted = false; AgoraDelegate = new AgoraRtcDelegate(this); _agoraKit = AgoraRtcEngineKit.SharedEngineWithAppIdAndDelegate(AgoraTestConstants.AgoraAPI, AgoraDelegate); _agoraKit.SetChannelProfile(ChannelProfile.Communication); _agoraKit.EnableVideo(); RemoteVideosContainer.DataSource = new RemoteVideosTableSource(_userList, _agoraKit); //var profile = AgoraSettings.Current.UseMySettings ? AgoraSettings.Current.Profile.ToAgoraRtcVideoProfile() : DT.Xamarin.Agora.VideoProfile.Default; //AgoraKit.SetVideoProfile(profile, false); AgoraRtcVideoCanvas videoCanvas = new AgoraRtcVideoCanvas(); videoCanvas.Uid = 0; videoCanvas.View = LocalView; LocalView.Hidden = false; videoCanvas.RenderMode = VideoRenderMode.Adaptive; _agoraKit.SetupLocalVideo(videoCanvas); if (!string.IsNullOrEmpty(AgoraSettings.Current.EncryptionPhrase)) { _agoraKit.SetEncryptionMode(AgoraSettings.Current.EncryptionType.GetModeString()); _agoraKit.SetEncryptionSecret(AgoraSettings.Current.EncryptionPhrase); } _agoraKit.StartPreview(); }
private void InitAgora() { _sharedAgoraEngine = AgoraRtcEngineKit.SharedEngineWithAppIdAndDelegate(AgoraTestConstants.AgoraAPI, null); _sharedAgoraEngine.SetChannelProfile(ChannelProfile.LiveBroadcasting); _sharedAgoraEngine.SetClientRole(ClientRole.Broadcaster); _sharedAgoraEngine.EnableVideo(); _sharedAgoraEngine.SetExternalVideoSource(true, useTexture: true, pushMode: true); var videoConfig = new AgoraVideoEncoderConfiguration(VideoDimension, VideoFrameRate.VideoFrameRateFps24, 3000, VideoOutputOrientationMode.Adaptative); _sharedAgoraEngine.SetVideoEncoderConfiguration(videoConfig); _sharedAgoraEngine.SetAudioProfile(AudioProfile.MusicStandardStereo, AudioScenario.Default); _sharedAgoraEngine.EnableExternalAudioSourceWithSampleRate(AudioSampleRate, AudioChannels); _sharedAgoraEngine.MuteAllRemoteVideoStreams(true); _sharedAgoraEngine.MuteAllRemoteAudioStreams(true); }
public override void FirstLocalVideoFrameWithSize(AgoraRtcEngineKit engine, CoreGraphics.CGSize size, nint elapsed) { _controller.FirstLocalVideoFrameWithSize(engine, size, elapsed); }