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

Similar Messages

  • 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.

  • Screen presenter application in an RTP stream using JMF - very slow..

    I am trying to build a screen presenter application using JMF. I got the AVTransmit2 code to run with the Screen grabber data source. I use the following calls
    java AVTransmit2 screen://0,0,160,120/10 224.122.122.122 2222
    - java AVReceive2 224.122.122.122/2222
    The AVReceive does receive the screen data stream in RTP, but either there are too many artifacts(h263) or it is too slow(JPEG format). Is there a way to optimize the screen grabber data source or the encoding somehow to make this more efficient?

    ucla_jatt wrote:
    The AVReceive does receive the screen data stream in RTP, but either there are too many artifacts(h263) or it is too slow(JPEG format). Is there a way to optimize the screen grabber data source or the encoding somehow to make this more efficient?It's not really a question of efficiency, most likely.
    You're probably trying to broadcast a very, very high resolution video (your screen is probably a minimum of 1024x768) at a very, very high framerate (30 fps, I'd bet).
    A DVD runs at 640x480 at around 30 frames per second.
    You're trying to broadcast a video feed with over two and a half times as much visual information as a DVD has, and that's before you throw in that a DVD is encoded using MPEG4 compression.
    In the end, you're probably trying to broadcast 754,974,720 bits per second (1024x768x32(bit color)x30(fps)), or roughly trying to dump 1 CD-RWs worth of data to your network card per second...
    You want it to work well, you're going to need to decrease both the framerate and transcode the full-size video down into a smaller size...
    Or you can go into the DataSource code and modify the resolution of the screen capture image before it's compiled into the video. That would also work.

  • 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...

  • Raw.rtp

    I am now doing a video conferencing software I cannot see myself on my screen.
    Can anyone suggest some solution?
    I am currently trying to create a player to play datasource from sendstream but it says that cannot find player for something like javax.media.multiplex.
    The datasource from the sendstream is of format raw.rtp.

    Hi,
    Is JMF class files in your class path? Is JMFHOME set? OR Are JMF.jar/etc are in J2SDKHOME/JRE/LIB/EXT (e.g. C:\j2sdk1.4.2_03\jre\lib\ext) ?
    Any NO could be your problem. Correct it.
    Regards,

  • 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.

  • 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.

  • 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 capture the video in a file using JMF-RTP?

    Please someone help in capturing the live streaming in a file using JMF......
    Thanks..

    Hi, I have a problem with RTPExport output video files. One side streams H263/RTP(AVTransmit2.java) and other write this steam to a file by RTPExport.java. When network conditions are ideal, output video file has same fps and same number of frames like original file. Problem occures, when theres packet lost in network, then output file has different fps,and also has less frames like original video(because it didnt write missing frames to file, and thats why it get shorter). Pls how can I achieve output file that will have the same fps like original one? How to write to file an identical copy of what I can see while receiveing video with AVReceive2.java? Its there a way to modifi rtpexport or avreceiver to do this? Thanks!

  • How to transfer multimedia file using JMF/RTP through Bluetooth

    Hi,
    I am trying to stream a multimedia file via bluetooth but I don't know how to wrap RTP into bluetooth connection.
    I also tried to cut the multimedia file in small pieces but they can't be read by the player.
    How can I stream a multimedia file via Bluetooth using JMF ??
    Regards,
    Danix

    -danix- wrote:
    Hi,
    I am trying to stream a multimedia file via bluetooth but I don't know how to wrap RTP into bluetooth connection.I know absolutely nothing about Bluetooth networking, but I assume you don't wrap protocols into connections with it...
    How can I stream a multimedia file via Bluetooth using JMF ??You'd need to write a custom RTPConnector that would transmit the RTP packets over a Bluetooth connection rather than the standard UDP socket...
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/RTPConnector.html]
    There's some code to get you started. You'll need to update the SockOutputStream & SockOutputStream classes of the RTPConnector to read/write to a Bluetooth connection rather than a UDP socket.
    Good luck.

  • How to send video and audio (videoconference) using JMF without using RTP

    Hi everyone,
    I am creating an application using JMF, a videoconference, but I would like to transmit the packets by myself without using RTP. I would have a socket (or virtual Serial Port -- > Bluetooth) and I would send the info that way. Is it possible??
    Thanks in advance!!
    Cheers

    Yeah, you'd need to implement something like this for that.
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/RTPConnector.html]

  • Vaibility of RTP relay server using JMF

    Hello!
    I am thinking of making an RTP server that would just relay the streams received from single user to multiple users.
    I want to ask following questions:
    1- Is it viable to make such a Server using JMF?
    2- If it is, then how should I proceed?
    3- Should I need to create Processor for each recieved stream at the server or just cloning the DataSource received and sending them using separate RTPManagers would solve my problem?
    4- Is cloning of data source needed at all?
    I am asking this before doing any coding just in case if it is not possible than you warn me ,and because I had real bad experiences while cloning the data source and this server, I think depends on cloning.
    Else, I want some help regarding code. I would highly appreciate some code snippets.
    Thanks in advance.
    Thanks!
    P.S.: captfoss, Are you listening?

    Now some simple questions from a novice, thats me:I will answer them out of order
    3- Are these terms specific to JMF or are they general Networking terms?They are general networking terms.
    2- What is difference b/w unicasting and multicasting?Uni = Latin prefix for "one".
    Multi = Latin prefix for "many"
    Broad = Latin prefix for "all" (okay, this one is probably not true, but...)
    unicast = sending data to a single recipient.
    broadcast = sending data to all recipients.
    multicasting = sending data to many recipients.
    It deals with how the underlaying UDP packets are handled.
    Unicast addresses the packets to a specific host, so all other hosts that receive those packets go "Not for me" and ignore it.
    Broadcast addresses the packets to a special IP address, the broadcast ip, so all hosts that receive it say "Oh, this is a broadcast message so it's for me"
    Multicast addresses the packets to an IP address in a special range (Class D addresses), and all hosts can opt to join in to the "multicast session". If they join the multicast session, it basiclly means when they receive packets addressed to any multicast addresses that they have joined the session of, they will consider those packets to be "for them".
    1- What exactly is multicasting in JMF?JMF multicasting is basiclly where the "host" can send out a single stream, and any number of "clients" can receive the stream.
    4- How multicasting is handled at Transmitter and Reciever side using JMF, some java statements please.Multicasting is almost handled "automaticlly".
    It's handled by giving the transmitter a multicast IP address to send to. "224.123.123.123" is an example of the one I always used for testing (because it was easy to remember). Transmitting multicast packets is handled automaticlly.
    Receiving multicast packets requires a little special handling.
    From AVReceive2.java
    if( ipAddr.isMulticastAddress()) {
        // local and remote address pairs are identical:
        localAddr= new SessionAddress( ipAddr,
                           session.port,
                           session.ttl);
        destAddr = new SessionAddress( ipAddr,
                           session.port,
                           session.ttl);
    } else {
        localAddr= new SessionAddress( InetAddress.getLocalHost(),
                                session.port);
        destAddr = new SessionAddress( ipAddr, session.port);
    }The main difference here is that your "local" address isn't going to be LocalHost address, "127.0.0.1", it's going to be the multicast address.
    And you should define the TTL (time to live) for the SessionAddress because multicast packets can only travel a certain number of "hops" (number of times forwarded).
    But honestly, I'm pretty sure I ripped that IF statement out and multicasting still worked (but I define the TTL for unicast as well, so bear that in mind...)
    Ignoring all of the stuff above, multicasting is a great idea for a local LAN application where there are no routers between the host and the clients. If you've got a router between them, then the router may not forward the multicast packets and your stream may never get to the remote clients.
    That's why in my project, which is web based, clients attempt to get the multicast packets and if they fail at that, then they request a unicast from my server.

  • VoIP using JMF - RTP tx, rx - doubt

    Hi, I am computer engineering graduate from India doing a VOIP project.
    I am using JMF to develop the software and I have a few doubts :
    1. There are quite a few techniques for RTP transmission :
    a) Using RTPSocket and a custom UDP handler.
    b) Using RTPManager to start a session.
    c) Using a medialocator (rtp//inet addr.port//ttl) and a Datasink.
    and may there are other methods too ?!
    Now which of these should I use so that I have the best quality voice ?
    Please advise.
    2. Secondly, I read that H.323 is the ITU-T standard for multimedia networks. Is it necessary for my software to adhere to this standard ? If yes, how can I go about it?
    My email-id is : [email protected]
    Thank you,
    Arun .K

    well friend it depends totolly on you, what sort of thing u want to do i mean using media locator to send and recieve the media streams u can only response to single stream.While using RTPManager u can have mutiple streams in a session and using custom UDP protocols u can have much more controll over the media stream.
    I think u should send me a little detail about what you want so that i can guide u properly.
    thank you
    bye

  • RTP Server/ Client Program using JMF Library

    Hi folks,
    I am trying to send A/V data from Camcorder(SONY DCR-PC115) to PC(Red Hat Linux 7.3 kernal version 2-18.3), and then send that data to clinet programm via a network ( i.e. A/V data should be delivered by network using RTP/RTCP Protocol).
    I guess I need to make RTP Server and RTP Client program, and using JMF library in order to send data with RTP Protocol. Isn't it?
    So what I want here is Do any body have idea/experiance in making RTP Clinet /Server program using JMF library then pls let me know
    my e-mail id is [email protected], [email protected]
    Many thanks
    looking forward to hear from you soon
    Regards
    Madhu Chundu

    Hi,
    I'm also working on the same type of problem, so if anyone has already worked or have an idea of how it works or does, please mail me the details to my mail-id: [email protected]
    Thanks In Advance,
    Rajanikanth Joshi

Maybe you are looking for

  • IPOD - Continuous play

    I was given an older 40gb IPOD with lots of music. I bought an IHome clock radio to play the music. Problem: The IPOD will only play the song I selected before I put it into the Ihome cradle and when the song is finished it does not advance to the ne

  • ORDER BY for alphanumeric

    I need an 'ORDER BY' that sorts this format ABC-1001 ABC-200 so that it sorts like this: ABC-200 ABC-1001 Here's a script that works:   SELECT ItemNumber,   (SELECT SUBSTRING(Items.[ItemNumber],1,CHARINDEX('-',Items.[ItemNumber],1)-1 ))  as ItemNumbe

  • HT1338 What's the software update code

    whats the code to download IOS 7.1.2 software

  • Thread safety bug in XPS Serializer or FixedDocument sequence? "calling thread cannot access this object..."

    Every once in a while (500 iterations or more) I'm getting an exception in the static method below stating "calling thread cannot access this object because a different thread owns it".  Thing is, this method references no external objects and perfor

  • Folder of application builder(*.exe) with run-time DLL

    My application consists of main.vi, subvi folder, and example folder. In addition, I have to add the run-time libraries for add-on tool kit (advanced signal processing, lvwa.dll) which should be located in the root folder. (For exe application, can I