Wowza Community

a variable (Java) to identify the streams that have been published using an encoder

Hello,

I want to add a stream listener only to the main streams that have been published using an encoder like FMLE not through smil or transcoder.

I think that creating a listener on every onStreamCreate (clients who play| clients who publish) is not practical. And it will create a load on the CPU & the memory.

I have found a way to get it working. I am not sure whether it is the best way. At least it works

	public void onStreamCreate(IMediaStream stream) {
		String UniqueStreamIdStr = stream.getUniqueStreamIdStr();
		if (UniqueStreamIdStr.contains("_")) {
			getLogger().info("onStreamCreate:.................................................... " +  UniqueStreamIdStr);
			IMediaStreamActionNotify3 actionNotify = new StreamListener(this.vhost, this.appInstance);
			WMSProperties props = stream.getProperties();
			synchronized (props) {
				props.put("streamActionNotifier", actionNotify);
			}
			stream.addClientListener(actionNotify);
		}
	}
	public void onStreamDestroy(IMediaStream stream) {
		String UniqueStreamIdStr = stream.getUniqueStreamIdStr();
		if (UniqueStreamIdStr.contains("_")) {
			getLogger().info("onStreamDestroy:.................................................... " +  UniqueStreamIdStr);
			IMediaStreamActionNotify3 actionNotify = null;
			WMSProperties props = stream.getProperties();
			synchronized (props) {
				actionNotify = (IMediaStreamActionNotify3) stream.getProperties().get("streamActionNotifier");
			}
			if (actionNotify != null) {
				stream.removeClientListener(actionNotify);
			}
		}
	}

I have found that this will not going to work when using a mobile application for streaming. It’s only tested with FMLE.

I have tried streaming rtsp through mobile app but it doesn’t give UniqueStreamIdStr. It is giving me “1” instead of “54587897_1”.