private void OnBandwidthChanged(int index) { if (_pc1 == null || _pc2 == null) { return; } ulong? bandwidth = bandwidthOptions.Values.ElementAt(index); RTCRtpSender sender = _pc1.GetSenders().First(); RTCRtpSendParameters parameters = sender.GetParameters(); if (bandwidth == null) { parameters.encodings[0].maxBitrate = null; parameters.encodings[0].minBitrate = null; } else { parameters.encodings[0].maxBitrate = bandwidth * 1000; parameters.encodings[0].minBitrate = bandwidth * 1000; } RTCError error = sender.SetParameters(parameters); if (error.errorType != RTCErrorType.None) { Debug.LogErrorFormat("RTCRtpSender.SetParameters failed {0}", error.errorType); } Debug.Log("SetParameters:" + bandwidth); }
private IEnumerator UpdateStatsCoroutine() { RTCRtpSender sender = _pc1?.GetSenders().First(); if (sender == null) { yield break; } RTCStatsReportAsyncOperation op = sender.GetStats(); yield return(op); if (op.IsError) { Debug.LogErrorFormat("RTCRtpSender.GetStats() is failed {0}", op.Error.errorType); } else { UpdateStatsPacketSize(op.Value); } }