Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental WebGL implementation #478

Conversation

nvanofwegen
Copy link

First and foremost, thanking @gtk2k for making the fundamental code which was used to make this contribution.

Summary

This PR adds experimental functionality for the WebGL platform, including:

  • Data channels
  • Receiving audio/video tracks
  • Sending video with limited performance
  • Sending audio not implemented yet
  • RTCParameters and RTCStats are using complete JSON (de)serialization instead of pointers/marshalling, so the performance is low. For now, jillejr.newtonsoft.json-for-unity is required
  • getUserMedia to send webcam/microphone over WebRTC (added to Samples)
  • adapter.js to improve browser support

A demo can be accessed here: https://d1ddjbgn3ezoae.cloudfront.net

Known issues/limitations

Audio

  • Audio in WebGL is limited. Currently the AudioStreamTracks are not sending any data over WebRTC, as OnAudioFilterRead is not available

Video

  • Using Camera to generate VideoStreamTracks has limited performance and a lot of WebGL warnings appear
  • Receiving video has a colorspace issue (rendering slightly too white)
  • (Samples) Using the framebuffer causes the UICamera to crash and the UI turns black
  • When receiving multiple VideoStreamTracks OnTrack simultaneously events, some tracks can remain grey and are not initialized properly

Firefox

  • The RTCStatsReport generated by Firefox contains less information
  • getCapabilities() is not implemented in Firefox, so setting the codec is not available.
  • Firefox has a loopback error when the hostname is http://localhost:port (which is the hostname when you Build and Run and Unity hosts the files). However, the hostname http://localhost:port/path works. So serving the files with your own toolkit can be used as a workaround (eg jetbrains/vscode/apache/nginx)

Improvements/todo

  • Find a way to generate and send audio sources. Alternatively, incoming audio could be implemented using the Web Audio API to send the audio data to Unity, or the DOM could be responsible for the audio and Unity can control the HTMLAudioElement
  • Improve Camera video rendering performance
  • Update RTCStats and RTCParameters to use pointers/marshalling
  • Some RTCErrors are ignored
  • Numerous TODO tags in the cs/jslib files
  • The implementation is not fully tested, so expect unknown issues/bugs

antoined73 and others added 30 commits June 7, 2021 15:07
Fork update before webGL implementation
…/com.unity.webrtc into antoined73-feature/webgl-support

# Conflicts:
#	Runtime/Plugins/WebGL/Context.jslib
#	Runtime/Plugins/WebGL/RTCDataChannel.jslib
#	Runtime/Plugins/WebGL/RTCPeerConnection.jslib
#	Runtime/Scripts/VideoStreamTrack.cs
…/com.unity.webrtc into feature/webgl-support

# Conflicts:
#	Runtime/Plugins/WebGL/Context.jslib
#	Runtime/Plugins/WebGL/RTCDataChannel.jslib
#	Runtime/Plugins/WebGL/RTCPeerConnection.jslib
#	Runtime/Scripts/VideoStreamTrack.cs
Renamed VideoStreamTrack
…/com.unity.webrtc into antoined73-feature/webgl-support

# Conflicts:
#	Runtime/Plugins/WebGL/VideoStreamTrack.jslib.meta
# Conflicts:
#	Runtime/Scripts/AudioStreamTrack.cs
#	Runtime/Scripts/VideoStreamTrack.cs
…quires the RTCPeerConnection to have a MediaStream to attach to.
# Conflicts:
#	Runtime/Scripts/AudioStreamTrack.cs
@karasusan
Copy link
Collaborator

When pushing the Back button in DataChannel sample, we received the error below.
image

@karasusan
Copy link
Collaborator

In Stats sample, we got error below.

  1. Push Call button.
  2. Push Hangup button.

image

@nvanofwegen
Copy link
Author

For audio: Not part of this PR, so errors are to be expected.

For data channels: as stated in this comment the 'error' is in this case, not an actual error.
Because the datachannel itself is already disposed, the datachannel that gets disconnected doesn't exist anymore in the reference table. It's basically a false error, which occurs by only destroying the context without cleanup first. However, I don't want to remove the comment, as the datachannel can be disconnected from the other side of the peer connection. It's simply prevented by hanging up first, then destroy the context.
Also, this scenario only occurs when you are connected to yourself, which is not a very likely scenario (but a valid scenario nonetheless)

For stats: I'll take a look, hangup should clean properly, so that needs to be fixed.

@mukaschultze
Copy link

There's a small inconsistency for data channels between the web and standalone. On the web the OnOpen callback is called for channels received via RTCPeerConnection.OnDataChannel, but on standalone it's not.

I suspect the web behaviour is the correct one, but I'm not sure.

@karasusan
Copy link
Collaborator

@mukaschultze
Yes, web browser behavior is correct, so It might be the bug.
I will be so glad if you make the issue page and write more detail of that.

@kannan-xiao4
Copy link
Contributor

In MultiPeers sample,
On push Start button, console logging below error.

OverflowException: Arithmetic operation resulted in an overflow

after push Call button, this log continue to be output.

And push HangUp , error pop below

Uncaught RuntimeError: null function or function signature mismatch
    at build.wasm.gz:0x62735d
    at build.wasm.gz:0x165dea2
    at build.wasm.gz:0x147a5ab
    at build.wasm.gz:0xe6c456
    at invoke_vii (build.framework.js.gz:3425)
...
    at invoke_viiii (build.framework.js.gz:3425)
...
    at invoke_iiii (build.framework.js.gz:3425)
...
    at browserIterationFunc (build.framework.js.gz:3425)
    at callUserCallback (build.framework.js.gz:3425)
    at Object.runIter (build.framework.js.gz:3425)
    at Browser_mainLoop_runner (build.framework.js.gz:3425)

enviroment

  • GoogleChrome on Windows10
  • Build by Unity 2021.2

@kannan-xiao4
Copy link
Contributor

In Bandwidth sample
On change parameter using dropdown menu, error happened.
image

but this error only occurred in app that build by Unity 2020.

@kannan-xiao4
Copy link
Contributor

In PerfectNegotiation sample
The following error has occurred in the second (and from then) Swaps.

[jslib] SenderReplaceTrack: Unmanaged track. Ptr: 0

Sample works fine, but I think BAD_ACCESS happen.

@karasusan
Copy link
Collaborator

karasusan commented Jan 13, 2022

@nvanofwegen
Hi, how is the situation here?

@nvanofwegen
Copy link
Author

Just got back from a long vacation, so I didn't have the time to look at it yet.

As for the stats issue and the issues @kannan-xiao4 mentioned, I will inspect those probably somewhere this week.

However, I have some things about the webgl implementation in general.

This PR is open for half a year now, and every couple of weeks things were added that had to be fixed. Meanwhile, the last rebase is also 5 months old, so I'm pretty sure there are again a lot of issues before this PR can be merged.
As this is done in my own free time, it's starting to feel a bit annoying that small issues are added every now and then and the PR stays open without a real plan and it feels more like a chore now.

So what is the roadmap for WebGL? For both this PR and the steps afterwards until it is ready to be merged in develop. The roadmap table in readme.md also hasn't been updated in a while.

I'm happy to look at the current issues found, but also patching the last 5 months of development where I'm the only one that can fix it is not something I'm looking forward to...

What is the downside of accepting the PR in the coming period, managing the issues here on github, work on the implementation and also let others be able to help?

@karasusan
Copy link
Collaborator

@nvanofwegen
I apologize for taking your free time. Our team are discussing about your reply.

FYI: I posted this thread for describing our direction.
https://forum.unity.com/threads/unity-render-streaming-status-update-q4-2021.1215801/

@gtk2k
@antoined73
@mukaschultze
If you have an opinion, I would like to hear it.

@nvanofwegen
Copy link
Author

No need to apologize! I picked up the work from gtk2k myself! I actually had a lot of fun developing so far. I only think that my lack of a clear understanding of how to proceed took the fun out a bit.

About the forum thread, awesome, haven't seen it and already clarifies a bit!

With WebGL being a community-based development for the foreseeable future, I do think the proposed approach should be in place rather sooner than later, as this PR is far from a 'release'.

In the thread you mention that people can see the progress in this PR, but this PR has become a bit of a dragon (80+ replies). There are several decisions in this PR made about audio, marshalling, refactoring the api, etc, but there is no overview of that.

With those new managed issues (like refactoring, marshalling, audio, etc) discussions about the implementation could be better structured and organized and we could have a good overview in one main WebGL issue.

@mukaschultze
Copy link

I've been using mostly the DataChannels to implement a transport for https://github.com/vis2k/Mirror. From my tests it works as well as the native implementation.

With WebGL being a community-based development for the foreseeable future, I do think the proposed approach should be in place rather sooner than later, as this PR is far from a 'release'.

Totally agree with that

@gtk2k
Copy link

gtk2k commented Jan 19, 2022

Thank you for your contribution to WebGL platform support over the long term to this day.

About the three points @nvanofwegen mentioned, audio, marshalling, and refactoring

audio

I think we are considering whether to implement this in the current PR. Since Microphone is not officially supported by Unity, it is possible to implement it by means such as using external assets, but I would like to avoid it as much as possible.

marshalling

Earlier, @karasusan drew a diagram and commented
#478 (comment)
I recognize that this is the main thing.
Currently, I've put together the Plugin API calls in WebRTC.cs (using a preprocessor), but I think it's easier to implement by creating a separate file for WebGL (eg WebRTC_WebGL.cs) and implementing a layer for WebGL there. increase.

refactoring

Refactor once all the tests pass with the current PR. After that, I think it would be better to consider audio and marshalling, but how about it?

If there is something I can help, I would like to help.

@karasusan
(日本語で失礼します)
私は、このリポジトリのフォルダ構成でUnityプロジェクトを開く方法がわかりません。WebRTC~フォルダにAssetsフォルダなどのUnityプロジェクトフォルダ構成となっており、このWebRTC~フォルダをUnityで開いてみたのですが、以下の画像のエラーが発生します。
com unity webrtc_project_load_error

package.jsonには相対アドレスが書かれていますが、これは本来Unity側で認識してくれて、実際のファイルを読み込んでくれるものなのでしょうか?

ちなみに Windows (11)です。

試しに、Windowsでのシンボリックリンクに置き換えてみたのですが(Runtime, Editor, TestsフォルダもWindowsシンボリックリンクに変更)、今度はプロジェクトを開くと以下の状態でずっとローディングのままとなってしまいます。(CPU使用率が上がりっぱなしで、一応何らかの処理は行われているようですが。。。)
com unity webrtc_project_never_ending_load

どのようにすればプロジェクトを(Windows)Unityで開けるのでしょうか?

@karasusan
Copy link
Collaborator

Sorry for everyone but writing in Japanese is easier for me 🙂

@gtk2k
WebRTC~ 以下を Unity プロジェクトとして開くことができます。
git のチェックアウト時にシンボリックリンクが正しく反映されなかった可能性があります。以下の記事を確認してください。
https://isgs-lab.com/440/

指摘のあった package.jsonこれのことだと思いますが、相対パスのように表示されているということは、git がシンボリックリンクをファイルとして扱っているということだと思います。

Windows11 が原因ではないとは思いますが、テスト環境が手元にないので確証はないです。

@gtk2k
Copy link

gtk2k commented Jan 19, 2022

( Excuse me for continuing in Japanese. )
@karasusan
ありがとうございます。
Windowsの場合、git の config が複数存在し、また、アカウントを切り替えて使用しているため、Symlinks が false となっているのが原因で、これをtrueにすることでプロジェクトを開くことができました。

ですが、WebGLにプラットフォームを切り替えるときに Sampleの*.wavファイルで Import が進まなくなってしまいます。
現時点において、オーディオは実装されていないため、とりあえず*.wavファイルを削除することで回避してます。

@karasusan
Copy link
Collaborator

@nvanofwegen
@gtk2k
@antoined73
@mukaschultze

Hi, our team discussed about this topic.

  • We are going to merge this pull request to the experimental feature branch experimental/webgl-platform in our repository soon.
  • After merged that, please keep developing based on the feature branch.
  • About known issues for WebGL support, we expect that you create issues on GitHub Issues, and add the link for the parent issue.

What our team do

  • Maintain CI system (building and testing)
  • Review pull requests from external developers
  • Check issue tickets

If you have questions, please feel free to ask me.
I appreciate your efforts.

@karasusan karasusan merged commit a39e89c into Unity-Technologies:experimental/webgl-platform Jan 26, 2022
Thaina pushed a commit to Thaina/com.unity.webrtc that referenced this pull request Jun 10, 2023
* webgl initial plugin

* merge with @gtk2k prototype (part 1)

* Add newtonsoft json parser in package dependencies

* merge with @gtk2k prototype (part 2)

* webgl lib compile fixes

* WebGL build can be done

* bugfix : remove useless condition that brake linux compatibility

* Initial WebGL webrtc plugins

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Added OnTextMessage on RTCDataChannel
Renamed VideoStreamTrack

* Remove duplicate method RegisterRenderingWebRTCPlugin in WebTC.cs

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Signaling is not part of WebRTC specification

* Browser crash on DataChannel options using newtonsoft

* Added missing ContextUnRegisterMediaStreamObserver, not implemented yet

* Removed audio/video offer options

* Added missing ReceiverGetStreams, not implemented yet

* RTCIceCandidates on WebGL

* Moved RTCDataChannel onmessage listeren to OnDataChannel (receiver) from createDataChannel (sender)

* Added VideoTrack with MediaStream created by WebGL's getUserMedia. Requires the RTCPeerConnection to have a MediaStream to attach to.

* Fixed CreateAudioTrack

* Fixed adding getUserMedia stream tracks to unity MediaStream

* Enabled open/close/message on both creation and ondatachannel objects

* Negotiation workaround
Often the candidate message is handled earlier than the description (probably due coroutines when setting the description)
For now the icecandidate handling waits 1 second, which is sufficient. But a fix would be to store an ICECandidate queue on the peer connection and handle the queue when the description is set

* Workaround to parse datachannel options, jsonutility/newtonsoft have trouble with the Optional fields

* Samples: working DataChannels and PeerConnection
- Fixed MediaStream getTracks with deserializer
- Added adapter.js, should improve browser compatibility
- Using objects instead of 'this' in jslib for peer events

* Added TextMessage event handling for DataChannels sample

* Fix for UpdateRendererTexture 'no video' issue

* Temp to show video tracks created by peer.ontrack

* getTracks using WebRTC.Deserialize, prevents creation of existing tracks

* Using Deserializer for RTP objects

* Firefox requires a string, instead of int for credentialType

* Fixed optional fields serialization in RTCConfiguration

* Disabled context check. Context is already removed when disposing peer/data/media objects

* Improved UWManaged array. C# objects can be disposed but still accessed at a later stage

* Delete transceiver

* Fixed DeleteMediaStreamTrack parameters

* Registering stream for videotrack is not needed

* Removing video tracks from local/remote video list object on DeleteMediaStreamTrack

* Added RegisterMediaStreamObserver, not tested

* DataChannel options parsing done in jslib file

* Moved parsing of RTCConfiguration

* Updated webrtc.dll

* Wip: create audiotrack

* Corrected RTCConfiguration parsing with new optional fields using enums

* Fixed webcam stream from getUserMedia
Improved creation of HTMLMediaElements, local and remote tracks are created on AddTrack and ontrack respectively, which enables the receiver to play the received audio stream.
The local video track is currently only needed to display the local webcam stream, but is created for every videotrack (todo)

* Added a check for RTCDataChannels onclose/open. onclose is fired when already disposed in unity.

* Fixed icecandidate struct

* Missing import and removed peer label (for now)

* Fixed some enum values (including ice/peer connection state)

* RTCStats. Not fully checked for every enum/statstype. Note: Requires "jillejr.newtonsoft.json-for-unity"

* Don't show video elements

* Use strToPtr

* RTPParameters

* RTPParameters

* RTPParameters: removed debug log and added todo

* setCodec support, only supported in chrome

* Datachannel config parsing to support firefox

* Removed debug log

* Removed debug logs

* Removed dual initializers (sourcetree bug?)

* Moved OnRemoveTrack

* Added guard for sender track

* Moved #!UNITY_WEBGL inside WebRTC.Sync

* Reducing the number of #if !UNITY_WEBL directives

* Using RTCOfferOptions object

* Added todo's

* Removed commented lines

* Removed comments lines in RTCStats

* Removed/optimized some #if webgl directives

* Added WebGLSample

* Default flip, so the correct image is transported over webrtc

* Updated local render method with flip

* Updated samples to allow webgl builds

* Some comments/codestyle changes

* Added getUserMedia TODO

* Reverted Android meta change

* fix test-case

* revert asmdef

* fixed compile error

* fix compile error

(cherry picked from commit 8eb9e4b)

* add webgl platform to CI test

(cherry picked from commit a478886)

* fix yaml

(cherry picked from commit 00939df785d1b5da64d7e3ab0795600e4f17d1a1)

* fix yaml

* fix

* fix bug

* fix yaml

* fix permission

* add job to test for webgl platform

* WIP test runner and jslib fixes
- Runs [Test] methods
- Parameterized tests are disabled [TestCase]
- Added webgl platform exclude to [UnityTest]
- VideoReceiver disabled
- AudioStream disabled
- (todo) NativeAPI
- Fixed several native method bugs

* wip NativeAPI test
enabled most test cases
needs json dll

* Passing DataChannelTest

* Fixed several tests
- Transceiver direction
- Ice candidate component (added todo/comments)
- MediaStreamAddTrack return value
- ContextCreate methods with labels
- Dummy TrackSource methods
- AudioTrack id (added custom guid field)
- MediaStream id (added custom guid field)
- Fixed NativeAPITest for WebGL MediaStream tracks length

* More test fixes - Replaced return with array  [errortype,object]
- AddTrack retursn both sender and errortype
- SetDescription returns errortype and message. TODO: make async/await to actually return the error(type)

* Fixed test cases
- Applied OptionalFields for PeerConnection config
- Fixed IceTransportPolicy enum
- Fixed Set Description of PeerConnection
- Enabled VideoReceiveTest (but are commented out)
- Added TODOs

* fix yaml for package test

* Add Preserve attribute for avoiding code stripping

* Fixed Transceiver SetCodecsPreferences

* Fixed incorrect assert in SenderGetParameter test

* Excluded failing tests + added todos

* Fixed SetLocalDescriptionWithoutDescription

* Added WebGL sample to build settings

* add edtitor version for auto-testing on CI

* Replaced Pointer_Stringify with UTF8ToString to support 2021.2

* fix: undefined `side` variable

* fix: undefined `err` variable

* fix: pass byt length to `DataChannelNativeOnMessage` callback

* ops...

Co-authored-by: Antoine Dezarnaud <dezartoine@hotmail.fr>
Co-authored-by: Antoine Dezarnaud <antoine.dezarnaud-ext@epicnpoc.com>
Co-authored-by: kazuki <karasusan@gmail.com>
Co-authored-by: Muka Schultze <samuelschultze@gmail.com>
Co-authored-by: gtk2k <gtk2k@yahoo.co.jp>
Thaina added a commit to Thaina/com.unity.webrtc that referenced this pull request Jun 11, 2023
* webgl initial plugin

* merge with @gtk2k prototype (part 1)

* Add newtonsoft json parser in package dependencies

* merge with @gtk2k prototype (part 2)

* webgl lib compile fixes

* WebGL build can be done

* bugfix : remove useless condition that brake linux compatibility

* Initial WebGL webrtc plugins

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Added OnTextMessage on RTCDataChannel
Renamed VideoStreamTrack

* Remove duplicate method RegisterRenderingWebRTCPlugin in WebTC.cs

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Signaling is not part of WebRTC specification

* Browser crash on DataChannel options using newtonsoft

* Added missing ContextUnRegisterMediaStreamObserver, not implemented yet

* Removed audio/video offer options

* Added missing ReceiverGetStreams, not implemented yet

* RTCIceCandidates on WebGL

* Moved RTCDataChannel onmessage listeren to OnDataChannel (receiver) from createDataChannel (sender)

* Added VideoTrack with MediaStream created by WebGL's getUserMedia. Requires the RTCPeerConnection to have a MediaStream to attach to.

* Fixed CreateAudioTrack

* Fixed adding getUserMedia stream tracks to unity MediaStream

* Enabled open/close/message on both creation and ondatachannel objects

* Negotiation workaround
Often the candidate message is handled earlier than the description (probably due coroutines when setting the description)
For now the icecandidate handling waits 1 second, which is sufficient. But a fix would be to store an ICECandidate queue on the peer connection and handle the queue when the description is set

* Workaround to parse datachannel options, jsonutility/newtonsoft have trouble with the Optional fields

* Samples: working DataChannels and PeerConnection
- Fixed MediaStream getTracks with deserializer
- Added adapter.js, should improve browser compatibility
- Using objects instead of 'this' in jslib for peer events

* Added TextMessage event handling for DataChannels sample

* Fix for UpdateRendererTexture 'no video' issue

* Temp to show video tracks created by peer.ontrack

* getTracks using WebRTC.Deserialize, prevents creation of existing tracks

* Using Deserializer for RTP objects

* Firefox requires a string, instead of int for credentialType

* Fixed optional fields serialization in RTCConfiguration

* Disabled context check. Context is already removed when disposing peer/data/media objects

* Improved UWManaged array. C# objects can be disposed but still accessed at a later stage

* Delete transceiver

* Fixed DeleteMediaStreamTrack parameters

* Registering stream for videotrack is not needed

* Removing video tracks from local/remote video list object on DeleteMediaStreamTrack

* Added RegisterMediaStreamObserver, not tested

* DataChannel options parsing done in jslib file

* Moved parsing of RTCConfiguration

* Updated webrtc.dll

* Wip: create audiotrack

* Corrected RTCConfiguration parsing with new optional fields using enums

* Fixed webcam stream from getUserMedia
Improved creation of HTMLMediaElements, local and remote tracks are created on AddTrack and ontrack respectively, which enables the receiver to play the received audio stream.
The local video track is currently only needed to display the local webcam stream, but is created for every videotrack (todo)

* Added a check for RTCDataChannels onclose/open. onclose is fired when already disposed in unity.

* Fixed icecandidate struct

* Missing import and removed peer label (for now)

* Fixed some enum values (including ice/peer connection state)

* RTCStats. Not fully checked for every enum/statstype. Note: Requires "jillejr.newtonsoft.json-for-unity"

* Don't show video elements

* Use strToPtr

* RTPParameters

* RTPParameters

* RTPParameters: removed debug log and added todo

* setCodec support, only supported in chrome

* Datachannel config parsing to support firefox

* Removed debug log

* Removed debug logs

* Removed dual initializers (sourcetree bug?)

* Moved OnRemoveTrack

* Added guard for sender track

* Moved #!UNITY_WEBGL inside WebRTC.Sync

* Reducing the number of #if !UNITY_WEBL directives

* Using RTCOfferOptions object

* Added todo's

* Removed commented lines

* Removed comments lines in RTCStats

* Removed/optimized some #if webgl directives

* Added WebGLSample

* Default flip, so the correct image is transported over webrtc

* Updated local render method with flip

* Updated samples to allow webgl builds

* Some comments/codestyle changes

* Added getUserMedia TODO

* Reverted Android meta change

* fix test-case

* revert asmdef

* fixed compile error

* fix compile error

(cherry picked from commit 8eb9e4b)

* add webgl platform to CI test

(cherry picked from commit a478886)

* fix yaml

(cherry picked from commit 00939df785d1b5da64d7e3ab0795600e4f17d1a1)

* fix yaml

* fix

* fix bug

* fix yaml

* fix permission

* add job to test for webgl platform

* WIP test runner and jslib fixes
- Runs [Test] methods
- Parameterized tests are disabled [TestCase]
- Added webgl platform exclude to [UnityTest]
- VideoReceiver disabled
- AudioStream disabled
- (todo) NativeAPI
- Fixed several native method bugs

* wip NativeAPI test
enabled most test cases
needs json dll

* Passing DataChannelTest

* Fixed several tests
- Transceiver direction
- Ice candidate component (added todo/comments)
- MediaStreamAddTrack return value
- ContextCreate methods with labels
- Dummy TrackSource methods
- AudioTrack id (added custom guid field)
- MediaStream id (added custom guid field)
- Fixed NativeAPITest for WebGL MediaStream tracks length

* More test fixes - Replaced return with array  [errortype,object]
- AddTrack retursn both sender and errortype
- SetDescription returns errortype and message. TODO: make async/await to actually return the error(type)

* Fixed test cases
- Applied OptionalFields for PeerConnection config
- Fixed IceTransportPolicy enum
- Fixed Set Description of PeerConnection
- Enabled VideoReceiveTest (but are commented out)
- Added TODOs

* fix yaml for package test

* Add Preserve attribute for avoiding code stripping

* Fixed Transceiver SetCodecsPreferences

* Fixed incorrect assert in SenderGetParameter test

* Excluded failing tests + added todos

* Fixed SetLocalDescriptionWithoutDescription

* Added WebGL sample to build settings

* add edtitor version for auto-testing on CI

* Replaced Pointer_Stringify with UTF8ToString to support 2021.2

* fix: undefined `side` variable

* fix: undefined `err` variable

* fix: pass byt length to `DataChannelNativeOnMessage` callback

* ops...

Co-authored-by: Antoine Dezarnaud <dezartoine@hotmail.fr>
Co-authored-by: Antoine Dezarnaud <antoine.dezarnaud-ext@epicnpoc.com>
Co-authored-by: kazuki <karasusan@gmail.com>
Co-authored-by: Muka Schultze <samuelschultze@gmail.com>
Co-authored-by: gtk2k <gtk2k@yahoo.co.jp>
Thaina added a commit to Thaina/com.unity.webrtc that referenced this pull request Jun 11, 2023
* webgl initial plugin

* merge with @gtk2k prototype (part 1)

* Add newtonsoft json parser in package dependencies

* merge with @gtk2k prototype (part 2)

* webgl lib compile fixes

* WebGL build can be done

* bugfix : remove useless condition that brake linux compatibility

* Initial WebGL webrtc plugins

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Added OnTextMessage on RTCDataChannel
Renamed VideoStreamTrack

* Remove duplicate method RegisterRenderingWebRTCPlugin in WebTC.cs

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Signaling is not part of WebRTC specification

* Browser crash on DataChannel options using newtonsoft

* Added missing ContextUnRegisterMediaStreamObserver, not implemented yet

* Removed audio/video offer options

* Added missing ReceiverGetStreams, not implemented yet

* RTCIceCandidates on WebGL

* Moved RTCDataChannel onmessage listeren to OnDataChannel (receiver) from createDataChannel (sender)

* Added VideoTrack with MediaStream created by WebGL's getUserMedia. Requires the RTCPeerConnection to have a MediaStream to attach to.

* Fixed CreateAudioTrack

* Fixed adding getUserMedia stream tracks to unity MediaStream

* Enabled open/close/message on both creation and ondatachannel objects

* Negotiation workaround
Often the candidate message is handled earlier than the description (probably due coroutines when setting the description)
For now the icecandidate handling waits 1 second, which is sufficient. But a fix would be to store an ICECandidate queue on the peer connection and handle the queue when the description is set

* Workaround to parse datachannel options, jsonutility/newtonsoft have trouble with the Optional fields

* Samples: working DataChannels and PeerConnection
- Fixed MediaStream getTracks with deserializer
- Added adapter.js, should improve browser compatibility
- Using objects instead of 'this' in jslib for peer events

* Added TextMessage event handling for DataChannels sample

* Fix for UpdateRendererTexture 'no video' issue

* Temp to show video tracks created by peer.ontrack

* getTracks using WebRTC.Deserialize, prevents creation of existing tracks

* Using Deserializer for RTP objects

* Firefox requires a string, instead of int for credentialType

* Fixed optional fields serialization in RTCConfiguration

* Disabled context check. Context is already removed when disposing peer/data/media objects

* Improved UWManaged array. C# objects can be disposed but still accessed at a later stage

* Delete transceiver

* Fixed DeleteMediaStreamTrack parameters

* Registering stream for videotrack is not needed

* Removing video tracks from local/remote video list object on DeleteMediaStreamTrack

* Added RegisterMediaStreamObserver, not tested

* DataChannel options parsing done in jslib file

* Moved parsing of RTCConfiguration

* Updated webrtc.dll

* Wip: create audiotrack

* Corrected RTCConfiguration parsing with new optional fields using enums

* Fixed webcam stream from getUserMedia
Improved creation of HTMLMediaElements, local and remote tracks are created on AddTrack and ontrack respectively, which enables the receiver to play the received audio stream.
The local video track is currently only needed to display the local webcam stream, but is created for every videotrack (todo)

* Added a check for RTCDataChannels onclose/open. onclose is fired when already disposed in unity.

* Fixed icecandidate struct

* Missing import and removed peer label (for now)

* Fixed some enum values (including ice/peer connection state)

* RTCStats. Not fully checked for every enum/statstype. Note: Requires "jillejr.newtonsoft.json-for-unity"

* Don't show video elements

* Use strToPtr

* RTPParameters

* RTPParameters

* RTPParameters: removed debug log and added todo

* setCodec support, only supported in chrome

* Datachannel config parsing to support firefox

* Removed debug log

* Removed debug logs

* Removed dual initializers (sourcetree bug?)

* Moved OnRemoveTrack

* Added guard for sender track

* Moved #!UNITY_WEBGL inside WebRTC.Sync

* Reducing the number of #if !UNITY_WEBL directives

* Using RTCOfferOptions object

* Added todo's

* Removed commented lines

* Removed comments lines in RTCStats

* Removed/optimized some #if webgl directives

* Added WebGLSample

* Default flip, so the correct image is transported over webrtc

* Updated local render method with flip

* Updated samples to allow webgl builds

* Some comments/codestyle changes

* Added getUserMedia TODO

* Reverted Android meta change

* fix test-case

* revert asmdef

* fixed compile error

* fix compile error

(cherry picked from commit 8eb9e4b)

* add webgl platform to CI test

(cherry picked from commit a478886)

* fix yaml

(cherry picked from commit 00939df785d1b5da64d7e3ab0795600e4f17d1a1)

* fix yaml

* fix

* fix bug

* fix yaml

* fix permission

* add job to test for webgl platform

* WIP test runner and jslib fixes
- Runs [Test] methods
- Parameterized tests are disabled [TestCase]
- Added webgl platform exclude to [UnityTest]
- VideoReceiver disabled
- AudioStream disabled
- (todo) NativeAPI
- Fixed several native method bugs

* wip NativeAPI test
enabled most test cases
needs json dll

* Passing DataChannelTest

* Fixed several tests
- Transceiver direction
- Ice candidate component (added todo/comments)
- MediaStreamAddTrack return value
- ContextCreate methods with labels
- Dummy TrackSource methods
- AudioTrack id (added custom guid field)
- MediaStream id (added custom guid field)
- Fixed NativeAPITest for WebGL MediaStream tracks length

* More test fixes - Replaced return with array  [errortype,object]
- AddTrack retursn both sender and errortype
- SetDescription returns errortype and message. TODO: make async/await to actually return the error(type)

* Fixed test cases
- Applied OptionalFields for PeerConnection config
- Fixed IceTransportPolicy enum
- Fixed Set Description of PeerConnection
- Enabled VideoReceiveTest (but are commented out)
- Added TODOs

* fix yaml for package test

* Add Preserve attribute for avoiding code stripping

* Fixed Transceiver SetCodecsPreferences

* Fixed incorrect assert in SenderGetParameter test

* Excluded failing tests + added todos

* Fixed SetLocalDescriptionWithoutDescription

* Added WebGL sample to build settings

* add edtitor version for auto-testing on CI

* Replaced Pointer_Stringify with UTF8ToString to support 2021.2

* fix: undefined `side` variable

* fix: undefined `err` variable

* fix: pass byt length to `DataChannelNativeOnMessage` callback

* ops...

Co-authored-by: Antoine Dezarnaud <dezartoine@hotmail.fr>
Co-authored-by: Antoine Dezarnaud <antoine.dezarnaud-ext@epicnpoc.com>
Co-authored-by: kazuki <karasusan@gmail.com>
Co-authored-by: Muka Schultze <samuelschultze@gmail.com>
Co-authored-by: gtk2k <gtk2k@yahoo.co.jp>
Thaina added a commit to Thaina/com.unity.webrtc that referenced this pull request Jun 11, 2023
* webgl initial plugin

* merge with @gtk2k prototype (part 1)

* Add newtonsoft json parser in package dependencies

* merge with @gtk2k prototype (part 2)

* webgl lib compile fixes

* WebGL build can be done

* bugfix : remove useless condition that brake linux compatibility

* Initial WebGL webrtc plugins

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Added OnTextMessage on RTCDataChannel
Renamed VideoStreamTrack

* Remove duplicate method RegisterRenderingWebRTCPlugin in WebTC.cs

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Signaling is not part of WebRTC specification

* Browser crash on DataChannel options using newtonsoft

* Added missing ContextUnRegisterMediaStreamObserver, not implemented yet

* Removed audio/video offer options

* Added missing ReceiverGetStreams, not implemented yet

* RTCIceCandidates on WebGL

* Moved RTCDataChannel onmessage listeren to OnDataChannel (receiver) from createDataChannel (sender)

* Added VideoTrack with MediaStream created by WebGL's getUserMedia. Requires the RTCPeerConnection to have a MediaStream to attach to.

* Fixed CreateAudioTrack

* Fixed adding getUserMedia stream tracks to unity MediaStream

* Enabled open/close/message on both creation and ondatachannel objects

* Negotiation workaround
Often the candidate message is handled earlier than the description (probably due coroutines when setting the description)
For now the icecandidate handling waits 1 second, which is sufficient. But a fix would be to store an ICECandidate queue on the peer connection and handle the queue when the description is set

* Workaround to parse datachannel options, jsonutility/newtonsoft have trouble with the Optional fields

* Samples: working DataChannels and PeerConnection
- Fixed MediaStream getTracks with deserializer
- Added adapter.js, should improve browser compatibility
- Using objects instead of 'this' in jslib for peer events

* Added TextMessage event handling for DataChannels sample

* Fix for UpdateRendererTexture 'no video' issue

* Temp to show video tracks created by peer.ontrack

* getTracks using WebRTC.Deserialize, prevents creation of existing tracks

* Using Deserializer for RTP objects

* Firefox requires a string, instead of int for credentialType

* Fixed optional fields serialization in RTCConfiguration

* Disabled context check. Context is already removed when disposing peer/data/media objects

* Improved UWManaged array. C# objects can be disposed but still accessed at a later stage

* Delete transceiver

* Fixed DeleteMediaStreamTrack parameters

* Registering stream for videotrack is not needed

* Removing video tracks from local/remote video list object on DeleteMediaStreamTrack

* Added RegisterMediaStreamObserver, not tested

* DataChannel options parsing done in jslib file

* Moved parsing of RTCConfiguration

* Updated webrtc.dll

* Wip: create audiotrack

* Corrected RTCConfiguration parsing with new optional fields using enums

* Fixed webcam stream from getUserMedia
Improved creation of HTMLMediaElements, local and remote tracks are created on AddTrack and ontrack respectively, which enables the receiver to play the received audio stream.
The local video track is currently only needed to display the local webcam stream, but is created for every videotrack (todo)

* Added a check for RTCDataChannels onclose/open. onclose is fired when already disposed in unity.

* Fixed icecandidate struct

* Missing import and removed peer label (for now)

* Fixed some enum values (including ice/peer connection state)

* RTCStats. Not fully checked for every enum/statstype. Note: Requires "jillejr.newtonsoft.json-for-unity"

* Don't show video elements

* Use strToPtr

* RTPParameters

* RTPParameters

* RTPParameters: removed debug log and added todo

* setCodec support, only supported in chrome

* Datachannel config parsing to support firefox

* Removed debug log

* Removed debug logs

* Removed dual initializers (sourcetree bug?)

* Moved OnRemoveTrack

* Added guard for sender track

* Moved #!UNITY_WEBGL inside WebRTC.Sync

* Reducing the number of #if !UNITY_WEBL directives

* Using RTCOfferOptions object

* Added todo's

* Removed commented lines

* Removed comments lines in RTCStats

* Removed/optimized some #if webgl directives

* Added WebGLSample

* Default flip, so the correct image is transported over webrtc

* Updated local render method with flip

* Updated samples to allow webgl builds

* Some comments/codestyle changes

* Added getUserMedia TODO

* Reverted Android meta change

* fix test-case

* revert asmdef

* fixed compile error

* fix compile error

(cherry picked from commit 8eb9e4b)

* add webgl platform to CI test

(cherry picked from commit a478886)

* fix yaml

(cherry picked from commit 00939df785d1b5da64d7e3ab0795600e4f17d1a1)

* fix yaml

* fix

* fix bug

* fix yaml

* fix permission

* add job to test for webgl platform

* WIP test runner and jslib fixes
- Runs [Test] methods
- Parameterized tests are disabled [TestCase]
- Added webgl platform exclude to [UnityTest]
- VideoReceiver disabled
- AudioStream disabled
- (todo) NativeAPI
- Fixed several native method bugs

* wip NativeAPI test
enabled most test cases
needs json dll

* Passing DataChannelTest

* Fixed several tests
- Transceiver direction
- Ice candidate component (added todo/comments)
- MediaStreamAddTrack return value
- ContextCreate methods with labels
- Dummy TrackSource methods
- AudioTrack id (added custom guid field)
- MediaStream id (added custom guid field)
- Fixed NativeAPITest for WebGL MediaStream tracks length

* More test fixes - Replaced return with array  [errortype,object]
- AddTrack retursn both sender and errortype
- SetDescription returns errortype and message. TODO: make async/await to actually return the error(type)

* Fixed test cases
- Applied OptionalFields for PeerConnection config
- Fixed IceTransportPolicy enum
- Fixed Set Description of PeerConnection
- Enabled VideoReceiveTest (but are commented out)
- Added TODOs

* fix yaml for package test

* Add Preserve attribute for avoiding code stripping

* Fixed Transceiver SetCodecsPreferences

* Fixed incorrect assert in SenderGetParameter test

* Excluded failing tests + added todos

* Fixed SetLocalDescriptionWithoutDescription

* Added WebGL sample to build settings

* add edtitor version for auto-testing on CI

* Replaced Pointer_Stringify with UTF8ToString to support 2021.2

* fix: undefined `side` variable

* fix: undefined `err` variable

* fix: pass byt length to `DataChannelNativeOnMessage` callback

* ops...

Co-authored-by: Antoine Dezarnaud <dezartoine@hotmail.fr>
Co-authored-by: Antoine Dezarnaud <antoine.dezarnaud-ext@epicnpoc.com>
Co-authored-by: kazuki <karasusan@gmail.com>
Co-authored-by: Muka Schultze <samuelschultze@gmail.com>
Co-authored-by: gtk2k <gtk2k@yahoo.co.jp>
Thaina added a commit to Thaina/com.unity.webrtc that referenced this pull request Jun 11, 2023
* webgl initial plugin

* merge with @gtk2k prototype (part 1)

* Add newtonsoft json parser in package dependencies

* merge with @gtk2k prototype (part 2)

* webgl lib compile fixes

* WebGL build can be done

* bugfix : remove useless condition that brake linux compatibility

* Initial WebGL webrtc plugins

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Added OnTextMessage on RTCDataChannel
Renamed VideoStreamTrack

* Remove duplicate method RegisterRenderingWebRTCPlugin in WebTC.cs

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Signaling is not part of WebRTC specification

* Browser crash on DataChannel options using newtonsoft

* Added missing ContextUnRegisterMediaStreamObserver, not implemented yet

* Removed audio/video offer options

* Added missing ReceiverGetStreams, not implemented yet

* RTCIceCandidates on WebGL

* Moved RTCDataChannel onmessage listeren to OnDataChannel (receiver) from createDataChannel (sender)

* Added VideoTrack with MediaStream created by WebGL's getUserMedia. Requires the RTCPeerConnection to have a MediaStream to attach to.

* Fixed CreateAudioTrack

* Fixed adding getUserMedia stream tracks to unity MediaStream

* Enabled open/close/message on both creation and ondatachannel objects

* Negotiation workaround
Often the candidate message is handled earlier than the description (probably due coroutines when setting the description)
For now the icecandidate handling waits 1 second, which is sufficient. But a fix would be to store an ICECandidate queue on the peer connection and handle the queue when the description is set

* Workaround to parse datachannel options, jsonutility/newtonsoft have trouble with the Optional fields

* Samples: working DataChannels and PeerConnection
- Fixed MediaStream getTracks with deserializer
- Added adapter.js, should improve browser compatibility
- Using objects instead of 'this' in jslib for peer events

* Added TextMessage event handling for DataChannels sample

* Fix for UpdateRendererTexture 'no video' issue

* Temp to show video tracks created by peer.ontrack

* getTracks using WebRTC.Deserialize, prevents creation of existing tracks

* Using Deserializer for RTP objects

* Firefox requires a string, instead of int for credentialType

* Fixed optional fields serialization in RTCConfiguration

* Disabled context check. Context is already removed when disposing peer/data/media objects

* Improved UWManaged array. C# objects can be disposed but still accessed at a later stage

* Delete transceiver

* Fixed DeleteMediaStreamTrack parameters

* Registering stream for videotrack is not needed

* Removing video tracks from local/remote video list object on DeleteMediaStreamTrack

* Added RegisterMediaStreamObserver, not tested

* DataChannel options parsing done in jslib file

* Moved parsing of RTCConfiguration

* Updated webrtc.dll

* Wip: create audiotrack

* Corrected RTCConfiguration parsing with new optional fields using enums

* Fixed webcam stream from getUserMedia
Improved creation of HTMLMediaElements, local and remote tracks are created on AddTrack and ontrack respectively, which enables the receiver to play the received audio stream.
The local video track is currently only needed to display the local webcam stream, but is created for every videotrack (todo)

* Added a check for RTCDataChannels onclose/open. onclose is fired when already disposed in unity.

* Fixed icecandidate struct

* Missing import and removed peer label (for now)

* Fixed some enum values (including ice/peer connection state)

* RTCStats. Not fully checked for every enum/statstype. Note: Requires "jillejr.newtonsoft.json-for-unity"

* Don't show video elements

* Use strToPtr

* RTPParameters

* RTPParameters

* RTPParameters: removed debug log and added todo

* setCodec support, only supported in chrome

* Datachannel config parsing to support firefox

* Removed debug log

* Removed debug logs

* Removed dual initializers (sourcetree bug?)

* Moved OnRemoveTrack

* Added guard for sender track

* Moved #!UNITY_WEBGL inside WebRTC.Sync

* Reducing the number of #if !UNITY_WEBL directives

* Using RTCOfferOptions object

* Added todo's

* Removed commented lines

* Removed comments lines in RTCStats

* Removed/optimized some #if webgl directives

* Added WebGLSample

* Default flip, so the correct image is transported over webrtc

* Updated local render method with flip

* Updated samples to allow webgl builds

* Some comments/codestyle changes

* Added getUserMedia TODO

* Reverted Android meta change

* fix test-case

* revert asmdef

* fixed compile error

* fix compile error

(cherry picked from commit 8eb9e4b)

* add webgl platform to CI test

(cherry picked from commit a478886)

* fix yaml

(cherry picked from commit 00939df785d1b5da64d7e3ab0795600e4f17d1a1)

* fix yaml

* fix

* fix bug

* fix yaml

* fix permission

* add job to test for webgl platform

* WIP test runner and jslib fixes
- Runs [Test] methods
- Parameterized tests are disabled [TestCase]
- Added webgl platform exclude to [UnityTest]
- VideoReceiver disabled
- AudioStream disabled
- (todo) NativeAPI
- Fixed several native method bugs

* wip NativeAPI test
enabled most test cases
needs json dll

* Passing DataChannelTest

* Fixed several tests
- Transceiver direction
- Ice candidate component (added todo/comments)
- MediaStreamAddTrack return value
- ContextCreate methods with labels
- Dummy TrackSource methods
- AudioTrack id (added custom guid field)
- MediaStream id (added custom guid field)
- Fixed NativeAPITest for WebGL MediaStream tracks length

* More test fixes - Replaced return with array  [errortype,object]
- AddTrack retursn both sender and errortype
- SetDescription returns errortype and message. TODO: make async/await to actually return the error(type)

* Fixed test cases
- Applied OptionalFields for PeerConnection config
- Fixed IceTransportPolicy enum
- Fixed Set Description of PeerConnection
- Enabled VideoReceiveTest (but are commented out)
- Added TODOs

* fix yaml for package test

* Add Preserve attribute for avoiding code stripping

* Fixed Transceiver SetCodecsPreferences

* Fixed incorrect assert in SenderGetParameter test

* Excluded failing tests + added todos

* Fixed SetLocalDescriptionWithoutDescription

* Added WebGL sample to build settings

* add edtitor version for auto-testing on CI

* Replaced Pointer_Stringify with UTF8ToString to support 2021.2

* fix: undefined `side` variable

* fix: undefined `err` variable

* fix: pass byt length to `DataChannelNativeOnMessage` callback

* ops...

Co-authored-by: Antoine Dezarnaud <dezartoine@hotmail.fr>
Co-authored-by: Antoine Dezarnaud <antoine.dezarnaud-ext@epicnpoc.com>
Co-authored-by: kazuki <karasusan@gmail.com>
Co-authored-by: Muka Schultze <samuelschultze@gmail.com>
Co-authored-by: gtk2k <gtk2k@yahoo.co.jp>
Thaina added a commit to Thaina/com.unity.webrtc that referenced this pull request Dec 17, 2023
* webgl initial plugin

* merge with @gtk2k prototype (part 1)

* Add newtonsoft json parser in package dependencies

* merge with @gtk2k prototype (part 2)

* webgl lib compile fixes

* WebGL build can be done

* bugfix : remove useless condition that brake linux compatibility

* Initial WebGL webrtc plugins

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Added OnTextMessage on RTCDataChannel
Renamed VideoStreamTrack

* Remove duplicate method RegisterRenderingWebRTCPlugin in WebTC.cs

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Signaling is not part of WebRTC specification

* Browser crash on DataChannel options using newtonsoft

* Added missing ContextUnRegisterMediaStreamObserver, not implemented yet

* Removed audio/video offer options

* Added missing ReceiverGetStreams, not implemented yet

* RTCIceCandidates on WebGL

* Moved RTCDataChannel onmessage listeren to OnDataChannel (receiver) from createDataChannel (sender)

* Added VideoTrack with MediaStream created by WebGL's getUserMedia. Requires the RTCPeerConnection to have a MediaStream to attach to.

* Fixed CreateAudioTrack

* Fixed adding getUserMedia stream tracks to unity MediaStream

* Enabled open/close/message on both creation and ondatachannel objects

* Negotiation workaround
Often the candidate message is handled earlier than the description (probably due coroutines when setting the description)
For now the icecandidate handling waits 1 second, which is sufficient. But a fix would be to store an ICECandidate queue on the peer connection and handle the queue when the description is set

* Workaround to parse datachannel options, jsonutility/newtonsoft have trouble with the Optional fields

* Samples: working DataChannels and PeerConnection
- Fixed MediaStream getTracks with deserializer
- Added adapter.js, should improve browser compatibility
- Using objects instead of 'this' in jslib for peer events

* Added TextMessage event handling for DataChannels sample

* Fix for UpdateRendererTexture 'no video' issue

* Temp to show video tracks created by peer.ontrack

* getTracks using WebRTC.Deserialize, prevents creation of existing tracks

* Using Deserializer for RTP objects

* Firefox requires a string, instead of int for credentialType

* Fixed optional fields serialization in RTCConfiguration

* Disabled context check. Context is already removed when disposing peer/data/media objects

* Improved UWManaged array. C# objects can be disposed but still accessed at a later stage

* Delete transceiver

* Fixed DeleteMediaStreamTrack parameters

* Registering stream for videotrack is not needed

* Removing video tracks from local/remote video list object on DeleteMediaStreamTrack

* Added RegisterMediaStreamObserver, not tested

* DataChannel options parsing done in jslib file

* Moved parsing of RTCConfiguration

* Updated webrtc.dll

* Wip: create audiotrack

* Corrected RTCConfiguration parsing with new optional fields using enums

* Fixed webcam stream from getUserMedia
Improved creation of HTMLMediaElements, local and remote tracks are created on AddTrack and ontrack respectively, which enables the receiver to play the received audio stream.
The local video track is currently only needed to display the local webcam stream, but is created for every videotrack (todo)

* Added a check for RTCDataChannels onclose/open. onclose is fired when already disposed in unity.

* Fixed icecandidate struct

* Missing import and removed peer label (for now)

* Fixed some enum values (including ice/peer connection state)

* RTCStats. Not fully checked for every enum/statstype. Note: Requires "jillejr.newtonsoft.json-for-unity"

* Don't show video elements

* Use strToPtr

* RTPParameters

* RTPParameters

* RTPParameters: removed debug log and added todo

* setCodec support, only supported in chrome

* Datachannel config parsing to support firefox

* Removed debug log

* Removed debug logs

* Removed dual initializers (sourcetree bug?)

* Moved OnRemoveTrack

* Added guard for sender track

* Moved #!UNITY_WEBGL inside WebRTC.Sync

* Reducing the number of #if !UNITY_WEBL directives

* Using RTCOfferOptions object

* Added todo's

* Removed commented lines

* Removed comments lines in RTCStats

* Removed/optimized some #if webgl directives

* Added WebGLSample

* Default flip, so the correct image is transported over webrtc

* Updated local render method with flip

* Updated samples to allow webgl builds

* Some comments/codestyle changes

* Added getUserMedia TODO

* Reverted Android meta change

* fix test-case

* revert asmdef

* fixed compile error

* fix compile error

(cherry picked from commit 8eb9e4b)

* add webgl platform to CI test

(cherry picked from commit a478886)

* fix yaml

(cherry picked from commit 00939df785d1b5da64d7e3ab0795600e4f17d1a1)

* fix yaml

* fix

* fix bug

* fix yaml

* fix permission

* add job to test for webgl platform

* WIP test runner and jslib fixes
- Runs [Test] methods
- Parameterized tests are disabled [TestCase]
- Added webgl platform exclude to [UnityTest]
- VideoReceiver disabled
- AudioStream disabled
- (todo) NativeAPI
- Fixed several native method bugs

* wip NativeAPI test
enabled most test cases
needs json dll

* Passing DataChannelTest

* Fixed several tests
- Transceiver direction
- Ice candidate component (added todo/comments)
- MediaStreamAddTrack return value
- ContextCreate methods with labels
- Dummy TrackSource methods
- AudioTrack id (added custom guid field)
- MediaStream id (added custom guid field)
- Fixed NativeAPITest for WebGL MediaStream tracks length

* More test fixes - Replaced return with array  [errortype,object]
- AddTrack retursn both sender and errortype
- SetDescription returns errortype and message. TODO: make async/await to actually return the error(type)

* Fixed test cases
- Applied OptionalFields for PeerConnection config
- Fixed IceTransportPolicy enum
- Fixed Set Description of PeerConnection
- Enabled VideoReceiveTest (but are commented out)
- Added TODOs

* fix yaml for package test

* Add Preserve attribute for avoiding code stripping

* Fixed Transceiver SetCodecsPreferences

* Fixed incorrect assert in SenderGetParameter test

* Excluded failing tests + added todos

* Fixed SetLocalDescriptionWithoutDescription

* Added WebGL sample to build settings

* add edtitor version for auto-testing on CI

* Replaced Pointer_Stringify with UTF8ToString to support 2021.2

* fix: undefined `side` variable

* fix: undefined `err` variable

* fix: pass byt length to `DataChannelNativeOnMessage` callback

* ops...

Co-authored-by: Antoine Dezarnaud <dezartoine@hotmail.fr>
Co-authored-by: Antoine Dezarnaud <antoine.dezarnaud-ext@epicnpoc.com>
Co-authored-by: kazuki <karasusan@gmail.com>
Co-authored-by: Muka Schultze <samuelschultze@gmail.com>
Co-authored-by: gtk2k <gtk2k@yahoo.co.jp>
Thaina added a commit to Thaina/com.unity.webrtc that referenced this pull request Dec 17, 2023
* webgl initial plugin

* merge with @gtk2k prototype (part 1)

* Add newtonsoft json parser in package dependencies

* merge with @gtk2k prototype (part 2)

* webgl lib compile fixes

* WebGL build can be done

* bugfix : remove useless condition that brake linux compatibility

* Initial WebGL webrtc plugins

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Added OnTextMessage on RTCDataChannel
Renamed VideoStreamTrack

* Remove duplicate method RegisterRenderingWebRTCPlugin in WebTC.cs

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Signaling is not part of WebRTC specification

* Browser crash on DataChannel options using newtonsoft

* Added missing ContextUnRegisterMediaStreamObserver, not implemented yet

* Removed audio/video offer options

* Added missing ReceiverGetStreams, not implemented yet

* RTCIceCandidates on WebGL

* Moved RTCDataChannel onmessage listeren to OnDataChannel (receiver) from createDataChannel (sender)

* Added VideoTrack with MediaStream created by WebGL's getUserMedia. Requires the RTCPeerConnection to have a MediaStream to attach to.

* Fixed CreateAudioTrack

* Fixed adding getUserMedia stream tracks to unity MediaStream

* Enabled open/close/message on both creation and ondatachannel objects

* Negotiation workaround
Often the candidate message is handled earlier than the description (probably due coroutines when setting the description)
For now the icecandidate handling waits 1 second, which is sufficient. But a fix would be to store an ICECandidate queue on the peer connection and handle the queue when the description is set

* Workaround to parse datachannel options, jsonutility/newtonsoft have trouble with the Optional fields

* Samples: working DataChannels and PeerConnection
- Fixed MediaStream getTracks with deserializer
- Added adapter.js, should improve browser compatibility
- Using objects instead of 'this' in jslib for peer events

* Added TextMessage event handling for DataChannels sample

* Fix for UpdateRendererTexture 'no video' issue

* Temp to show video tracks created by peer.ontrack

* getTracks using WebRTC.Deserialize, prevents creation of existing tracks

* Using Deserializer for RTP objects

* Firefox requires a string, instead of int for credentialType

* Fixed optional fields serialization in RTCConfiguration

* Disabled context check. Context is already removed when disposing peer/data/media objects

* Improved UWManaged array. C# objects can be disposed but still accessed at a later stage

* Delete transceiver

* Fixed DeleteMediaStreamTrack parameters

* Registering stream for videotrack is not needed

* Removing video tracks from local/remote video list object on DeleteMediaStreamTrack

* Added RegisterMediaStreamObserver, not tested

* DataChannel options parsing done in jslib file

* Moved parsing of RTCConfiguration

* Updated webrtc.dll

* Wip: create audiotrack

* Corrected RTCConfiguration parsing with new optional fields using enums

* Fixed webcam stream from getUserMedia
Improved creation of HTMLMediaElements, local and remote tracks are created on AddTrack and ontrack respectively, which enables the receiver to play the received audio stream.
The local video track is currently only needed to display the local webcam stream, but is created for every videotrack (todo)

* Added a check for RTCDataChannels onclose/open. onclose is fired when already disposed in unity.

* Fixed icecandidate struct

* Missing import and removed peer label (for now)

* Fixed some enum values (including ice/peer connection state)

* RTCStats. Not fully checked for every enum/statstype. Note: Requires "jillejr.newtonsoft.json-for-unity"

* Don't show video elements

* Use strToPtr

* RTPParameters

* RTPParameters

* RTPParameters: removed debug log and added todo

* setCodec support, only supported in chrome

* Datachannel config parsing to support firefox

* Removed debug log

* Removed debug logs

* Removed dual initializers (sourcetree bug?)

* Moved OnRemoveTrack

* Added guard for sender track

* Moved #!UNITY_WEBGL inside WebRTC.Sync

* Reducing the number of #if !UNITY_WEBL directives

* Using RTCOfferOptions object

* Added todo's

* Removed commented lines

* Removed comments lines in RTCStats

* Removed/optimized some #if webgl directives

* Added WebGLSample

* Default flip, so the correct image is transported over webrtc

* Updated local render method with flip

* Updated samples to allow webgl builds

* Some comments/codestyle changes

* Added getUserMedia TODO

* Reverted Android meta change

* fix test-case

* revert asmdef

* fixed compile error

* fix compile error

(cherry picked from commit 8eb9e4b)

* add webgl platform to CI test

(cherry picked from commit a478886)

* fix yaml

(cherry picked from commit 00939df785d1b5da64d7e3ab0795600e4f17d1a1)

* fix yaml

* fix

* fix bug

* fix yaml

* fix permission

* add job to test for webgl platform

* WIP test runner and jslib fixes
- Runs [Test] methods
- Parameterized tests are disabled [TestCase]
- Added webgl platform exclude to [UnityTest]
- VideoReceiver disabled
- AudioStream disabled
- (todo) NativeAPI
- Fixed several native method bugs

* wip NativeAPI test
enabled most test cases
needs json dll

* Passing DataChannelTest

* Fixed several tests
- Transceiver direction
- Ice candidate component (added todo/comments)
- MediaStreamAddTrack return value
- ContextCreate methods with labels
- Dummy TrackSource methods
- AudioTrack id (added custom guid field)
- MediaStream id (added custom guid field)
- Fixed NativeAPITest for WebGL MediaStream tracks length

* More test fixes - Replaced return with array  [errortype,object]
- AddTrack retursn both sender and errortype
- SetDescription returns errortype and message. TODO: make async/await to actually return the error(type)

* Fixed test cases
- Applied OptionalFields for PeerConnection config
- Fixed IceTransportPolicy enum
- Fixed Set Description of PeerConnection
- Enabled VideoReceiveTest (but are commented out)
- Added TODOs

* fix yaml for package test

* Add Preserve attribute for avoiding code stripping

* Fixed Transceiver SetCodecsPreferences

* Fixed incorrect assert in SenderGetParameter test

* Excluded failing tests + added todos

* Fixed SetLocalDescriptionWithoutDescription

* Added WebGL sample to build settings

* add edtitor version for auto-testing on CI

* Replaced Pointer_Stringify with UTF8ToString to support 2021.2

* fix: undefined `side` variable

* fix: undefined `err` variable

* fix: pass byt length to `DataChannelNativeOnMessage` callback

* ops...

Co-authored-by: Antoine Dezarnaud <dezartoine@hotmail.fr>
Co-authored-by: Antoine Dezarnaud <antoine.dezarnaud-ext@epicnpoc.com>
Co-authored-by: kazuki <karasusan@gmail.com>
Co-authored-by: Muka Schultze <samuelschultze@gmail.com>
Co-authored-by: gtk2k <gtk2k@yahoo.co.jp>
Thaina added a commit to Thaina/com.unity.webrtc that referenced this pull request Dec 17, 2023
* webgl initial plugin

* merge with @gtk2k prototype (part 1)

* Add newtonsoft json parser in package dependencies

* merge with @gtk2k prototype (part 2)

* webgl lib compile fixes

* WebGL build can be done

* bugfix : remove useless condition that brake linux compatibility

* Initial WebGL webrtc plugins

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Added OnTextMessage on RTCDataChannel
Renamed VideoStreamTrack

* Remove duplicate method RegisterRenderingWebRTCPlugin in WebTC.cs

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Signaling is not part of WebRTC specification

* Browser crash on DataChannel options using newtonsoft

* Added missing ContextUnRegisterMediaStreamObserver, not implemented yet

* Removed audio/video offer options

* Added missing ReceiverGetStreams, not implemented yet

* RTCIceCandidates on WebGL

* Moved RTCDataChannel onmessage listeren to OnDataChannel (receiver) from createDataChannel (sender)

* Added VideoTrack with MediaStream created by WebGL's getUserMedia. Requires the RTCPeerConnection to have a MediaStream to attach to.

* Fixed CreateAudioTrack

* Fixed adding getUserMedia stream tracks to unity MediaStream

* Enabled open/close/message on both creation and ondatachannel objects

* Negotiation workaround
Often the candidate message is handled earlier than the description (probably due coroutines when setting the description)
For now the icecandidate handling waits 1 second, which is sufficient. But a fix would be to store an ICECandidate queue on the peer connection and handle the queue when the description is set

* Workaround to parse datachannel options, jsonutility/newtonsoft have trouble with the Optional fields

* Samples: working DataChannels and PeerConnection
- Fixed MediaStream getTracks with deserializer
- Added adapter.js, should improve browser compatibility
- Using objects instead of 'this' in jslib for peer events

* Added TextMessage event handling for DataChannels sample

* Fix for UpdateRendererTexture 'no video' issue

* Temp to show video tracks created by peer.ontrack

* getTracks using WebRTC.Deserialize, prevents creation of existing tracks

* Using Deserializer for RTP objects

* Firefox requires a string, instead of int for credentialType

* Fixed optional fields serialization in RTCConfiguration

* Disabled context check. Context is already removed when disposing peer/data/media objects

* Improved UWManaged array. C# objects can be disposed but still accessed at a later stage

* Delete transceiver

* Fixed DeleteMediaStreamTrack parameters

* Registering stream for videotrack is not needed

* Removing video tracks from local/remote video list object on DeleteMediaStreamTrack

* Added RegisterMediaStreamObserver, not tested

* DataChannel options parsing done in jslib file

* Moved parsing of RTCConfiguration

* Updated webrtc.dll

* Wip: create audiotrack

* Corrected RTCConfiguration parsing with new optional fields using enums

* Fixed webcam stream from getUserMedia
Improved creation of HTMLMediaElements, local and remote tracks are created on AddTrack and ontrack respectively, which enables the receiver to play the received audio stream.
The local video track is currently only needed to display the local webcam stream, but is created for every videotrack (todo)

* Added a check for RTCDataChannels onclose/open. onclose is fired when already disposed in unity.

* Fixed icecandidate struct

* Missing import and removed peer label (for now)

* Fixed some enum values (including ice/peer connection state)

* RTCStats. Not fully checked for every enum/statstype. Note: Requires "jillejr.newtonsoft.json-for-unity"

* Don't show video elements

* Use strToPtr

* RTPParameters

* RTPParameters

* RTPParameters: removed debug log and added todo

* setCodec support, only supported in chrome

* Datachannel config parsing to support firefox

* Removed debug log

* Removed debug logs

* Removed dual initializers (sourcetree bug?)

* Moved OnRemoveTrack

* Added guard for sender track

* Moved #!UNITY_WEBGL inside WebRTC.Sync

* Reducing the number of #if !UNITY_WEBL directives

* Using RTCOfferOptions object

* Added todo's

* Removed commented lines

* Removed comments lines in RTCStats

* Removed/optimized some #if webgl directives

* Added WebGLSample

* Default flip, so the correct image is transported over webrtc

* Updated local render method with flip

* Updated samples to allow webgl builds

* Some comments/codestyle changes

* Added getUserMedia TODO

* Reverted Android meta change

* fix test-case

* revert asmdef

* fixed compile error

* fix compile error

(cherry picked from commit 8eb9e4b)

* add webgl platform to CI test

(cherry picked from commit a478886)

* fix yaml

(cherry picked from commit 00939df785d1b5da64d7e3ab0795600e4f17d1a1)

* fix yaml

* fix

* fix bug

* fix yaml

* fix permission

* add job to test for webgl platform

* WIP test runner and jslib fixes
- Runs [Test] methods
- Parameterized tests are disabled [TestCase]
- Added webgl platform exclude to [UnityTest]
- VideoReceiver disabled
- AudioStream disabled
- (todo) NativeAPI
- Fixed several native method bugs

* wip NativeAPI test
enabled most test cases
needs json dll

* Passing DataChannelTest

* Fixed several tests
- Transceiver direction
- Ice candidate component (added todo/comments)
- MediaStreamAddTrack return value
- ContextCreate methods with labels
- Dummy TrackSource methods
- AudioTrack id (added custom guid field)
- MediaStream id (added custom guid field)
- Fixed NativeAPITest for WebGL MediaStream tracks length

* More test fixes - Replaced return with array  [errortype,object]
- AddTrack retursn both sender and errortype
- SetDescription returns errortype and message. TODO: make async/await to actually return the error(type)

* Fixed test cases
- Applied OptionalFields for PeerConnection config
- Fixed IceTransportPolicy enum
- Fixed Set Description of PeerConnection
- Enabled VideoReceiveTest (but are commented out)
- Added TODOs

* fix yaml for package test

* Add Preserve attribute for avoiding code stripping

* Fixed Transceiver SetCodecsPreferences

* Fixed incorrect assert in SenderGetParameter test

* Excluded failing tests + added todos

* Fixed SetLocalDescriptionWithoutDescription

* Added WebGL sample to build settings

* add edtitor version for auto-testing on CI

* Replaced Pointer_Stringify with UTF8ToString to support 2021.2

* fix: undefined `side` variable

* fix: undefined `err` variable

* fix: pass byt length to `DataChannelNativeOnMessage` callback

* ops...

Co-authored-by: Antoine Dezarnaud <dezartoine@hotmail.fr>
Co-authored-by: Antoine Dezarnaud <antoine.dezarnaud-ext@epicnpoc.com>
Co-authored-by: kazuki <karasusan@gmail.com>
Co-authored-by: Muka Schultze <samuelschultze@gmail.com>
Co-authored-by: gtk2k <gtk2k@yahoo.co.jp>
Thaina added a commit to Thaina/com.unity.webrtc that referenced this pull request Dec 17, 2023
* webgl initial plugin

* merge with @gtk2k prototype (part 1)

* Add newtonsoft json parser in package dependencies

* merge with @gtk2k prototype (part 2)

* webgl lib compile fixes

* WebGL build can be done

* bugfix : remove useless condition that brake linux compatibility

* Initial WebGL webrtc plugins

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Added OnTextMessage on RTCDataChannel
Renamed VideoStreamTrack

* Remove duplicate method RegisterRenderingWebRTCPlugin in WebTC.cs

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Signaling is not part of WebRTC specification

* Browser crash on DataChannel options using newtonsoft

* Added missing ContextUnRegisterMediaStreamObserver, not implemented yet

* Removed audio/video offer options

* Added missing ReceiverGetStreams, not implemented yet

* RTCIceCandidates on WebGL

* Moved RTCDataChannel onmessage listeren to OnDataChannel (receiver) from createDataChannel (sender)

* Added VideoTrack with MediaStream created by WebGL's getUserMedia. Requires the RTCPeerConnection to have a MediaStream to attach to.

* Fixed CreateAudioTrack

* Fixed adding getUserMedia stream tracks to unity MediaStream

* Enabled open/close/message on both creation and ondatachannel objects

* Negotiation workaround
Often the candidate message is handled earlier than the description (probably due coroutines when setting the description)
For now the icecandidate handling waits 1 second, which is sufficient. But a fix would be to store an ICECandidate queue on the peer connection and handle the queue when the description is set

* Workaround to parse datachannel options, jsonutility/newtonsoft have trouble with the Optional fields

* Samples: working DataChannels and PeerConnection
- Fixed MediaStream getTracks with deserializer
- Added adapter.js, should improve browser compatibility
- Using objects instead of 'this' in jslib for peer events

* Added TextMessage event handling for DataChannels sample

* Fix for UpdateRendererTexture 'no video' issue

* Temp to show video tracks created by peer.ontrack

* getTracks using WebRTC.Deserialize, prevents creation of existing tracks

* Using Deserializer for RTP objects

* Firefox requires a string, instead of int for credentialType

* Fixed optional fields serialization in RTCConfiguration

* Disabled context check. Context is already removed when disposing peer/data/media objects

* Improved UWManaged array. C# objects can be disposed but still accessed at a later stage

* Delete transceiver

* Fixed DeleteMediaStreamTrack parameters

* Registering stream for videotrack is not needed

* Removing video tracks from local/remote video list object on DeleteMediaStreamTrack

* Added RegisterMediaStreamObserver, not tested

* DataChannel options parsing done in jslib file

* Moved parsing of RTCConfiguration

* Updated webrtc.dll

* Wip: create audiotrack

* Corrected RTCConfiguration parsing with new optional fields using enums

* Fixed webcam stream from getUserMedia
Improved creation of HTMLMediaElements, local and remote tracks are created on AddTrack and ontrack respectively, which enables the receiver to play the received audio stream.
The local video track is currently only needed to display the local webcam stream, but is created for every videotrack (todo)

* Added a check for RTCDataChannels onclose/open. onclose is fired when already disposed in unity.

* Fixed icecandidate struct

* Missing import and removed peer label (for now)

* Fixed some enum values (including ice/peer connection state)

* RTCStats. Not fully checked for every enum/statstype. Note: Requires "jillejr.newtonsoft.json-for-unity"

* Don't show video elements

* Use strToPtr

* RTPParameters

* RTPParameters

* RTPParameters: removed debug log and added todo

* setCodec support, only supported in chrome

* Datachannel config parsing to support firefox

* Removed debug log

* Removed debug logs

* Removed dual initializers (sourcetree bug?)

* Moved OnRemoveTrack

* Added guard for sender track

* Moved #!UNITY_WEBGL inside WebRTC.Sync

* Reducing the number of #if !UNITY_WEBL directives

* Using RTCOfferOptions object

* Added todo's

* Removed commented lines

* Removed comments lines in RTCStats

* Removed/optimized some #if webgl directives

* Added WebGLSample

* Default flip, so the correct image is transported over webrtc

* Updated local render method with flip

* Updated samples to allow webgl builds

* Some comments/codestyle changes

* Added getUserMedia TODO

* Reverted Android meta change

* fix test-case

* revert asmdef

* fixed compile error

* fix compile error

(cherry picked from commit 8eb9e4b)

* add webgl platform to CI test

(cherry picked from commit a478886)

* fix yaml

(cherry picked from commit 00939df785d1b5da64d7e3ab0795600e4f17d1a1)

* fix yaml

* fix

* fix bug

* fix yaml

* fix permission

* add job to test for webgl platform

* WIP test runner and jslib fixes
- Runs [Test] methods
- Parameterized tests are disabled [TestCase]
- Added webgl platform exclude to [UnityTest]
- VideoReceiver disabled
- AudioStream disabled
- (todo) NativeAPI
- Fixed several native method bugs

* wip NativeAPI test
enabled most test cases
needs json dll

* Passing DataChannelTest

* Fixed several tests
- Transceiver direction
- Ice candidate component (added todo/comments)
- MediaStreamAddTrack return value
- ContextCreate methods with labels
- Dummy TrackSource methods
- AudioTrack id (added custom guid field)
- MediaStream id (added custom guid field)
- Fixed NativeAPITest for WebGL MediaStream tracks length

* More test fixes - Replaced return with array  [errortype,object]
- AddTrack retursn both sender and errortype
- SetDescription returns errortype and message. TODO: make async/await to actually return the error(type)

* Fixed test cases
- Applied OptionalFields for PeerConnection config
- Fixed IceTransportPolicy enum
- Fixed Set Description of PeerConnection
- Enabled VideoReceiveTest (but are commented out)
- Added TODOs

* fix yaml for package test

* Add Preserve attribute for avoiding code stripping

* Fixed Transceiver SetCodecsPreferences

* Fixed incorrect assert in SenderGetParameter test

* Excluded failing tests + added todos

* Fixed SetLocalDescriptionWithoutDescription

* Added WebGL sample to build settings

* add edtitor version for auto-testing on CI

* Replaced Pointer_Stringify with UTF8ToString to support 2021.2

* fix: undefined `side` variable

* fix: undefined `err` variable

* fix: pass byt length to `DataChannelNativeOnMessage` callback

* ops...

Co-authored-by: Antoine Dezarnaud <dezartoine@hotmail.fr>
Co-authored-by: Antoine Dezarnaud <antoine.dezarnaud-ext@epicnpoc.com>
Co-authored-by: kazuki <karasusan@gmail.com>
Co-authored-by: Muka Schultze <samuelschultze@gmail.com>
Co-authored-by: gtk2k <gtk2k@yahoo.co.jp>
Thaina added a commit to Thaina/com.unity.webrtc that referenced this pull request Dec 17, 2023
* webgl initial plugin

* merge with @gtk2k prototype (part 1)

* Add newtonsoft json parser in package dependencies

* merge with @gtk2k prototype (part 2)

* webgl lib compile fixes

* WebGL build can be done

* bugfix : remove useless condition that brake linux compatibility

* Initial WebGL webrtc plugins

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Added OnTextMessage on RTCDataChannel
Renamed VideoStreamTrack

* Remove duplicate method RegisterRenderingWebRTCPlugin in WebTC.cs

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Signaling is not part of WebRTC specification

* Browser crash on DataChannel options using newtonsoft

* Added missing ContextUnRegisterMediaStreamObserver, not implemented yet

* Removed audio/video offer options

* Added missing ReceiverGetStreams, not implemented yet

* RTCIceCandidates on WebGL

* Moved RTCDataChannel onmessage listeren to OnDataChannel (receiver) from createDataChannel (sender)

* Added VideoTrack with MediaStream created by WebGL's getUserMedia. Requires the RTCPeerConnection to have a MediaStream to attach to.

* Fixed CreateAudioTrack

* Fixed adding getUserMedia stream tracks to unity MediaStream

* Enabled open/close/message on both creation and ondatachannel objects

* Negotiation workaround
Often the candidate message is handled earlier than the description (probably due coroutines when setting the description)
For now the icecandidate handling waits 1 second, which is sufficient. But a fix would be to store an ICECandidate queue on the peer connection and handle the queue when the description is set

* Workaround to parse datachannel options, jsonutility/newtonsoft have trouble with the Optional fields

* Samples: working DataChannels and PeerConnection
- Fixed MediaStream getTracks with deserializer
- Added adapter.js, should improve browser compatibility
- Using objects instead of 'this' in jslib for peer events

* Added TextMessage event handling for DataChannels sample

* Fix for UpdateRendererTexture 'no video' issue

* Temp to show video tracks created by peer.ontrack

* getTracks using WebRTC.Deserialize, prevents creation of existing tracks

* Using Deserializer for RTP objects

* Firefox requires a string, instead of int for credentialType

* Fixed optional fields serialization in RTCConfiguration

* Disabled context check. Context is already removed when disposing peer/data/media objects

* Improved UWManaged array. C# objects can be disposed but still accessed at a later stage

* Delete transceiver

* Fixed DeleteMediaStreamTrack parameters

* Registering stream for videotrack is not needed

* Removing video tracks from local/remote video list object on DeleteMediaStreamTrack

* Added RegisterMediaStreamObserver, not tested

* DataChannel options parsing done in jslib file

* Moved parsing of RTCConfiguration

* Updated webrtc.dll

* Wip: create audiotrack

* Corrected RTCConfiguration parsing with new optional fields using enums

* Fixed webcam stream from getUserMedia
Improved creation of HTMLMediaElements, local and remote tracks are created on AddTrack and ontrack respectively, which enables the receiver to play the received audio stream.
The local video track is currently only needed to display the local webcam stream, but is created for every videotrack (todo)

* Added a check for RTCDataChannels onclose/open. onclose is fired when already disposed in unity.

* Fixed icecandidate struct

* Missing import and removed peer label (for now)

* Fixed some enum values (including ice/peer connection state)

* RTCStats. Not fully checked for every enum/statstype. Note: Requires "jillejr.newtonsoft.json-for-unity"

* Don't show video elements

* Use strToPtr

* RTPParameters

* RTPParameters

* RTPParameters: removed debug log and added todo

* setCodec support, only supported in chrome

* Datachannel config parsing to support firefox

* Removed debug log

* Removed debug logs

* Removed dual initializers (sourcetree bug?)

* Moved OnRemoveTrack

* Added guard for sender track

* Moved #!UNITY_WEBGL inside WebRTC.Sync

* Reducing the number of #if !UNITY_WEBL directives

* Using RTCOfferOptions object

* Added todo's

* Removed commented lines

* Removed comments lines in RTCStats

* Removed/optimized some #if webgl directives

* Added WebGLSample

* Default flip, so the correct image is transported over webrtc

* Updated local render method with flip

* Updated samples to allow webgl builds

* Some comments/codestyle changes

* Added getUserMedia TODO

* Reverted Android meta change

* fix test-case

* revert asmdef

* fixed compile error

* fix compile error

(cherry picked from commit 8eb9e4b)

* add webgl platform to CI test

(cherry picked from commit a478886)

* fix yaml

(cherry picked from commit 00939df785d1b5da64d7e3ab0795600e4f17d1a1)

* fix yaml

* fix

* fix bug

* fix yaml

* fix permission

* add job to test for webgl platform

* WIP test runner and jslib fixes
- Runs [Test] methods
- Parameterized tests are disabled [TestCase]
- Added webgl platform exclude to [UnityTest]
- VideoReceiver disabled
- AudioStream disabled
- (todo) NativeAPI
- Fixed several native method bugs

* wip NativeAPI test
enabled most test cases
needs json dll

* Passing DataChannelTest

* Fixed several tests
- Transceiver direction
- Ice candidate component (added todo/comments)
- MediaStreamAddTrack return value
- ContextCreate methods with labels
- Dummy TrackSource methods
- AudioTrack id (added custom guid field)
- MediaStream id (added custom guid field)
- Fixed NativeAPITest for WebGL MediaStream tracks length

* More test fixes - Replaced return with array  [errortype,object]
- AddTrack retursn both sender and errortype
- SetDescription returns errortype and message. TODO: make async/await to actually return the error(type)

* Fixed test cases
- Applied OptionalFields for PeerConnection config
- Fixed IceTransportPolicy enum
- Fixed Set Description of PeerConnection
- Enabled VideoReceiveTest (but are commented out)
- Added TODOs

* fix yaml for package test

* Add Preserve attribute for avoiding code stripping

* Fixed Transceiver SetCodecsPreferences

* Fixed incorrect assert in SenderGetParameter test

* Excluded failing tests + added todos

* Fixed SetLocalDescriptionWithoutDescription

* Added WebGL sample to build settings

* add edtitor version for auto-testing on CI

* Replaced Pointer_Stringify with UTF8ToString to support 2021.2

* fix: undefined `side` variable

* fix: undefined `err` variable

* fix: pass byt length to `DataChannelNativeOnMessage` callback

* ops...

Co-authored-by: Antoine Dezarnaud <dezartoine@hotmail.fr>
Co-authored-by: Antoine Dezarnaud <antoine.dezarnaud-ext@epicnpoc.com>
Co-authored-by: kazuki <karasusan@gmail.com>
Co-authored-by: Muka Schultze <samuelschultze@gmail.com>
Co-authored-by: gtk2k <gtk2k@yahoo.co.jp>
Thaina added a commit to Thaina/com.unity.webrtc that referenced this pull request Dec 17, 2023
* webgl initial plugin

* merge with @gtk2k prototype (part 1)

* Add newtonsoft json parser in package dependencies

* merge with @gtk2k prototype (part 2)

* webgl lib compile fixes

* WebGL build can be done

* bugfix : remove useless condition that brake linux compatibility

* Initial WebGL webrtc plugins

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Added OnTextMessage on RTCDataChannel
Renamed VideoStreamTrack

* Remove duplicate method RegisterRenderingWebRTCPlugin in WebTC.cs

* Merge branch 'feature/webgl-support' of https://github.com/antoined73/com.unity.webrtc into antoined73-feature/webgl-support

* Signaling is not part of WebRTC specification

* Browser crash on DataChannel options using newtonsoft

* Added missing ContextUnRegisterMediaStreamObserver, not implemented yet

* Removed audio/video offer options

* Added missing ReceiverGetStreams, not implemented yet

* RTCIceCandidates on WebGL

* Moved RTCDataChannel onmessage listeren to OnDataChannel (receiver) from createDataChannel (sender)

* Added VideoTrack with MediaStream created by WebGL's getUserMedia. Requires the RTCPeerConnection to have a MediaStream to attach to.

* Fixed CreateAudioTrack

* Fixed adding getUserMedia stream tracks to unity MediaStream

* Enabled open/close/message on both creation and ondatachannel objects

* Negotiation workaround
Often the candidate message is handled earlier than the description (probably due coroutines when setting the description)
For now the icecandidate handling waits 1 second, which is sufficient. But a fix would be to store an ICECandidate queue on the peer connection and handle the queue when the description is set

* Workaround to parse datachannel options, jsonutility/newtonsoft have trouble with the Optional fields

* Samples: working DataChannels and PeerConnection
- Fixed MediaStream getTracks with deserializer
- Added adapter.js, should improve browser compatibility
- Using objects instead of 'this' in jslib for peer events

* Added TextMessage event handling for DataChannels sample

* Fix for UpdateRendererTexture 'no video' issue

* Temp to show video tracks created by peer.ontrack

* getTracks using WebRTC.Deserialize, prevents creation of existing tracks

* Using Deserializer for RTP objects

* Firefox requires a string, instead of int for credentialType

* Fixed optional fields serialization in RTCConfiguration

* Disabled context check. Context is already removed when disposing peer/data/media objects

* Improved UWManaged array. C# objects can be disposed but still accessed at a later stage

* Delete transceiver

* Fixed DeleteMediaStreamTrack parameters

* Registering stream for videotrack is not needed

* Removing video tracks from local/remote video list object on DeleteMediaStreamTrack

* Added RegisterMediaStreamObserver, not tested

* DataChannel options parsing done in jslib file

* Moved parsing of RTCConfiguration

* Updated webrtc.dll

* Wip: create audiotrack

* Corrected RTCConfiguration parsing with new optional fields using enums

* Fixed webcam stream from getUserMedia
Improved creation of HTMLMediaElements, local and remote tracks are created on AddTrack and ontrack respectively, which enables the receiver to play the received audio stream.
The local video track is currently only needed to display the local webcam stream, but is created for every videotrack (todo)

* Added a check for RTCDataChannels onclose/open. onclose is fired when already disposed in unity.

* Fixed icecandidate struct

* Missing import and removed peer label (for now)

* Fixed some enum values (including ice/peer connection state)

* RTCStats. Not fully checked for every enum/statstype. Note: Requires "jillejr.newtonsoft.json-for-unity"

* Don't show video elements

* Use strToPtr

* RTPParameters

* RTPParameters

* RTPParameters: removed debug log and added todo

* setCodec support, only supported in chrome

* Datachannel config parsing to support firefox

* Removed debug log

* Removed debug logs

* Removed dual initializers (sourcetree bug?)

* Moved OnRemoveTrack

* Added guard for sender track

* Moved #!UNITY_WEBGL inside WebRTC.Sync

* Reducing the number of #if !UNITY_WEBL directives

* Using RTCOfferOptions object

* Added todo's

* Removed commented lines

* Removed comments lines in RTCStats

* Removed/optimized some #if webgl directives

* Added WebGLSample

* Default flip, so the correct image is transported over webrtc

* Updated local render method with flip

* Updated samples to allow webgl builds

* Some comments/codestyle changes

* Added getUserMedia TODO

* Reverted Android meta change

* fix test-case

* revert asmdef

* fixed compile error

* fix compile error

(cherry picked from commit 8eb9e4b)

* add webgl platform to CI test

(cherry picked from commit a478886)

* fix yaml

(cherry picked from commit 00939df785d1b5da64d7e3ab0795600e4f17d1a1)

* fix yaml

* fix

* fix bug

* fix yaml

* fix permission

* add job to test for webgl platform

* WIP test runner and jslib fixes
- Runs [Test] methods
- Parameterized tests are disabled [TestCase]
- Added webgl platform exclude to [UnityTest]
- VideoReceiver disabled
- AudioStream disabled
- (todo) NativeAPI
- Fixed several native method bugs

* wip NativeAPI test
enabled most test cases
needs json dll

* Passing DataChannelTest

* Fixed several tests
- Transceiver direction
- Ice candidate component (added todo/comments)
- MediaStreamAddTrack return value
- ContextCreate methods with labels
- Dummy TrackSource methods
- AudioTrack id (added custom guid field)
- MediaStream id (added custom guid field)
- Fixed NativeAPITest for WebGL MediaStream tracks length

* More test fixes - Replaced return with array  [errortype,object]
- AddTrack retursn both sender and errortype
- SetDescription returns errortype and message. TODO: make async/await to actually return the error(type)

* Fixed test cases
- Applied OptionalFields for PeerConnection config
- Fixed IceTransportPolicy enum
- Fixed Set Description of PeerConnection
- Enabled VideoReceiveTest (but are commented out)
- Added TODOs

* fix yaml for package test

* Add Preserve attribute for avoiding code stripping

* Fixed Transceiver SetCodecsPreferences

* Fixed incorrect assert in SenderGetParameter test

* Excluded failing tests + added todos

* Fixed SetLocalDescriptionWithoutDescription

* Added WebGL sample to build settings

* add edtitor version for auto-testing on CI

* Replaced Pointer_Stringify with UTF8ToString to support 2021.2

* fix: undefined `side` variable

* fix: undefined `err` variable

* fix: pass byt length to `DataChannelNativeOnMessage` callback

* ops...

Co-authored-by: Antoine Dezarnaud <dezartoine@hotmail.fr>
Co-authored-by: Antoine Dezarnaud <antoine.dezarnaud-ext@epicnpoc.com>
Co-authored-by: kazuki <karasusan@gmail.com>
Co-authored-by: Muka Schultze <samuelschultze@gmail.com>
Co-authored-by: gtk2k <gtk2k@yahoo.co.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants