[mirotalksfu] - signaling producer pause/resume
هذا الالتزام موجود في:
@@ -1128,9 +1128,52 @@ function startServer() {
|
|||||||
room.closeProducer(socket.id, data.producer_id);
|
room.closeProducer(socket.id, data.producer_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('resume', async (_, callback) => {
|
socket.on('pauseProducer', async ({ producer_id }, callback) => {
|
||||||
await consumer.resume();
|
if (!roomList.has(socket.room_id)) return;
|
||||||
callback();
|
|
||||||
|
const room = roomList.get(socket.room_id);
|
||||||
|
|
||||||
|
const peer_name = getPeerName(room, false);
|
||||||
|
|
||||||
|
const producer = room.getPeers()?.get(socket.id)?.getProducer(producer_id);
|
||||||
|
|
||||||
|
if (!producer) {
|
||||||
|
return callback({ error: `producer with id "${producer_id}" not found` });
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug('Producer paused', { peer_name: peer_name, producer_id: producer_id });
|
||||||
|
|
||||||
|
try {
|
||||||
|
await producer.pause();
|
||||||
|
} catch (error) {
|
||||||
|
return callback({ error: error.message });
|
||||||
|
}
|
||||||
|
|
||||||
|
callback('successfully');
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('resumeProducer', async ({ producer_id }, callback) => {
|
||||||
|
if (!roomList.has(socket.room_id)) return;
|
||||||
|
|
||||||
|
const room = roomList.get(socket.room_id);
|
||||||
|
|
||||||
|
const peer_name = getPeerName(room, false);
|
||||||
|
|
||||||
|
const producer = room.getPeers()?.get(socket.id)?.getProducer(producer_id);
|
||||||
|
|
||||||
|
if (!producer) {
|
||||||
|
return callback({ error: `producer with id "${producer_id}" not found` });
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug('Producer resumed', { peer_name: peer_name, producer_id: producer_id });
|
||||||
|
|
||||||
|
try {
|
||||||
|
await producer.resume();
|
||||||
|
} catch (error) {
|
||||||
|
return callback({ error: error.message });
|
||||||
|
}
|
||||||
|
|
||||||
|
callback('successfully');
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('getProducers', () => {
|
socket.on('getProducers', () => {
|
||||||
|
|||||||
@@ -1676,7 +1676,7 @@ class RoomClient {
|
|||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
pauseProducer(type) {
|
async pauseProducer(type) {
|
||||||
if (!this.producerLabel.has(type)) {
|
if (!this.producerLabel.has(type)) {
|
||||||
return console.log('There is no producer for this type ' + type);
|
return console.log('There is no producer for this type ' + type);
|
||||||
}
|
}
|
||||||
@@ -1684,6 +1684,13 @@ class RoomClient {
|
|||||||
const producer_id = this.producerLabel.get(type);
|
const producer_id = this.producerLabel.get(type);
|
||||||
this.producers.get(producer_id).pause();
|
this.producers.get(producer_id).pause();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await this.socket.request('pauseProducer', { producer_id: producer_id });
|
||||||
|
console.log('Producer paused', response);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error pausing producer', error);
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case mediaType.audio:
|
case mediaType.audio:
|
||||||
this.event(_EVENTS.pauseAudio);
|
this.event(_EVENTS.pauseAudio);
|
||||||
@@ -1699,7 +1706,7 @@ class RoomClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resumeProducer(type) {
|
async resumeProducer(type) {
|
||||||
if (!this.producerLabel.has(type)) {
|
if (!this.producerLabel.has(type)) {
|
||||||
return console.log('There is no producer for this type ' + type);
|
return console.log('There is no producer for this type ' + type);
|
||||||
}
|
}
|
||||||
@@ -1707,6 +1714,13 @@ class RoomClient {
|
|||||||
const producer_id = this.producerLabel.get(type);
|
const producer_id = this.producerLabel.get(type);
|
||||||
this.producers.get(producer_id).resume();
|
this.producers.get(producer_id).resume();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await this.socket.request('resumeProducer', { producer_id: producer_id });
|
||||||
|
console.log('Producer resumed', response);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error resuming producer', error);
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case mediaType.audio:
|
case mediaType.audio:
|
||||||
this.event(_EVENTS.resumeAudio);
|
this.event(_EVENTS.resumeAudio);
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم