Closed youfeed closed 6 months ago
Add a New Track : Adds a media track (audio or video) to an existing session.
POST /apps/{appId}/sessions/{sessionId}/tracks/new
send let sessionId = "dba9fdd166de19f45f7af02242e8b5b8" let params = { "sessionDescription":{ "type":"offer", "sdp":"v=0\r\no=- 615243220580619098 3 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na......" }, "tracks":[ {"location":"local","mid":"1","trackName":"bd1e5427-88f4-482a-8cc0-2bc4ef836f09"}, {"location":"local","mid":"2","trackName":"56ab258d-cb53-4e66-b73d-488c6948efb1"} ] } use function
send
let sessionId = "dba9fdd166de19f45f7af02242e8b5b8" let params = { "sessionDescription":{ "type":"offer", "sdp":"v=0\r\no=- 615243220580619098 3 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na......" }, "tracks":[ {"location":"local","mid":"1","trackName":"bd1e5427-88f4-482a-8cc0-2bc4ef836f09"}, {"location":"local","mid":"2","trackName":"56ab258d-cb53-4e66-b73d-488c6948efb1"} ] }
use function
v1/apps/${appId}/sessions/${sessionId}/tracks/new
function rtcFetch(router,params=false,method='GET'){ return new Promise((resolve,reject)=>{ const options = { json:true, method: method, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization':`Bearer ${appSecret}` } }; const req = https.request(`https://rtc.live.cloudflare.com/${router}`,options,res=>{ var data = ''; res.on('data', (chuck) => { data += chuck; }); res.on('end', () => { try { resolve(JSON.parse(data)) } catch (error) { resolve(data) } }); }); req.on('error', (error) => { reject(error) }); console.log(router,params) params && req.write(JSON.stringify(params)); req.end(); }) }
return { "errorCode": "decoding_error", "errorDescription": "Failed to decode body as JSON", } nodejs Send https.request the SDP Are there any special characters?
return
{ "errorCode": "decoding_error", "errorDescription": "Failed to decode body as JSON", }
nodejs Send https.request the SDP Are there any special characters?
params.tracks[].location === local
Add a New Track : Adds a media track (audio or video) to an existing session.
POST /apps/{appId}/sessions/{sessionId}/tracks/new
rtcFetch(
v1/apps/${appId}/sessions/${sessionId}/tracks/new
,params,"POST")