private void MediaStreamer_StateChanged() { var state = mediaStreamer.State; logger.Debug("MediaStreamer_StateChanged() " + state); if (state == MediaStreamerState.Starting) { //PropertyNetwork.CommunicationPort = streamSession.CommunicationPort; } else if (state == MediaStreamerState.Streaming) { PropertyNetwork.CommunicationPort = streamSession.CommunicationPort; } else if (state == MediaStreamerState.Stopping) { } else if (state == MediaStreamerState.Stopped) { PropertyNetwork.CommunicationPort = PropertyNetwork.Port; var errorObj = mediaStreamer.ExceptionObj; var errorCode = mediaStreamer.ErrorCode; var internalCode = mediaStreamer.CheckError(); var internalError = mediaStreamer.GetInternalError(); if (errorObj != null || errorCode != 0 || internalCode != 0 || internalError != null) { logger.Warn("Process error..."); //... //Process error this.ErrorCode = internalCode; this.ErrorObj = internalError; if (ErrorObj == null) { ErrorObj = errorObj; } if (ErrorCode != 0) { ErrorCode = errorCode; } ErrorOccurred?.Invoke(ErrorObj); } mediaStreamer.Shutdown(); } else if (state == MediaStreamerState.Shutdown) { } StateChanged?.Invoke(); }