Jmf dropping RTP packets

I'm writing an RTP de-packetizer for MPEG-4 video, but the JMF RTP implementation seems to be dropping packets. I've verified that the packets are arriving on my computer in order and on time. But some are never given to my de-packetizer. Has anyone else come across this, and if you have, have you found a solution?
Scott

There are some video and audio codecs in JMF that have this problem. 1 in every 6 packets is lost.. I guess it's not a problem but rather a bug in RTP sequencing. Packets are probably not lost... Just the RTP sequence is misplaced..
there are some existing threads that discussed this in the past. try to search.

Similar Messages

  • Does JMF support RTP packets being sent "Faster than real time"?

    I have a situation where some stored audio is passed to a speech recogniser using RTP. This is all working well with JMF. However, since this operation is "offline" (i.e. no live person is actually speaking or hearing this audio stream) and the recognizer is capable of processing the audio very quickly, then the RTP stream could be sending the audio in "faster than real time". What settings in the following components would allow this?
    DataSource _dataSource = Manager.createDataSource(source);
    Processor _processor = Manager.createProcessor(_dataSource);
    TrackControl[] trackControls = _processor.getTrackControls();
    Codec codec[] = new Codec[3];
    codec[0] = new com.ibm.media.codec.audio.rc.RCModule();
    codec[1] = new com.ibm.media.codec.audio.ulaw.JavaEncoder();
    codec[2] = new com.sun.media.codec.audio.ulaw.Packetizer();
    ((com.sun.media.codec.audio.ulaw.Packetizer) codec[2]).setPacketSize(160);
    _processor.realize();
    DataSource dataOutput = _processor.getDataOutput();
    SendStream _sendStream = _rtpManager.createSendStream(dataOutput, 0);
    _sendStream.start();          
    _processor.start();I tried "setRate" on the processor but this had no effect. getRate showed that it was still 1.0
    Best Regards,
    Jamie

    I wrote my own RTP client in about an hour - (seemed simpler than navigating JMF options). It is very basic, but works as I want. The RTP server (the speech recognizer it able to consume the stream and gives exactly the same results).
    package com.sss.mrcp;
    import java.io.InputStream;
    import java.net.DatagramPacket;
    import java.net.DatagramSocket;
    import java.net.InetAddress;
    import java.util.Random;
    public class RTP extends Thread {
         InputStream is;
         String address;
         int port;
         int localPort;
         public RTP(InputStream is, int localPort, String address, int port) {
              this.is = is;
              this.address = address;
              this.port = port;
              this.localPort = localPort;
         public void run()  {
              try {
              DatagramSocket socket = new DatagramSocket(localPort);
              Random r = new Random();
              int sequenceNumber = r.nextInt();
              int syncId = r.nextInt();
              int timeStamp = 0;
              int len = 256;
              byte[] buf = new byte[len];
              int code = 0;
              int headerLength = 12;
              while ((code = is.read(buf, headerLength, len - headerLength)) > -1) {
                   int i = 0;
                   buf[i++] = (byte) 0x80; // version info
                   buf[i++] = (byte) 0x08;     // 8=alaw,0=ulaw
                   sequenceNumber++;
                   buf[i++] = (byte) (sequenceNumber / 0x100);
                   buf[i++] = (byte) (sequenceNumber % 0x100);
                   timeStamp += (len - 12);
                   int timeStampTop = (timeStamp / 0x10000);
                   buf[i++] = (byte) (timeStampTop / 0x100);
                   buf[i++] = (byte) (timeStampTop % 0x100);
                   int timeStampBottom = (timeStamp % 0x10000);
                   buf[i++] = (byte) (timeStampBottom / 0x100);
                   buf[i++] = (byte) (timeStampBottom % 0x100);
                   int syncIdTop = (syncId / 0x10000);
                   buf[i++] = (byte) (syncIdTop / 0x100);
                   buf[i++] = (byte) (syncIdTop % 0x100);
                   int syncIdBottom = (syncId % 0x10000);
                   buf[i++] = (byte) (syncIdBottom / 0x100);
                   buf[i++] = (byte) (syncIdBottom % 0x100);
                   DatagramPacket packet = new DatagramPacket(buf, code+headerLength, InetAddress.getByName(address), port);
                   socket.send(packet);
                   Thread.sleep(1); // this sets the speed of delivery "faster than real time"
              } catch (Exception e) {
                   throw new RuntimeException(e);
    }

  • JMF and RTP packet size

    I have the sample program AVTransmit3 compiled and successfully transmitting the contents of a WAV file to a multicast address. However, I want to put the data on the wire according to the G711 spec, which is u-law and 50 packets per second.
    I've been playing with the source code, but thus far I'm unable to achieve this. No matter what I do, the packets are larger (have more samples) than what I need.
    Anybody out there that has sent G711 data over the network successfully?
    Thanks.

    I have the sample program AVTransmit3 compiled and successfully transmitting the contents of a WAV file to a multicast address. However, I want to put the data on the wire according to the G711 spec, which is u-law and 50 packets per second.
    I've been playing with the source code, but thus far I'm unable to achieve this. No matter what I do, the packets are larger (have more samples) than what I need.
    Anybody out there that has sent G711 data over the network successfully?
    Thanks.

  • How to use jmf convert the rtp packet (captured by jpcap) in to wav file?

    I use the jpcap capture the rtp packets(payload: ITU-T G.711 PCMU ,from voip)
    and now I want to use JMF read those data and convert in to wav file
    How to do this? please help me

    pedrorp wrote:
    Hi Captfoss!
    I fixed it but now I have another problem. My application send me this message:
    Cannot initialize audio renderer with format: LINEAR, Unknown Sample Rate, 16-bit, Mono, LittleEndian, Signed
    Unable to handle format: ALAW/rtp, Unknown Sample Rate, 8-bit, Mono, FrameSize=8 bits
    Failed to prefetch: com.sun.media.PlaybackEngine@1b45ddc
    Error: Unable to prefetch com.sun.media.PlaybackEngine@1b45ddc
    This time the fail is prefetching. I have no idea why this problem is. Could you help me?The system cant play an audio file / stream if it doesn't know the sample rate...somewhere along the way, in your code, the sample rate got lost. Sample rates are highly important, because they tell the system how fast to play the file.
    You need to go look through your code and find where the sample rate information is getting lost...

  • Packet sniffer only picks up UDP and no RTP packets when using JMF???

    Hi,
    I am developing a voice mail application to interface with asterisk. Here is the problem.
    I am using ethereal packet sniffer to sniff the packets. When I connect two regular SIP phones and sniff , I can sniff the RTP packets.
    But when I use JMF AVtransmit2.java and AVReceive2.java I sniff only UDP packets and no RTP packets.
    I am very confused. What is going on? If JMF sends over RTP (that uses UDP underneath), then why cannot packet sniffers detect it.

    Hi,
    I am developing a voice mail application to interface with asterisk. Here is the problem.
    I am using ethereal packet sniffer to sniff the packets. When I connect two regular SIP phones and sniff , I can sniff the RTP packets.
    But when I use JMF AVtransmit2.java and AVReceive2.java I sniff only UDP packets and no RTP packets.
    I am very confused. What is going on? If JMF sends over RTP (that uses UDP underneath), then why cannot packet sniffers detect it.

  • Setting dimension of RTP packet with 'rtp' jmf

    How is it possibile to set the dimension of RTP packet with JMF in the transmitting audio stream with RTP????

    thesti wrote:
    how JMF deal with RTP packet loss? since my application doesn't handle anything due to RTP packet loss, i believe that JMF has a mechanism to deal with it.It "deals" with it by having a blank spot in the rendering where that packet would have gone...

  • Decode raw RTP packets using JMF

    Hi!
    I have a stream of raw RTP packets comming from another program.
    How can I use JMF to decode all raw RTP packets and get the media stream using JMF?
    /Tec

    Hello,
    Have you resolved your problem?
    I've tried with Jmf, but finaly i receive each stream and save raw data in a file.
    Then i convert it to an audio file format. (tritonus : RawAudioConverter.java)
    If you have resolved with jmf i'm interested by your solution.
    try{
    rtpRcvSock.receive(rcvPkt);
    data = rcvPkt.getData();
              boolean extensionHeader = ( (data[0] & 0x08) == 0x08) ? true : false;
         int payloadType = data[1] & 0x7F;
         int cc = data[0] & 0x0F;
         int sequenceNumber = ( (data[2] & 0xFF) << 8) | (data[3] & 0xFF);
         int mediaStart = 3 * 4 + cc * 4;
         int extLength = 0;
              System.out.println("PayLoad = "+payloadType);
              System.out.println("Seqnum = "+sequenceNumber);
              System.out.println("Data Length = "+ (data.length - mediaStart));
         if (extensionHeader) {
         extLength = (data[mediaStart + 3] & 0xFF)
         | ( (data[mediaStart + 2] & 0xFF) << 8);
         mediaStart += extLength;
         byte[] mediaData = new byte[data.length - mediaStart];
         System.arraycopy(data, mediaStart, mediaData, 0, mediaData.length);
              ByteArrayInputStream bb = new ByteArrayInputStream(mediaData);
                   AudioInputStream aiStream = new AudioInputStream(bb,format,mediaData.length);
                   //AudioSystem.write(aiStream,AudioFileFormat.Type.WAVE,file);
                   file.write(mediaData);
    Then as i told i use RawAudioDataConverter.java
    Sam

  • Cretae a RTP packet without using JMF

    I have to create a RTP packet of existing audio/video file using all the parameters of RTP Packet
    I dont have to use JMF.
    Please suggest me the soluion and if possible provide me the codes.
    Thanks alot.

    I have to create a RTP packet of existing audio/video file using all the parameters of RTP Packet
    I dont have to use JMF.
    Please suggest me the soluion and if possible provide me the codes.
    Thanks alot.

  • Create one player to play RTP packets from many clients

    Hi,
    Am a JMF newbie and I want to create one player to play packets from many clients.
    So I wrote a small UDPserver thread within the app to receive rtp packets from the clients on the LAN which in turn forwards them to the player.
    I instatiated two threads one to forward RTP packets and another to forward RTCP packets which listens on RTPPort+1
    The reason why i do this is that i don't want the whole internet to bombard the player with anonymous voice transmissions.So the server thread is acting as a firewall. To filter out packets from from unknown ip addresses.
    this is a snippet of the player.
    MY_IPADDRESS =   InetAddress.getLocalHost().getHostAddress();+
    url = "rtp://" + MY_IPADDRESS + ":" + RTPPlayer.PORT + "/audio/1";
    MediaLocator mrl = new MediaLocator(url);
    player = Manager.createPlayer(mrl);
    More code which starts the server thread
    if (player != null) {
           player.addControllerListener(this);
           player.realize();
    player.start();When the server thread receives the packet it calls its forward method to forward the packet to the player by resetting the only the IP and PORT.
    public void forward(DatagramPacket rtpPacket) {
             //print out packet info to view which packets are being received
             System.out.println("forwarding "+request.getAddress() + " -> " + MY_IPADDRESS+":"+portToSend);
             //set address of packet to MY_IPADDRESS
           rtpPacket.setAddress(
                   InetAddress.getByName(RTPPlayer.MY_IPADDRESS));
              //set the port to the rtp port
           rtpPacket.setPort(RTPPlayer.PORT);
           datagramSocket.send(rtpPacket);
    }This works fine for two clients.
    When the clients become three(c1, c2 and c3),
    two clients communicate well(c1 and c2) but c3's voice cannot be heard on any other pc(c1 or c2) though it plays voice from both c1 and c2.
    But System.out.println("forwarding "+request.getAddress() + " -> " + MY_IPADDRESS+":"+portToSend);in the forward() method shows that packets from all clients on each pc are being received.
    Does any one have an idea why this happens?
    Are the packets so many that they overwhelm the player so it discards some or all?
    Is this the best way of doing this?
    Just to let u know all the mics are working fine.
    Thx in advance
    Edited by: noryak on Oct 29, 2008 10:29 AM

    THAT IS MY MAIN PROBLEM. In the future, please do a little bit of research before you shout at people trying to help you. I'm so so sorry if you find my answer bothersom because it sheds some light on the fact that you have absolutely no idea what you're doing.
    Your problem is that you obviously do not understand how JMF works...and you obviously havn't bothered to do any sort of research into it.
    You also don't seem to understand the concept of streaming media, concurrency, politeness, good design, proper programming, audio interleaving, or common sense.
    At least i have implemented a player playing packets from 2 different clients.Yeah, you implemented a player that plays packets from 2 different clients using a horrible workaround that doesn't treat the data correctly and manages to just drop data after scaling past 2 clients.
    Oh yeah, you've definately found the holy grail there. At least.
    You wanna know what your player is actually doing? It's playing a peice of data from A, and then a peice of data from B. It might sound like it's playing them both at the same time, but it's not. It's playing the data from one client in the gaps where there's no data, and once you've filled up the gaps in time by adding more nodes, you'll end up with data getting dropped (and that's the best case scenerio).
    my issue is that i wouldn't like to create a player for each participant imagine they were people in a conference that makes it 10 players. Please understand that if you have 10 players, you'll receive 10 times as much data as you can play with one player. You end up either having to drop 90% of your data, or having to play the data at 1/10th the speed... because you're not mixing the audio data, you're interleaving it.
    I just want to use one standard port on each client so that all clients send to the same port: The RTPManager class will allow you to receive as many streams as you want on a single port.
    As a matter of fact, had you bothered to play with any of the source code readily available online, you'd realize there is a file that does exactly what you want.
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/AVReceive2.java]
    It handles receiving multiple RTP streams from a single port, and plays them all simultaniously using an array of player objects.
    Does absolutely everything you want, out of the box.
    That sounds like alot of threadsIf you're concerned that it's too many threads, well, maybe you should stick to hello world and other things less scary. Concurrent data processing requires threads...one per peice of concurrent data, as a matter of fact, and you're dealing with a lot of streams of concurrent data here.

  • DVI/RTP packet decode

    Hi,
    I need to stream audio and/or video to a PDA device. There is a trick here which is:
    The PDA must receive the stream from a multicast address. For this I have implemented a Bridge application which joins the multicast group on behalf of the PDA and receives the Multicast RTP packets (which are sent from JMStudio) and Unicasts them to the PDA.(HP iPAQ) I had no problem implementing this. The streaming is done using JMStudio player which encodes the streaming audio data into a number of encodings (DVI/RTP in my case). I choose DVI/RTP and stream a .wav audio file.
    Now I have to accept the packets and play the stream on the PDA.
    The j2me application receives all the RTP packets successfully and I can extract usefull information from the packets such as: Timestamp, sequence number, payload type. The payload type is 5 which means it is a DVI4 encoding.
    I use the following method to decode the samples:
    public int decode(Object state, byte[] input, int inp, int len, short[] output, int outp) {
    int sign;
    int delta;
    int vpdiff;
    //int valprev = audio.Convert.byte2short(input, inp);
    //int index = input[inp + 2];
    int valprev=0,index=0;
    int inputbuffer = 0;
    int bufferstep = 0;
    valprev = input[0] <<8;
    valprev |= input[1] &0xff;
    index = input[2] &0xff;
    if ( index < 0 ) index = 0;
    else if ( index > 88 ) index = 88;
    int step = stepsizeTable[index];
    inp += 4;
    len = (len - 4) * 2;
    int count = len;
    while(count-- > 0) {
    if ( 0 == bufferstep ) {
    inputbuffer = input[inp++];
    delta = (inputbuffer >> 4) & 0xf;
    bufferstep = 1;
    } else {
    delta = inputbuffer & 0xf;
    bufferstep = 0;
    index += indexTable[delta];
    if ( index < 0 ) index = 0;
    else if ( index > 88 ) index = 88;
    sign = delta & 8;
    delta = delta & 7;
    vpdiff = step >> 1;
    if ( (delta & 4) == 4 ) vpdiff += (step << 2);
    if ( (delta & 2) == 2 ) vpdiff += (step << 1);
    if ( (delta & 1) == 1 ) vpdiff += step;
    vpdiff >>= 2;
    if ( 0 != sign )
    valprev -= vpdiff;
    else
    valprev += vpdiff;
    if ( valprev > 32767 )
    valprev = 32767;
    else if ( valprev < -32768 )
    valprev = -32768;
    step = stepsizeTable[index];
    output[outp++] = (short) valprev;
    ((AdpcmState)state).valprev = valprev;
    ((AdpcmState)state).index = index;
    return len;
    which stores the result into a short[] array.
    I then convert this short[] array into a byte[] array with the following way:
    s is the short[] array
    adp is the byte array
    for(int g=0,k=0;g<s.length;g++,k=k+2){
    audio.Convert.short2byte(s[g],adp,k);
    public static void short2byte(short ival, byte b[], int offset) {
    int i;
    int bits = 16;
    for(i = 0; i >< 2; i++) {
    bits -= 8;
    b[offset + i] = (byte) ((ival >> bits) & 0xff);
    The final result is loaded to the player as follows:
    ByteArrayInputStream input1 = new ByteArrayInputStream(adp);
    player = Manager.createPlayer(input1, "audio/x-wav");//create new player
    player.addPlayerListener(this);
    player.prefetch();
    player.realize();
    player.start();
    The player begins to play but I only get horrible sounds instead of the original wave file
    The player now initializes ok without any problem but I can only hear a meesed up sound rather than the original. So now I strongly believe that the problem is in the decoding of the samples of the DVI/RTP codec.

    thesti wrote:
    how JMF deal with RTP packet loss? since my application doesn't handle anything due to RTP packet loss, i believe that JMF has a mechanism to deal with it.It "deals" with it by having a blank spot in the rendering where that packet would have gone...

  • How to edit RTP Packets

    Hi,
    I want to add some information in RTP Packet, (in Extensions Header). How can I do that in JMF ?
    Thanks in Advance,
    Karthikeyan R

    OK, thank you. So specifically -- if I want to prioritize all of the RTP traffic flowing out through the router, can I do it ALL with just COS and not set any QoS, profile binding etc?
    So far I have enabled the COS Queue, left the default settings (where COS Priorities 6 and 7 are set to highest), then on the COS to DSCP page I have entered the value 46 into the Priority 6 and 7 boxes. All the rest I left at 0.
    Unfortunately this didn't seem to solve the issue. The way I have been testing is to call our PBX from an outside line, then put myself on hold so I can hear the hold music (effectively an audio stream from the PBX server). Then I listen carefully while I run a bandwidth test from speedtest.net.
    During the download test the audio (music on hold) is pretty smooth. But during the upload test (lots of data flowing outbound) the audio gets very choppy. The COS settings I've tried don't seem to improve or even change that
    I assume I'm doing something wrong and/or need to involve QoS somehow?
    - Keith

  • How to send RTP packet through SIP Dialog

    Hello there !
    I work on a Java softphone which use JMF and Jain-SIP. I know JMF is "old" but I think it would be simple to capture and transmit RTP audio. So, my SIP dialog is working, I can send text messages but now, I would like to send RTP with this SIP session. I know I have to send SDP messages for codec convenience but then, what is the MediaLocator for RTP packet ? Only SIP User Agent IP or something else ?
    I also accept all ressources that can help me achieve my work :)

    I have no idea how SIP works, but, RTP packets go to an IP:PORT... theoretically, in the SIP phonecall setup, I'd imagine you'd have to be given the address to send RTP packets to the remote phone. Or perhaps the port is already well-defined by the SIP standard.
    Either way, you should have a way of knowing / finding out which PORT to send to for your SIP call, either from the call setup or the SIP standard itself.

  • Raw RTP packets

    I have extracted raw RTP packets with Ethereal and want the media to be put together and saved to file. Can I user JMF to put a raw RTP session together?
    If "Yes", how?
    /Tec

    I know that, but I will always have raw RTP packets that I need to have "decoded" and put to file. I cant use JMF to fetch the RTP packets.

  • Directly sending RTP Packets

    Hello,
    I have a media file divided in chunks on disk.
    I want to stream the whole media file with RTP. How can I do that? Can you directly send RTP Packets?
    For example:
    for every chunk i
       for (every 1000 bytes b[] in i)
          sendRTPPacket(b[]) //this creates a new RTP Packet with the contents of b[] and sends itIs that possible?
    If that is not possible, I have another idea:
    If I open a different RTP session for each chunk (so I can just specify as dataSource the actual chunk file), can I synchronize that at the receiver side? how can I then reconstruct the whole file ?
    How would you do that?
    Thank you!

    Hello,
    after searchig the internet, I found this:
    http://forums.sun.com/thread.jspa?threadID=5356475&tstart=1
    I think creating a customized Push DataSource will work fine, what do you think? it would push data each time a new chunk is available.
    I tried the example on http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/LiveData.html but I'm not sure how to use it: I cannot register it.
    I would like to see the results on a player, so I used a player that I have:
    DataSource dataSource = new DataSource();
                   //dataSource.connect();
                   //dataSource.start();
                   player = Manager.createPlayer(dataSource);But I get Error: DataSource not connected
    If I call dataSource.connect() I get:
    java.lang.ClassCastException: [B cannot be cast to [I
         at com.omnividea.media.renderer.video.Java2DRenderer.bufferToImage(Java2DRenderer.java:131)
         at com.omnividea.media.renderer.video.Java2DRenderer.process(Java2DRenderer.java:105)
         at com.sun.media.BasicRendererModule.processBuffer(BasicRendererModule.java:728)
         at com.sun.media.BasicRendererModule.scheduleBuffer(BasicRendererModule.java:499)
         at com.sun.media.BasicRendererModule.doProcess(BasicRendererModule.java:400)
         at com.sun.media.RenderThread.process(BasicRendererModule.java:1114)
         at com.sun.media.util.LoopThread.run(LoopThread.java:135)
    Do you have a media player where this works? or can you tell me how to use the example, maybe without explicitly registering the new dataSource, to play media in a media player?
    What do you think about the idea of creating a similar DataSource (push) in order to push the data chunks that we have already into it?
    Thanks!
    Edited by: thawxx on Mar 11, 2009 7:20 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to read sequence numbers from RTP packets

    hi everyone.
    i want to know how to read sequence numbers of RTP packets. I will need that to reconstruct my stream from packet losses.
    URGENT Help needed!!

    The StreamTokenizer parses all numbers into only one type of value, a double. If you know that all the numeric values in the file will be integers, you could just cast the nval double field to an int and the toString() method will format it correctly.
    If you want to have different tokens and value types for different kinds of numbers, you will have to sub-class StreamTokenizer and add these capabilities yourself. You can add the type constant TT_INT, and provide an int field named ival. The toString() method would then format the value in the correct manner.
    If, on the other hand, you are actually looking for the exact text that was parsed, you could add code that collects the characters as they are parsed for any token type into the sval field in the nextToken() method, just like it already does when the token is a TT_WORD. In this manner sval is always valid for any token type.
    I hope you find this of some help.

Maybe you are looking for

  • I can't burn movie to dvd on idvd

    I have completed my movie and I am ready to burn but when I insert the blank disk it tells me that I need to enter a recordable dvd.  I have tried several new disks and it keeps telling me the same thing on all.

  • Lost newly purchased Iphone5, Reported complain in police station but not getting proper responce. Can apple help me out for this?

    Lost newly purchased Iphone5, Reported complain in police station but not getting proper responce. Can apple help me out for this?

  • Basic auth and MSIE

    Hi, I'm using basic auth and used to send username/password with the URL to authenticate from another webserver (with some other kind of authentication), but - as you know - Microsoft doesn't support that any longer and so this works for some other w

  • My earphone hole won't work on my iPod touch

    Ok, iv had my iPod touch 4g since last Christmas and it's been working fine but about a week ago something somehow got wrong with the earphone hole because my earphones won't snap in the hole it goes all the way in but doesn't click in. The music doe

  • Screen jumping

    My screen has been jumping and it has static lines through several areas of the screen. It also will turn like an infrared color. It does it every time I try to take a picture or look through my photos. It hasn't not been in contact with water or any