示例#1
0
        public MediaServerService(WebRTCHost webrtc, string serverAddress, string streamName)
        {
            this.webrtc        = webrtc;
            this.streamName    = streamName;
            this.ServerAddress = serverAddress;

            var _ = EstablishAsBroadcasterAsync();
        }
示例#2
0
        /// <summary>
        /// Creates a new instance of <see cref="WebRTCWriter"/>.
        /// </summary>
        /// <param name="FileName">Output file path.</param>
        /// <param name="Codec">The Avi Codec.</param>
        /// <param name="ImageProvider">The image source.</param>
        /// <param name="FrameRate">Video Frame Rate.</param>
        /// <param name="AudioProvider">The audio source. null = no audio.</param>
        public WebRTCWriter(string FileName, WebRTCCodec Codec, WebRTCSettings settings, IImageProvider ImageProvider, int FrameRate, IAudioProvider AudioProvider = null)
        {
            _codec = Codec;

            _width       = ImageProvider.Width;
            _height      = ImageProvider.Height;
            _videoBuffer = new byte[_width * _height * 4];
            _connection  = new WebRTC.WebRTCHost(settings);
        }
示例#3
0
        /// <summary>
        /// Frees all resources used by this object.
        /// </summary>
        public void Dispose()
        {
            lock (_syncLock)
            {
                _connection.Dispose();
                _connection = null;
            }

            _videoBuffer = null;
        }
示例#4
0
        public WebSocketService(WebRTCHost webrtc, string path, int port, string certPath = null, bool secure = false)
        {
            Util.WriteLine("Starting web socket server...");
            webSocketServer = new WebSocketServer(IPAddress.Any, port, secure);
            if (secure)
            {
                webSocketServer.SslConfiguration.ServerCertificate          = new System.Security.Cryptography.X509Certificates.X509Certificate2(certPath);
                webSocketServer.SslConfiguration.CheckCertificateRevocation = false;
            }

            webSocketServer.AddWebSocketService(path, () => new WebSocketSignaler(new WebRTCSession(webrtc)));
            webSocketServer.Start();
        }
示例#5
0
        public WebRTCSession(WebRTCHost webrtc)
        {
            this.webrtc        = webrtc;
            this.cancelSession = new CancellationTokenSource();
            this.peer          = new PeerConnection();
            this.source        = new SceneVideoSource()
            {
                PeerConnection = peer
            };

            this.peer.IceStateChanged += OnIceStateChanged;
            this.peer.Connected       += OnConnected;

            this.webrtc.VideoFrameReady += OnFrameReady;
            this.webrtc.Register(this);
        }