Coder Social home page Coder Social logo

Comments (7)

mkhahani avatar mkhahani commented on July 20, 2024

Hi
Put a console.error() in the catch block to see possible errors:

try {
stream = await getUserMedia(transport, isWebcam);
} catch (err) {
$txtPublish.innerHTML = 'failed';
}

from mediasoup-sample-app.

Yang03 avatar Yang03 commented on July 20, 2024

thanks your response
i have try add console.error

image

the console
image

from mediasoup-sample-app.

mkhahani avatar mkhahani commented on July 20, 2024

There must be an error on the server side. Run the following command before running the app to activate the log:

export DEBUG="mediasoup*"
npm start

from mediasoup-sample-app.

Yang03 avatar Yang03 commented on July 20, 2024

thanks
by debug, state === connected run before getUserMedia return stream
declare stream on top scope, is ok!
i don't know why ?

from mediasoup-sample-app.

mkhahani avatar mkhahani commented on July 20, 2024

by debug, state === connected run before getUserMedia

That's impossible. The state will change to connected just after a successful produce() that is called inside getUserMedia().

Could you check the server log against possible errors?

from mediasoup-sample-app.

applegrew avatar applegrew commented on July 20, 2024

by debug, state === connected run before getUserMedia

That's impossible. The state will change to connected just after a successful produce() that is called inside getUserMedia().

Could you check the server log against possible errors?

What you say is correct and that is the source of error. getUserMedia defines a local stream variable which it initialises. There before returning that stream it invokes

producer = await transport.produce(params);

which causes the code in

document.querySelector('#local_video').srcObject = stream;
to be executed. The stream variable in that closure is still undefined. After that code block is done, the control is back to producer = await transport.produce(params); and then getUserMediareturns thestream`.

To fix this I moved the codes https://github.com/mkhahani/mediasoup-sample-app/blob/master/client.js#L169...L181

const track = stream.getVideoTracks()[0];
const params = { track };
if ($chkSimulcast.checked) {
  params.encodings = [
    { maxBitrate: 100000 },
    { maxBitrate: 300000 },
    { maxBitrate: 900000 },
  ];
  params.codecOptions = {
    videoGoogleStartBitrate : 1000
  };
}
producer = await transport.produce(params);

below

stream = await getUserMedia(transport, isWebcam);

from mediasoup-sample-app.

mkhahani avatar mkhahani commented on July 20, 2024

@applegrew Thanks for your feedback. It's working for me. Is there possibility for race condition?

from mediasoup-sample-app.

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.