Hi,
send and sendDirect are used for live streams only. Send broadcasts the message directly to the clients that are playing the stream. SendDirect inserts the data into the incoming stream so that it is then used by any processes that work with the live stream before it goes out to the client. This includes recording, transcoder and the internal publishing api.
Because the vod stream doesn’t have a live stream source, send & sendDirect will be ignored.
You need to do something like the following to send a response directly to the player stream object. The first part is the recommended way to handle the stream name. It will automatically strip out the any prefix or query string so just the stream name is returned.
private String decodeStreamName(String streamName)
{
String streamExt = MediaStream.BASE_STREAM_EXT;
if (streamName != null)
{
String[] streamDecode = ModuleUtils.decodeStreamExtension(streamName, streamExt);
streamName = streamDecode[0];
streamExt = streamDecode[1];
boolean isStreamNameURL = streamName.indexOf("://") >= 0;
int streamQueryIdx = streamName.indexOf("?");
if (!isStreamNameURL && streamQueryIdx >= 0)
{
streamName = streamName.substring(0, streamQueryIdx);
}
}
return streamName;
}
_vodStreamName = decodeStreamName(_vodStreamName);
List<IMediaStream> playStreams = client.getAppInstance().getPlayStreamsByName(_vodStreamName);
AMFDataObj data = new AMFDataObj();
AMFDataArray parameters = new AMFDataArray();
parameters.add("param1");
parameters.add("param2");
data.put("testMetadata", parameters);
for(IMediaStream streamInstance:playStreams)
{
if(streamInstance != null)
{
ResponseFunction resp = new ResponseFunction(client, stream.getRespAMFDataObj());
resp.createDefaultMessage("onMetaData", 0.0);
resp.setSrc(stream.getSrc());
resp.addBody(parameters);
client.getRespFunctions().add(resp);
}
}
If the stream is not live or you want to send a message back to the publisher of the stream then you need to use a ResponseFunction. This will send the message directly to the stream client. By calling (stream.getSrc());, this indicates to the api that you want to send the message to the NetStream object on the client and not the NetConnection object.
See IClient.getRespFunctions() in the server api documentation for a complete example implementation.
Hope this helps.
Roger.