private IEnumerator FramePushStartReconnectable(StartConnectionFunc startConnection) { while (Application.isPlaying && autoReconnect) { if (frameQueue == null || framePusher == null) { yield break; } var disconnectedEvent = new AutoResetEvent(false); startConnection(pusher => { MJMedia.Logger.LogInfo("OnDisconnect called."); disconnectedEvent.Set(); }); // disconnectまたはStopされるまでループする。 while (!disconnectedEvent.WaitOne(1)) { if (framePusher == null) { yield break; } yield return(new WaitForSeconds(3.0f)); } disconnectedEvent.Close(); if (framePusher != null) { MJMedia.Logger.LogInfo("Disconnect Detected!"); framePusher.Stop(); } else { yield break; } yield return(new WaitForSeconds(8.0f)); } }
private void StartStreamingCommon(StartConnectionFunc startConnection) { MJMedia.Logger.LogInfo("StartStreaming() called."); StopStreaming(); if (!TurboJpegDecoder.TurboAvailable) { MJMedia.Logger.LogError("Error! TurboJPEG is not available."); return; } if (framePusher != null) { framePusher.Stop(); } framePusher = new FramePusher(); StartCoroutine(FramePushStartReconnectable(startConnection)); frameDecoder = new DelaylessFrameDecoder(frameQueue); frameDecoder.Start(); }