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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Official Unity Render Streaming Introduction & FAQ

Discussion in 'Unity Render Streaming' started by kazuki_unity729, Sep 10, 2019.

  1. Dev_Sebas

    Dev_Sebas

    Joined:
    Jul 10, 2014
    Posts:
    19
    Thanks for the feedback, looking forward into that version 2.3
     
  2. kayy

    kayy

    Joined:
    Jul 26, 2011
    Posts:
    110
    I get a similar error only when using Safari (14 on macOS 10.15.7) while FF and Chrome are working fine. Mine occurs when setting the local answer:
    Failed to set local answer sdp: Failed to set local video description recv parameters for m-section with mid='1'.,​
     
  3. fourbb

    fourbb

    Joined:
    Jul 22, 2020
    Posts:
    13
    Hello, I want to apply Renderstreaming to my own game project, But I have some problems.
    My game project has multiple game scenes, each with a separate camera, This means I have to change the video track every time I switch scenes.
    How do I implement this?

    Thanks in advance.
     
  4. gtk2k

    gtk2k

    Joined:
    Aug 13, 2014
    Posts:
    277
    VideoStreamTrack can now be created from RenderTexture, so if the scene changes, I think it can be done by rendering the camera image of that scene to the RenderTexture that generated VideoStreamTrack.
     
  5. indie6

    indie6

    Joined:
    Dec 15, 2012
    Posts:
    100
    Hi, I am looking for an advice.

    Since the websocket-sharp library used by RenderStreaming does not support adding headers(which I need for cookie authentication) and also has some protocol issues with TLS 1.3

    I opted for this Socket library (https://github.com/endel/NativeWebSocket)

    So far I have been able to establish a connection to our websocket server and also exchange STOMP messages. I wanted to know that how long of an effort is it to replace the websocket-sharp library in the RenderStreaming project with the one mentioned above(NativeWebSocket)? And is it even possible to do so? I have looked at the source code but since I don't have the render-streaming's domain knowledge I am not sure if diving into the code and replacing the socket library would end up as a success
     
    Last edited: Nov 18, 2020
  6. MastersOfUs

    MastersOfUs

    Joined:
    Aug 29, 2015
    Posts:
    17
    I noticed that when creating a new VideoStreamTrack with the constructor that takes a label and a RenderTexture, it only works when the RenderTexture is a targetTexture for some camera.

    For example, if I have rendertex1 which is a target texture for some camera, and I also create rendertex2 and call
    Graphics.Blit(rendertex1, rendertex2) every frame, rendertex2 gets properly updated in the editor, but when i try to create a new VideoStreamTrack("test", rendertex2), the stream connects, but is black. I noticed that it worked with just regular texture assets, but these can't be Blitted into.

    Is there a plan to support this?
     
  7. Alexander21

    Alexander21

    Joined:
    Dec 14, 2015
    Posts:
    301
    Hi All

    I am trying the web Streaming. I am using Streaming Template ,webrtc 2.0 version. When i run the project it shows the error .

    If i run webrtc.exe it shows the ipaddress.... But when the unity project it shows the error.

    How can i solve this error.
     
  8. MastersOfUs

    MastersOfUs

    Joined:
    Aug 29, 2015
    Posts:
    17
    Hello. I have an issue with UI. In the editor, the UI works fine both in the game, and on the stream. However, in a build the UI doesn't show in any of the places. It doesn't seem to get rendered to the render texture even. I am using LegacyRPRenderTextureBlitter
     
  9. fourbb

    fourbb

    Joined:
    Jul 22, 2020
    Posts:
    13
    Thank you for your answer, I have successfully solved my problem.
     
  10. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
    It is a good suggestion for us and valuable to consider.
    We need more time to migrate it for checking on multi-platform.
     
  11. salvolannister

    salvolannister

    Joined:
    Jan 3, 2019
    Posts:
    50
    Hello developers,
    I would like to read input from a remote XRController (eg. Oculus motion controller), as it is made for the gamepad in SimpleCameraController.cs and here.
    Can anyone give me some ints?
     
  12. fourbb

    fourbb

    Joined:
    Jul 22, 2020
    Posts:
    13
    Hello, I would like to know what audio encoding methods are supported by RenderStreaming and whether Settings of audio encoding parameters (such as sampling rate) are supported?
     
  13. fourbb

    fourbb

    Joined:
    Jul 22, 2020
    Posts:
    13
    Hello,
    I try to use the RTCRtpSender Get/SetParameters logic to set:
    • RTCRtpEncodingParameters - Frame Rate
    • RTCRtpEncodingParameters - Min Bit Rate
    • RTCRtpEncodingParameters - Max Bit Rate
    But I find that it sometimes fails, and the frame rate I see through Chrome :// webrtC-Internal is not the same as what I set.
    Do you know what caused this?
     
  14. Maktech

    Maktech

    Joined:
    Jan 15, 2015
    Posts:
    31
    We are still using the older SDP munging technique in our code. We have the configuration to turn it on and off so it gives us better control. I know it was removed in the newer versions of the RenderStreaming package but, it is nice to have options.
    Code (CSharp):
    1. var startKbits = Convert.ToInt32(Configuration.Instance.WebRTCStartBitRateMegabit.Value * 1024f);
    2. var maxKbits = Convert.ToInt32(Configuration.Instance.WebRTCMaxBitRateMegabit.Value * 1024f);
    3.  
    4. var pattern = @"(a=fmtp:\d+ .*level-asymmetry-allowed=.*)\r\n";
    5. var newSDP = Regex.Replace(originalSDP, pattern, "$1;x-google-start-bitrate=" + startKbits + ";x-google-max-bitrate=" + maxKbits + "\r\n");
     
  15. TeddyGeorgeoff

    TeddyGeorgeoff

    Joined:
    Oct 21, 2012
    Posts:
    9
    Looks like calling AddICECandidate is crashing unity? Maybe my ice candidate is no good but a crash seems excessive, it dies right at this line.

    upload_2020-12-4_18-17-29.png
     
  16. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
    Thanks.
    I will reproduce the issue. Would you show the sample code to me?
     
  17. fourbb

    fourbb

    Joined:
    Jul 22, 2020
    Posts:
    13
    Thanks for your reply.

    Hello, I would like to know whether you have tried to use SDP to control the audio coding parameters. I tried to use SDP to modify the opUS sampling rate, code rate and sound channel number, but it was invalid.

    Is it the renderStreaming itself that is not supported or my problem
     
  18. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    869
    Hello,

    I have a unity app for IOS and Android, and I was wondering if this render streamer works on those two platforms?

    Thanks
     
  19. TeddyGeorgeoff

    TeddyGeorgeoff

    Joined:
    Oct 21, 2012
    Posts:
    9
    For DataChannel configuration, when making RTCDataChannelInit config, and passing it in by reference I get an error that says

    ArgumentException: RTCDataChannelInit object is incorrect.


    Code (CSharp):
    1. var conf = new RTCDataChannelInit(false)
    2.         {
    3.             id = 231,
    4.             maxRetransmits = 1,
    5.             maxRetransmitTime = 1,
    6.             negotiated = false,
    7.             ordered = false,
    8.             protocol = ""
    9.         };
    10. _defaultDataChannel = _peerConnection.CreateDataChannel("data", ref conf);
    11.  
    using the default config works:
    var conf = new RTCDataChannelInit(true)


    But also this is slightly outdated I think. reliable looks like it was depricated and names are a bit off assuming this reference is correct: https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel
     
    SenaJP likes this.
  20. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
    Thanks, I will check it.
    I created a ticket on GitHub issues, I am glad if you add more information on this page.
    https://github.com/Unity-Technologies/com.unity.webrtc/issues/281
     
  21. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    264
    It's December 2020, and all links of the first post has broken:(
    I just made this 5 minutes basic demo guide of Unity Render Streaming with URP, super simple:
     
    Bivens32, pigeon6 and kazuki_unity729 like this.
  22. adam_unity450

    adam_unity450

    Joined:
    Aug 3, 2020
    Posts:
    12
    Are there any estimates on when we can expect this package to support Unity 2020?
     
  23. Maktech

    Maktech

    Joined:
    Jan 15, 2015
    Posts:
    31
  24. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
  25. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    I am currently testing Unity Render Streaming and I am wondering if we can receive a stream inside Unity.

    Right now, you can stream from Unity to a web Page. But is it possible to stream from Unity to Unity?

    I would think it's possible, Would it be possible to define the videoSource to be a Unity Render Stream ? (https://docs.unity3d.com/Manual/Video.html).

    thanks,

    Jean
     
  26. gtk2k

    gtk2k

    Joined:
    Aug 13, 2014
    Posts:
    277
    Yes, you can try it.
    https://github.com/Unity-Technologi...p/Samples~/VideoReceive/VideoReceiveSample.cs
     
  27. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    Cool, I'll try that, thanks :)

    Bye,

    Jean
     
  28. leon-do

    leon-do

    Joined:
    Jul 6, 2020
    Posts:
    4
    Hello

    I'm experimenting with getting a sdp from another peer.

    Assume you're given an offer sdp:

    Code (csharp):
    1. v=0\r\n
    2. o=- 535940652912167540 2 IN IP4 127.0.0.1\r\n
    3. s=-\r\n
    4. t=0 0\r\n
    5. a=group:BUNDLE 0\r\n
    6. a=msid-semantic: WMS\r\n
    7. m=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\n
    8. c=IN IP4 0.0.0.0\r\n
    9. a=ice-ufrag:scMp\r\n
    10. a=ice-pwd:IqZuYs3gcfcEqnazoQQzeP/x\r\n
    11. a=ice-options:trickle\r\n
    12. a=fingerprint:sha-256 C4:4C:CE:C2:1E:F6:99:BB:7C:24:6D:31:8A:51:31:EB:A5:14:FD:0E:4F:2C:A7:6C:91:3E:E1:48:0E:97:E1:BA\r\n
    13. a=setup:actpass\r\n
    14. a=mid:0\r\n
    15. a=sctp-port:5000\r\n
    16. a=max-message-size:262144\r\n
    How do you set this as a remote description? I've been trying this.

    Code (csharp):
    1. // get sdp from above
    2. string sdp = "v=0\r\"
    3.  
    4. RTCSessionDescription offer = new RTCSessionDescription{};
    5. offer.sdp = sdp
    6.  
    7. var op2 = pc2.SetRemoteDescription(ref offer);
    8. yield return op2
    9.  
    But I'm getting this error: RTCErrorException: Failed to create fingerprint from the digest.

    Am I on the right track? I'm basically having trouble setting a remote description from a sdp string.
     
  29. leon-do

    leon-do

    Joined:
    Jul 6, 2020
    Posts:
    4

    Answered my question. The string has to be like:

    Code (csharp):
    1. string sdp = "v=0\r\no=- 535940652912167540 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic: WMS\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:scMp\r\na=ice-pwd:IqZuYs3gcfcEqnazoQQzeP/x\r\na=ice-options:trickle\r\na=fingerprint:sha-256 C4:4C:CE:C2:1E:F6:99:BB:7C:24:6D:31:8A:51:31:EB:A5:14:FD:0E:4F:2C:A7:6C:91:3E:E1:48:0E:97:E1:BA\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n";
     
  30. merpheus

    merpheus

    Joined:
    Mar 5, 2013
    Posts:
    199
    Is there a way to send phone's gyro data to unity to control the camera?
     
  31. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
    Currently, gyro support is contained in a list of high priority tasks.
    We might be able to support it at the end of this month.

     
    merpheus and gtk2k like this.
  32. licoder

    licoder

    Joined:
    Dec 28, 2018
    Posts:
    2
    when i create ice from websocket like this
    var initInfo = new RTCIceCandidateInit();
    initInfo.candidate = ice;
    initInfo.sdpMid = sdpMid;
    initInfo.sdpMLineIndex = sdpMlineIndex;
    RTCIceCandidate candidate = null;
    try
    {
    candidate = new RTCIceCandidate(initInfo);
    }
    catch (Exception ex)
    {
    Debug.LogError($"{ex}");
    }
    i will get a error like this,
    System.ArgumentException: Value does not fall within the expected range.
    at Unity.WebRTC.RTCIceCandidate..ctor (Unity.WebRTC.RTCIceCandidateInit candidateInfo) [0x00031] in D:\Project\Rtc\Library\PackageCache\com.unity.webrtc@2.3.0-preview\Runtime\Scripts\RTCIceCandidate.cs:251
    at STRtcConnection.OnRemoteIce (System.String remoteId, System.String label, System.String ice) [0x00076] in D:\Project\Rtc\Assets\STRtc\STRtcImpl\STBase\STRtcConnection.cs:285
    UnityEngine.Debug:LogError(Object)

    from the error log ...can't get any idea ,help..
     
  33. licoder

    licoder

    Joined:
    Dec 28, 2018
    Posts:
    2
    the old version 2.2.1 is ok,but don't know why
     
  34. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
    Could you show me the detail of the `RTCIceCandidateInit` parameter?
     
  35. salvolannister

    salvolannister

    Joined:
    Jan 3, 2019
    Posts:
    50
    @kazuki_unity729 Why didn't you answer to this guy? If you can, I would be curious to know it too
     
    Lukas_Kastern likes this.
  36. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
    The reason for removing SDP is written on this issue page. This is for the stability of the bandwidth.
    https://github.com/Unity-Technologies/com.unity.webrtc/issues/182

    I guess this link is written about this issue of input stutter.
    https://github.com/Unity-Technologies/com.unity.webrtc/issues/164

    This issue related to the input stutter has remained, this fix is a big change so we need more time.
    https://github.com/Unity-Technologies/com.unity.webrtc/issues/205

    Yeah, I think their work is great, but maybe our approach is not the same as them because they are keeping to use the old version of libwebrtc.

    Certainly, developers in our team are not many, but I am not alone.

    We will continue this work, and we are aiming to publish our package as a verified-package in 2022.
     
    Lukas_Kastern likes this.
  37. Lukas_Kastern

    Lukas_Kastern

    Joined:
    Aug 31, 2018
    Posts:
    97
    Unreal's PixelStreaming is also not production-ready by the way. They are still in 'beta' themselves with their own set of issues.
     
  38. SunnyChow

    SunnyChow

    Joined:
    Jun 6, 2013
    Posts:
    360
    i see there is app2.js in the project, which seems like demostrating how html side sending video to Unity. I would like to ask how should i set it up? i have uncomment the app2 section of index.html. the html ui is working, and it can enable webcam video when i access localhost. but i can't achieve anything farther. the best i can do is triggering an error in server side


    Code (CSharp):
    1. TypeError: Cannot read property '0' of undefined
    2.     at ........\WebApp\build\signaling.js:132:30
     
  39. adsssss

    adsssss

    Joined:
    Jan 6, 2021
    Posts:
    1
    I cannot access my server on the public network now. How can I expose my server to the public network
     
  40. gtk2k

    gtk2k

    Joined:
    Aug 13, 2014
    Posts:
    277
    @licoder @kazuki_unity729
    I have same issue.
    I used only Unity WebRTC package.(not use Unity Render streaming package)

    my params
    candidate: "Cand[:xxxxxxxxx:x:udp:xxxxxxxxxx:xxx.xxx.xxx.xxx:xxxxx:local::x:yyyyy::x:xx:x]"
    sdpMid: "0"
    sdpMLineIndex:0

    The format of ICE Candidate is
    "candidate: 4234997325 1 udp 2043278322 192.168.0.56 6502 typ srflx raddr 192.168.2.77 rport 32768 generation 0"
    I imagined something like that, but it was completely different.
     

    Attached Files:

    Last edited: Jan 6, 2021
    SenaJP likes this.
  41. Maktech

    Maktech

    Joined:
    Jan 15, 2015
    Posts:
    31
    Kazuki,
    I see you have posted you are working on the merge in for the fix of [BUG] Visual artifacts when using hardware encoding #205
    It looks like this fix won't be in until version 2.5 (April) according to the road map. Is there a branch with those changes available? We have been looking into addressing this bug ourselves and would like to see what solution you came up with and even potentially merge it early into our own code.

    Thank you
     
  42. anchalsinha

    anchalsinha

    Joined:
    Jan 28, 2020
    Posts:
    3
    Hello,

    I am using the Unity WebRTC library (not RenderStreaming) on iOS, and was experiencing some issues when signaling. Everything works fine in the editor and desktop platforms, but when run on an iOS device, the ICE connection state never changes to Connected/Completed. I have verified that the ICE candidates are successfully generated and sent to the remote peer, and that remote candidates are properly received by the local peer.
    Do you have any ideas on what this could be? Once again, this only happens on iOS, and I am trying to receive video and create a data channel.

    Thanks!
     
  43. CaptainPixels

    CaptainPixels

    Joined:
    Jun 7, 2018
    Posts:
    4
    Is there a method that takes takes a string and converts it to an RTCIceCandidate / RTCSessionDescription or do we have to make our own? (Same goes for the other way- turn the class into a string)
     
  44. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
    @licoder, @gtk2k
    Thanks. I am trying to reproduce the issue, and if it is a bug,
    will release the hotfix version ASAP.

    Edited:

    I understood this exception is thrown when using a default constructor.

    This is the same behavior as browsers like Google chrome, you can see this in this sample code.
    https://jsfiddle.net/c0dko4jy/1/

    Certainly, the description of the exception is unkind and it should be fixed to give more detail of the error. For example, Google chrome outputs the log below.
    Code (JavaScript):
    1. Uncaught TypeError: Failed to construct 'RTCIceCandidate': sdpMid and sdpMLineIndex are both null."
     
    Last edited: Jan 7, 2021
    SenaJP likes this.
  45. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
    Is this issue occurring on iOS only?
    It might be a network connection issue (like a firewall), but I can not say the exact thing.
     
  46. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
    you can make instances using constructors.

    Code (CSharp):
    1. var option = new RTCIceCandidateInit
    2. {
    3.     sdpMid = "0",
    4.     sdpMLineIndex = 0,
    5.     candidate = str
    6. };
    7. var candidate = new RTCIceCandidate(option);
    Code (CSharp):
    1. var desc = new RTCSessionDescription { sdp = str, type = RTCSdpType.Offer };
     
  47. gtk2k

    gtk2k

    Joined:
    Aug 13, 2014
    Posts:
    277
    @kazuki_unity729

    My problem is that the code I wrote myself (Simple.cs attached to my last post)
    The value of the candidate property of iceCandidate passed by OnIceCandidate is
    "Cand [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]"

    When I tried the Unity.RenderStreaming sample, the value of the candidate property of iceCandidate passed by OnIceCandidate is
    "candidate: xxxxxxxxxxxxxxxxxxx typ host xxxxxxxxxxxxxxxxx"
    It is passed in a well-known format.

    I still don't know why this difference occurs.
     
  48. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
    I totally understood...
    I am fixing it.

    Edited: This issue should be fixed by this change. #297
     
    Last edited: Jan 7, 2021
    gtk2k likes this.
  49. CaptainPixels

    CaptainPixels

    Joined:
    Jun 7, 2018
    Posts:
    4
    Thank you so much, is there something that will convert it to a string so I can send it over the signaling server or do I have to write my own ToString method?
     
  50. SenaJP

    SenaJP

    Joined:
    Jan 31, 2016
    Posts:
    4

    Thanks to you guys for the quick fix!
    I have updated the WebRTC package to v2.3.1 in my project at hand and confirmed that the problem is fixed.
     
    kazuki_unity729 likes this.