mirror of
https://github.com/koush/scrypted.git
synced 2026-03-02 09:12:08 +00:00
rebroadcast: fix bug where packet length was parsed as signed integer.
This commit is contained in:
@@ -109,7 +109,13 @@ export class RtspClient extends RtspBase {
|
||||
async request(method: string, headers?: Headers, path?: string, body?: Buffer) {
|
||||
headers = headers || {};
|
||||
|
||||
const line = `${method} ${this.url}${path || ''} RTSP/1.0`;
|
||||
let fullUrl: string;
|
||||
if (path)
|
||||
fullUrl = new URL(path, this.url).toString();
|
||||
else
|
||||
fullUrl = this.url;
|
||||
|
||||
const line = `${method} ${fullUrl} RTSP/1.0`;
|
||||
headers['CSeq'] = (this.cseq++).toString();
|
||||
this.write(line, headers, body);
|
||||
|
||||
|
||||
@@ -15,3 +15,22 @@ export function parsePayloadTypes(sdp: string) {
|
||||
videoPayloadTypes,
|
||||
}
|
||||
}
|
||||
|
||||
function getTrackId(track: string) {
|
||||
if (!track)
|
||||
return;
|
||||
const lines = track.split('\n').map(line => line.trim());
|
||||
const control = lines.find(line => line.startsWith('a=control:'));
|
||||
return control?.split('a=control:')?.[1];
|
||||
}
|
||||
|
||||
export function parseTrackIds(sdp: string) {
|
||||
const tracks = sdp.split('m=');
|
||||
|
||||
const audioTrack = tracks.find(track => track.startsWith('audio'));
|
||||
const videoTrack = tracks.find(track => track.startsWith('video'));
|
||||
return {
|
||||
audio: getTrackId(audioTrack),
|
||||
video: getTrackId(videoTrack),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user