Compare commits
68 Commits
LAPI-675-g
...
950298c4f6
Author | SHA1 | Date | |
---|---|---|---|
950298c4f6 | |||
6e74083733 | |||
8ef6c2abb0 | |||
2a86042c80 | |||
56b8e2ea74 | |||
6c42814229 | |||
e65b7e0d7c | |||
aa7c2aea90 | |||
458342c0d2 | |||
fa5a1a5ae7 | |||
9fbe01ae1d | |||
e5bcc6262b | |||
c758a9106c | |||
fcbc28c801 | |||
ba63fb20bf | |||
e8bd6837cf | |||
d386915ff2 | |||
2479f58e21 | |||
d49b8e42ff | |||
a3ae874f8e | |||
c2dbef1918 | |||
b41b8f2d64 | |||
c089e91fba | |||
c63aee83a1 | |||
a97ec24148 | |||
3c23c6791d | |||
1a7b44807d | |||
daa2c556e4 | |||
22656722e8 | |||
f5b9067b7e | |||
0b3a45ae45 | |||
dfe4630839 | |||
d18041cadd | |||
fa42caeeb2 | |||
4dbb7ad554 | |||
d1063803b9 | |||
3cbd31b49c | |||
a39e0eaa17 | |||
b63fb39fd4 | |||
0dfbd296a7 | |||
233f49a998 | |||
127f17cd97 | |||
d1ad8b4d3a | |||
f20e1ad260 | |||
27151a26d1 | |||
544e9e59ab | |||
4e4cd6f893 | |||
e9ff060544 | |||
7d677f4a34 | |||
8f96b8c98b | |||
1084a808c7 | |||
3838f774bf | |||
06bb275f0d | |||
a05f7cc987 | |||
c5c8bc5bb3 | |||
d6bc4e51e5 | |||
4ae02f70d6 | |||
d593d6dc83 | |||
1a1fa9450e | |||
0d24604f2a | |||
1d7c994036 | |||
bc2bf24a65 | |||
cdbfc7891d | |||
c730341674 | |||
b621b76e37 | |||
39ad9cad27 | |||
8860423e21 | |||
9179a67f64 |
75
app.js
75
app.js
@ -90,21 +90,70 @@ worker = createWorker();
|
|||||||
// https://mediasoup.org/documentation/v3/mediasoup/rtp-parameters-and-capabilities/#RtpCodecCapability
|
// https://mediasoup.org/documentation/v3/mediasoup/rtp-parameters-and-capabilities/#RtpCodecCapability
|
||||||
// list of media codecs supported by mediasoup ...
|
// list of media codecs supported by mediasoup ...
|
||||||
// https://github.com/versatica/mediasoup/blob/v3/src/supportedRtpCapabilities.ts
|
// https://github.com/versatica/mediasoup/blob/v3/src/supportedRtpCapabilities.ts
|
||||||
const mediaCodecs = [
|
const mediaCodecs = [
|
||||||
{
|
{
|
||||||
kind: 'audio',
|
kind : 'audio',
|
||||||
mimeType: 'audio/opus',
|
mimeType : 'audio/opus',
|
||||||
clockRate: 48000,
|
clockRate : 48000,
|
||||||
channels: 2,
|
channels : 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: 'video',
|
kind : 'video',
|
||||||
mimeType: 'video/VP8',
|
mimeType : 'video/VP8',
|
||||||
clockRate: 90000,
|
clockRate : 90000,
|
||||||
parameters: {
|
parameters :
|
||||||
'x-google-start-bitrate': 1000,
|
{
|
||||||
},
|
'x-google-start-bitrate' : 1000
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
kind : 'video',
|
||||||
|
mimeType : 'video/VP9',
|
||||||
|
clockRate : 90000,
|
||||||
|
parameters :
|
||||||
|
{
|
||||||
|
'profile-id' : 2,
|
||||||
|
'x-google-start-bitrate' : 1000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
kind : 'video',
|
||||||
|
mimeType : 'video/h264',
|
||||||
|
clockRate : 90000,
|
||||||
|
parameters :
|
||||||
|
{
|
||||||
|
'packetization-mode' : 1,
|
||||||
|
'profile-level-id' : '4d0032',
|
||||||
|
'level-asymmetry-allowed' : 1,
|
||||||
|
'x-google-start-bitrate' : 1000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
kind : 'video',
|
||||||
|
mimeType : 'video/h264',
|
||||||
|
clockRate : 90000,
|
||||||
|
parameters :
|
||||||
|
{
|
||||||
|
'packetization-mode' : 1,
|
||||||
|
'profile-level-id' : '42e01f',
|
||||||
|
'level-asymmetry-allowed' : 1,
|
||||||
|
'x-google-start-bitrate' : 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// {
|
||||||
|
// kind: 'audio',
|
||||||
|
// mimeType: 'audio/opus',
|
||||||
|
// clockRate: 48000,
|
||||||
|
// channels: 2,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// kind: 'video',
|
||||||
|
// mimeType: 'video/VP8',
|
||||||
|
// clockRate: 90000,
|
||||||
|
// parameters: {
|
||||||
|
// 'x-google-start-bitrate': 1000,
|
||||||
|
// },
|
||||||
|
// },
|
||||||
];
|
];
|
||||||
|
|
||||||
const closeCall = (callId) => {
|
const closeCall = (callId) => {
|
||||||
@ -236,7 +285,9 @@ peers.on('connection', async socket => {
|
|||||||
const callId = socketDetails[socket.id];
|
const callId = socketDetails[socket.id];
|
||||||
if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters);
|
if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters);
|
||||||
|
|
||||||
console.log('[transport-produce] | socket.id', socket.id, '| callId', callId);
|
console.log(`[transport-produce] kind: ${kind} | socket.id: ${socket.id} | callId: ${callId}`);
|
||||||
|
console.log('kind', kind);
|
||||||
|
console.log('rtpParameters', rtpParameters);
|
||||||
videoCalls[callId].producer = await videoCalls[callId].producerTransport.produce({
|
videoCalls[callId].producer = await videoCalls[callId].producerTransport.produce({
|
||||||
kind,
|
kind,
|
||||||
rtpParameters,
|
rtpParameters,
|
||||||
|
1365
public/bundle.js
1365
public/bundle.js
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,4 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
hubAddress: 'https://hub.dev.linx.safemobile.com/',
|
hubAddress: 'https://hub.dev.linx.safemobile.com/',
|
||||||
mediasoupAddress: 'https://video.safemobile.org/mediasoup',
|
mediasoupAddress: 'https://video.safemobile.org',
|
||||||
// mediasoupAddress: 'http://localhost:3000/mediasoup',
|
|
||||||
}
|
}
|
@ -43,7 +43,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<div id="sharedBtns">
|
<div id="sharedBtns">
|
||||||
<video id="localVideo" autoplay class="video" ></video>
|
<video id="localVideo" autoplay class="video" muted></video>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
293
public/index.js
293
public/index.js
@ -12,141 +12,191 @@ let callId = parseInt(urlParams.get('callId')) || null;
|
|||||||
const IS_PRODUCER = urlParams.get('producer') === 'true' ? true : false
|
const IS_PRODUCER = urlParams.get('producer') === 'true' ? true : false
|
||||||
console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', callId, ' | IS_PRODUCER', IS_PRODUCER)
|
console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', callId, ' | IS_PRODUCER', IS_PRODUCER)
|
||||||
|
|
||||||
let socket
|
console.log('🟩 config', config)
|
||||||
hub = io(config.hubAddress)
|
|
||||||
|
|
||||||
const connectToMediasoup = () => {
|
let socket, hub
|
||||||
|
|
||||||
socket = io(config.mediasoupAddress, {
|
setTimeout(() => {
|
||||||
reconnection: true,
|
hub = io(config.hubAddress)
|
||||||
reconnectionDelay: 1000,
|
|
||||||
reconnectionDelayMax : 5000,
|
|
||||||
reconnectionAttempts: Infinity
|
|
||||||
})
|
|
||||||
|
|
||||||
socket.on('connection-success', ({ _socketId, existsProducer }) => {
|
|
||||||
console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`)
|
|
||||||
if (!IS_PRODUCER && existsProducer && consumer === undefined) {
|
|
||||||
goConnect()
|
|
||||||
// document.getElementById('btnRecvSendTransport').click();
|
|
||||||
}
|
|
||||||
if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IS_PRODUCER === true) {
|
|
||||||
hub.on('connect', async () => {
|
|
||||||
console.log(`[HUB] ${config.hubAddress} | connected: ${hub.connected}`)
|
|
||||||
connectToMediasoup()
|
|
||||||
|
|
||||||
hub.emit(
|
|
||||||
'ars',
|
|
||||||
JSON.stringify({
|
|
||||||
ars: true,
|
|
||||||
asset_id: ASSET_ID,
|
|
||||||
account_id: ACCOUNT_ID,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
hub.on('video', (data) => {
|
const connectToMediasoup = () => {
|
||||||
const parsedData = JSON.parse(data);
|
|
||||||
|
|
||||||
if (parsedData.type === 'notify-request') {
|
|
||||||
console.log('video', parsedData)
|
|
||||||
originAssetId = parsedData.origin_asset_id;
|
|
||||||
// originAssetName = parsedData.origin_asset_name;
|
|
||||||
// originAssetTypeName = parsedData.origin_asset_type_name;
|
|
||||||
callId = parsedData.video_call_id;
|
|
||||||
|
|
||||||
console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId);
|
socket = io(config.mediasoupAddress, {
|
||||||
getLocalStream()
|
reconnection: true,
|
||||||
}
|
reconnectionDelay: 1000,
|
||||||
|
reconnectionDelayMax : 5000,
|
||||||
if (parsedData.type === 'notify-end') {
|
reconnectionAttempts: Infinity
|
||||||
console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId);
|
|
||||||
resetCallSettings()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
socket.on('connection-success', ({ _socketId, existsProducer }) => {
|
||||||
|
console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`)
|
||||||
|
if (!IS_PRODUCER && existsProducer && consumer === undefined) {
|
||||||
|
goConnect()
|
||||||
|
// document.getElementById('btnRecvSendTransport').click();
|
||||||
|
}
|
||||||
|
if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_PRODUCER === true) {
|
||||||
|
hub.on('connect', async () => {
|
||||||
|
console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`)
|
||||||
|
connectToMediasoup()
|
||||||
|
|
||||||
|
hub.emit(
|
||||||
|
'ars',
|
||||||
|
JSON.stringify({
|
||||||
|
ars: true,
|
||||||
|
asset_id: ASSET_ID,
|
||||||
|
account_id: ACCOUNT_ID,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
hub.on('video', (data) => {
|
||||||
|
const parsedData = JSON.parse(data);
|
||||||
|
|
||||||
|
if (parsedData.type === 'notify-request') {
|
||||||
|
console.log('video', parsedData)
|
||||||
|
originAssetId = parsedData.origin_asset_id;
|
||||||
|
// originAssetName = parsedData.origin_asset_name;
|
||||||
|
// originAssetTypeName = parsedData.origin_asset_type_name;
|
||||||
|
callId = parsedData.video_call_id;
|
||||||
|
|
||||||
|
console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId);
|
||||||
|
getLocalStream()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parsedData.type === 'notify-end') {
|
||||||
|
console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId);
|
||||||
|
resetCallSettings()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
hub.on('connect_error', (error) => {
|
||||||
|
console.log('connect_error', error);
|
||||||
|
});
|
||||||
|
|
||||||
|
hub.on('connection', () => {
|
||||||
|
console.log('connection')
|
||||||
|
})
|
||||||
|
|
||||||
|
hub.on('disconnect', () => {
|
||||||
|
console.log('disconnect')
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
connectToMediasoup()
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 1600);
|
||||||
|
|
||||||
hub.on('connect_error', (error) => {
|
|
||||||
console.log('connect_error', error);
|
|
||||||
});
|
|
||||||
|
|
||||||
hub.on('connection', () => {
|
|
||||||
console.log('connection')
|
|
||||||
})
|
|
||||||
|
|
||||||
hub.on('disconnect', () => {
|
|
||||||
console.log('disconnect')
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
connectToMediasoup()
|
|
||||||
}
|
|
||||||
|
|
||||||
let device
|
let device
|
||||||
let rtpCapabilities
|
let rtpCapabilities
|
||||||
let producerTransport
|
let producerTransport
|
||||||
let consumerTransport
|
let consumerTransport
|
||||||
let producer
|
let producerVideo
|
||||||
|
let producerAudio
|
||||||
let consumer
|
let consumer
|
||||||
let originAssetId
|
let originAssetId
|
||||||
// let originAssetName = 'Adi'
|
|
||||||
// let originAssetTypeName = 'linx'
|
|
||||||
|
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions
|
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
||||||
let params = {
|
let videoParams = {
|
||||||
// mediasoup params
|
|
||||||
encodings: [
|
encodings: [
|
||||||
{
|
{ scaleResolutionDownBy: 4, maxBitrate: 500000 },
|
||||||
rid: 'r0',
|
{ scaleResolutionDownBy: 2, maxBitrate: 1000000 },
|
||||||
maxBitrate: 100000,
|
{ scaleResolutionDownBy: 1, maxBitrate: 5000000 },
|
||||||
scalabilityMode: 'S1T3',
|
{ scalabilityMode: 'S3T3_KEY' }
|
||||||
},
|
|
||||||
{
|
|
||||||
rid: 'r1',
|
|
||||||
maxBitrate: 300000,
|
|
||||||
scalabilityMode: 'S1T3',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
rid: 'r2',
|
|
||||||
maxBitrate: 900000,
|
|
||||||
scalabilityMode: 'S1T3',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions
|
|
||||||
codecOptions: {
|
codecOptions: {
|
||||||
videoGoogleStartBitrate: 1000
|
videoGoogleStartBitrate: 1000
|
||||||
}
|
}
|
||||||
|
// encodings: [
|
||||||
|
// {
|
||||||
|
// rid: 'r0',
|
||||||
|
// maxBitrate: 100000,
|
||||||
|
// scalabilityMode: 'S1T3',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// rid: 'r1',
|
||||||
|
// maxBitrate: 300000,
|
||||||
|
// scalabilityMode: 'S1T3',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// rid: 'r2',
|
||||||
|
// maxBitrate: 900000,
|
||||||
|
// scalabilityMode: 'S1T3',
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions
|
||||||
|
// codecOptions: {
|
||||||
|
// videoGoogleStartBitrate: 1000
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
let audioParams = {
|
||||||
|
codecOptions :
|
||||||
|
{
|
||||||
|
opusStereo : true,
|
||||||
|
opusDtx : true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const streamSuccess = (stream) => {
|
const streamSuccess = (stream) => {
|
||||||
console.log('[streamSuccess]');
|
console.log('[streamSuccess] device', device);
|
||||||
localVideo.srcObject = stream
|
localVideo.srcObject = stream
|
||||||
const track = stream.getVideoTracks()[0]
|
console.log('stream', stream);
|
||||||
params = {
|
const videoTrack = stream.getVideoTracks()[0]
|
||||||
track,
|
const audioTrack = stream.getAudioTracks()[0]
|
||||||
...params
|
|
||||||
|
videoParams = {
|
||||||
|
track: videoTrack,
|
||||||
|
// codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'),
|
||||||
|
// codec : 'video/vp9',
|
||||||
|
...videoParams
|
||||||
}
|
}
|
||||||
|
|
||||||
|
audioParams = {
|
||||||
|
track: audioTrack,
|
||||||
|
...audioParams
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams);
|
||||||
goConnect()
|
goConnect()
|
||||||
|
// console.log('[streamSuccess]');
|
||||||
|
// localVideo.srcObject = stream
|
||||||
|
// const track = stream.getVideoTracks()[0]
|
||||||
|
// videoParams = {
|
||||||
|
// track,
|
||||||
|
// ...videoParams
|
||||||
|
// }
|
||||||
|
// goConnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
const getLocalStream = () => {
|
const getLocalStream = () => {
|
||||||
console.log('[getLocalStream]');
|
console.log('[getLocalStream]');
|
||||||
navigator.mediaDevices.getUserMedia({
|
navigator.mediaDevices.getUserMedia({
|
||||||
audio: false,
|
audio: true,
|
||||||
video: {
|
video: {
|
||||||
width: {
|
qvga : { width: { ideal: 320 }, height: { ideal: 240 } },
|
||||||
min: 640,
|
vga : { width: { ideal: 640 }, height: { ideal: 480 } },
|
||||||
max: 1920,
|
hd : { width: { ideal: 1280 }, height: { ideal: 720 } }
|
||||||
},
|
|
||||||
height: {
|
|
||||||
min: 400,
|
|
||||||
max: 1080,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// navigator.mediaDevices.getUserMedia({
|
||||||
|
// audio: false,
|
||||||
|
// video: {
|
||||||
|
// width: {
|
||||||
|
// min: 640,
|
||||||
|
// max: 1920,
|
||||||
|
// },
|
||||||
|
// height: {
|
||||||
|
// min: 400,
|
||||||
|
// max: 1080,
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
.then(streamSuccess)
|
.then(streamSuccess)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log(error.message)
|
console.log(error.message)
|
||||||
@ -167,7 +217,7 @@ const goCreateTransport = () => {
|
|||||||
// server side to send/recive media
|
// server side to send/recive media
|
||||||
const createDevice = async () => {
|
const createDevice = async () => {
|
||||||
try {
|
try {
|
||||||
console.log('[createDevice]');
|
console.log('[createDevice] 1 device', device);
|
||||||
device = new mediasoupClient.Device()
|
device = new mediasoupClient.Device()
|
||||||
|
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load
|
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load
|
||||||
@ -178,7 +228,8 @@ const createDevice = async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
console.log('Device RTP Capabilities', device.rtpCapabilities)
|
console.log('Device RTP Capabilities', device.rtpCapabilities)
|
||||||
|
console.log('[createDevice] 2 device', device);
|
||||||
|
|
||||||
// once the device loads, create transport
|
// once the device loads, create transport
|
||||||
goCreateTransport()
|
goCreateTransport()
|
||||||
|
|
||||||
@ -207,6 +258,7 @@ const getRtpCapabilities = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const createSendTransport = () => {
|
const createSendTransport = () => {
|
||||||
|
console.log('[createSendTransport');
|
||||||
// see server's socket.on('createWebRtcTransport', sender?, ...)
|
// see server's socket.on('createWebRtcTransport', sender?, ...)
|
||||||
// this is a call from Producer, so sender = true
|
// this is a call from Producer, so sender = true
|
||||||
socket.emit('createWebRtcTransport', { sender: true, callId }, ({ params }) => {
|
socket.emit('createWebRtcTransport', { sender: true, callId }, ({ params }) => {
|
||||||
@ -217,7 +269,7 @@ const createSendTransport = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(params)
|
console.log('[createWebRtcTransport] params', params)
|
||||||
|
|
||||||
// creates a new WebRTC Transport to send media
|
// creates a new WebRTC Transport to send media
|
||||||
// based on the server's producer transport params
|
// based on the server's producer transport params
|
||||||
@ -244,7 +296,7 @@ const createSendTransport = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
producerTransport.on('produce', async (parameters, callback, errback) => {
|
producerTransport.on('produce', async (parameters, callback, errback) => {
|
||||||
console.log(parameters)
|
console.log('[produce] parameters', parameters)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// tell the server to create a Producer
|
// tell the server to create a Producer
|
||||||
@ -270,22 +322,44 @@ const createSendTransport = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const connectSendTransport = async () => {
|
const connectSendTransport = async () => {
|
||||||
|
|
||||||
|
console.log('[connectSendTransport] producerTransport');
|
||||||
|
|
||||||
// we now call produce() to instruct the producer transport
|
// we now call produce() to instruct the producer transport
|
||||||
// to send media to the Router
|
// to send media to the Router
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
||||||
// this action will trigger the 'connect' and 'produce' events above
|
// this action will trigger the 'connect' and 'produce' events above
|
||||||
producer = await producerTransport.produce(params)
|
|
||||||
|
|
||||||
producer.on('trackended', () => {
|
producerVideo = await producerTransport.produce(videoParams)
|
||||||
|
console.log('producerVideo', producerVideo);
|
||||||
|
producerVideo.on('trackended', () => {
|
||||||
console.log('track ended')
|
console.log('track ended')
|
||||||
// close video track
|
// close video track
|
||||||
})
|
})
|
||||||
|
|
||||||
producer.on('transportclose', () => {
|
producerVideo.on('transportclose', () => {
|
||||||
console.log('transport ended')
|
console.log('transport ended')
|
||||||
// close video track
|
// close video track
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
producerAudio = await producerTransport.produce(audioParams)
|
||||||
|
console.log('producerAudio', producerAudio);
|
||||||
|
producerAudio.on('trackended', () => {
|
||||||
|
console.log('track ended')
|
||||||
|
// close video track
|
||||||
|
})
|
||||||
|
|
||||||
|
producerAudio.on('transportclose', () => {
|
||||||
|
console.log('transport ended')
|
||||||
|
// close video track
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const answer = {
|
const answer = {
|
||||||
origin_asset_id: ASSET_ID,
|
origin_asset_id: ASSET_ID,
|
||||||
dest_asset_id: originAssetId || parseInt(urlParams.get('dest_asset_id')),
|
dest_asset_id: originAssetId || parseInt(urlParams.get('dest_asset_id')),
|
||||||
@ -320,7 +394,7 @@ const createRecvTransport = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(params)
|
console.log('[createRecvTransport] params', params)
|
||||||
|
|
||||||
// creates a new WebRTC Transport to receive media
|
// creates a new WebRTC Transport to receive media
|
||||||
// based on server's consumer transport params
|
// based on server's consumer transport params
|
||||||
@ -353,7 +427,8 @@ const resetCallSettings = () => {
|
|||||||
localVideo.srcObject = null
|
localVideo.srcObject = null
|
||||||
remoteVideo.srcObject = null
|
remoteVideo.srcObject = null
|
||||||
consumer = null
|
consumer = null
|
||||||
producer = null
|
producerVideo = null
|
||||||
|
producerAudio = null
|
||||||
producerTransport = null
|
producerTransport = null
|
||||||
consumerTransport = null
|
consumerTransport = null
|
||||||
device = undefined
|
device = undefined
|
||||||
|
Reference in New Issue
Block a user