# Creating a MediaListRendition from a stream name?

**URL:** <https://community.wowza.com/t/creating-a-medialistrendition-from-a-stream-name/34080>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [April 21, 2014, 10:43pm UTC](https://community.wowza.com/t/creating-a-medialistrendition-from-a-stream-name/34080 "2014-04-21T22:43:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steffen\_Christensen](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@Steffen\_Christensen](https://community.wowza.com/u/Steffen_Christensen)\
**Post date:** [April 21, 2014, 10:43pm UTC](https://community.wowza.com/t/creating-a-medialistrendition-from-a-stream-name/34080/1 "2014-04-21T22:43:52Z")

</div>

Hey guys,

Some background: I’m building a module designed to automatically create grouped manifest/playlist files for multiple streams. This is very similar to what _ngrp:_ does for grouped streams in the transcoder – but I have specific requirements where I need other streams grouped as well. My approach has been to create an _IMediaListProvider_ module to return the manifest/playlist from a set of renditions within the _amlst:_ namespace.

The question: Given only the name of a live stream, how can I build a rendition object complete with width, height, bitrates and codecs?

The simple way to illustrate the question is in code: What would I write in _resolveMediaListRendition()_?

_package com.wowza.wms.plugin.testing;_

_import com.wowza.wms.medialist.\*;_

_import com.wowza.wms.util.\*;_

_import com.wowza.wms.module.\*;_

_import com.wowza.wms.stream.\*;_

_import com.wowza.wms.application.\*;_

_import java.util.\*;_

_public class ModuleTestingStreamList extends ModuleBase implements IMediaListProvider {_

_private IApplicationInstance appInstance = null;_

_public MediaListRendition resolveMediaListRendition(String streamName) {_

_// … do stuff to create a MediaListRendition streamRendition from the streamName_

_…_

_…_

_return streamRendition;_

_}_

_public MediaList resolveMediaList(IMediaListReader mediaListReader, IMediaStream stream, String streamName) {_

_MediaList mediaList = new MediaList();_

_MediaListSegment segment = new MediaListSegment();_

_mediaList.addSegment(segment);_

_List streams = this.appInstance.getStreams().getPublishStreamNames();_

_Iterator streamsIterator = streams.iterator();_

_while (streamsIterator.hasNext()) {_

_String renditionStreamName = streamsIterator.next();_

_segment.addRendition(resolveMediaListRendition(renditionStreamName));_

_}_

_return mediaList;_

_}_

_public void onAppStart(IApplicationInstance appInstance) {_

_this.appInstance = appInstance;_

_this.appInstance.setMediaListProvider(this);_

_}_

_}_

Thanks,

Steffen

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [April 23, 2014, 2:57pm UTC](https://community.wowza.com/t/creating-a-medialistrendition-from-a-stream-name/34080/2 "2014-04-23T14:57:40Z")

</div>

Hi Steffen,

Have you seen [the AMLST example](https://www.wowza.com/docs/how-to-use-java-api-calls-to-resolve-smil-file-requests)?

The streams you reference have to exist. You probably need some naming scheme to iterate over the renditions starting with a base stream name.

You can get frame size and codec info from [IMediaStreamActionNotify3onCodecInfoVideo() and IMediaStreamActionNotify3onCodecInfoAudio(), and IMediaStreamActionNotify3onMetaData()](https://www.wowza.com/docs/how-to-use-imediastreamactionnotify3-interface-to-listen-for-rtmp-stream-events-includes-codec-info%28includes-codec-info%29), the

With that in place, you can store info in the stream then retrieve it in the IMediaListProvider using WMSProperties.

```auto
public void onCodecInfoVideo(IMediaStream stream,
				MediaCodecInfoVideo codecInfoVideo) {
				stream.getProperties().setProperty("videocodec", codecInfoVideo.toCodecsStr());
		
		}

```

Then you can get that in IMediaListProvider:

```auto
while (streamsIterator.hasNext())
		{
			IMediaStream _stream = this.appInstance().getStreams().getStream(streamsIterator.next());
			String videocodec = _stream.getProperties().getPropertyStr("videocodec");

```

You could use the naming convention for bitrate. In your encoder or with Wowza Transcoder, name each rendition according to the bitrate of the stream: myStream\_360p

Richard

---

<div class="post-metadata">

**Author:** ![Steffen\_Christensen](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@Steffen\_Christensen](https://community.wowza.com/u/Steffen_Christensen)\
**Post date:** [April 23, 2014, 4:41pm UTC](https://community.wowza.com/t/creating-a-medialistrendition-from-a-stream-name/34080/3 "2014-04-23T16:41:33Z")

</div>

Thanks Richard – that’s actually extremely close to where I ended up myself: Naming schemes to iterate over relevant streams; bit rate in stream names; listening directly to events about meta data.

My initial assumption was that I’d be able to get away with less heavy lifting in detecting codecs and formats since my code overlaps with what’s already being done for the streams already.

Having said that though, it turned out to be pretty easy to build.

Thanks for all the help,

Steffen
