# PushPublishRTMP with onMetadata

**URL:** https://community.wowza.com/t/pushpublishrtmp-with-onmetadata/45997
**Category:** Wowza Developer Dojo
**Tags:** wowza-streaming-server-java-api
**Created:** [September 26, 2015, 2:54pm UTC](https://community.wowza.com/t/pushpublishrtmp-with-onmetadata/45997 "2015-09-26T14:54:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![David\_Sveningsson](https://avatars.discourse-cdn.com/v4/letter/d/5fc32e/32.png) [@David\_Sveningsson](https://community.wowza.com/u/David_Sveningsson)
#### Post date: [September 26, 2015, 2:54pm UTC](https://community.wowza.com/t/pushpublishrtmp-with-onmetadata/45997/1 "2015-09-26T14:54:10Z")

</div>

In my module I create streams dynamically using Stream.createInstance and use stream.play(…) to play video on them. These streams should be republished using RTMP so I create an instance of PushPublishRTMP and set source and destination. As long as I disable sendOnMetadata it works, the video played on the stream is published.

I would like to inject the metadata dynamically as well (as @setDataFrame) but I cannot figure out how to do this. I saw other posts referencing stream.sendDirect(“onMetadata”, …) but it doesn’t send it and the streaming doesn’t start (waiting for the metadata I assume). I tried calling sendData when creating the stream, when creating the push publisher, adding a listener and sending it from onStreamOnStatus and onStreamCreate, neither which worked.

The log contains:

```auto
2015-09-26 15:18:26 CEST comment server INFO 200 - PushPublishRTMP.connect[rtmp://example.net:1935/app/dst] - - - 40.479 - - - - -- - - - - - - - - - - - - - - - -- - -
2015-09-26 15:18:26 CEST comment server INFO 200 - PushPublishRTMP#IdleHandler.create[rtmp://example.net:1935/app/dst] - - - 40.487 - - - -- - - - - - - - - - - - - - - - -- - - -
2015-09-26 15:18:26 CEST comment server INFO 200 - ExampleModule: onPushPublisherSessionCreate - -- 40.489 - - - - - - - - - - - - - - -- - - - - - - - - -
2015-09-26 15:18:26 CEST comment server INFO 200 - ExampleModule: onConnectStart - - - 40.49 - - - - - - - - - - - - - - - -- - - - - - - - -
2015-09-26 15:18:26 CEST comment server INFO 200 - PushPublishRTMP.addSession[rtmp://example.net:1935/app/dst]: {[0]: 1367593 } - - - 40.522 - - -- - - - - - - - - - - - - - - - -- - - - -
2015-09-26 15:18:26 CEST comment server INFO 200 - ExampleModule: onSessionOpened - - -40.529 - - - - - - - - - - - - - - - -- - - - - - - - -
2015-09-26 15:18:27 CEST comment server INFO 200 - PushPublishRTMP.callConnect[rtmp://example.net:1935/app/dst]: app/
{Obj[]: app: "app/", flashVer: "FMLE/3.0 (compatible; FMSc/1.0)", swfUrl: "WowzaProLiveRepeater", tcUrl: "rtmp://example.net:1935/app/", fpad: false, audioCodecs: 3191.0, videoCodecs: 252.0, pageUrl: "", sendChunkSize: 4096.0} - - -40.929 - - - - - - - - - - - - - - - -- - - - - - - - -
2015-09-26 15:18:27 CEST comment server INFO 200 - PushPublishRTMP#ConnectResult.onResult[rtmp://example.net:1935/app/dst]: result: NetConnection.Connect.Success description:Connection accepted. Message: - - - 41.168 - - - - - - - - -- - - - - - - - - - - - - - - -
2015-09-26 15:18:27 CEST comment server INFO 200 - PushPublishRTMP#FCPublishResult.onCallback[rtmp://example.net:1935/app/dst]: result: NetStream.Publish.Start - - -41.383 - - - - - - - - - - - - - - - -- - - - - - - - -
2015-09-26 15:18:27 CEST comment server INFO 200 - ExampleModule: onStreamCreate - - - 41.384 - - - - - - - - - - - - - - - -- - - - - - - - -
2015-09-26 15:18:27 CEST comment server INFO 200 - PushPublishRTMP#StreamCreateResult.onResult[rtmp://example.net:1935/app/dst]: publishStream: com.wowza.wms.stream.MediaStreamVODTest@e6dbf8 - - - 41.385 - - - - - - - - - - -- - - - - - - - - - - - - -
2015-09-26 15:18:27 CEST comment server INFO 200 - ExampleModule: onStreamOnStatus - - -41.669 - - - - - - - - - - - - - - - -- - - - - - - - -
2015-09-26 15:18:27 CEST comment server INFO 200 - ExampleModule: onMetadata injected - - -41.67 - - - - - - - - - - - - - - - -- - - - - - - - -
2015-09-26 15:18:27 CEST comment server INFO 200 - PushPublishRTMP#StreamOnStatus.onCallback[rtmp://example.net:1935/app/dst]: NetStream.Publish.Start - - - 41.671 - - - - - - - - - - - - - - - -- - - - - - - - -
2015-09-26 15:18:27 CEST comment server INFO 200 - PushPublishRTMP[rtmp://example.net:1935/app/dst].isOnMetadataReady: count:0 time:0 video:true/false videoRate:false/false audio:true/false audioRate:false/false ready:false/false - - - 41.671 - - - - - -- - - - - - - - - - - - - - - - -- -
2015-09-26 15:18:27 CEST comment server INFO 200 - PushPublishRTMP[rtmp://example.net:1935/app/dst].isOnMetadataReady: count:1 time:135 video:true/false videoRate:false/false audio:true/false audioRate:false/false ready:false/false - - - 41.806 - - - - - -- - - - - - - - - - - - - - - - -- -
...
(last message is repeated until it gives up)

```

Part of the code:

```auto
publisher.setAppInstance(appInstance);
publisher.setSrcStreamName(streamName());
publisher.setHostname("example.net");
publisher.setPort(1935);
publisher.setDstApplicationName("app");
publisher.setDstStreamName("dst");
publisher.setDstAppInstanceName("");
publisher.setSendFCPublish(true);
publisher.setSendOnMetadata(true);
publisher.setOnMetadataToSetDataFrame(true);
publisher.setDebugLog(true);
publisher.setImplementation("rtmp");
/* ... */
IMediaStream stream = appInstance.getStreams().getStream(streamName());
if (stream != null) {
	AMFDataObj amfData = new AMFDataObj();
	amfData.put("title", new AMFDataItem("Example stream"));
	amfData.put("language", new AMFDataItem("Swedish"));
	//stream.sendDirect("onMetaData", amfData);
	stream.sendDirect("onMetadata", amfData);
	logger.info("onMetadata injected");
}

```

Any ideas what I’m doing wrong?

---

<div class="post-metadata">

### Author: ![Chris\_Deely](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/chris_deely/32/977_2.png) [@Chris\_Deely](https://community.wowza.com/u/Chris_Deely)
#### Post date: [October 1, 2015, 2:49pm UTC](https://community.wowza.com/t/pushpublishrtmp-with-onmetadata/45997/2 "2015-10-01T14:49:27Z")

</div>

Try adding

```auto
stream.processSendDirectMessages();

```

after your sendDirect() call. That works for me with “onTextData” events
