Giter Site home page Giter Site logo

Comments (11)

sepfy avatar sepfy commented on May 27, 2024

Do you connect with internet? Because the default STUN server is 18.191.223.12

from libpeer.

AleXoundOS avatar AleXoundOS commented on May 27, 2024

Yes.
I tracked down the problem and here is the workaround diff which makes example work (record.h264 gets saved):

--- a/examples/recording/index_html.h
+++ b/examples/recording/index_html.h
@@ -13,6 +13,7 @@ const char index_html[] = " \
   <body> \n \
     <video style='display:block; margin: 0 auto;' id='localVideo' autoplay muted></video> \n \
     <script> \n \
+      var counter=0; \n \
       function jsonRpc(payload, cb) { \n \
         var xhttp = new XMLHttpRequest(); \n \
         xhttp.onreadystatechange = function() { \n \
@@ -45,7 +46,14 @@ console.log(JSON.parse(atob(sdp))); \n\
         } \n \
       } \n \
       pc.onicecandidate = event => { \n \
-        if (event.candidate === null) { \n \
+        counter++; \n \
+        console.log(\"counter = \" + String(counter)); \n \
+        console.log(event); \n \
+        if (event.candidate === null || event.candidate.address.length > 15) { \n \
+          console.log(\"ignoring this event\") \n \
+        } \n \
+        else \n \
+        { \n \
           let sdp = pc.localDescription.sdp; \n \
           var payload = {\"jsonrpc\": \"2.0\", \"method\": \"call\", \"params\": btoa(sdp)}; \n \
           jsonRpc(payload, jsonRpcHandle); \n \

(counter is used only for debugging.)

from libpeer.

sepfy avatar sepfy commented on May 27, 2024

OK, Thanks!

from libpeer.

AleXoundOS avatar AleXoundOS commented on May 27, 2024

I have no experience with javascript and the workaround was found just empirically. It definitely needs a more correct approach.

from libpeer.

sepfy avatar sepfy commented on May 27, 2024

I see you ignoring the ice candidate which the length of address is larger than 15. I guess it is a mDNS address. I tried to remove it and transfer to a ipv4 address, but it still seems to have some problems. I will check that.

from libpeer.

AleXoundOS avatar AleXoundOS commented on May 27, 2024

I'm not only ignoring candidates which are not IPs basically, but since there is only one IP candidate, jsonRpc is called only once. Otherwise, setRemoteDescription was called 2 times what caused an error.
Without my changes jsonRpc was not called at all, because the condition for calling was event.candidate === null (now it's the opposite).

from libpeer.

AleXoundOS avatar AleXoundOS commented on May 27, 2024

I used chrome://webrtc-internals for debugging.

from libpeer.

sepfy avatar sepfy commented on May 27, 2024

According to the onicecanidate API, if the event's candidate property is null, ICE gathering has finished. It should be waited until all candidates are obtained, then send the offer. So you don't get event with null candidate property?

from libpeer.

AleXoundOS avatar AleXoundOS commented on May 27, 2024

So you don't get event with null candidate property?

It seems the browser does not get event with null candidate property. Log without workaround:

11/29/2021, 2:07:23 PM	transceiverAdded
11/29/2021, 2:07:23 PM	createOffer
11/29/2021, 2:07:23 PM	negotiationneeded
11/29/2021, 2:07:23 PM	createOfferOnSuccess (type: "offer", 2 sections)
11/29/2021, 2:07:23 PM	setLocalDescription (type: "offer", 2 sections)
11/29/2021, 2:07:23 PM	setLocalDescriptionOnSuccess
11/29/2021, 2:07:23 PM	signalingstatechange
11/29/2021, 2:07:23 PM	transceiverModified
11/29/2021, 2:07:23 PM	icegatheringstatechange
11/29/2021, 2:07:23 PM	icecandidate (host)
11/29/2021, 2:07:23 PM	icecandidate (srflx)

When workaround is in use the log continues further with setRemoteDescription (type: "answer", 2 sections).

from libpeer.

sepfy avatar sepfy commented on May 27, 2024

After getting null candidate, the browser should call jsonRpc function to send the offer to recording program. When recording program accepts the offer and response an answer, browser should be callback to jsonRpcHandle and setRemoteDescription.
I think the recording program doesn't response the answer, because mDNS parse failed or it need more time to resolve.

I created a branch to disable mDNS resolver. If possible, please try again. Thanks.

from libpeer.

sepfy avatar sepfy commented on May 27, 2024

This example is no longer supported

from libpeer.

Related Issues (20)

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.