stopProducing method
Stops the underlying producing of a stream for a particular label NOTE: This will notify all the RemotePeers that this producer has stopped producing and they should stop consuming it.`
Implementation
void stopProducing({required String label}) {
_waitingToProduce.remove(label);
_pendingProducerTasks.remove(label);
bool closedStream = false;
final producer = getProducerWithLabel(label);
if (producer != null) {
logger.i(
'🔔 Closing Producer ',
error: {
'label': label,
'producerId': producer.id,
},
);
logger.i(
'🔔 Closing Producer | {label: $label, producerId: ${producer.id}}}',
);
producer.close();
producer.on('trackended', () {
logger.d('🔔 Track Ended For the Producer');
});
_producers.remove(producer.id);
closedStream = true;
socket.publish(Request_Request.closeProducer, {
'producerId': producer.id,
});
}
final closedStreamLabel = label;
final stream = _activeStreams[closedStreamLabel];
if (stream != null) {
deviceHandler.stopStream(stream);
_activeStreams.remove(closedStreamLabel);
closedStream = true;
}
if (closedStream) {
emit('stream-closed', {
'label': label,
'reason': {
'code': 1200,
'tag': 'STREAM_CLOSED',
'message': 'Stopped Streaming',
},
});
}
}