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.

Similar Messages

  • Unable to play RTP packets

    I am developing a J2ME Voip Client,
    For testing purposes I am using a soft phone(Zoiper) on the other end.
    I am able to receive RTP packets,encoded using G711-PCMA from the Soft phone in my J2ME client and I am able to extract useful data like payload type,SSRC etc.
    But I am unable to play the RTP payload.I tried in WTK ,S60 emulator and N80
    Here is part of the code.
    RTPPacket rtpPacket = getRTPPacket(dg, dg.getData());
    buffer = rtpPacket.getData();
    form.append(rtpPacket + " with media length: " + buffer.length);
    ByteArrayInputStream input1 = new ByteArrayInputStream(buffer);
    form.append("\n Receiving RTP Packets...");
    try {
    form.append("\n Trying to create player...");
    player= Manager.createPlayer(input1,"audio/x-wav");
    form.append("\n Player created");
    player.prefetch();
    player.realize();
    player.start();
    form.append("\n Player started");
    form.append("Player duration:"+player.getDuration());
    } catch(Exception e) {
    e.printStackTrace();
    Thanks in advance.
    Ramya

    I am developing a J2ME Voip Client,
    For testing purposes I am using a soft phone(Zoiper) on the other end.
    I am able to receive RTP packets,encoded using G711-PCMA from the Soft phone in my J2ME client and I am able to extract useful data like payload type,SSRC etc.
    But I am unable to play the RTP payload.I tried in WTK ,S60 emulator and N80
    Here is part of the code.
    RTPPacket rtpPacket = getRTPPacket(dg, dg.getData());
    buffer = rtpPacket.getData();
    form.append(rtpPacket + " with media length: " + buffer.length);
    ByteArrayInputStream input1 = new ByteArrayInputStream(buffer);
    form.append("\n Receiving RTP Packets...");
    try {
    form.append("\n Trying to create player...");
    player= Manager.createPlayer(input1,"audio/x-wav");
    form.append("\n Player created");
    player.prefetch();
    player.realize();
    player.start();
    form.append("\n Player started");
    form.append("Player duration:"+player.getDuration());
    } catch(Exception e) {
    e.printStackTrace();
    Thanks in advance.
    Ramya

  • HT3775 I have a webpage where I embeded more than 2 quicktime players. I want that at a time , only one player is played. When second player is played the first one should stop. I am using simple EMBED / OBJECT tags to embed the player.

    I have a webpage where I embeded more than 2 quicktime players. Only one player need to play at a time. When second player is played the first one should stop. I am using simple EMBED tags to embed the player.

    I have a webpage where I embeded more than 2 quicktime players. Only one player need to play at a time. When second player is played the first one should stop. I am using simple EMBED tags to embed the player.

  • Using Flash Media player to play files run from a database

    Hello all,
    I have a dynamic webpage which is connected to a MySQL
    database displaying dynamic information stored in a MySQL table.
    One additional field I have added is a 'video' field in which
    the path to a flash video file is displayed.
    I have a number of user (each user corresponds to a row in
    the table) pictures which are stored in a folder, but the paths to
    which are stored in the database.Using Dreamweaver, I can drag the
    dynamic binding onto the image place holder and then it will lift
    the corresponding image from the table, but the flash video player
    doesn't seem to allow me to do this.
    I would like to do something similar for flash videos, but
    I'm not sure how to do it. Whenever I add a flash movie through the
    media player I need to specify the path - which will change
    depending on what entry in the table is being viewed.
    I have created my websites only with dreamweaver and can't
    program which probably explains why I've got no idea what to do.
    Hope I made sense - will gladly clarify or send you my code.
    Any help would be greatly appreciated.
    Thanks
    Adam

    Make sure that your database has the full path and that you
    are tetsing in
    the browser. You won't be able to see anything in DW
    Paul Whitham
    Certified Dreamweaver MX2004 Professional
    Adobe Community Expert - Dreamweaver
    Valleybiz Internet Design
    www.valleybiz.net
    "fool" <[email protected]> wrote in message
    news:eec8i6$9f3$[email protected]..
    > Thanks - I inserted the media player which came with
    Dreamweaver 8 and
    > the
    > following code was generated:
    >
    > <object
    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    > codebase="
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve
    > rsion=8,0,0,0" width="130" height="98"
    id="FLVPlayer">
    > <param name="movie" value="FLVPlayer_Progressive.swf"
    />
    > <param name="salign" value="lt" />
    > <param name="quality" value="high" />
    > <param name="scale" value="noscale" />
    > <param name="FlashVars"
    >
    value="&MM_ComponentVersion=1&skinName=Corona_Skin_1&streamName=videos/naomi3&au
    > toPlay=false&autoRewind=false" />
    > <embed src="FLVPlayer_Progressive.swf"
    >
    flashvars="&MM_ComponentVersion=1&skinName=Corona_Skin_1&streamName=videos/naomi
    > 3&autoPlay=false&autoRewind=false"
    quality="high" scale="noscale"
    > width="130"
    > height="98" name="FLVPlayer" salign="LT"
    > type="application/x-shockwave-flash"
    > pluginspage="
    http://www.macromedia.com/go/getflashplayer"
    />
    > </object>
    >
    > I attempted to replace 'videos/naomi3' (the file is at
    video/naomi.flv)
    > with
    > <?php echo $row_d['video']; ?>(this is the field
    of the sql table in which
    > the
    > location to the flv file is located, but nothing
    happened (no video
    > appeared).
    >
    > The mysql table is set up properly as I can view image
    files which are
    > linked
    > to by paths in the MySQL table so the problem can't be
    that.
    >
    > Thanks
    >

  • HT201840 What is the best Midi player to play Midi files from my Mac to my keyboard?

    I am having trouble outputing midi files from my Mac to my Clavanova keyboard. I am using a an XMIDI 1x1. When I use it on a Windows computers Window Media Players opens and it works just fine. I have also tested it in Midi Studio and it works. I just can't get files to play on my keyboard.

    The deal with syncing contacts is that you either do so through iTunes, with a supported application on your computer, or over-the-air with something like iCloud. You don't do both at the same time. Doing so will create duplicates & a mess. As to whether one is better than the other, that's up to you. Over-the-air keeps everything in sync across all your devices, automatically, but relies on the stability of the iCloud servers. With your computer, requires that you regularly sync, to keep stuff updated, and that you maintain a current backup.

  • What is the best approach to send/recv multiple types of network packets from server/client?

    I am writing two programs (server.vi) and (client.vi).  that communicate with each other over a TCP connection. 
    After the client opens a TCP connection with the server, the server responds with a packet of type "A".  The client sends another packet of type "A" back to the server as an acknowledgement.  At this point the server starts sending a continous stream of packets of type "B" to the client.  And the client starts sending a continous stream of packets with type "C". 
    This means the sending an receiving of packet with types B and C will be in parallel. 
    How should I implement something like this in labview?
    Here is one idea i have and I was hoping someone could either comment or provide a better suggestion.
    1. the server has two while loops
         a. first while loop consists of a TCP read function that receives packets of type "C".
         b. second while loop consists of a TCP write function that sends packets of type "B"
    2. the client has two while loops
        a. first while loop consists of a TCP write function that sends packets of type "C"
         b. second while loop consists of a TCP read function that receives packets of type "B".
    This way we are sending and receiving packets of type "B" and "C" in parallel. 
    Does this make any sense? Is there a more clever / better aproach to doing this?

    Putting the sending and receiving code in separate loops is a reasonable thing to do. You will need a bit of logic to handle a dropped connection, since you will need to pass the new connection information to both loops when the connection is re-established.

  • Problem in receiving packets from the client

    private static boolean isSocketOpen = true;
    public void receivePackets(){
              if (isSocketOpen) {
                   byte[] buffer = new byte[IOBConstant.MSG_SIZE];
                   DatagramPacket packet = getDatagramPacket(buffer, buffer.length);
                   packet.setPort(7000);
                   try {
                   packet.setAddress(InetAddress.getLocalHost());
                             if (udpSerSocket.isConnected()) {
                             System.out.println("inside receive");
                             logger.logDebug("listening on port 7000");
                             udpSerSocket.receive(packet);
                   } catch (IOException ioe) {
                        logger.logError("Error to receive message", ioe);
    The problem is that the receive() method inside the receivePacket() is not working. It is not receiving any packets. If you have any suggestion please let me know.

                   packet.setPort(7000);
                   try {
                   packet.setAddress(InetAddress.getLocalHost());Setting the port number and address on a DatagramPacket you are about to receive into makes no sense. It doesn't do any filtering, if that's what you're expecting. It doesn't do anything at all useful. The IP:port will be overwritten by the sending IP:port when a packet is received.
                             if (udpSerSocket.isConnected()) {Have you connected it?
    >
                             System.out.println("inside receive");Does this display?

  • How to prioritize RTP Packets for VOIP Audio on RV180

    Hi There,
    I'm a relative newbie to more advanced networking but have managed to get our small office IP PBX running over a SIP Trunk. The only real problem we are having is choppy outgoing audio when there is other heavy outgoing traffic on the network.
    My understanding is that I need to set some QoS parameters, which I have played with but it didn't seem to help much. I mostly dealt with allocating bandwidth. I now think I need to somehow prioritize the outgoing RTP packets from our PBX (which runs on a PC on our LAN) to help avoid the choppy audio. My research shows this can maybe be done with something called DSCP 46 and my router does support that -- I'm just a little confused on how to exactly set the configuration.
    Our router is a Cisco rv180w. I'm thinking it should be pretty straightforward, but any guidance would be appreciated (and feel free to let me know if I'm barking up the entirely wrong tree, too!)
    Thanks so much.

    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 use mathscript node in server side with the parameter from the client side

    I tried to develop a server/client system with some algorithms written in matlab. So I included a mathscript node on the server side. The client will send the parameter to the server. According to these parameters, the sever will call the matlab functions to do some computings and then send the results back to the client. The server has to wait for all parameters received before the computings. How do I know this since I only connect the parameter variables to the inputs of mathscript node on the server. The sever cannot know whethere these parameters are the new ones or old ones since the client may send parameters multiple times?

    It seems to me you have two perfectly good options to start with. You could send all possible parameters in a single packet from the client to the server. This could be in the form of a cluster or an array of values. If by server/client you mean you are sending data over the network, then you could flatten this data to string before sending and unflatten it on the other side. Since all parameters come in one packet, you know all the data is valid every time you send data.
    The other option is to send the parameters individually, but include some extra information such as a timestamp or iteration count. The server keeps reading and storing parameter values until a packet arrives with the next timestamp. Alternatively, you could include some information such as an end-of-parameter-list boolean that is sent with every parameter. It would be false until the last parameter packet.
    Give it a thought. There are lots of solutions.
    Jarrod S.
    National Instruments

  • Hi I just updated from Snow Leopard to Mountain Lion. I write DVD's using Final Cut Pro, creating a DVD that plays HD and Standard Definition on one disk. My problem is when I used load the disk on my G5 it would ask if you want High Definition or Standar

    Hi I just updated from Snow Leopard to Mountain Lion.
    I write DVD's using Final Cut Pro, creating a DVD that plays HD and Standard Definition on one disk.
    My problem is when I used load the disk on my G5 it would ask if you want High Definition or Standard Definition, now it just defaults to Standard Definition.(I'm using Apple's DVD Player)
    Can I fix this problem?

    Addendum: I read on a post here (http://forums.macrumors.com/showthread.php?t=420169) about removing some kext files in order to trick OSX into thinking that there were no FireWire ports.
    I followed the instructions and removed from /System/Library/Extensions/ the following files:
    IOFireWireSerialBusProtocolTransport.kext
    IOFireWireAVC.kext
    IOFireWireFamily.kext
    IOFireWireIP.kext
    IOFireWireSBP2.kext
    I restarted and BAM...Snow Leopard booted crazy fast and the mouse and keyboard worked instantly.
    The System Profiler says "No FireWire ports were found."
    So this tells me that the FW port is probably the culprit and is messing up the installation.
    So how do I hack the Mountain Lion installer and tell it to ignore the FW port, which is obviously quite dead? Or is there something I can do to the Base system that is similar?

  • How can I make several videos play from one player much like Presentation widget

    Is there a way to have several videos, in thumbnails, play through one player similar to the manner which Presentation dosplays selections from image thumbnails?
    Greg

    I found the answer.
    http://helpx.adobe.com/muse/tutorials/building-your-first-website-part-4.html#Adding%20a%2 0Lightbox%20Composition%20widgethttp://

  • How to play many assets in one player only ?

    Do I really need to open each asset to play it and view the movie, for example, i got 70 clips on Sony XDCAM, and the clips are short, and i'd like to see all clips in one player, after they had been uploaded to FCServer. Is that possible?
    I'd appreciate
    Tks in advance

    I don`t think that`s possible inside FCSrv, unless you make a Reference Movie from all this clips.
    You could automate a "make reference movie" from a production (that have only those 70 clips inside). But to do this you have to create scripts and configure responses and subscriptions on FCSrv. If you are confortable with this I think it`s a great way.
    If some one has another way of doing this please let US know!
    Regards

  • How can I show album art in the mini player when playing songs from a plugged in iPhone?

    How can I show album art in the mini player when playing songs from a plugged in iPhone?
    When I play from my phone and switch to the mini player it's always showing the music notes in the thumbnaill. It'd be nice if it could get album art off of the phone.
    I'm on iTunes version 11.0.4.4

    He @mracole,
    it is very nice that you post a solution to complete the library with artwork for album's that do not have an artwork. Your solution perfectly addresses the problem for assigning artwork, BUT this thread is about CHANGING artwork for albums already uploaded into iTunes Match. Just try to replace for example a blue artwork cover for an album with a red one. If you made it in a simple way (without deleting the album from iTunes Match and local changes on the files with an external ID3-Application or 2 or more iTunes libraries on different Mac's) this is the right place to give a solution. I really tried for hours to change the artwork to make them visible in landscape cover flow mode on my iPhone5. In rare cases I made it, but then the covers sometimes where restored to the old onces - exacly how it is mentioned by Starhawk
    As long as there is no simple way to change the cover of an iTunes Match stored album (you can change title, artist and so on without hitting "update iTunes Match" over all distributed Library on different devices - this date will be synchronized almost instantly) I considered the behaviour from iTunes as BUGGY! For me the local artwork cache (and if there is any iCloud artwork cache - I don't know) do not interfere with iCloud. Even when I delete the whole local cache (album artwork music - everything) I do not manage to change the artwork.
    Regards from Munich, Germany

  • Creating a Player from an InputStream

    Hi guyz
    I have a media application am writing with an issues on it.
    The application is to receive Byte chucks containing media content with a content type String from a network via RMI
    Is there any samples code for creating a player from an InputStream in JMF? Something to do with a java.io.ByteArrayInputStreamAt the moment am forced to write the byte chucks to a temporary file then pass the file to JMF which is working OK, byte i belive the must be a better way to Override the temp file.
    I believe this is possible since sun provides the same for J2ME javax.microedition.medi.Manager.createPlayer(java.io.InputStream stream,  java.lang.String type) of which the MIDlet version of my application processes the same quite fine.
    If not i have tried to implement my own DataSource for known media formats after i checked out this thread http://forums.sun.com/thread.jspa?threadID=5264968 but kept me stack for some days so i decided to come out here and look for some help. Ad really appreciate some feedback.
    Thanks in advance.

    Well i have a small glitch that i don't quit understand don know whether to ask here or no or it should be on a new thread. but her goes.
    I am under Mandriva2008.1 with JMF performance pack installed on my classpath. i register jffmpeg plugin on the fly and can play most of the video and audio files supported by jffmpeg though not in so good of the quality but in just works 4me since am only using it for preveiw purposes.
    The problem is that i used mencoder mencoder vcd://02 -vf scale=640:272 -o track02.mpg -oac copy -ovc lavc -lavcopts vcodec=mpeg4 from the console to convert some VCD files to mpeg4 but the JVM just crashes when i try to open the files. After i look at the crash log it is related to some native libraries C  [libjmmpx.so+0x14b54].
    Wonder whether is the mencoder issue i.e am using the wrong mencoder args or is it that JMF is loading the wrong decoder for the mpeg4 codec?

  • Creating one file per each 50 Mb of data received from PI

    Hi Experts,
    I have a scenario JMS to FIle.I have to create separate files for each maximum of 50MB received by SAP PI.
    For example if PI receive 160 MB data then i have to create 4 files i.e 1st file with 50 MB file data ,2nd file with 50 MB file data ,3rd file with 50 MB file data and 4th file with 10 MB file data. How to acheive this any suggestion.
    Regards
    Deepak

    Hi Deepak,
    Following logic can be applied if and only if the data that you are receiving from JMS is binary one(not a structured). In that case, you can break your large binary data file into small small packets of any size.
    In SAP PI 7.30/7.31 this fuctionality is available in the File sender and receiver channel. You can directly use it if you are working on the PI 7.30/7.31.
    If you are not using 7.30/7.31 then you need to write a adapter module which does same functionality. Logic is simple:
    Step 1: Get the XI message payload and convert it into binaryStream object.
    Step2: find the length of binaryStream and then calculate the no.of packets that you want to create by dividing binaryStream size with packet's size that you want. eg. if main payload size is 160 MB and packet's size is 50 MB and no.of packets = 160/50 =3.2 round off to 3.
    Step 3: Divide the large file size 4 times with given packet size and put remaining data into last packet.
    Step5: change all the small binaryStream packet into Files and store them into target directory.
    Best Regards,
    RK

Maybe you are looking for

  • Opening an Application on Current Desktop

    So I've tried digging around on my Mac to see if I could figure it out myself, but there didn't seem to be a way to do it, so I'm curious if anybody has an answer. Usually, I have a lot of desktops open, with one application open on each one so it's

  • Event Handler/Cr​eate User Event bug

    This is a problem I've run into a few times on my system (Win2k) so I finally went back and reproduced it step by step since it wasn't too hard. It causes LabVIEW to crash and exit without saving. - Create an Event Handler - Place 'Register Events',

  • White box around text in Windows-based PDFs viewed on Mac

    I make a lot of Microsoft Word-based PDFs that include colored, text-filled tables. They look great when viewed on my machine, but Mac users see a faint white outline around the text in each cell of the table. How do I get rid of the white box?

  • Dvd burn only creates data disc

    recently I succesfully created an SD DVD which I first built and then formatted to a DVD. this disc played perfectly in my dvd player. after this success I went ahead and created a new DVD but this time with HD footage (I changed the settings to HD i

  • E71 shortcut key not working

    Hi, The shortcut key on the upper left corner of the panel (shorcut for camera by defualt) stopped working. I tried resetting the shorcuts, formatting the phone also. But none helps. awaiting response. Thanks Prons.