Coder Social home page Coder Social logo

srs-unity's Introduction

srs-unity

Video Streaming and WebRTC Samples for Unity.

Unity supports WebRTC, see com.unity.webrtc or github. However, the demos only work in P2P mode, not with remote SFU or SRS.

To work with SFU or WebRTC server, the best practice is to use WHIP for Unity to publish to SFU, such as SRS. Actually, you're also able to play stream by WHIP.

The most common use scenaio for publishing stream, is to covert video game as live streaming. However you can use OBS to capture the window and audio, but it enable you to capture from Unity inside, cool! It works like this:

(Scenario 1)
Unity Game ---WebRTC----> SRS --+-----RTMP--> YouTube/FFmpeg
                                +---WebRTC--> H5/Unity

And the playing stream can be used for streaming consuming, it's a new feature enabled by Unity WebRTC. It works like this:

                                        (Scenario 2)
OBS/FFmpeg ----RTMP----+--> SRS --WebRTC--> Unity Game
H5/Unity -----WebRTC-----+

It also allows multiple Unity Games to communicate by WebRTC. And there should be a set of new use scenarios for Unity+WebRTC+SRS, that you can finger out and please let us know

Environments

We have tested on:

  • Unity editor 2020.3.48f1 LTS, other latest LTS versions should work well also.
  • WebRTC 2.4+, because CaptureStream API changed, see #2 for detail.

The supported versions:

WebRTC Supported Note
3.0.0-pre.6 v1.0.2, v1.0.3 Stable. Fix #963
3.0.0-pre.5 v1.0.1 Stable
2.4.0-exp.11 to 3.0.0-pre.4 v1.0.1 Known issue, see #5 and #882.

The latest version should work well also, please file an issue if not.

Setting up project

First, please setup you Unity Project. If you're stuck, please get help from Discord.

Step 1: Download and setup Unity Hub.

  1. Open Unity Hub.
  2. Click Installs > Install Editor, please select one release to install.
  3. Check modules for Unity Editor, (Windows: make sure Visual Studio installed).

Step 2: Create a Unity project.

  1. Open Unity Hub.
  2. Click Projects > New Project.
  3. Select 3D Core or 3D URP template.
  4. Set the Project Name to My project.
  5. Click Create project, and an Unity Editor will be opened.

Step 3: Install dependency package com.unity.webrtc.

  1. Click Window > Package Manager.
  2. Click + > Add package from git URL.
  3. Input com.unity.webrtc then click Add.

Step 3.1 Case of Unity 2020.3 or 2021.3:

  1. Click Window > Package Manager.
  2. Click + > Advanced button and enable Show preview packages
  3. Search webrtc and install the package.

Step 3.2 Case of Unity 2019.4:

  1. Click Window > Package Manager.
  2. Click + > Add package from git URL.
  3. Input com.unity.webrtc then click Add.

Step 4: Install srs-unity package.

  1. Download package SRS.WebRTC.Samples.unitypackage.
  2. Click Asserts > Import Package > Custom Package, select the file SRS.WebRTC.Samples.unitypackage, then click Import.
  3. From Project panel, open Asserts > io.ossrs > Samples, where you got all samples there.

Step 5: Start SRS WebRTC media server:

CANDIDATE="192.168.1.10"
docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 \
    --env CANDIDATE=$CANDIDATE -p 8000:8000/udp \
    ossrs/srs:5 ./objs/srs -c conf/docker.conf

Note: Make sure your SRS is v4.0.264+ or v5.0.62+. Please read this guide to setup SRS.

Note: Please remember to replace the CANDIDATE to your server IP, please read link for details.

Note: For online service, you might need authentication and other features, please read How to Setup a Video Streaming Service by 1-Click or How to Setup a Video Streaming Service with aaPanel to build a service by SRS.

Bellow is detail guide for different use scenarios.

Usage: Publisher

To publish your WebCamera and Microphone using WebRTC. If you're stuck, please get help from Discord.

Please follow Setting up project, then work with Publisher sample.

  1. From Project panel, open Asserts > io.ossrs > Samples > Publisher, then open the Scene.
  2. Click Edit > Play to play Unity scene, which publish WebRTC stream to SRS.
  3. Open Main camera object in the editor and under the SRS publisher script, change the ip address and stream key to your e.g. http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream
  4. Play the WebRTC stream by H5.

Note: Note that the Publisher scene require the WebCamera and Microphone permission, you can try other sample if no device.

The stream flows like this:

Unity ---WebRTC---> SRS --WebRTC--> H5/Chrome
(WebCamera and Microphone)

Note: You could use other WebRTC media server and client to replace SRS and Chrome.

1662719512637159.mp4

Note: The latency is extremely low, which allows you to communicate with another Unity App. For example, you can use this mode to build a metting application by Unity.

Usage: Streamer

To publish your game camera and voice using WebRTC. If you're stuck, please get help from Discord.

Please follow Setting up project, then work with Streamer sample.

  1. From Project panel, open Asserts > io.ossrs > Samples > Streamer, then open the Scene.
  2. Click Edit > Play to play Unity scene, which publish WebRTC stream to SRS.
  3. Open Main camera object in the editor and under the SRS streamer script, change the ip address and stream key to your e.g. http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream
  4. Play the WebRTC stream by H5.

Note: Note that the Streamer scene grab an extra camera in game and voice of Main Camera, and we add an example audio clip from hls.

The stream flows like this:

Unity ---WebRTC---> SRS --WebRTC--> H5/Chrome
(Game camera and voice)

Note: You could use other WebRTC media server and client to replace SRS and Chrome.

1662715460552658.mp4

Note: A rotating cube is in the video stream, which is also the demostration of WebRTC.

1662727649470018.mp4

Note: Please note that we also capture the audio of game, so when we mute the H5 player there is no audio.

Usage: Player

To play stream using WebRTC. If you're stuck, please get help from Discord.

Note: The stream might be published by another WebRTC client, or live stream like OBS or FFmpeg

Please follow Setting up project, then work with Player sample.

  1. Publish the WebRTC stream by H5.
  2. From Project panel, open Asserts > io.ossrs > Samples > Player, then open the Scene.
  3. Open Main camera object in the editor and under the SRS player script, change the ip address and stream key to your e.g. http://localhost:1985/rtc/v1/whip-play/?app=live&stream=livestream
  4. Click Edit > Play to play Unity scene, which publish WebRTC stream to SRS.

Note: You're also able to publish a live stream and play it in Unity using WebRTC, see WebRTC for Live Streaming.

The stream flows like this:

H5/Chrome ---WebRTC---> SRS --WebRTC--> Unity

Note: You could use other WebRTC media server and client to replace SRS and Chrome.

1662719351347655.mp4

Note: By converting live streaming to WebRTC, you're able to play normal stream from OBS or exists stream to Unity. For example, you can view a live sport or music by Unity.

srs-unity's People

Contributors

winlinvip avatar davzoltan avatar

Stargazers

 avatar Antonio Schneider avatar renfengyi avatar Gerson avatar  avatar Doshagyasing Gowardun avatar Lotharie avatar Baris avatar Eren Şen avatar TLabAltoh avatar  avatar LuZhongde avatar  avatar Alireza avatar  avatar Maria Heine avatar  avatar Rockiez avatar Auni avatar Ken Roda avatar CYJ avatar FrappuChanee avatar  avatar Brenden avatar  avatar 2300yy avatar Q avatar  avatar  avatar Jony avatar  avatar 炼金师-金奇 avatar Cornell Pruse avatar Lizivr avatar chimera kang avatar  avatar  avatar devmoon0 avatar zeifDev avatar  avatar Joe avatar dingxiaowei avatar yingran-cn avatar 幸音小姐拜托了 avatar  avatar Youngkyoung Lee avatar ZTIF avatar Vatsal Ambastha avatar Adrián Ciborro Montes avatar mika avatar JT5D avatar yanghua Xin avatar James Tone avatar Max Brand avatar  avatar pengqian avatar Ming avatar  avatar  avatar Takashi Kannan avatar Ebere Abanonu avatar gtk2k avatar Adam Raźniewski avatar

Watchers

Ebere Abanonu avatar  avatar James Tone avatar

srs-unity's Issues

RTCErrorException with Unity using SrsPlayer

Hey, unfortunately i am getting an RTC Exception using the SrsPlayer using the following url:

http://localhost:1985/rtc/v1/whep-play/?app=live&stream=livestream

WebRTC: Exchange SDP ok, answer is {"code":0,"server":"vid-3i79c04","service":"6207a0g0","pid":"1","urls":{"api":"the api root","rtc":{"v1":{"play":"Play stream","publish":"Publish stream","nack":"Simulate the NACK"}}}}

RTCErrorException: Expect line: v=

I am using Unity 2021.3.19f1 and SRS 5.

Streaming a RTMP Stream with OBS to SRS and watching it at http://localhost:8080/players/rtc_player.html?schema=http with the following URL (webrtc://localhost/live/livestream) does work fine.

Is there anything else that needs to be done?

Using the following docker run command:

docker run --rm --env CANDIDATE="192.168.178.83" -p 1935:1935 -p 8080:8080 -p 1985:1985 -p 8000:8000/udp ossrs/srs:5 objs/srs -c conf/rtmp2rtc.conf

请问autostreaming找不到如何解决

An error occurred while resolving packages:
Project has invalid dependencies:
com.unity.modules.autostreaming: Package [[email protected]] cannot be found

A re-import of the project may be required to fix the issue or a manual modification of /Users/love/Downloads/srs-unity-main/Packages/manifest.json file.

包管理器里提示

This package is not available offline.

请问需要如何操作?

Server error code-2000 using Streamer example

Hi,

Thanks for provide this plugins for unity streaming.
I set up the WebRTC SRS Server by docker and got an error on exchange SDP with the server.

Here is the error code shows when I enter Play mode in Unity:

[2023-01-16 05:48:47.879][Error][1][eo96j813][11] serve error code=2000 : rtmp handshake : simple handshake : only support rtmp plain text, version=50
thread [1][eo96j813]: do_cycle() [src/app/srs_app_rtmp_conn.cpp:167][errno=11]
thread [1][eo96j813]: handshake() [src/protocol/srs_rtmp_stack.cpp:2280][errno=11]
thread [1][eo96j813]: handshake_with_client() [src/protocol/srs_rtmp_handshake.cpp:1094][errno=11](Resource temporarily unavailable)

Thanks in advance for any help!

Can't play video when player starts after publisher

Hello, I encountered a problem. I use SrsStreamer in the project for streaming. If I start the streaming end first and then start the RTC player, I cannot get the video stream. When I check in chrome://webrtc-internals/, there is indeed no video data. However, if I start the RTC player and click the play button first, and then start Unity SrsStreamer for streaming, the streaming is successful at this time. What could be the cause of this?

TRANS_BY_GPT4

WebRTC: Exchange SDP failed

Hello, I encountered an error in Unity while using SRS-Unity.

WebRTC: Exchange SDP failed, url=http://localhost:1985/rtc/v1/whep/?app=live&stream=livestream, err is System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error getting response stream (ReadDoneAsync2): ReceiveFailure
  at System.Net.WebResponseStream+<InitReadAsync>d__61.MoveNext () [0x000f5] in <1e13855442cf491a8b11d7de866cc016>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Net.WebOperation+<Run>d__54.MoveNext () [0x001df] in <1e13855442cf491a8b11d7de866cc016>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x0001d] in <1e13855442cf491a8b11d7de866cc016>:0 
  at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <695d1cc93cca45069c528c15c9fdd749>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Net.Http.HttpClientHandler+<SendAsync>d__65.MoveNext () [0x004b0] in <3ee5766096bc480d9aeb424e1fc9d289>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Net.WebOperation+<FinishReading>d__55.MoveNext () [0x00089] in <1e13855442cf491a8b11d7de866cc016>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Net.WebOperation+<WaitForCompletion>d__53.MoveNext () [0x00074] in <1e13855442cf491a8b11d7de866cc016>:0 
   --- End of inner exception stack trace ---
  at System.Net.Http.HttpClientHandler+<SendAsync>d__65.MoveNext () [0x0050b] in <3ee5766096bc480d9aeb424e1fc9d289>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Net.Http.HttpClient+<SendAsyncWorker>d__47.MoveNext () [0x000ed] in <3ee5766096bc480d9aeb424e1fc9d289>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at SrsPlayer+<>c__DisplayClass7_1+<<Start>b__10>d.MoveNext () [0x000a7] in F:\_Practice\unity-editor-2020\Assets\io.ossrs\Samples\Player\SrsPlayer.cs:151 
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error getting response stream (ReadDoneAsync2): ReceiveFailure
  at System.Net.WebResponseStream+<InitReadAsync>d__61.MoveNext () [0x000f5] in <1e13855442cf491a8b11d7de866cc016>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Net.WebOperation+<Run>d__54.MoveNext () [0x001df] in <1e13855442cf491a8b11d7de866cc016>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x0001d] in <1e13855442cf491a8b11d7de866cc016>:0 
  at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <695d1cc93cca45069c528c15c9fdd749>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Net.Http.HttpClientHandler+<SendAsync>d__65.MoveNext () [0x004b0] in <3ee5766096bc480d9aeb424e1fc9d289>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Net.WebOperation+<FinishReading>d__55.MoveNext () [0x00089] in <1e13855442cf491a8b11d7de866cc016>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Net.WebOperation+<WaitForCompletion>d__53.MoveNext () [0x00074] in <1e13855442cf491a8b11d7de866cc016>:0 
   --- End of inner exception stack trace ---
  at System.Net.Http.HttpClientHandler+<SendAsync>d__65.MoveNext () [0x0050b] in <3ee5766096bc480d9aeb424e1fc9d289>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Net.Http.HttpClient+<SendAsyncWorker>d__47.MoveNext () [0x000ed] in <3ee5766096bc480d9aeb424e1fc9d289>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at SrsPlayer+<>c__DisplayClass7_1+<<Start>b__10>d.MoveNext () [0x000a7] in F:\_Practice\unity-editor-2020\Assets\io.ossrs\Samples\Player\SrsPlayer.cs:151 <---

UnityEngine.Debug:Log (object)
SrsPlayer/<<Start>g__ExchangeSDP|7_7>d:MoveNext () (at Assets/io.ossrs/Samples/Player/SrsPlayer.cs:164)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)

Additionally, the SRS console displayed the following error message:

[2024-05-05 08:32:48.165][ERROR][1][208t4773][11] serve error code=5018(RtcSdpNegotiate)(RTC do SDP negotiate failed) : process request=0 : cors serve : serve http : serve : serve : create session, dtls=1, srtp=1, eip= : create session : add player : play negotiate, offer=v=0\r\no=- 178266112283041645 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=audio 9 UDP/TLS/RTP/SAVPF 96 97 98 102 103 104 9 0 8 99 100 101 107 108 109 106 105 13 110 112 113 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:50PP\r\na=ice-pwd:3e0NKoHa6XD+KxPdw0xb44pL\r\na=ice-options:trickle\r\na=fingerprint:sha-256 15:A0:C0:FA:6B:E5:F9:E7:C2:04:55:3C:11:08:99:EC:EC:8F:2C:A0:A1:5A:16:5C:BE:AB:2F:5B:73:34:D2:FD\r\na=setup:actpass\r\na=mid:0\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\na=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:96 opus/48000/2\r\na=rtcp-fb:96 transport-cc\r\na=fmtp:96 minptime=10;sprop-stereo=1;stereo=1;useinbandfec=1\r\na=rtpmap:97 multiopus/48000/6\r\na=fmtp:97 channel_mapping=0,4,1,2,3,5;coupled_streams=2;minptime=10;num_streams=4;useinbandfec=1\r\na=rtpmap:98 multiopus/48000/8\r\na=fmtp:98 channel_mapping=0,6,1,2,3,4,5,7;coupled_streams=3;minptime=10;num_streams=5;useinbandfec=1\r\na=rtpmap:102 ILBC/8000\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:99 L16/8000\r\na=rtpmap:100 L16/16000\r\na=rtpmap:101 L16/32000\r\na=rtpmap:107 L16/8000/2\r\na=rtpmap:108 L16/16000/2\r\na=rtpmap:109 L16/32000/2\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:112 telephone-event/32000\r\na=rtpmap:113 telephone-event/16000\r\na=rtpmap:126 telephone-event/8000\r\nm=video 9 UDP/TLS/RTP/SAVPF 127 120 125 119 124 118 121 35 36 123 117 122 37\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:50PP\r\na=ice-pwd:3e0NKoHa6XD+KxPdw0xb44pL\r\na=ice-options:trickle\r\na=fingerprint:sha-256 15:A0:C0:FA:6B:E5:F9:E7:C2:04:55:3C:11:08:99:EC:EC:8F:2C:A0:A1:5A:16:5C:BE:AB:2F:5B:73:34:D2:FD\r\na=setup:actpass\r\na=mid:1\r\na=extmap:14 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:13 urn:3gpp:video-orientation\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:12 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\na=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\na=recvonly\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:127 VP8/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 implementation_name=Internal\r\na=rtpmap:120 rtx/90000\r\na=fmtp:120 apt=127\r\na=rtpmap:125 VP9/90000\r\na=rtcp-fb:125 goog-remb\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 ccm fir\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 implementation_name=Internal;profile-id=0\r\na=rtpmap:119 rtx/90000\r\na=fmtp:119 apt=125\r\na=rtpmap:124 VP9/90000\r\na=rtcp-fb:124 goog-remb\r\na=rtcp-fb:124 transport-cc\r\na=rtcp-fb:124 ccm fir\r\na=rtcp-fb:124 nack\r\na=rtcp-fb:124 nack pli\r\na=fmtp:124 implementation_name=Internal;profile-id=2\r\na=rtpmap:118 rtx/90000\r\na=fmtp:118 apt=124\r\na=rtpmap:121 VP9/90000\r\na=rtcp-fb:121 goog-remb\r\na=rtcp-fb:121 transport-cc\r\na=rtcp-fb:121 ccm fir\r\na=rtcp-fb:121 nack\r\na=rtcp-fb:121 nack pli\r\na=fmtp:121 implementation_name=Internal;profile-id=1\r\na=rtpmap:35 AV1X/90000\r\na=rtcp-fb:35 goog-remb\r\na=rtcp-fb:35 transport-cc\r\na=rtcp-fb:35 ccm fir\r\na=rtcp-fb:35 nack\r\na=rtcp-fb:35 nack pli\r\na=fmtp:35 implementation_name=Internal\r\na=rtpmap:36 rtx/90000\r\na=fmtp:36 apt=35\r\na=rtpmap:123 red/90000\r\na=rtpmap:117 rtx/90000\r\na=fmtp:117 apt=123\r\na=rtpmap:122 ulpfec/90000\r\na=rtpmap:37 flexfec-03/90000\r\na=rtcp-fb:37 goog-remb\r\na=rtcp-fb:37 transport-cc\r\na=fmtp:37 repair-window=10000000\r\n : no valid found h264 payload type
thread [1][208t4773]: process_requests() [./src/app/srs_app_http_conn.cpp:209][errno=11]
thread [1][208t4773]: process_request() [./src/app/srs_app_http_conn.cpp:236][errno=11]
thread [1][208t4773]: serve_http() [./src/protocol/srs_protocol_http_stack.cpp:768][errno=11]
thread [1][208t4773]: serve_http() [./src/app/srs_app_rtc_api.cpp:648][errno=11]
thread [1][208t4773]: do_serve_http() [./src/app/srs_app_rtc_api.cpp:752][errno=11]
thread [1][208t4773]: serve_http() [./src/app/srs_app_rtc_api.cpp:244][errno=11]
thread [1][208t4773]: create_session() [./src/app/srs_app_rtc_server.cpp:518][errno=11]
thread [1][208t4773]: do_create_session() [./src/app/srs_app_rtc_server.cpp:539][errno=11]
thread [1][208t4773]: add_player() [./src/app/srs_app_rtc_conn.cpp:1971][errno=11]
thread [1][208t4773]: negotiate_play_capability() [./src/app/srs_app_rtc_conn.cpp:3066][errno=11](Resource temporarily unavailable)

The steps to reproduce the issue are as follows:

It is known that streaming can be successfully pulled up on the web page at http://localhost:8080/players/whep.html?schema=http, where the video feed from OBS can be viewed.

How should I go about resolving this issue?

TRANS_BY_GPT4

There is an echo during the call

I want to build a conferencing software, but there is an echo during the call. It may be that the echo cancellation is not done. Is there any solution?

Unity import package error for CaptureStream arguments changed.

After import:Assets\ossrs.io\Video Streaming and WebRTC Samples\Streamer\SrsStreamer.cs(96,64): error CS1503: Argument 4: cannot convert from 'int' to 'Unity.WebRTC.RenderTextureDepth'

Version:unity2021.3.6f1, webRTC v3.0.0-pre.2-December 09, 2022

WebRTC: Exchange SDP failed

SDP negotiation failed!
The local SRS service uses SRS-Windows-x86_64-5.0-b3-setup and Docker has been tried, the configuration is rtc2rtmp.conf
This is the case from Unity 19 to 22, [email protected]~5 and 2.4 are also the same,
I see the error is in this part of the code,
image
Because there is an RTSP camera, it also pushes to the SRS service, but when pulling the stream, some computers also report this error, while some computers work well, which is very strange.
请问如何解决?是哪里出了问题?
image

image

WebRTC: Exchange SDP failed, url=http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream, err is System.AggregateException: One or more errors occurred. (An error occurred while sending the request) ---> System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error getting response stream (ReadDoneAsync2): ReceiveFailure
at System.Net.WebResponseStream.InitReadAsync (System.Threading.CancellationToken cancellationToken) [0x000f3] in <6d7c4c8dd3624dc596686fb7270ae1e6>:0
at System.Net.WebOperation.Run () [0x001d9] in <6d7c4c8dd3624dc596686fb7270ae1e6>:0
at System.Net.WebCompletionSource1[T].WaitForCompletion () [0x00094] in <6d7c4c8dd3624dc596686fb7270ae1e6>:0 at System.Net.HttpWebRequest.RunWithTimeoutWorker[T] (System.Threading.Tasks.Task1[TResult] workerTask, System.Int32 timeout, System.Action abort, System.Func1[TResult] aborted, System.Threading.CancellationTokenSource cts) [0x000f8] in <6d7c4c8dd3624dc596686fb7270ae1e6>:0 at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00020] in <6d7c4c8dd3624dc596686fb7270ae1e6>:0 at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <6073cf49ed704e958b8a66d540dea948>:0
--- End of stack trace from previous location where exception was thrown ---

at System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x004ae] in <8ab5a610e55c46a3a47ee18acfd3668c>:0
--- End of inner exception stack trace ---
at System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00509] in <8ab5a610e55c46a3a47ee18acfd3668c>:0
at System.Net.Http.HttpClient.SendAsyncWorker (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x000e8] in <8ab5a610e55c46a3a47ee18acfd3668c>:0
at SrsStreamer+<>c__DisplayClass10_0.b__11 () [0x00073] in C:\Users\Kane\Desktop\srs-unity\Assets\ossrs.io\Video Streaming and WebRTC Samples\Streamer\SrsStreamer.cs:173
--- End of inner exception stack trace ---
---> (Inner Exception #0) System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error getting response stream (ReadDoneAsync2): ReceiveFailure
at System.Net.WebResponseStream.InitReadAsync (System.Threading.CancellationToken cancellationToken) [0x000f3] in <6d7c4c8dd3624dc596686fb7270ae1e6>:0
at System.Net.WebOperation.Run () [0x001d9] in <6d7c4c8dd3624dc596686fb7270ae1e6>:0
at System.Net.WebCompletionSource1[T].WaitForCompletion () [0x00094] in <6d7c4c8dd3624dc596686fb7270ae1e6>:0 at System.Net.HttpWebRequest.RunWithTimeoutWorker[T] (System.Threading.Tasks.Task1[TResult] workerTask, System.Int32 timeout, System.Action abort, System.Func`1[TResult] aborted, System.Threading.CancellationTokenSource cts) [0x000f8] in <6d7c4c8dd3624dc596686fb7270ae1e6>:0

TRANS_BY_GPT4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.