private void ChangeBandwitdh(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); statsField.text += $"Failed change bandwidth to {bandwidth * 1000}{Environment.NewLine}"; bandwidthSelector.value = 0; } }
private void ChangeBandwitdh(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; } RTCErrorType error = sender.SetParameters(parameters); if (error != RTCErrorType.None) { Debug.LogErrorFormat("RTCRtpSender.SetParameters failed {0}", error); } }
private void ChangeFramerate(RTCRtpSender sender, uint framerate) { RTCRtpSendParameters parameters = sender.GetParameters(); parameters.encodings[0].maxFramerate = framerate; RTCError error = sender.SetParameters(parameters); if (error.errorType != RTCErrorType.None) { Debug.LogErrorFormat("RTCRtpSender.SetParameters failed {0}", error.errorType); } }
private void ChangeFramerate(int index) { if (_pc1 == null || _pc2 == null) { return; } uint? framerate = framerateOptions.Values.ElementAt(index); RTCRtpSender sender = _pc1.GetSenders().First(); RTCRtpSendParameters parameters = sender.GetParameters(); parameters.encodings[0].maxFramerate = framerate; RTCError error = sender.SetParameters(parameters); if (error.errorType != RTCErrorType.None) { Debug.LogErrorFormat("RTCRtpSender.SetParameters failed {0}", error.errorType); statsField.text += $"Failed maxFramerate to " + $"{framerate}{Environment.NewLine}"; framerateSelector.value = 0; } }
private void ChangeScaleResolutionDown(int index) { if (_pc1 == null || _pc2 == null) { return; } double scale = scaleResolutionDownOptions.Values.ElementAt(index); RTCRtpSender sender = _pc1.GetSenders().First(); RTCRtpSendParameters parameters = sender.GetParameters(); parameters.encodings[0].scaleResolutionDownBy = scale; RTCError error = sender.SetParameters(parameters); if (error.errorType != RTCErrorType.None) { Debug.LogErrorFormat("RTCRtpSender.SetParameters failed {0}", error.errorType); statsField.text += $"Failed scale down video resolution to " + $"{(int)(width / scale)}x{(int)(height / scale)}{Environment.NewLine}"; scaleResolutionDownSelector.value = 0; } }