public void Close() { if (this.Handle != PluginUtils.InvalidHandle) { PluginUtils.CheckHResult(Wrapper.exRemoveDisconnected(this.Handle, this.disconnectedToken), "Connection.Close() - RemoveDisconnected - Handle= " + this.Handle); PluginUtils.CheckHResult(Wrapper.exRemoveReceived(this.Handle, this.dataReceivedToken), "Connection.Close() - RemoveReceived - Handle= " + this.Handle); PluginUtils.CheckHResult(Wrapper.exClose(this.Handle), "Connection.Close() - CloseConnection - Handle= " + this.Handle); } this.State = ConnectionState.Closed; this.Closed?.Invoke(this, EventArgs.Empty); this.Handle = PluginUtils.InvalidHandle; }
private bool DestroyServer() { if (isServerRunning) { Debug.Log("Cannot StopServer() - server not active"); return(false); } var hr = VideoServerWrapper.exShutdown(this.serverHandle); PluginUtils.CheckHResult(hr, "RealtimeVideoServer::StopServer"); // Invalidate our handle this.serverHandle = PluginUtils.InvalidHandle; return(hr == PluginUtils.S_OK); }
public void Stop() { if (!this.isPlayerCreated) { return; } Debug.Log("RealTimePlayer::Stop"); // Run plugin command on background thread and not UI thread. Weird bug where MF locks the thread Task task = new Task(() => { PluginUtils.CheckHResult(PlayerPlugin.exStop(this.playerHandle), "RealTimePlayer::exStop"); this.plugin.QueueAction(() => this.PlayerState = PlaybackState.Ended); }); task.Start(); }
public bool WriteFrame(byte[] data) { if (data == null || data.Length <= 0) { Debug.LogError("RealtimeVideoServer::WriteFrame - byte[] data cannot be null"); return(false); } if (!isServerRunning) { Debug.LogError("Cannot WriteFrame() - server not active"); return(false); } var hr = VideoServerWrapper.exWrite(this.serverHandle, data, (uint)data.Length); PluginUtils.CheckHResult(hr, "RealtimeVideoServer::WriteFrame"); return(hr == PluginUtils.S_OK); }
private bool CreateServer(Connection connection) { Debug.Log("RealtimeVideoServer::InitializeServer()"); if (connection == null) { Debug.LogError("RealtimeVideoServer.Initialize() - requires a valid connection component to start."); return(false); } if (isServerRunning) { Debug.LogError("RealtimeVideoServer.Initialize() - cannot start until previous instance is stopped."); return(false); } this.networkConnection = connection; this.networkConnection.Disconnected += this.OnDisconnected; this.networkConnection.Closed += this.OnConnectionClosed; uint handle = PluginUtils.InvalidHandle; bool useHEVC = this.OutputEncoding == Encoding.H265; var hr = VideoServerWrapper.exCreate(this.networkConnection.Handle, useHEVC, this.OutputWidth, this.OutputHeight, ref handle); PluginUtils.CheckHResult(hr, "RealtimeVideoServer::exCreate"); if (handle == PluginUtils.InvalidHandle || hr != PluginUtils.S_OK) { Debug.Log("VideoServerWrapper.exCreate - Failed"); Shutdown(); return(false); } this.serverHandle = handle; this.CurrentState = ServerState.Ready; return(true); }
public void Shutdown() { Debug.Log("RealtimeVideoPlayer::Shutdown"); if (this.connector != null) { this.StopConnector(); } if (this.isPlayerCreated) { Stop(); CloseNetworkConnection(); PluginUtils.CheckHResult(PlayerPlugin.exReleasePlayer(this.playerHandle), "RealtimeVideoPlayer::exReleasePlayer()"); this.Texture_Luma = this.Texture_Chroma = null; this.onCreatedCallback = null; this.onStateChangedCallback = null; this.playerHandle = PluginUtils.InvalidHandle; PlayerState = PlaybackState.None; } }