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

**URL:** <https://community.wowza.com/t/a-variable-java-to-identify-the-streams-that-have-been-published-using-an-encoder/46885>\
**Category:** Wowza Streaming Engine\
**Created:** [April 22, 2016, 1:34pm UTC](https://community.wowza.com/t/a-variable-java-to-identify-the-streams-that-have-been-published-using-an-encoder/46885 "2016-04-22T13:34:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dracula\_Akumajou](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dracula\_Akumajou](https://community.wowza.com/u/Dracula_Akumajou)\
**Post date:** [April 22, 2016, 1:34pm UTC](https://community.wowza.com/t/a-variable-java-to-identify-the-streams-that-have-been-published-using-an-encoder/46885/1 "2016-04-22T13:34:11Z")

</div>

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

```auto
	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);
			}
		}
	}

```

---

<div class="post-metadata">

**Author:** ![Dracula\_Akumajou](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dracula\_Akumajou](https://community.wowza.com/u/Dracula_Akumajou)\
**Post date:** [April 24, 2016, 1:46pm UTC](https://community.wowza.com/t/a-variable-java-to-identify-the-streams-that-have-been-published-using-an-encoder/46885/2 "2016-04-24T13:46:11Z")

</div>

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”.
