private async void Unsubscribe_Click(object sender, EventArgs e) { client = new JanusRestClient(); var result = await client.UnPublish_RegisterRoom(); // return result; }
// Media media // public audioDevice aud; // public videoDevice vid; // public device dev; public WebRTCServer(int port) //: this("ws://0.0.0.0:" + port) { client = new JanusRestClient(); client.OnPollingMessageReceived += Client_OnPollingMessageReceived; client.Ip = "192.168.2.19"; client.Port = 8089; }
private void btn1_Click(object sender, EventArgs e) { client = new JanusRestClient(); var result = client.UnPublish_RegisterRoom(); }
public async Task <IActionResult> JanusEcho([FromBody] RTCSessionDescriptionInit offer, int duration = MAX_JANUS_ECHO_DURATION) { if (offer == null) { _logger.LogWarning($"Janus echo controller was supplied an empty SDP offer."); return(BadRequest("SDP offer missing")); } else if (duration > MAX_JANUS_ECHO_DURATION) { duration = MAX_JANUS_ECHO_DURATION; } _logger.LogDebug($"Creating Janus echo test with duration {duration}s."); CancellationTokenSource cts = new CancellationTokenSource(); cts.CancelAfter(duration * 1000); var janusClient = new JanusRestClient(_janusUrl, _logger, cts.Token); var startSessionResult = await janusClient.StartSession(); if (!startSessionResult.Success) { return(Problem("Failed to create Janus session.")); } else { var waitForAnswer = new TaskCompletionSource <string>(); janusClient.OnJanusEvent += (resp) => { if (resp.jsep != null) { _logger.LogDebug($"janus get event jsep={resp.jsep.type}."); _logger.LogDebug($"janus SDP Answer: {resp.jsep.sdp}"); waitForAnswer.SetResult(resp.jsep.sdp); } }; var pluginResult = await janusClient.StartEcho(offer.sdp); if (!pluginResult.Success) { await janusClient.DestroySession(); waitForAnswer.SetCanceled(); cts.Cancel(); return(Problem("Failed to create Janus Echo Test Plugin instance.")); } else { using (cts.Token.Register(() => { // This callback will be executed if the token is cancelled. waitForAnswer.TrySetCanceled(); })) { // At this point we're waiting for a response on the Janus long poll thread that // contains the SDP answer to send back tot he client. try { var sdpAnswer = await waitForAnswer.Task; _logger.LogDebug("SDP answer ready, sending to client."); return(Ok(new RTCSessionDescriptionInit { type = RTCSdpType.answer, sdp = sdpAnswer })); } catch (TaskCanceledException) { await janusClient.DestroySession(); return(Problem("Janus operation timed out waiting for Echo Test plugin SDP answer.")); } } } } }