-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Chrome screen sharing is streamed to SRS via WebRTC, but clients cannot play it using the WebRTC protocol, and playing it will cause SRS to crash. #2719
Comments
Does the crash have a stack trace? Also, what endpoint is used for streaming? I didn't see the SDP in the above logs.
|
|
@xiaozhihong, do you think this part in the log is the SDP information sent by the streaming client and the response from SRS?
|
Yes, you're right, I missed that haha. The stack trace is important. Let's see if we can print the stack trace.
|
@xiaozhihong If there are any other ways to obtain the stack information you mentioned, please let me know or provide a reference link. I will do my best to obtain it. Thank you.
|
@xiaozhihong
|
Crashes definitely need to be resolved. The server should not crash just because the client provides an input; this could be considered as a form of attack. 😄
|
@moliyadi
|
@luojq661 After reporting this bug last year, the new version of SRS has already fixed this crash issue. If you are unable to play, it may not be caused by this problem. You can check whether the sdp generated by the playback end createOffer contains unnecessary audio tracks. If the number or order of tracks in the requested sdp and the returned sdp do not match, it will also cause playback failure.
|
Streaming is done using Chrome, based on srs.sdk.js, by using
|
@linkewei0580 Roughly, the logic can be referred to as follows
|
Thank you!
林可伟
Sender: moliyadi
Sent: 2023-04-11 21:28
Recipient: ossrs/srs
CC: linkewei0580; Mention
Subject: Re: [ossrs/srs] Unable to play Chrome screen sharing via WebRTC to SRS, and playing causes SRS crash (Issue #2719)
@linkewei0580, you can refer to the following logic for configuration constraints.
self.screenConstraints = {
audio: false,
video: {
width: 1280,
height: 720,
frameRate: 30
}
};
// Create PeerConnection
self.prepareShareStream = async function (shareConstraints) {
if (self.pc === null) {
self.pc = new RTCPeerConnection(null);
}
var stream = await navigator.mediaDevices.getDisplayMedia(shareConstraints);
console.log('prepareShareStream:', stream, shareConstraints);
// @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addStream#Migrating_to_addTrack
stream.getTracks().forEach(function (track) {
console.log('prepareShareStream_track:', track);
self.pc.addTrack(track);
// Notify about local track when stream is ok.
self.ontrack && self.ontrack({
track: track
});
});
}
// Live streaming
self.publishStream = async function (url) {
var conf = self.__internal.prepareUrl(url);
if (self.pc === null) {
console.log("publishStream error: not prepare stream");
return "";
}
var offer = await self.pc.createOffer();
await self.pc.setLocalDescription(offer);
var session = await new Promise(function (resolve, reject) {
// @see https://github.com/rtcdn/rtcdn-draft
var data = {
api: conf.apiUrl,
tid: conf.tid,
streamurl: conf.streamUrl,
clientip: null,
sdp: offer.sdp
};
console.log("Generated offer: ", data);
axios({
method: "POST",
url: conf.apiUrl,
data: JSON.stringify(data),
contentType: 'application/json',
dataType: 'json'
}).then(function (response) {
var data = response.data;
console.log("Got answer: ", data);
if (data.code) {
reject(data);
return;
}
resolve(data);
}).catch(function (reason) {
reject(reason);
});
});
await self.pc.setRemoteDescription(
new RTCSessionDescription({
type: 'answer',
sdp: session.sdp
})
);
session.simulator = conf.schema + '//' + conf.urlObject.server + ':' + conf.port + '/rtc/v1/nack/';
return session;
}
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
`TRANS_BY_GPT3`
|
Description
getDisplayMedia
.constraints configuration:
Expected Behavior (Expect)
TRANS_BY_GPT3
The text was updated successfully, but these errors were encountered: