Пример #1
0
        public void Run()
        {
            // Initializes webrtc.
            _webRtcControl = new WebRtcControl(WEBRTC_CONFIG_FILE);
            _webRtcControl.OnInitialized += (() =>
            {
                _webRtcControl.ConnectToServer();
            });

            Conductor.Instance.OnAddRemoteStream += ((evt) =>
            {
                var peerVideoTrack = evt.Stream.GetVideoTracks().FirstOrDefault();
                if (peerVideoTrack != null)
                {
                    PredictionTimestampDelegate predictionTimestampDelegate = (id, timestamp) =>
                    {
                        _appCallbacks.OnPredictionTimestamp(id, timestamp);
                    };

                    FpsReportDelegate fpsReportDelegate = () =>
                    {
                        return(_appCallbacks.FpsReport());
                    };

                    var mediaSource = Media.CreateMedia().CreateMediaStreamSource(
                        peerVideoTrack,
                        DEFAULT_MEDIA_SOURCE_TYPE,
                        DEFAULT_MEDIA_SOURCE_ID,
                        VIDEO_FRAME_WIDTH,
                        VIDEO_FRAME_HEIGHT,
                        predictionTimestampDelegate,
                        fpsReportDelegate);

                    _appCallbacks.SetMediaStreamSource(
                        (MediaStreamSource)mediaSource,
                        VIDEO_FRAME_WIDTH,
                        VIDEO_FRAME_HEIGHT);
                }

                _webRtcControl.IsReadyToDisconnect = true;
            });

            _webRtcControl.Initialize();

            // Starts the main render loop.
            _appCallbacks.Run();
        }