# Publishing raw RTP packets

**URL:** <https://community.wowza.com/t/publishing-raw-rtp-packets/41080>\
**Category:** Wowza Streaming Engine\
**Created:** [December 22, 2013, 5:43am UTC](https://community.wowza.com/t/publishing-raw-rtp-packets/41080 "2013-12-22T05:43:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johnathan\_Kanarek](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@Johnathan\_Kanarek](https://community.wowza.com/u/Johnathan_Kanarek)\
**Post date:** [December 22, 2013, 5:43am UTC](https://community.wowza.com/t/publishing-raw-rtp-packets/41080/1 "2013-12-22T05:43:51Z")

</div>

Hi,

I’m listening using my own RTP socket implementation and receiving and parsing the packets including the version, padding, extension, csrc count, marker, payload type, sequence number, time-stamp, ssrc and the data itself.

The codec are H.264 and G.722.

Basically I use similar code to publish the stream:

> publisher = Publisher.createInstance(vhost, appInstance.getApplication().getName(), appInstance.getName());
> 
> publisher.setFileExtension(“flv”); // I tried also mp4
> 
> publisher.setStreamType(“live-record”);
> 
> publisher.publish(currentStreamName, “live”);
> 
> byte rawBuf = rtpPacket.getData();
> 
> if (rtpPacket.getPayloadType() == G722)
> 
> publisher.addAudioData(rawBuf, 0, rawBuf.length, rtpPacket.getTimestamp());
> 
> if (rtpPacket.getPayloadType() == H264)
> 
> publisher.addAudioData(rawBuf, 0, rawBuf.length, rtpPacket.getTimestamp());
> 
> I also recording the content.
> 
> The stream and the recorded file are not playable.
> 
> Can you please offer me a better solution or help me understand what I do wrong?
> 
> Thanks,
> 
> T.

---

<div class="post-metadata">

**Author:** ![Roger\_Littin1](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@Roger\_Littin1](https://community.wowza.com/u/Roger_Littin1)\
**Post date:** [December 23, 2013, 9:58am UTC](https://community.wowza.com/t/publishing-raw-rtp-packets/41080/2 "2013-12-23T09:58:25Z")

</div>

Hi,

Wowza does not use RTP packets directly as you are trying to do. It first passes them through a depacketizer that reassembles them into AMFPackets.

RTP video packets are normally fragments of complete video packets and the timecodes are based on video clock cycles (90K clock). RTP audio packets have their timecodes based on the sample rate. AMFPacket timecodes are based on wall clock values and are in milliseconds.

If you push your RTP stream into a pair of ports that wowza is listening to (use an rtp mediaCaster on wowza to connect to the source stream), then Wowza will be able to create an inbound stream and depackatize your rtp stream into AMFPackets. You can then monitor the packet list of the stream and get the AMFPackets. Use stream.getPlayPackets() to get the currently available packets that you can insert into your publisher stream. You may need to provide an sdp file for Wowza to know how to read your source stream

As each packet is inserted into the inbound stream, it is allocated a sequence number. You need to track this sequence number to make sure you are not reinserting the same packets into the publisher stream.

Roger.

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [December 24, 2013, 7:58pm UTC](https://community.wowza.com/t/publishing-raw-rtp-packets/41080/3 "2013-12-24T19:58:00Z")

</div>

This [example demonstrates](https://www.wowza.com/docs/how-to-use-imediastreamactionnotify2-to-monitor-live-streams-modulestreamwatchdog) use of IMediaStream.getPlayPackets()

Richard

---

<div class="post-metadata">

**Author:** ![Roger\_Littin1](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@Roger\_Littin1](https://community.wowza.com/u/Roger_Littin1)\
**Post date:** [December 27, 2013, 8:31am UTC](https://community.wowza.com/t/publishing-raw-rtp-packets/41080/4 "2013-12-27T08:31:41Z")

</div>

Hi,

We are not really sure what it is that you are wanting to do and I think the best approach will be to open a ticket with support@wowza.com. Please explain in detail what you are wanting to do. Also, please link to this thread.

Roger.

---

<div class="post-metadata">

**Author:** ![Johnathan\_Kanarek](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@Johnathan\_Kanarek](https://community.wowza.com/u/Johnathan_Kanarek)\
**Post date:** [December 22, 2013, 11:52pm UTC](https://community.wowza.com/t/publishing-raw-rtp-packets/41080/5 "2013-12-22T23:52:16Z")

</div>

Thank you.

I don’t need to monitor the packets, I just want to listen on RTP that its signaling is SIP and not RTSP.

Would it be more simple to use Wowza RTPPort, RTPStream and RTPSession classes to listen on the port I need?

Can I initialize RTPPort that will be already assigned to my appInstance?

Thanks,

T.

---

<div class="post-metadata">

**Author:** ![Johnathan\_Kanarek](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@Johnathan\_Kanarek](https://community.wowza.com/u/Johnathan_Kanarek)\
**Post date:** [December 22, 2013, 11:55pm UTC](https://community.wowza.com/t/publishing-raw-rtp-packets/41080/6 "2013-12-22T23:55:39Z")

</div>

Or,

Would it be more simple to build the stream header using FLVUtils.writeHeader or RTPUtils.formatH264CodecConfigPacket and write it into the publisher?

Thanks,

T.

---

<div class="post-metadata">

**Author:** ![Johnathan\_Kanarek](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@Johnathan\_Kanarek](https://community.wowza.com/u/Johnathan_Kanarek)\
**Post date:** [December 23, 2013, 10:33pm UTC](https://community.wowza.com/t/publishing-raw-rtp-packets/41080/7 "2013-12-23T22:33:54Z")

</div>

Could you please direct me to code example or documentation explaining how to implement it using the mediaCaster?

Thanks,

T.

---

<div class="post-metadata">

**Author:** ![Johnathan\_Kanarek](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@Johnathan\_Kanarek](https://community.wowza.com/u/Johnathan_Kanarek)\
**Post date:** [December 25, 2013, 8:37am UTC](https://community.wowza.com/t/publishing-raw-rtp-packets/41080/8 "2013-12-25T08:37:44Z")

</div>

Thanks Richard, but I have no interest in monitoring the packets.

My only interest is to stream the packets, by adding them the h.264 myself, by using a tool that the Wowza server can supply, or by using Wowza server RTP sockets in the first place instead of my socket.

In fact, the only reason I implemented my own RTP socket is because I don’t know how to initialize a listening RTP socket in Wowza using my custom port on RTPPort class.

T.
