Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Receiving WebRTC stream from UE

Discussion in 'Unity Render Streaming' started by dzz, Jul 19, 2022.

  1. dzz

    dzz

    Joined:
    May 14, 2014
    Posts:
    4
    Hello,

    For an HMI project, I need to receive a WebRTC stream from Unreal Engine. The way is as follows:

    - Unreal Engine is running and streaming its content via WebRTC on a websocket server
    - If I connect with any browser to this websocket server (https://127.0.0.1:80), I can see the result. I guess similarly as how the Unity Render Streaming would work if it is streaming its content.

    My question is the following: can I connect my Unity app to this websocket server in order to get the WebRTC stream from UE via the WebRPC package?

    Thanks!
     
  2. kannan-xiao4

    kannan-xiao4

    Unity Technologies

    Joined:
    Nov 5, 2020
    Posts:
    43
    Once the signaling is complete, you can send and receive video, etc. using WebRTC between Unity and UE.

    Please refer to the following about signaling.
    https://webrtcforthecurious.com/docs/02-signaling/
     
  3. dzz

    dzz

    Joined:
    May 14, 2014
    Posts:
    4
    Thanks for the reference, I could now successfully connect after doing the signaling stuff via the websocket server (it seems). However I can't receive any texture, OnVideoReceived is never called, so probably I did something wrong, in the end :).

    Any insights would be helpful as I'm not sure what is going wrong!

    In attachment the code as well as the log file of what is being sent and what I'm receiving from the websocket server.

    WS <- is what is received in Unity from webserver
    WS -> is what is being sent in Unity to webserver

    [8/3/2022 4:42:23 PM]Successfully connected to ws://127.0.0.1:80
    [8/3/2022 4:42:23 PM]WS <- {"type":"config","peerConnectionOptions":{}}
    [8/3/2022 4:42:23 PM]WS <- {"type":"playerCount","count":1}
    [8/3/2022 4:42:24 PM]WS -> {"type":"offer","sdp":"v=0\r\no=- 2783483260383796420 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic: ...too long, see attached file for full log
    [8/3/2022 4:42:24 PM]WS -> CANDIDATE: [2409:8900:2650:fe0b:a472:3141:564f:bca]:54377
    [8/3/2022 4:42:24 PM]WS -> CANDIDATE: [2409:8900:2650:fe0b:e99d:5cfe:828a:2291]:54378
    [8/3/2022 4:42:24 PM]WS -> CANDIDATE: 192.168.90.120:54379
    [8/3/2022 4:42:24 PM]WS -> CANDIDATE: [2409:8900:2650:fe0b:a472:3141:564f:bca]:52377
    [8/3/2022 4:42:24 PM]WS -> CANDIDATE: [2409:8900:2650:fe0b:e99d:5cfe:828a:2291]:52378
    [8/3/2022 4:42:24 PM]WS -> CANDIDATE: 192.168.90.120:52379
    [8/3/2022 4:42:24 PM]WS <- {"type":"answer","sdp":"v=0\r\no=- 3568475973502208657 2 IN IP4 127.0.0.1 ...too long, see attached file for full log
    [8/3/2022 4:42:24 PM]CONNECTION STATE CHANGE: Connecting
    [8/3/2022 4:42:24 PM]Received Texture! <- However, video..OnVideoReceived is never called
    [8/3/2022 4:42:24 PM]CONNECTION STATE CHANGE: Connected
    [8/3/2022 4:42:24 PM]WS <- {"type":"iceCandidate","candidate":{"sdpMid":"0","sdpMLineIndex":0,"candidate":"candidate:2378221925 1 udp 2122197247 2409:8900:2650:fe0b:e99d:5cfe:828a:2291 54383 typ host generation 0 ufrag 2cgX network-id 3 network-cost 10"}}
    [8/3/2022 4:42:24 PM]WS <- {"type":"iceCandidate","candidate":{"sdpMid":"0","sdpMLineIndex":0,"candidate":"candidate:2322053569 1 udp 2122129151 192.168.90.120 54384 typ host generation 0 ufrag 2cgX network-id 1 network-cost 10"}}
     

    Attached Files:

    Last edited: Aug 3, 2022
  4. kannan-xiao4

    kannan-xiao4

    Unity Technologies

    Joined:
    Nov 5, 2020
    Posts:
    43
    Is this Issue made by you?
    https://github.com/Unity-Technologies/com.unity.webrtc/issues/794

    If not, I think it will help solve the problem.