here is my java code for wowza server project .
package com.wowza.example.module;
import com.wowza.wms.amf.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;
import com.wowza.wms.stream.*;
public class ModuleInjectData1 extends ModuleBase {
public void setTag (IClient client, RequestFunction function, AMFDataList params)
{
String streamname = params.getString(PARAM1);
String caption = params.getString(PARAM2);
System.out.println("StreamName:: " +streamname);
System.out.println("Caption :: " +caption);
IMediaStream stream = client.getAppInstance().getStreams().getStream(streamname);
System.out.println("Stream :: " +streamname.toString()) ;
AMFDataList amfList = new AMFDataList();
AMFDataMixedArray data = new AMFDataMixedArray();
data.put(“caption”, new AMFDataItem(caption));
amfList.add(new AMFDataItem(“setCaption”));
amfList.add(data);
String streamtype = stream.getClient().getAppInstance().getStreamType();
System.out.println("Stream Type :: " + streamtype);
if (streamtype.equals(“live”))
{
stream.send(“setCaption”, caption); // this works on the live stream.
stream.sendDirect(“setCaption”, caption);
System.out.println("Live Record Caption :: " + caption);
}
byte[] dataData = amfList.serialize();
int size = dataData.length;
synchronized(stream)
{
long timecode = Math.max(stream.getAudioTC(), stream.getVideoTC());
System.out.println("timecode :: " + timecode);
stream.setDataTC(timecode);
stream.setDataSize(size);
stream.addDataData(dataData, 0, size);
stream.sendDirect(“setCaption”, caption);
}
// System.out.println(“Before Thread…”);
// try{
//
// Thread.sleep(1000);
// }catch(Exception e){
// e.printStackTrace();
// }
// System.out.println(“After Thread…”);
//
injectMetaData(client , function , params);
getLogger().info("Caption: " + caption);
}
public void injectMetaData(IClient client, RequestFunction function, AMFDataList params)
{
System.out.println("Inside injectMetaData ::: AIMAN ");
String streamName = params.getString(PARAM1);
String data = params.getString(PARAM2);
IMediaStream stream = client.getAppInstance().getStreams().getStream(streamName);
if (stream != null)
{
AMFDataList amfList = new AMFDataList();
amfList.add(new AMFDataItem("@setDataFrame"));
amfList.add(new AMFDataItem(“onMetaData”));
AMFDataMixedArray metaData = new AMFDataMixedArray();
metaData.put(“param1”, data);
metaData.put(“param2”, new AMFDataItem(“data2”));
amfList.add(metaData);
synchronized(stream)
{
byte[] dataData = amfList.serialize();
System.out.println(“dataData ::” +dataData.toString());
int size = dataData.length;
System.out.println("size :: " + size);
long timecode = Math.max(stream.getAudioTC(), stream.getVideoTC());
System.out.println(“timecode ::” +timecode);
stream.setDataTC(timecode);
stream.setDataSize(size);
stream.startDataPacket();
stream.addDataData(dataData, 0, size);
stream.sendDirect(“streaming”, amfList );
}
}
}
}
as3 code from flex app
protected function sendData_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
_nc.call(“setTag”,null,“livefeed”,“hello room”,“eng”,“0”);
}
private function streaming(obj:Object):void
{
var a:String = obj.toString();
textbox.text = a + “\n” ;
}
i get error message . i have used stream.sendDirect();
please let me know where im gng wrong.
my error in java :
INFO session connect-pending 127.0.0.1 -
INFO session connect 127.0.0.1 -
INFO stream create - -
INFO stream play livefeed -
StreamName:: livefeed
Caption :: hello room
Stream :: livefeed
Stream Type :: live
Live Record Caption :: hello room
timecode :: 8508
Inside injectMetaData ::: AIMAN
dataData ::[B@6b543e44
size :: 74
timecode ::8508
WARN server comment - LiveReceiver.startDataPacket[test/definst/livefeed]: Data packet sync issue.
ERROR server comment - addDataA[this.size:26 this.dataA.length:26 this.startDataLoc:0 this.dataLoc:0 data.length:74 offset:0 size:74 missing:26 ]: java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException
INFO server comment - Caption: hello room
WARN server comment - LiveReceiver.startDataPacket[test/definst/livefeed]: Data packet sync issue.
at java.lang.System.arraycopy(Native Method)
at com.wowza.wms.amf.AMFPacket.addData(Unknown Source)
at com.wowza.wms.stream.live.LiveReceiver.addDataData(Unknown Source)
at com.wowza.wms.stream.live.MediaStreamLive.addDataData(Unknown Source)
at com.wowza.example.module.ModuleInjectData1.injectMetaData(ModuleInjectData1.java:94)
at com.wowza.example.module.ModuleInjectData1.setTag(ModuleInjectData1.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.wowza.wms.module.ModuleFunction.invoke(Unknown Source)
at com.wowza.wms.module.ModuleFunctions.invoke(Unknown Source)
at com.wowza.wms.request.RequestProcessFunctions.processFunctions(Unknown Source)
at com.wowza.wms.request.RequestProcessData.flushFunction(Unknown Source)
at com.wowza.wms.request.RequestProcessData.processNextRequest(Unknown Source)
at com.wowza.wms.client.ClientWorker.processNextReq(Unknown Source)
at com.wowza.wms.request.RTMPRequestAdapter.service(Unknown Source)
at com.wowza.wms.server.ServerHandler.a(Unknown Source)
at com.wowza.wms.server.ServerHandler.a(Unknown Source)
at com.wowza.wms.server.ServerHandler.messageReceived(Unknown Source)
at com.wowza.wms.server.ServerHandlerThreadedSession.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
INFO stream stop livefeed -
INFO stream destroy livefeed -
INFO session disconnect 2131692034 -