Is it possible to close direct streaming using XPMobileSDK?

Hello,

i’m trying to close direct streaming using XPMobileSDK.

Using

var params = {
                    ConnectionId : self.connectionId,
                    VideoId :camera.videoId,
                    ProcessingMessage : 'No'
                }
                XPMobileSDK.CloseStream(params);

I can only close transcoded streaming.

Is possibile to send to Mobile Server a command to close all (or specific for a camera) direct streaming?

Best regards

Marcello

Hi Marcello,

I can’t think of a good reason for CloseStream to work for Transcoded streams and not work for Direct ones.

I just tried the following code in Web client / Chrome console (Video ID is obtained from RequestStream’s response):

var params = {
 ConnectionId : self.connectionId, 
 VideoId :"fa07dfb6-0c74-4d29-abe6-4172c10483c1", 
 ProcessingMessage : 'No' 
} 
XPMobileSDK.CloseStream(params);

Stream was successfully closed.

Please double-check that your VideoId is correct and if issue persists, provide some more information - e.g. what is the server error you see when you try to close DS?

Hi Nikolay,

to get Direct Streamings i’m using something like SDK example:

function buildLiveStreamingElement(item, wrapper) {
		var videoElement = document.createElement('videos-stream');
		videoElement.cameraId = item.Id;
		videoElement.name = item.Name;
		wrapper.appendChild(videoElement);
		videoElement.dispatchEvent(new CustomEvent('start'));
		videoElement.addEventListener('fallback', function (event) {
			var player = event.target.shadow.lastElementChild.getElementsByClassName('player')[0];
			var errorMsg = document.createElement('div');
			errorMsg.innerHTML = "Could not start direct streaming.";
			player && player.parentNode.appendChild(errorMsg);
			player && player.parentNode.removeChild(player);
			errorMsg = null;
			player = null;
		});
	}

I’m debugging to find if this pattern use RequestStreamParams and watching the Call Stack i see that after this :

                player.dispatchEvent(new Event('start'));

VideoStream/main.js takes control and i can’t get videoId by response.

Is there any alternative to get this ID using this pattern to start Direct Streamings?

Thank you very much

Hi Marcello,

If you want to take the videoID you can subscribe for a method videoElement.addEventListener(‘playerStarted’, (event) => {}) where on event.detail you will receive the videoId and the cameraId

Please let me know if you have other questions.

Br

Asen Bozhilov

Hello Asen,

it worked and now I can use CloseStream.

But now, when I use CloseStream, VideoStream automatically restart a new stream for the Camera calling function restartStream.

How can i stop this?

I’m tryng to not overload Mobile Server and I have to close some streams.

Thank you very much

Hi Marcello,

I can not understand the main decision to stop the direct stream but if you dispatch destroy event for the videoElement like a “videoElement.dispatchEvent(new CustomEvent(‘destroy’));” You going to stop direct streaming, the effect is the same as calling for request CloseStream.

Please, let me know if you have other questions.