Beispiel #1
0
        public void Run()
        {
            // Initializes webrtc.
            _webRtcControl = new WebRtcControl("ms-appx:///webrtcConfig.json");
            _webRtcControl.OnInitialized += (() =>
            {
                _webRtcControl.ConnectToServer();
            });

            Conductor.Instance.OnAddRemoteStream += ((evt) =>
            {
                var peerVideoTrack = evt.Stream.GetVideoTracks().FirstOrDefault();
                if (peerVideoTrack != null)
                {
                    var media = Media.CreateMedia().CreateMediaStreamSource(
                        peerVideoTrack, DEFAULT_FRAME_RATE, DEFAULT_MEDIA_SOURCE_ID);

                    _appCallbacks.SetMediaStreamSource((MediaStreamSource)media);
                }

                _webRtcControl.IsReadyToDisconnect = true;
            });

            _webRtcControl.Initialize();

            // Starts the main render loop.
            _appCallbacks.Run();
        }
Beispiel #2
0
    void Start()
    {
#if !UNITY_EDITOR
        _webRtcControl = new WebRtcControl();
        _webRtcControl.OnInitialized             += WebRtcControlOnInitialized;
        _webRtcControl.OnPeerMessageDataReceived += WebRtcControlOnPeerMessageDataReceived;
        _webRtcControl.OnStatusMessageUpdate     += WebRtcControlOnStatusMessageUpdate;

        Conductor.Instance.OnAddRemoteStream += Conductor_OnAddRemoteStream;
        _webRtcControl.Initialize();
#endif
    }
Beispiel #3
0
        public void Run()
        {
            // Initializes webrtc.
            _webRtcControl = new WebRtcControl("ms-appx:///webrtcConfig.json");
            _webRtcControl.OnInitialized += (() =>
            {
                _webRtcControl.ConnectToServer();
            });

            Conductor.Instance.OnAddRemoteStream += ((evt) =>
            {
                var peerVideoTrack = evt.Stream.GetVideoTracks().FirstOrDefault();
                if (peerVideoTrack != null)
                {
                    MediaSourceReadyDelegate mediaSourceReadyDelegate = (mediaSource) =>
                    {
                        _appCallbacks.SetMediaStreamSource(
                            (MediaStreamSource)mediaSource,
                            VIDEO_FRAME_WIDTH,
                            VIDEO_FRAME_HEIGHT);
                    };

                    SampleTimestampDelegate sampleTimestampDelegate = (id, timestamp) =>
                    {
                        _appCallbacks.OnSampleTimestamp(id, timestamp);
                    };

                    FpsReportRequestedDelegate fpsReportRequestedDelegate = () =>
                    {
                        return(_appCallbacks.OnFpsReportRequested());
                    };

                    Media.CreateMedia().CreateMediaStreamSource(
                        peerVideoTrack,
                        DEFAULT_MEDIA_SOURCE_ID,
                        VIDEO_FRAME_WIDTH,
                        VIDEO_FRAME_HEIGHT,
                        mediaSourceReadyDelegate,
                        sampleTimestampDelegate,
                        fpsReportRequestedDelegate);
                }

                _webRtcControl.IsReadyToDisconnect = true;
            });

            _webRtcControl.Initialize();

            // Starts the main render loop.
            _appCallbacks.Run();
        }
Beispiel #4
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();
        }
Beispiel #5
0
        public MainPage()
        {
            this.InitializeComponent();
            _uiDispatcher          = CoreApplication.MainView.CoreWindow.Dispatcher;
            StatusTextBlock.Text   = string.Empty;
            MessagesTextBlock.Text = string.Empty;
            VideoTextBlock.Text    = string.Empty;
            frameCounter           = 0;

            _webRtcControl = new WebRtcControl();
            _webRtcControl.OnInitialized                 += _webRtcControl_OnInitialized;
            _webRtcControl.OnPeerMessageDataReceived     += _webRtcControl_OnPeerMessageDataReceived;
            _webRtcControl.OnStatusMessageUpdate         += _webRtcControl_OnStatusMessageUpdate;
            Conductor.Instance.OnAddRemoteStream         += Instance_OnAddRemoteStream;
            Conductor.Instance.OnPeerDataChannelReceived += Instance_OnPeerDataChannelReceived;
            _webRtcControl.Initialize();
        }
    void Start()
    {
        camTransform = Camera.main.transform;
        prevPos      = camTransform.position;
        prevRot      = camTransform.rotation;

#if !UNITY_EDITOR
        _webRtcControl = new WebRtcControl();
        _webRtcControl.OnInitialized             += WebRtcControlOnInitialized;
        _webRtcControl.OnPeerMessageDataReceived += WebRtcControlOnPeerMessageDataReceived;
        _webRtcControl.OnStatusMessageUpdate     += WebRtcControlOnStatusMessageUpdate;

        Conductor.Instance.OnAddRemoteStream += Conductor_OnAddRemoteStream;
        _webRtcControl.Initialize();

        // Setup Low-Level Graphics Plugin
        CreateTextureAndPassToPlugin(textureWidth, textureHeight);
        SetPluginMode(PluginMode);
        StartCoroutine(CallPluginAtEndOfFrames());
#endif
    }