Wowza Community

Publishing raw RTP packets

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.

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.

This example demonstrates use of IMediaStream.getPlayPackets()

Richard

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.

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.

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.

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

Thanks,

T.

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.