Hello guys,
I would like to share an issue with you, and hope to get some help figuring out what’s going on.
So, in the project i’m working on, we’re using transcoder and we’re choosing the transcoder template based on metadata sent by encoders. To read metadata i’m setting a client listener to IMediaStream object once a stream is created:
public void onStreamCreate(IMediaStream stream) {
stream.addClientListener(new MediaStreamActionNotify());
}
My MediaStreamActionNotify class is defined as follow
public class MediaStreamActionNotify implements IMediaStreamActionNotify2 {
...
@SuppressWarnings("unchecked")
public void onMetaData(IMediaStream stream, AMFPacket metaDataPacket) {
// get data sent by encoders.
byte[] data = metaDataPacket.getData();
AMFDataList metaDataList = new AMFDataList(data);
ArrayList dataList = (ArrayList) metaDataList.getValue();
for (int i = 0; i < dataList.size(); i++) {
Object amfData = dataList.get(i);
if (!(amfData instanceof AMFDataObj)) {
continue;
}
AMFDataObj obj = (AMFDataObj) amfData;
stream.getProperties().put("stream_width", obj.getInt("width"));
stream.getProperties().put("stream_height", obj.getInt("height"));
break;
}
}
...
}
So, onMetaData method is where i’m catching data sent by encoder, data like height is used to decide which template to use, this is handled in a TranscoderActionNotifier class
public class TranscoderActionNotifier extends
LiveStreamTranscoderActionNotifyBase {
...
@Override
public void onInitBeforeLoadTemplate(LiveStreamTranscoder lsTranscoder) {
IMediaStream stream = lsTranscoder.getStream();
int height = stream.getProperties().getPropertyInt("stream_height", 0);
...
}
...
}
By the way i’m using a web(flash-based) encoder, written in as3
private function netStreamStatusHandler(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetStream.Publish.Start":
stream.send("@setDataFrame", "onMetaData", broadcastInfo);
...
}
}
So my issue is that on wowza server side the onMetaData method from MediaStreamActionNotify class sometimes is invoked after the onInitBeforeLoadTemplate method from TranscoderActionNotifier class, so the height is not set on time and we choose a wrong template for transcoder, this only happen when i sent stream from my web encoder, using FMLE or wirecast works ok, my question is somebody has got something similar? or what can i do to garantee this always works as expected.