예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }