Wowza Community

How to pass AMFDataByteArray from HTTPProvider to Module?

I have used the tutorials on HTTPProviders and Modules to send text based metadata into a module and insert it as timed ID3 metadata in an HLS stream. I used these tutorials:

https://www.wowza.com/docs/how-to-inject-timed-metadata-using-a-wowza-streaming-engine-http-provider

https://www.wowza.com/docs/how-to-convert-ontextdata-events-in-a-live-or-vod-stream-to-timed-events-id3-tags-in-an-apple-hls-stream

Now, I want to do the same thing but send an AMFDataByteArray from the HTTP Provider to the Module. In my HTTP Provider I have:

AMFDataByteArray amfDataBytes = AMFDataByteArray.wrap(data);
// this outputs a size of 90166!!
WMSLoggerFactory.getLogger(CLASS).info("sendBinaryMetadata amfDataBytes BEFORE SENDING SIZE - " + amfDataBytes.size());

AMFDataObj amfDataObj = new AMFDataObj();
amfDataObj.put("wowzaConverter", "basic_string");
amfDataObj.put("payload", amfDataBytes);

In the module I have:

AMFData amfDataItem = dataObj.get("payload");
getLogger().info("--> MODULE binary amfDataItem.toString " + amfDataItem.toString()  );
AMFDataByteArray amfBytes = (AMFDataByteArray)amfDataItem;

I get an error here that AMFDataItem cannot be cast to AMFDataByteArray. However, if you look at the logging line above that, the function “amfDataItem.toString()” outputs:

--> MODULE binary amfDataItem.toString {Obj[]: endian: "bigEndian", length: 90166.0, position: 90166.0, objectEncoding: 3.0}

That “length” of 90166 is the exact size the byte array I am sending, so the data MUST be here. How do I get it!?

This isn’t my area of expertise, but I asked one of our top engineers and he said:

“It’s not really the right way to use AMFDataByteArray. It is for sending data across an rtmp netConnection, not internally within the server. For that, he can just use a POJO.”

I would suggest sending in a support ticket so we can work directly with your configuration. Sorry I can’t be of more help.

What is it that you want to send ? Internal to the server everything is in jvm. So just create classes and do object exchange.

Simplest is to have static methods (although not the best practice) and have one module call the static method of another module or object and pass in the data in terms of java data types. Static methods are mostly useful when you know there is one instance of the class/module that you want to access the method on.

Thanks for the pointers. As suggested, I wound up creating a static method on the Module so I could set a variable with the byte[] data I want to send. Then, I trigger the actual ID3 insertion using the HTTPProvider to call “stream.sendDirect()”. This approach works!

1 Like