/// <summary> /// Accesses the local video track, specified by /// this.selectedDevice and this.selectedProfile. /// MUST NOT BE CALLED FROM THE UI THREAD. /// </summary> /// <param name="factory"></param> /// <returns></returns> private IMediaStreamTrack GetLocalVideo(IWebRtcFactory factory) { IReadOnlyList <IConstraint> mandatoryConstraints = new List <IConstraint>() { new Constraint("maxWidth", this.SelectedProfile.Width.ToString()), new Constraint("minWidth", this.SelectedProfile.Width.ToString()), new Constraint("maxHeight", this.SelectedProfile.Height.ToString()), new Constraint("minHeight", this.SelectedProfile.Height.ToString()), new Constraint("maxFrameRate", this.SelectedProfile.FrameRate.ToString()), new Constraint("minFrameRate", this.SelectedProfile.FrameRate.ToString()) }; IReadOnlyList <IConstraint> optionalConstraints = new List <IConstraint>(); var mediaConstraints = new MediaConstraints(mandatoryConstraints, optionalConstraints); // this will throw a very unhelpful exception if called from the UI thread var videoOptions = new VideoCapturerCreationParameters(); videoOptions.Id = this.SelectedDevice.Id; videoOptions.Name = this.SelectedDevice.Name; videoOptions.EnableMrc = false; var videoCapturer = VideoCapturer.Create(videoOptions); var options = new VideoOptions() { Factory = factory, Capturer = videoCapturer, Constraints = mediaConstraints }; var videoTrackSource = VideoTrackSource.Create(options); return(MediaStreamTrack.CreateVideoTrack("LocalVideo", videoTrackSource)); }
public VideoCapturerCreationParameters CreationParameters(WebRtcFactory factory) { var param = new VideoCapturerCreationParameters(); param.Name = DeviceName; param.Id = DeviceId; if (DeviceId.Equals("screen-share")) { param.Factory = factory; } param.Format = CreateVideoFormat(); return(param); }