Please, help with Live Audio/Video example from jmf solutions

Hello,
I�m desperate looking for a solution for a particular problem.
I�m trying to feed JMF with an AudioInputStream generated via Java Sound, so that I can send it via RTP. The problem is that I don�t know how to properly create a DataSource from an InputStream. I know the example Live Audio/Video Data from the jmf solutions focuses on something similar.
The problem is that I don�t know exactly how it works, os, the question is, how can I modify that example in order to use it and try to create a proper DataSource from the AudioInputStream, and then try to send it via RTP?
I think that I manage to create a DataSource and pass it to the class AVTransmit2 from the jmf examples, and from that DataSource create a processor, which creates successfully, and then find a corresponding format and try to send it, but when i try to send it or play it I get garbage sound, so I�m not really sure whether I create the DataSource correctly or not, as I�ve made some changes on the Live Audio/Video Data from the jmf solutions to construct a livestream from the audioinputstream. Actually, I don�t understand where in the code does it construct the DataSource from the livestream, from an inputStream, because there�s not constructor like this DataSource(InputStream) neither nothing similar.
Please help me as I�m getting very stuck with this, I would really appreciate your help,
thanks for your time, bye.

import javax.media.*;
import javax.media.format.*;
import javax.media.protocol.*;
import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
public class LiveAudioStream implements PushBufferStream, Runnable {
    protected ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW);
    protected int maxDataLength;
    protected int vez = 0;
    protected AudioInputStream data;
    public AudioInputStream audioStream;
    protected byte[] audioBuffer;
    protected javax.media.format.AudioFormat audioFormat;
    protected boolean started;
    protected Thread thread;
    protected float frameRate = 20f;
    protected BufferTransferHandler transferHandler;
    protected Control [] controls = new Control[0];
    public LiveAudioStream(byte[] audioBuf) {
         audioBuffer = audioBuf;
                  audioFormat = new AudioFormat(AudioFormat.ULAW,
                      8000.0,
                      8,
                      1,
                      Format.NOT_SPECIFIED,
                      AudioFormat.SIGNED,
                      8,
                      Format.NOT_SPECIFIED,
                      Format.byteArray);
                  maxDataLength = 40764;
                  thread = new Thread(this);
     * SourceStream
    public ContentDescriptor getContentDescriptor() {
     return cd;
    public long getContentLength() {
     return LENGTH_UNKNOWN;
    public boolean endOfStream() {
     return false;
     * PushBufferStream
    int seqNo = 0;
    double freq = 2.0;
    public Format getFormat() {
         return audioFormat;
    public void read(Buffer buffer) throws IOException {
     synchronized (this) {
         Object outdata = buffer.getData();
         if (outdata == null || !(outdata.getClass() == Format.byteArray) ||
          ((byte[])outdata).length < maxDataLength) {
          outdata = new byte[maxDataLength];
          buffer.setData(audioBuffer);          
          buffer.setFormat( audioFormat );
          buffer.setTimeStamp( 1000000000 / 8 );
         buffer.setSequenceNumber( seqNo );
         buffer.setLength(maxDataLength);
         buffer.setFlags(0);
         buffer.setHeader( null );
         seqNo++;
    public void setTransferHandler(BufferTransferHandler transferHandler) {
     synchronized (this) {
         this.transferHandler = transferHandler;
         notifyAll();
    void start(boolean started) {
     synchronized ( this ) {
         this.started = started;
         if (started && !thread.isAlive()) {
          thread = new Thread(this);
          thread.start();
         notifyAll();
     * Runnable
    public void run() {
     while (started) {
         synchronized (this) {
          while (transferHandler == null && started) {
              try {
               wait(1000);
              } catch (InterruptedException ie) {
          } // while
         if (started && transferHandler != null) {
          transferHandler.transferData(this);
          try {
              Thread.currentThread().sleep( 10 );
          } catch (InterruptedException ise) {
     } // while (started)
    } // run
    // Controls
    public Object [] getControls() {
     return controls;
    public Object getControl(String controlType) {
       try {
          Class  cls = Class.forName(controlType);
          Object cs[] = getControls();
          for (int i = 0; i < cs.length; i++) {
             if (cls.isInstance(cs))
return cs[i];
return null;
} catch (Exception e) {   // no such controlType or such control
return null;
and the other one, the DataSource,
import javax.media.Time;
import javax.media.protocol.*;
import java.io.IOException;
import java.io.InputStream;
import javax.sound.sampled.AudioInputStream;
public class CustomDataSource extends PushBufferDataSource {
    protected Object [] controls = new Object[0];
    protected boolean started = false;
    protected String contentType = "raw";
    protected boolean connected = false;
    protected Time duration = DURATION_UNKNOWN;
    protected LiveAudioStream [] streams = null;
    protected LiveAudioStream stream = null;
    public CustomDataSource(LiveAudioStream ls) {
         streams = new LiveAudioStream[1];
         stream = streams[0]= ls;
    public String getContentType() {
     if (!connected){
            System.err.println("Error: DataSource not connected");
            return null;
     return contentType;
    public byte[] getData() {
         return stream.audioBuffer;
    public void connect() throws IOException {
      if (connected)
            return;
      connected = true;
    public void disconnect() {
     try {
            if (started)
                stop();
        } catch (IOException e) {}
     connected = false;
    public void start() throws IOException {
     // we need to throw error if connect() has not been called
        if (!connected)
            throw new java.lang.Error("DataSource must be connected before it can be started");
        if (started)
            return;
     started = true;
     stream.start(true);
    public void stop() throws IOException {
     if ((!connected) || (!started))
         return;
     started = false;
     stream.start(false);
    public Object [] getControls() {
     return controls;
    public Object getControl(String controlType) {
       try {
          Class  cls = Class.forName(controlType);
          Object cs[] = getControls();
          for (int i = 0; i < cs.length; i++) {
             if (cls.isInstance(cs))
return cs[i];
return null;
} catch (Exception e) {   // no such controlType or such control
return null;
public Time getDuration() {
     return duration;
public PushBufferStream [] getStreams() {
     return streams;
hope this helps

Similar Messages

  • HT1296 Please Help with problem syncing Safari bookmarks from iPhone to MacBook

    i have an iPhone 5 (7 software) & Macbook Pro 10.9.1.  I have iCloud set to sync Safari in both.  I want the bookmarks on my iPhone to sync onto/be shared with my Macbook but this is not happening.  (I also have an iPad and the Safari bookmarks are automatically syncing from iPhone to iPad)
    Please help!
    Tx
    Pamela

    Hi goddessinrepose!
    Here is an article for you that will help you troubleshoot this issue with your ability to sync your iCloud bookmarks:
    iCloud: Troubleshooting iCloud Bookmarks and Reading List
    http://support.apple.com/kb/ts4001
    Thanks for being a part of the Apple Support Communities!
    Cheers,
    Braden

  • Help to execute AvTransmit and AVRecieve examples from JMF solution page

    hi, all. i want to use the AVTransmit and AVRecieve classess from the JMF solutions page to transmit voice from one computer to another.
    Please how can i specify the source locator to be the microphone connected to my PC. please help i want to implement a voive chat.
    If u have any links that could help me on my voice chat project, i'l appreciate it if u could help me with it.
    Thanks

    Hi
    I think this will be useful for you..
    http://java.sun.com/products/java-media/jmf/2.1.1/solutions/AVTransmit.html#howto
    To Transmit video use - "vfw://0" , to Transmit audio use - "javasound:/0/8000" - instead of "file:/avmedia.mov"
    Karthikeyan R

  • Please help with nested audio plug-ins

    I have built three sequences with audio mixer settings for each (compression, EQ, etc...).  I nest these individually and want to organize them in a "final output" sequence.  As the three sequences are placed in the "final output" sequence, all video clip references work fine, but the audio mixer settings do not follow the audio clips to the "final output" audio.
    How can I get the individual sequence audio plug-ins to follow the audio to the final output audio?
    I have rendered work area, rendered audio, and linked audio to video clips, still I am missing something...
    thanks for your help!!!
    Paul

    these sequences as built
    sequence A : Audio 1 (compression at 10)
    sequence B : Audio 2 (compression at 15)
    when nested, should become:
    Master sequence: {Nested  sequence A : Audio 1 (compression at 10)}  ,  {Nested sequence B : Audio 2 (compression at 15)} .
    but the compression settings do not come through at all.
    Ideally, I would be able to use the audio settings from individual sequences as built, then the program would feed them (as built) to a master output just like the video clips...but for some reason voiceover compression from sequence A (which is different from sequence B) is not applying to the output of the master sequence at all...
    as it exsists now, I would have to rebuild all of my audio on the master sequence because any audio mixer changes are not carrying through...
    I must be missing something...
    thanks,
    Paul

  • Help with an audio file - vows from a wedding.

    Evening all,
    My wife and I filmed a wedding yesterday and our wireless mic which was hooked up to the groom's lapel decided to cut out literally seconds before he spoke his vows. When I got the mic back from him, everything was soaked, literally dripping and also extremely warm. He couldnt explain why it was so wet, sweat he said. Unfortunately we lost our crystal clear version of the vows and have to work with a secondary version. We had two other cameras going as well as our primary. My wife had a Rode Shotgun mic on her camera and picked up the groom and brides vows, but you can hear the constant hum of the mic. I have dumped the file onto FileSnack and have provided the link to check out. Is there anything we can do to make this sound better, as well as perhaps bring up the audio from the bride and groom.
    http://snk.to/f-ct9yxq4s
    Hope one of you audio engineering savants can help out! Thank you very much in advance!
    Sincerely,
    L+J Films

    I've had a little play and Steve's right that there's no miracles to be had.  However, have a play with Audition's EQ section and try taking down the level between 3k and 4k.  That gives you a slightly boxy sounding voice but also cuts some of the clicky sound--it's a balancing act to decide how much EQ you want.  FYI, I tried both the 31 band graphic with 3.2k pulled down a lot and 4k somewhat down.  I also played with the parametric with a fairly steep Q centred around 3.7k.  I think the parametric will eventually do the better job but ran out of time when a paying job turned up.
    A bit of high and low cut would probably help as well and maybe some slight boost in the 250-800 range to help the intelligibility.
    Anyhow, hope this helps.
    Now, a tip for "next time".  Sweat outs are common in theatre where we often hide mics in the hairline.  If if have any inkling of an impending problem, spray a small section of an old pair of ladies stockings or panty hose with Scotchguard, cut out a small circle and stretch it over the mic capsule--a rubber band can hold it tight.  Similarly, putting the TX pack in an unlubricated condom or a ziplock bag with only then antenna peaking out protects that end.

  • Please help with creating a summary report from data collected in a fillable PDF form.

    I'm sure this has been asked before so I apologize in advance - I'm new to this forum and I'm not quite sure of which section I should be in. If I may just describe a certain scenario of something I am trying to create - could you please point me in the right direction?
    I'm looking to create a summary report/form to help me better organize my patients after each appointment. So data collected from other fillable forms I've created, will lead to the final page to print that will include selections from fillable text boxes or drop down lists, etc to basically summarize each encounter. It should go something like this:
    FORM 1:
    -pt chart #
    -pg age
    -purpose for visit
    -date of visit
    -diagnosis
    -prognosis
    -etc
    SUMMARY page
    On (-date of visit), patient (-pt chart #) arrived with complaint of (-purpose for visit)....
    The diagnosis was determined to be (-diagnosis), treatment to be performed is suggested to be (-treatment) with a (-prognosis) prognosis. Treatment was (accepted or not) and completed on... etc. etc... you get the idea
    Does anyone know how I can do this?
    Thank you all for your time and advice!

    I have downloaded Castor and got some good tutorials, but.......
    There is a problem, when I try to use the Marshaller to get an XML document the following error is reported:
    java.lang.NoClassDefFoundError: org/apache/xml/serialize/XMLSerializer
    I have scanned the Internet looking for a solution, some recommend including Xecers in the Classpath. I downloaded Xerces 2.7.1 and added it to as instructed but this did not work.
    Hope you can help

  • Please help with m-audio mobile pre driver not connecting with garageband08

    hey i just updated my powerbook G4 with leopard and lost my m-audio (mobile pre) driver in system preferences so i downloaded it b/c i don't have my original disc, the downloaded version shows in my system preferences now but won't appear in the garageband preferences audio/midi input, my only choices are built in mono/sterio. any ideas? besides finding the disc? i'd really appreciate any help as my band is trying to record a cd.

    Yeah, the Mobile Pre is not going to work on Leopard until M-Audio updates their drivers, unfortunately.
    There is one workaround that I've gotten to work, but it probably won't work for most folks. If you have two partitions on your system, one with Leopard and one with Tiger, you can get the mobile pre to work in Leopard. It's a bit odd, but it does work.
    First, boot into you Tiger partition that has the Mobile Pre drivers installed and verify that the system sees and can use the Mobile Pre.
    Now, boot into Leopard. Your Leopard system should now see the Mobile Pre and you should be able to use it until you have to reboot the Leopard system.
    If you have an external HD with Tiger installed, you might also be able to get this to work w/out having to repartition your system. Just install Tiger on the external HD, boot from it, then install the Mobile Pre drivers.
    Hope this helps and possibly provides some temporary relief until M-Audio updates their drivers....

  • Please help with how to copy CS3 from iMac (Snow Leopard) to MacBook Air (Mavericks)

    I have a 2006 Mac Desktop computer with the CS3 suite on it.  I still have the discs for the suite and would like to move it over to my macbook air.  I tried to just copy the Photoshop file, but that didn't work. Is there an easy way to migrate these files from one mac to another?  My MacBook Air does not have a DVD drive. Ideally, I would like to have these files on both computers, as I believe you can have your purchased programs on 2 computers.  Anyone have a a quick and easy way to make this happen?

    Never, ever migrate. CS installs are "Machine specific", you break licensing doing that.
    Go here: Download CS3 products and download the installer for your suite onto your new Mac.
    Gene

  • Please help with executing a java program from another java program

    Hi, I have tried to execute a very simple java program which is printed out "Hello world" from another java gui program when the user click on the "START" button. However, I don't receive any print out on the terminal when they click it. These two programs are being developed in Unix environment. Here is the code that I am trying to use.
    Runtime r = Runtime.getRuntime();
    r.exec("java HelloWorld");
    p.s. HelloWorld is java class of the HelloWorld.java

    I think you have to luanch your MS Prompt first before executing the command.

  • Problem with running example 'Generating Live Audio/Video Data'

    Hello,
    Concerning the example 'Generating Live Audio/Video Data', I'm having trouble with the run instructions.
    http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/LiveData.html
    How does JMFRegistry know about the location of jmfsample?
    How is 'live' resolved as a URL?
    2.Register the package prefix for the new data source using JMFRegistry
    - Run JMFRegistry
    - In the Protocol Prefix List section add "jmfsample" and hit Commit.
    4.Select File->Open URL and enter "live:"
    Much thanks,
    Ben

    I'm getting the following error message: "Could not create player for live"Implies you've either not registered the "live:" protocol prefix in the JMF Registry, or, it couldn't load the class you registered for it...or it might be erroring out inside the actual live protocol, I'm not sure what that would look like, but a System.err.println statement in the constructor of both of those classes might be a good idea.
    I added the output of javac (DataSource.class and LiveStream.class) to a directory on the classpath.
    C:\Program Files\JMF2.1.1e\lib\jmfsample\media\protocol\liveEh, that looks a little questionable to me. I'm not 100% sure that the JRE will automaticlly descend into the package subdirectories like that, looking for classfiles, for every folder on the path. I am, of course, fully open to the idea that it does and I just never thought about it...but I guess I just thought it only did that for JAR files, not CLASS files. Regardless, I'd recommend:
    1) Make sure you've registered the protocol prefix "live:" correctly in JMF Registry
    2) Try to run it with the 2 compiled class files in the same folder as your project
    3) Try to run it with the 2 compiled class files in the lib directory, if that's on the classpath
    4) Try to run it with the 2 compiled class files installed in the JRE as an extension (google for how to do this because I don't remember off the top of my head)
    5) Reinstall JMF and see if that helps

  • HT5824 I switched over from an iPhone to a Samsung Galaxy S3 & I haven't been able to receive any text messages from iPhones. Please help with turning my iMessage completely off..

    I switched over from an iPhone to a Samsung Galaxy S3 & I haven't been able to receive any text messages from iPhones. I have no problem sending the text messages but I'm not receivng any from iPhones at all. It has been about a week now that I'm having this problem. I've already tried fixing it myself and I also went into the sprint store, they tried everything as well. My last option was to contact Apple directly. Please help with turning my iMessage completely off so that I can receive my texts.

    If you registered your iPhone with Apple using a support profile, try going to https://supportprofile.apple.com/MySupportProfile.do and unregistering it.  Also, try changing the password associated with the Apple ID that you were using for iMessage.

  • Hi, please help with the installation of Lightroom 4, I bought a new Mac (Apple) and I want to install a software that I have on the album cd. My new computer does not have the drives. Can I download software from Adobe? Is my license number just to be ab

    Hi, please help with the installation of Lightroom 4, I bought a new Mac (Apple) and I want to install a software that I have on the album cd. My new computer does not have the drives. Can I download software from Adobe? Is my license number just to be able to download the srtony adobe.

    Adobe - Lightroom : For Macintosh
    Hal

  • TS1627 Please Help. I received 4 emails from 1 person with the same message heading. The emails were automatically grouped by Mail. I replied to the latest mail in the conversation. Once sent the other messages in the conversation disappeared. I NEED THEM

    Please Help. I received 4 emails from 1 person with the same message heading. The emails were automatically grouped Apple Mail. I replied to the latest mail in the conversation. Once sent the other messages in the conversation disappeared. I NEED THEM BACK! They all had very important attachments. I have tried looking for them in deleted items, even though I didn't throw any of them away, still cant find them. Never had this problem before. I'm pretty sure its a setting somewhere. Also tried expanding all conversations, no luck. Searching for the mails under the sent email address, no luck.
    I'm sure they are not deleted but have somehow been hidden by Mail. Very frustrating.
    Thanks in advance for any help.
    Kash.

    I have found found out what has happened. I had requested a statement dating back to April 2012 from a supplier. They replied back with the latest statementof 2013 only but used the same subject heading as the previous monthly statements. Apple Mail automatically grouped these and I thought that they were sent altogether. As soon as I replied to the last email all other the previous emails ungrouped from the conversation leaving me lost as to where they had gone. They were all still sitting in my inbox but no longer part of the trcked conversation. I searched under the subject heading and all individual mails were all still there. (feeling stupid - )

  • Please help with slideshow problems!

    Am using Photoshop Elements 8 and trying to make a slideshow. Have tried 4 times now and keep ending up with same problem, cannot reopen project to continue edititing.  Won't show up in orginizer and when I find on harddrive and try to open get message " wmv file cannot be opened".  How can I save a
    slideshow inprogress and be able to reopen and continue to edit and make slideshow?  I want to thank anyone who can help me with this in advance as I
    have gotten so frustrated that I want to just scream.
    Thanks

    Thanks for the help, thought I had done so but maybe not.  Anyway will have another go at it, now may I ask another
    question?  I am trying to add audio to slideshow.  I have some music I purchased thru amazon as mp3 files but I get
    message no codec and when I try to add wmv I get same message.  What type of file do I need and how can I add
    multiple songs to one slideshow.   I have one little wmv file that will go in, but it just replicates itself multiple times until
    it fills slide show. 
    Thanks again, sorry to be a bother, but this thing is driving this old man crazy.
    Date: Sun, 26 Dec 2010 20:34:32 -0700
    From: [email protected]
    To: [email protected]
    Subject: Please help with slideshow problems!
    You need to save the slideshow project in order to be able to go back later and make changes or additions to an existing slideshow . The wmv file is a final output format.
    Now you are most probably using only the Output command: that is what makes the wmv file.
    You should also do the Save Project command. (and I make it a practice to do the Save Project command before I do the Output command).
    If you look at the Elements Organizer 8 Help, there is a topic on "Create a slide show".
    -- Very close to the beginning of that topic is a screen shot of the Sldie Show Editor screen,
    -- The bar below the usual menu bar is labeled with a "B" and called the Shortcuts bar.
    -- The 1st entry on that Shortcuts bar is "Save Project"
    It is the Save Project command that saves the information about which photos, audio, etc you placed in that specific slide show so that you can come back again to do subsequent editing.  Save each Project with a unique name.
    After completing the Save Project command, you shoud see an "icon" in the Organizer for that slide show.
    Note:  you must also keep the photo files and audio files which you have used in this slide show: you can't delete them because the project file does NOT contain a copy of the photos, it only has the identification and folder location of the photo and audio files.
    >

  • How can I sync my iPhone on a different computer without erasing my applications? My iPhone was earlier synced with a PC which I don't use anymore. Please help with proper steps, if any.

    How can I sync my iPhone on a different computer without erasing my applications? My iPhone was earlier synced with a PC which I don't use anymore.
    On the new computer, I am getting a message that my all purchases would be deleted if I sync it with new iTunes library.
    Please help with proper steps, if any.

    Also see... these 2 Links...
    Recovering your iTunes library from your iPod or iOS device
    https://discussions.apple.com/docs/DOC-3991
    Syncing to a New Computer...
    https://discussions.apple.com/docs/DOC-3141

Maybe you are looking for

  • Syncing with Day-Timer

    I've been using Day-Timer Organizer as my address book/calendar for many years. Under Windows XP, it syncs perfectly with my Tungsten T5 over the cable. I have needed to replace my XP machine with a Windows 7 computer, and have run into an obstacle.

  • Is it possible to independently manipulate a snapped handle of a corner anchor point?

    I stopped reading what's new since many versions and simply learn the new stuff when I need to or by discovery so, today I had to create various vector shapes and I got very annoyed that I can't pull a snapped handle of a corner point back and manipu

  • Process Transaction Interface

    Dear All I am not able to find this concurrent program in inventory module. Previously this program was schedule i cancelled the schedule program but now when i am trying to find i am not able to. Regards Arifuddin

  • Can I use Power BI capabilities in iPad with Office 365

    Hello, Can I use power BI features in office 365 as native app in ipad ? if this is not possible what are the other options we have to use power BI features in ipad ? Thanks in advance.

  • Ovi Suite will still not update - "Install packet ...

    First the update does not want to install due to a bad signature, now I am now receiving the error "Internal error"  "Install packet ID not sent" can someone at Nokia please fix the update errors so that we can update Ovi suite? Surely it is not too