Cloning of datasource

hi,
i am using cloning of datasource for receiveing multiple instances of same player.
i am able to get multiple instances but the problem is when i generate new clone the all other players stop playing audio and video.
only the new cloned player is working. All other do not generate any new frame. They go to InactiveReceiveStreamEvent. Why is this happening ??
Edited by: 914586 on Mar 14, 2012 11:55 AM

Yesterday i have got this same problem and finally i found solution.
Try to do this:
1. Create cloneable DataSource:
ds = Manager.createDataSource(m);
ds = Manager.createCloneableDataSource(ds);2. Just start transmission using this DataSource ds (do not create clone yet!)
3. When transmission will start create clone of ds and use it for your player:
clone= ((SourceCloneable)cd).createClone();It works fine for me.

Similar Messages

  • Problem with cloning a DataSource

    Hello!!
    I have cloned a DataSource and used the cloned DataSource(not the original DataSource which i used for cloning) for transmitting via RTP. I don get any exception or any error but the audio isn't getting transmitted.
    (I tried receiving the transmitted audio stream using JMF.. But JMF doesn't detect any)
    However when i use the DataSource(which i used for cloning) it worked..
    dl=CaptureDeviceManager.getDeviceList(new AudioFormat(AudioFormat.LINEAR));
    ml=((CaptureDeviceInfo)dl.firstElement()).getLocator();
    +staticsource=Manager.createCloneableDataSource(Manager.createDataSource(ml));             //staticsource has been declared as static and i tried to clone it to produce new DataSources whenever i need+
    source=((SourceCloneable)staticsource).createClone();
    +p=Manager.createProcessor(source);           
    // I tried using staticsource and it worked but i need to get it right using the cloned one..+
    I think i have explained my problem pretty clearly.. Sorry if i din..
    Thanks!!
    Edited by: s.baalajee on Jun 2, 2009 9:08 AM

    Thanks for the help sir.. I read a previous post of yours which helped me to track down the mistake.. It was a small mistake in my logic.. I had not used the DataSource I used for cloning to create the processor(which means I din use it)..
    When I used that also to create processor the clones produced from that DataSource worked.. I have posted the modified code below..
    Edited by: s.baalajee on Jun 3, 2009 11:02 PM
    /*This program is to capture audio and send it to another system*/
    //package AudioChat;
    import java.awt.*;
    import java.net.*;
    import javax.media.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.media.format.*;
    import javax.media.protocol.*;
    import javax.media.control.*;
    import java.util.*;
    public class ATransmit extends JDialog implements ControllerListener
         Processor p=null;
         DataSink sink;
         MediaLocator ml;
         static DataSource staticsource=null;     
         DataSource source;          
         String cip,cun;
         Panel panel;
         int port;
         static boolean audioinuse;
         //     audioinuse will be false for the first time only
         public ATransmit(String c,JFrame f,MediaLocator medialocator,int po,String un,boolean audio)
              super(f,"Audio Chat "+un);
              cip=c;cun=un;
              port=po;
              audioinuse=audio;
              System.out.println("CIP :"+cip);
              setVisible(true);
              setBounds(600,50,300,75);
              setResizable(false);
              setLayout(new GridLayout(1,1));
              panel=new Panel();
              panel.setBackground(Color.BLACK);
              panel.setLayout(new BorderLayout());
              add(panel);
              addWindowListener(new WindowAdapter()
                   public void windowClosing(WindowEvent we)
                        stopEverything();     //     stops the DataSink and the Processor
              setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    // For the first time alone I create the DataSource(staticsource) from the MediaLocator and use it to create the processor
    //For the subsequent times I create Clones of staticsource and use it to create the Processor
              try
                   if(!audioinuse)
                        System.out.println("Initializing all components");
                        ml=medialocator;
                        Manager.setHint(Manager.LIGHTWEIGHT_RENDERER,true);
                        staticsource=Manager.createCloneableDataSource(Manager.createDataSource(ml));
                        p=Manager.createProcessor(staticsource);          
                   else
                        source=((SourceCloneable)staticsource).createClone();
                        p=Manager.createProcessor(source);     
                   p.addControllerListener(this);
                   p.configure();
                   Thread.sleep(500);
                   p.setContentDescriptor(new ContentDescriptor(ContentDescriptor.RAW_RTP));
                   if(encode(p))
                        p.realize();
                   else
                        System.out.println(“Encoding failed”);
                   Thread.sleep(500);
              catch (Exception e)
                   System.err.println("Got exception "+e);
         public boolean encode(Processor p)
              TrackControl track[] = p.getTrackControls();
              boolean encodingOk = false;
              for (int i = 0; i < track.length; i++)
                   if (!encodingOk && track[i] instanceof FormatControl)
                        if (((FormatControl)track).setFormat( new AudioFormat(AudioFormat.DVI_RTP)) == null)
                             track[i].setEnabled(false);
                        else
                             encodingOk = true;
                   else
                        track[i].setEnabled(false);
              return encodingOk;
         public synchronized void controllerUpdate(ControllerEvent ce)
              try
                   if (ce instanceof RealizeCompleteEvent)
                        Component comp;
                        System.out.println("Realized");     
                        sink=Manager.createDataSink(p.getDataOutput(), new MediaLocator("rtp://"+cip+":"+(15000+port)+"/audio"));
                        if ((comp=p.getControlPanelComponent()) != null)
                             panel.add(BorderLayout.SOUTH,comp);
                        startEverything();     //     start the DataSink and the Processor
                        validate();
                        System.out.println("Updated");
              catch(Exception e)
                   System.out.println("Exception rasied "+e);
         void startEverything()
              try
                   sink.open();sink.start();
                   p.start();
              catch(Exception e)
                   System.out.println("Got Exception :"+e);
         void stopEverything()
              try
                   if(p!=null)
                        p.stop();
                   if(sink!=null)
                        sink.stop();
                        sink.close();
                   if(p!=null)
                        p.deallocate();
                        p.close();
              catch(Exception e)
                   System.out.println("Got Exception :"+e);
         public static void main(String s[])
              Vector dl;
              MediaLocator ml;
              JFrame frame=new JFrame();
              frame.setBounds(400,400,400,400);
              frame.setVisible(true);
              dl=CaptureDeviceManager.getDeviceList(new AudioFormat(AudioFormat.LINEAR));     
              ml=((CaptureDeviceInfo)dl.firstElement()).getLocator();
              new ATransmit("192.192.175.64",frame,ml,0,"s.baalajee",false);               //Note the last argument is false
              new ATransmit("192.192.175.64",frame,ml,100,"s.baalajee",true);     
              new ATransmit("192.192.175.64",frame,ml,200,"s.baalajee",true);     
              new ATransmit("192.192.175.64",frame,ml,300,"s.baalajee",true);     
    Edited by: s.baalajee on Jun 3, 2009 11:04 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Cloning RTP DataSource

    I'm having difficulty making the Clone.java example (from JMF Solutions) clone an RTP transmission. The Clone program works fine with a video file, but when I attempt this:
    java Clone rtp://localhost:550/video 2
    where I have an RTP transmission from JMStudio on port 550, it complains:
    create player for: rtp
    Failed to create a player from the given DataSource: javax.media.NoPlayerException: Cannot find a Player for: com.ibm.media.protocol.CloneablePushBufferDataSour
    ce@551f60
    I must be missing something, and I'd be very appreciative for any pointers.
    Cheers,
    Frank

    You can see JMF guide. There're some helpful examples.
    Also, I have some problems when capture a RTP session to a file while playing it concurrently. I cloned the datatsource and use one for playing , one for capturing but the playback quality is very bad.
    What I have to do.

  • Cloning DataSource for web cam

    I'm transmitting live video from a web cam over the network and storing the video to a QuickTime file at the same time. From my experience, this requires cloning a DataSource.
    Is it more efficient to clone the DataSource that is coming directly from the web cam and feed those cloned DataSources to separate Processors for RTP transmission and file storage,
    OR
    is it more efficient to clone the OUTPUT DataSource from a single Processor and use the output cloned DataSources for sending to file, etc. ?
    Thanks,
    Frank

    Cloning the input DataSource is one method that works. See "Video Capture Utility with Monitoring" in the JMF Solutions page for 3 other methods that could be employed that produce better quality.
    http://java.sun.com/products/java-media/jmf/2.1.1/solutions/JVidCap.html

  • How to get the codecobject wich is used by a precessor in the moment

    Hi there
    is it possible to get the the instance of the used codecclass, which was instantiated by JMF? I want to start saving the bytes out of a selfmade depacktizer. But I want to set the medialocation not static. Cloning the Datasource is not possible in my case. Does anyone has an idea?

    Hi Paddy,
    unfortunately there isn't a standard way to do that (I asked to OSS some months ago), a part from navigating in tables RSZ* ... May be it's a good solution developing a program.
    For example start from table RSZSELECT with IOBJNM = 0GL_ACCOUNT and OBJVERS = A. With the list of ELTUID enter table RSZELTXREF where TELTUID = ELTUID and OBJVERS = A. Then using SELTUID enter RSZELTDIR (or RSZELTXT).
    Don't know if in the meanwhile something has changed ...
    Hope it helps
    GFV

  • Create a processor and a player from another processor

    Hello guys,
    I would like to create a processor that start once, and from it i get de datasource to set to a player and to other processor.
    I have a source code that create a processor but when i get the datasource to set to the player, i had some problems.
    Thanks again.

    You could try cloning the datasources...
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/Clone.html]
    Or you could use RTP to transmit to yourself, and then you can just receive as many copies of the feed as you need to do stuff with. First processor transmits the RTP feed, and then you attach a player to a receiver and then a Processor / Data Sink to another receiver...

  • View what I transmit

    I am messing around with the AVTransmit3 sample, and I'm trying to figure out how to display what I"m transmitting onto a JPanel.
    I have all the panel stuff worked out so it will add the player/processor visual components properly.
    The problem I am having is actually getting somthign to appear, rather than just black. I have cloned the datasource then created a processor to use that DS, I then waitForStart() of the processor to be realized, but then when it gets to my if statment to see if the processor has any visual components, it says there are none...
    Needless to say, I KNOW I'm doing somthing wrong, but I just can't seem to place it...
    Any help on this would be GREATLY apprciated.
    Below are the Constructor and Methods that I have changed...
    public AVTransmit3(MediaLocator locator,
                   String ipAddress,
                   String pb,
                   Format format, JPanel tmpPanel) {
         this.pnlWebCam = tmpPanel;
         this.locator = locator;
         this.ipAddress = ipAddress;
         Integer integer = Integer.valueOf(pb);
         if (integer != null)
         this.portBase = integer.intValue();
    public void addToPanel(DataSource tmpDs) {
    DataSource ds = javax.media.Manager.createCloneableDataSource(tmpDs);
    System.out.println("original:" + ds);
    System.out.println("clone :" + tmpDs);
    Processor webPlay = null;
    Component vc = null;
    try {
    webPlay = javax.media.Manager.createProcessor(ds);
    if (webPlay == null)
    return;
    boolean result = waitForState(webPlay, Processor.Realized);
    if (result == false)
    System.out.println("Couldn't configure processor");
    try {
    if ((vc = webPlay.getVisualComponent()) != null) {
    pnlWebCam.removeAll();
    pnlWebCam.add(vc);
    if ((vc = webPlay.getVisualComponent()) == null) {
    System.out.println("no visuals :-(");
    } catch(Exception e) {System.out.println("no luck here >.<");}
    webPlay.start();
    } catch (Exception ex){System.out.println("Can't make me player!");}
    The following is the code I changed in the createProcessor method
    //Create my cloned DataSource
    try {
    clone = javax.media.Manager.createCloneableDataSource(
    javax.media.Manager.createDataSource(locator));
    ds = javax.media.Manager.createCloneableDataSource(clone);
    } catch (Exception e) {
    return "Couldn't create DataSource";
    //Call my addToPanel()
    // Try to create a processor to handle the input media locator
    try {
    processor = javax.media.Manager.createProcessor(ds);
    } catch (NoProcessorException npe) {
    return "Couldn't create processor";
    } catch (IOException ioe) {
    return "IOException creating processor";
    addToPanel(clone);
    That's all I have, I know this is somthign small, but it's been bugging the hell out of me....
    Thanks in Advance

    I had a similar problem with clones... and there is very very little documentation about clones.
    The cloneable datasource must ALWAYS be started for the clones. I think the clones feed from it.
    You can stop a clon and the others works fine, but if you stop (or dont start) the cloneable datasource, the clones dont work.

  • Problem with installing JMF

    Hi all,
    Im kinda new to Java and im trying to play an avi file with java. I understood one need to add the jmf to its project to make this possible. I downloaded the jmf for windows from this site.
    The problem is it wont install. It says (translated): "C:\windows\system32\autoexec.nt. This systemfile is not applyable for ms DOS or Windows applications."
    I have really no idea what its talking about. I have no other problems with this comp or anything. Running windows xp prof. The file i try to install is called: "jmf-2_1_1e-windows-i586.exe"
    Can someone please help me or explain the problem? I need this for school and Im stuck as long as this problems keep appearing...
    Thanks in advance,
    Jordin

    I think I dont have a problem installing JMF without connect the webcam.
    The JMF registry can detect new media locator. isnt't it?
    Hey Khrisna, can u suggest me my question in topic
    "Video Conferrence over internet???"
    I get confuse about cloning the datasource. thanks

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

  • "simultaneous" problem?

    Hello.
    I have wrote a class " SavdVA.java" which can save video that is captured from a webcam/
    This class can also play the video that is captured from the webcam.
    However,it cannot save video and play it simultaneously.(I have cloned the datasource).
    Here are my codes:
    SaveVA.java
    package videoandaudio;
    import javax.media.NoDataSourceException;
    import javax.media.CaptureDeviceInfo;
    import javax.media.MediaLocator;
    import javax.media.protocol.DataSource;
    import java.io.IOException;
    import javax.media.IncompatibleSourceException;
    import javax.media.CaptureDeviceManager;
    import javax.media.protocol.FileTypeDescriptor;
    import javax.media.Format;
    import javax.media.format.VideoFormat;
    import javax.media.format.AudioFormat;
    import javax.media.ProcessorModel;
    import javax.media.Processor;
    import javax.media.Manager;
    import javax.media.NoProcessorException;
    import javax.media.CannotRealizeException;
    import javax.media.DataSink;
    import javax.media.NoDataSinkException;
    import javax.media.datasink.DataSinkEvent;
    import javax.media.datasink.DataSinkListener;
    import java.awt.BorderLayout;
    import java.awt.Panel;
    import javax.media.Player;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.WindowAdapter;
    import javax.media.rtp.ReceiveStream;
    import java.awt.event.WindowEvent;
    import java.awt.Frame;
    import javax.media.NoPlayerException;
    import javax.media.protocol.SourceCloneable;
    import javax.media.control.FormatControl;
    * <p>Title: &#35270;&#39057;&#37319;&#38598;&#25773;&#25918;&#31995;&#32479;</p>
    * <p>Description: &#21162;&#21147;&#23601;&#22909;</p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: &#28246;&#21335;&#22823;&#23398;</p>
    * @author [email protected]
    * @version 1.0
    public class SaveVA {
    private Mainframe mainFrame=null;
    private DataSource datasource=null;
    private Processor processor = null;
    private DataSink dataSink = null;
    private PlayerWindow pw=null;
    private FormatControl formatControl=null;
    private DataSource cloneableDataSource = null;
    private DataSource clonedDataSource1 = null;
    private DataSource clonedDataSource2 = null;
    private DataSource source;
    public SaveVA(Mainframe f) {
    mainFrame = f;
    preSettings();
    public void preSettings()
    if(mainFrame.audioCheckBox.isSelected())
    datasource = getCamMicDatasource();
    else
    if(!mainFrame.audioCheckBox.isSelected())
    datasource = getCamDatasource();
    public DataSource getCamMicDatasource()
    String defaultVideoDeviceName="vfw:Microsoft WDM Image Capture (Win32):0";
    //String defaultAudioDeviceName = "JavaSound audio capture";
    String defaultAudioDeviceName = "DirectSoundCapture";
    CaptureDeviceInfo vdi = CaptureDeviceManager.getDevice(defaultVideoDeviceName);
    CaptureDeviceInfo adi = CaptureDeviceManager.getDevice(defaultAudioDeviceName);
    MediaLocator videolocator=vdi.getLocator();
    MediaLocator audiolocator=adi.getLocator();
    DataSource videoDataSource = null;
    DataSource audioDataSource = null;
    try
    videoDataSource = javax.media.Manager.createDataSource(videolocator);
    catch (IOException ie) { return null;}
    catch (NoDataSourceException nse) { return null;}
    try
    audioDataSource = javax.media.Manager.createDataSource(audiolocator);
    catch (IOException ie) { return null;}
    catch (NoDataSourceException nse) { return null;}
    DataSource mixedDataSource = null;
    try
    DataSource dArray[] = new DataSource[2];
    dArray[0] = videoDataSource;
    dArray[1] = audioDataSource;
    mixedDataSource = javax.media.Manager.createMergingDataSource(dArray);
    return mixedDataSource;
    catch (IncompatibleSourceException ise) {return null; }
    public DataSource getCamDatasource()
    String defaultVideoDeviceName="vfw:Microsoft WDM Image Capture (Win32):0";
    //String defaultAudioDeviceName = "JavaSound audio capture";
    // String defaultAudioDeviceName = "DirectSoundCapture";
    CaptureDeviceInfo vdi = CaptureDeviceManager.getDevice(defaultVideoDeviceName);
    // CaptureDeviceInfo adi = CaptureDeviceManager.getDevice(defaultAudioDeviceName);
    MediaLocator videolocator=vdi.getLocator();
    // MediaLocator audiolocator=adi.getLocator();
    DataSource videoDataSource = null;
    // DataSource audioDataSource = null;
    try
    videoDataSource = javax.media.Manager.createDataSource(videolocator);
    catch (IOException ie) { return null;}
    catch (NoDataSourceException nse) { return null;}
    return videoDataSource;
    //&#20135;&#29983;&#20811;&#38534;&#30340;&#25968;&#25454;&#28304;clonedDataSource1&#21644;clonedDataSource2
    public void cloneDatasource()
    cloneableDataSource
    = Manager.createCloneableDataSource(datasource);
    clonedDataSource1
    = ((SourceCloneable)cloneableDataSource).createClone();
    clonedDataSource2
    = ((SourceCloneable)cloneableDataSource).createClone();
    public Format[] getOutputFormat()
    if(mainFrame.audioCheckBox.isSelected())
    Format outputFormat[] = new Format[2];
    outputFormat[0] = new VideoFormat(VideoFormat.RGB);
    outputFormat[1] = new AudioFormat(AudioFormat.GSM_MS);
    return outputFormat;
    else{
    Format outputFormat[] = new Format[1];
    outputFormat[0] = new VideoFormat(VideoFormat.RGB);
    return outputFormat;
    public void setProcessor()
    // setup output file format ->> msvideo
    FileTypeDescriptor outputType = new FileTypeDescriptor(FileTypeDescriptor.MSVIDEO);
    // setup output video and audio data format
    Format outputFormat[] = null;
    outputFormat=getOutputFormat();
    // create processor
    ProcessorModel processorModel = new ProcessorModel(clonedDataSource1, outputFormat, outputType);
    try
    processor = Manager.createRealizedProcessor(processorModel);
    catch (IOException e) { System.err.println(e); }
    catch (NoProcessorException e) { System.err.println(e); }
    catch (CannotRealizeException e) { System.err.println(e);}
    public void setDataSink()
    source = processor.getDataOutput();
    // create a File protocol MediaLocator with the location
    // of the file to which bits are to be written
    MediaLocator dest = new MediaLocator("file:ok.avi");
    // create a datasink to do the file
    //DataSink dataSink = null;
    MyDataSinkListener dataSinkListener = null;
    try
    dataSink = Manager.createDataSink(source, dest);
    dataSinkListener = new MyDataSinkListener();
    dataSink.addDataSinkListener(dataSinkListener);
    dataSink.open();
    catch (IOException e) { System.out.println(e); }
    catch (NoDataSinkException e) { System.out.println(e); }
    catch (SecurityException e) { System.out.println(e); }
    public void startRecord()
    // now start the datasink and processor
    try
    dataSink.start();
    catch (IOException e) { System.out.println(e); }
    processor.start();
    public void stopRecord()
    processor.stop();
    processor.close();
    dataSink.close();
    pw.close();
    public void StartPlaying()
    Player p=null;
    try{
    p=Manager.createRealizedPlayer(clonedDataSource2);
    catch(CannotRealizeException e)
    catch(IOException e)
    catch(NoPlayerException e)
    pw = new PlayerWindow(p);
    pw.initialize();
    p.start();
    formatControl = (FormatControl)p.getControl ( "javax.media.control.FormatControl" );
    //videoFormats = webCamDeviceInfo.getFormats();
    // myFormatList = new MyVideoFormat[videoFormats.length];
    //for ( int i=0; i<videoFormats.length; i++ )
    //myFormatList[i] = new MyVideoFormat ( (VideoFormat)videoFormats[i] );
    Format currFormat = formatControl.getFormat();
    private class MyDataSinkListener implements DataSinkListener{
    public void dataSinkUpdate(DataSinkEvent event)
    if (event instanceof javax.media.datasink.EndOfStreamEvent)
    // close the datasink when EndOfStream event is received...
    processor.stop();
    processor.close();
    dataSink.close();
    class PlayerPanel extends Panel {
    Component vc, cc;
    PlayerPanel(Player p) {
    setLayout(new BorderLayout());
    if ((vc = p.getVisualComponent()) != null)
    add("Center", vc);
    if ((cc = p.getControlPanelComponent()) != null)
    add("South", cc);
    public Dimension getPreferredSize() {
    int w = 0, h = 0;
    if (vc != null) {
    Dimension size = vc.getPreferredSize();
    w = size.width;
    h = size.height;
    if (cc != null) {
    Dimension size = cc.getPreferredSize();
    if (w == 0)
    w = size.width;
    h += size.height;
    if (w < 160)
    w = 160;
    return new Dimension(w, h);
    * GUI classes for the Player.
    class PlayerWindow extends Frame {
    private Player player;
    //private PlayerWindow playerwindow=this;
    PlayerWindow(Player p) {
    player = p;
    super.setTitle("Unkown Sender");
    this.addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e){
    //player.removeControllerListener(myself);
    close();
    setSize(360,310);
    public void initialize() {
    add(new PlayerPanel(player));
    setVisible(true);
    public void close() {
    player.close();
    setVisible(false);
    dispose();
    the main method works like this:
    saveva = new SaveVA(this);
    saveva.cloneDatasource();
    saveva.setProcessor();
    saveva.setDataSink();
    saveva.startRecord();
    saveva.StartPlaying();
    if I don't clone the datasource and just use the original one,and write the main method
    like this:
    saveva = new SaveVA(this);
    saveva.cloneDatasource();
    saveva.setProcessor();
    saveva.setDataSink();
    saveva.startRecord();
    // saveva.StartPlaying();
    or like this:
    saveva = new SaveVA(this);
    saveva.cloneDatasource();
    saveva.setProcessor();
    saveva.setDataSink();
    //saveva.startRecord();
    saveva.StartPlaying();
    I mean if I just play video or just save video with a single datasource,my class works well.
    Can anyone tell me why?
    Thanks a lot.

    I have not solved this problem.

  • What is a cloned DataSource and when do we need it?

    Hi,
    Could anybody tell me what a cloned DataSource is and when we need it? How to make a clone from a datasource? Thanks

    When you need to perform more than one thing with a DataSource (like saving to a file and broadcast a webcam stream) you need to clone the WebCam Datasource to create two differents graphs, one for saving to a file, and other for broadcast.
    The cloned DataSource will only repeat the stream that the cloned DataSource is producing.
    Use the methdos im Manager to create a clone.
    RGB

  • Cloned datasource, but unable to use the both at the same time

    I used the AVTransmit java application as sampe to build my applet for transmitting realtime image from the webcam. I desired that it has a container to contain the player and it has a button for RTP transmission.
    I have used the Manager.createCloneableDataSource(ds) to clone the datasource from webcam.
    The applet can display realtime image on the container. While I clicked the button, the container hanged up and then changed to black. But the data can transmit by RTP part. I can receive the transmitted image in another PC.
    Do you have any idea ?
         public void init() {
              Component vc = null;
              Component cp = null;
              JPanel visualContainer = new JPanel();
              visualContainer.setLayout(new BorderLayout());
              JPanel mainPanel = new JPanel();
              mainPanel.setLayout(new GridLayout(2,1));
              JPanel inputPanel = new JPanel();
              inputPanel.setLayout(new GridLayout(2,1));
              Vector vlist = CaptureDeviceManager.getDeviceList(new VideoFormat(VideoFormat.YUV));
              for (int i = 0; i < vlist.size(); i++) {
                   CaptureDeviceInfo vinfo = (CaptureDeviceInfo)vlist.elementAt(i);
                   locator = vinfo.getLocator();
              try {
                   ds = Manager.createDataSource(locator);
              } catch (Exception e) {
                   System.err.println("Unable to create DataSource from : " + locator);
                   System.exit(0);
              ds = Manager.createCloneableDataSource(ds);
              if (ds == null) {
                   System.err.println("Unable to clone the DataSource");
                   System.exit(0);
              try {
                   player = Manager.createRealizedPlayer(ds);               
              } catch (Exception e) {
                   System.err.println("Unable to create a player from the DataSource :" + e);
              player.addControllerListener(new PlayerStateListener());
              //Realize the player
              player.prefetch();
              if (!waitForPlayerState(player.Prefetched)) {
                   System.err.println("Failed to realize the player");
                   //return false;
              if ((vc = player.getVisualComponent()) != null)
                   visualContainer.add(vc, BorderLayout.CENTER);
              if ((cp = player.getVisualComponent()) != null)
                   visualContainer.add(cp, BorderLayout.SOUTH);
              player.start();
              mainPanel.add(visualContainer);
              System.out.println(player);          
              setVisible(true);
              getContentPane().setLayout(new BorderLayout());
              ipAddressField = new JTextField();
              pbField = new JTextField();
              sendButton = new JButton("Submit");
              sendButton.addActionListener(this);
              inputPanel.add(ipAddressField);
              inputPanel.add(pbField);
              inputPanel.add(sendButton);
              mainPanel.add(inputPanel);
              getContentPane().add(mainPanel);
              System.out.println("locator = " + locator);
    // this is the code segment for RTP transmit
              try {
                   processor = javax.media.Manager.createProcessor(ds);          
              } catch (NoProcessorException npe) {
                   return "Couldn't create processor";
              } catch (IOException ioe) {
                   return "IOException creating processor";
              // Wait for it to configure
              boolean result = waitForProcessorState(processor, Processor.Configured);
              if (result == false)
                   return "Couldn't configure processor";
              // Get the tracks from the processor
              TrackControl [] tracks = processor.getTrackControls();
              // Do we have atleast one track?
              if (tracks == null || tracks.length < 1)
                   return "Couldn't find tracks in processor";
              // Set the output content descriptor to RAW_RTP
              // This will limit the supported formats reported from
              // Track.getSupportedFormats to only valid RTP formats.
              ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW_RTP);
              processor.setContentDescriptor(cd);
              Format supported[];
              Format chosen;
              boolean atLeastOneTrack = false;
              // Program the tracks.
              for (int i = 0; i < tracks.length; i++) {
                   Format format = tracks.getFormat();
                   if (tracks[i].isEnabled()) {
                        supported = tracks[i].getSupportedFormats();
                   // We've set the output content to the RAW_RTP.
                   // So all the supported formats should work with RTP.
                   // We'll just pick the first one.
                   if (supported.length > 0) {
                        if (supported[0] instanceof VideoFormat) {
                             // For video formats, we should double check the
                             // sizes since not all formats work in all sizes.
                             chosen = checkForVideoSizes(tracks[i].getFormat(), supported[0]);
                        } else
                             chosen = supported[0];
                             tracks[i].setFormat(chosen);
                             System.err.println("Track " + i + " is set to transmit as:");
                             System.err.println(" " + chosen);
                             atLeastOneTrack = true;
                        } else
                             tracks[i].setEnabled(false);
                        } else
                             tracks[i].setEnabled(false);
              if (!atLeastOneTrack)
                   return "Couldn't set any of the tracks to a valid RTP format";
              // Realize the processor. This will internally create a flow
              // graph and attempt to create an output datasource for JPEG/RTP
              // audio frames.
              result = waitForProcessorState(processor, Controller.Realized);
              if (result == false)
                   return "Couldn't realize processor";
              // Set the JPEG quality to .5.
              setJPEGQuality(processor, 0.5f);
              // Get the output data source of the processor
    Many thank you in advance

    Dear jcparques
    Thank you for your reply.
    I have tried to use the clone datasoure for player and original datasource for RTP transmission, the player displayed black and the RTP successfully, as I can get the live image by another PC. I have tried to use the clone datasoure for RTP and original datasource for player, the player worked normal and the another PC awared the participant joined. It has just waiting the data from RTP.
    I sured the datasource has been cloned as I can System.out.println it, it is not a null.
    Any idea. Thank you very much.

  • I can not hear the voice from a cloned dataSource

    MediaLocator audioFile = new MediaLocator("rtp://192.168.2.210:"+audioPort+"/audio");
                             DataSource ds = Manager.createDataSource(audioFile);
                             Processor processor = Manager.createRealizedProcessor(new ProcessorModel(ds,null,new ContentDescriptor(ContentDescriptor.RAW)));
                             ds = processor.getDataOutput();
                             ds = Manager.createCloneableDataSource(ds);
                             DataSource playDataSource = ((SourceCloneable)ds).createClone();
                             Player player = Manager.createRealizedPlayer(playDataSource);
                             player.start();
    but i can not hear the voice,who can help me ?thank you very much!

    now, i can hear the voice from the cloned dataSource ,but how to save the voice at the same time?
    MediaLocator audioFile = new MediaLocator("rtp://192.168.2.210:"+audioPort+"/audio");
                             DataSource ds = Manager.createDataSource(audioFile);
                             Processor processor = null;
                             processor = Manager.createProcessor(ds);
                             processor.configure();
                           boolean result = waitForState(processor, processor.Configured);
                           if (result == false)
                               System.err.println("configuring failed");
                           processor.setContentDescriptor(new ContentDescriptor(ContentDescriptor.RAW));
                           processor.realize();
                           result = waitForState(processor, processor.Realized);
                           if (result == false)
                               System.err.println("realizing failed");
                           processor.start();
                           ds = processor.getDataOutput();
                           DataSource playDataSource = Manager.createCloneableDataSource( ds );
                           Processor saveProcessor = Manager.createRealizedProcessor(new ProcessorModel(ds,null,new FileTypeDescriptor(FileTypeDescriptor.RAW_RTP)));
                           Player player = javax.media.Manager.createPlayer(playDataSource);
                           DataSink dsink = Manager.createDataSink(saveProcessor.getDataOutput(), new MediaLocator("file://D:/record/1234.wav"));
                             System.out.println();
                             System.out.println("-> Playing file '" + audioFile + "'");
                             System.out.println("   Press the Enter key to exit");
                             player.start();
                             dsink.open();
                             dsink.start();
                             saveProcessor.start();i can get a local file named "1234.wav",but i can not play .Thank you !!

  • DataSource cloned returns NULL

    Hi.. I am trying to clone the datasource..
    However, the cloned datasource is just null..
    Can anyone please help....
    Thanks.

    Here is the code. Thanks.
    import java.io.*;
    import java.awt.*;
    import java.net.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.media.*;
    import javax.media.rtp.*;
    import javax.media.rtp.event.*;
    import javax.media.rtp.rtcp.*;
    import javax.media.protocol.*;
    import javax.media.format.AudioFormat;
    import javax.media.format.VideoFormat;
    import javax.media.Format;
    import javax.media.format.FormatChangeEvent;
    import javax.media.control.BufferControl;
    import com.sun.media.rtp.RTPSessionMgr;
    import javax.media.control.TrackControl;
    public class ServerBroadcaster005 implements ReceiveStreamListener, SessionListener,ControllerListener
    String serverIP = null;
    int port;
    RTPManager mgrs = null;
    RTPManager listedMgr[]=null;
    private Integer stateLock=new Integer(0);
    PlayerWindow pw=null;
    Processor processor=null;
    private boolean failure;
    private Vector connectedClient=new Vector();
    private SessionAddress newClient;
    boolean dataReceived = false;
    Object dataSync = new Object();
    Player player=null;
    private DataSource firstClone;
    /*public ServerBroadcaster005(String serverIP,String ports) {
         this.serverIP = serverIP;
         port=new Integer(ports).intValue();
    public ServerBroadcaster005() {
         try{
              String ports="80";
              serverIP = InetAddress.getLocalHost().getHostAddress();
              port=new Integer(ports).intValue();
         }catch(UnknownHostException uhe){
              System.out.println("Host NOT Known..");
    /* public void run(){
         if(initialize()){
    protected boolean initialize() {
    try {
         InetAddress ipAddr;
         SessionAddress localAddr = new SessionAddress();
         SessionAddress destAddr;
         // Open the RTP sessions.
              System.err.println(" - Open RTP session for: addr: " + serverIP + " port: " + port);
              mgrs = (RTPManager) RTPManager.newInstance();
              mgrs.addSessionListener(this);
              mgrs.addReceiveStreamListener(this);
              ipAddr = InetAddress.getByName(serverIP);
              localAddr= new SessionAddress( InetAddress.getLocalHost(),port);
    destAddr = new SessionAddress( ipAddr, port);          
              mgrs.initialize( localAddr);
              // You can try out some other buffer size to see
              // if you can get better smoothness.
              BufferControl bc = (BufferControl)mgrs.getControl("javax.media.control.BufferControl");
              if (bc != null)
              bc.setBufferLength(350);
              mgrs.addTarget(destAddr);
    } catch (Exception e){
    System.err.println("Cannot create the RTP Session: " + e.getMessage());
    return false;
         // Wait for data to arrive before moving on.
         long then = System.currentTimeMillis();
         long waitingPeriod = 30000; // wait for a maximum of 30 secs.
         try{
         synchronized (dataSync) {
              //while (!dataReceived && System.currentTimeMillis() - then < waitingPeriod) {
              while (!dataReceived) {
              if (!dataReceived)
                   System.err.println(" - Waiting for RTP data to arrive...");
              dataSync.wait(1000);
         } catch (Exception e) {}
         if (!dataReceived) {
         System.err.println("No RTP data was received.");
         close();
         return false;
    return true;
    * Close the players and the session managers.
    protected void close() {
         // close the RTP session.
         if(pw!=null)
              //player.close();
              pw.close();
              System.out.println("Player closed..");
         if (mgrs!= null) {
    mgrs.removeTargets( "Closing session from AVReceive2");
    mgrs.dispose();
              mgrs = null;
    * ReceiveStreamListener
    public synchronized void update( ReceiveStreamEvent evt) {
         RTPManager mgr = (RTPManager)evt.getSource();
         Participant participant = evt.getParticipant();     // could be null.
         ReceiveStream stream = evt.getReceiveStream(); // could be null.
         if (evt instanceof RemotePayloadChangeEvent) {
         System.err.println(" - Received an RTP PayloadChangeEvent.");
         System.err.println("Sorry, cannot handle payload change.");
         System.exit(0);
         else if (evt instanceof NewReceiveStreamEvent) {
              SessionAddress destAddress;
              InetAddress clientIP;
              int port=85;
              SendStream sendStream;
              DataSource senderDS=null,playerDS=null;     
         try {
              stream = ((NewReceiveStreamEvent)evt).getReceiveStream();
              DataSource ds = stream.getDataSource();
              DataSource ds2=ds;
              // Find out the formats.
              RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
              if (ctl != null){
              System.err.println(" - Recevied new RTP stream: " + ctl.getFormat());
              } else
              System.err.println(" - Recevied new RTP stream");
              if (participant == null)
              System.err.println(" The sender of this stream had yet to be identified.");
              else {
              System.err.println(" The stream comes from: " + participant.getCNAME());
              // create a player by passing datasource to the Media Manager
              player = javax.media.Manager.createPlayer(ds);
              if (player == null)
              return;
              player.addControllerListener(this);
              player.realize();
              pw = new PlayerWindow(player, stream);               
              //addNewClient(InetAddress.getLocalHost().toString(),"86");     
              if(connectedClient==null || connectedClient.size()<1){
                   System.out.println(" -No client is connected..");
              else{
                   System.out.println(" -In connectedClient ..");
              Format h263Format=new VideoFormat(VideoFormat.H263_RTP);
              createMyProcessor(ds2);
              //createMyProcessor(senderDS);
              PushBufferDataSource pbds=(PushBufferDataSource)firstClone;
              PushBufferStream pbss[]=pbds.getStreams();
              RTPManager rtpMgrs[]=new RTPManager[pbss.length];
                   for(int a=0;a<pbss.length;a++){
                   try{
                        rtpMgrs[a]=RTPManager.newInstance();
                        SessionAddress localAddr=new SessionAddress(InetAddress.getLocalHost(),port+2*a);
                        System.out.println("localAddr : "+localAddr);
                        System.out.println("LocalAddress: "+InetAddress.getLocalHost()+" Port: "+port+2*a);                    
                        //-> NOT NEEDED in a newer version of transmitter
                        rtpMgrs[a].initialize(localAddr);     
                        System.out.println(" -RTPManager is initialized for LocalAddress..");          
                        for(int b=0;b<connectedClient.size();b++){
                             Target target=(Target)connectedClient.elementAt(b);
                             int targetPort=new Integer(target.port).intValue();
                             addNewClient(rtpMgrs[a],target.addr,targetPort+2*a);
                             System.out.println(" - A new client at "+target.addr+" with port:"+targetPort+" is added...");
                             System.out.println(" Created RTP session: "+localAddr+" "+targetPort+" to "+target.addr);
                        sendStream=rtpMgrs[a].createSendStream(firstClone,a);
                        sendStream.start();
                        System.out.println(" <-> RTP stream is started..");                         
                   catch(IOException ioe){
                        System.out.println(" --X IOException : "+ioe.getMessage());                    
                   catch(Exception ex){
                        System.out.println(" --X Unable to create RTP Manager...");
                        System.out.println(ex.getMessage());     
         }     // For loop closing
              // Notify intialize() that a new stream had arrived.
              synchronized (dataSync) {
              dataReceived = true;
              dataSync.notifyAll();
         } catch (Exception e) {
              System.err.println("NewReceiveStreamEvent exception " + e.getMessage());
              return;
         else if (evt instanceof StreamMappedEvent) {
         if (stream != null && stream.getDataSource() != null) {
              DataSource ds = stream.getDataSource();
              // Find out the formats.
              RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
              System.err.println(" - The previously unidentified stream ");
              if (ctl != null)
              System.err.println(" " + ctl.getFormat());
              System.err.println(" had now been identified as sent by: " + participant.getCNAME());
         else if (evt instanceof ByeEvent) {
         System.err.println(" - Got \"bye\" from: " + participant.getCNAME());
         if (pw != null) {
              pw.close();
              System.out.println("Player closed..");
         public synchronized void update(SessionEvent evt) {
         if (evt instanceof NewParticipantEvent) {
         Participant p = ((NewParticipantEvent)evt).getParticipant();
         System.err.println(" - A new participant had just joined: " + p.getCNAME());
         public void createMyProcessor(DataSource videoDS)
              boolean result=false;
              DataSource ds=videoDS;
              // Check if the media locator is null
              if(videoDS==null){
                   System.out.println(" --X No datasource..");
              System.out.println(" - Trying to create a Processor..");
              // Try to create Processor from DataSource
              try{
                   processor=Manager.createProcessor(ds);
                   System.out.println(" -Processor is created..");
              }catch(NoProcessorException npe){
                   System.out.println(" --X Unable to create Processor: "+npe.getMessage());
                   //infoField.setText(" --X Unable to create Processor: "+npe.getMessage());
              catch(IOException ioe){
                   System.out.println(" --X IOException creating Processor..");
                   //infoField.setText(" --X IOException creating Processor..");
              // Wait for the processor to be configured
              result=waitForState(processor,Processor.Configured);
              System.out.println(" -Processor is configured : "+result);
              if(result==false){
                   System.out.println(" --X Could not configure processor..");
                   //infoField.setText(" --X Could not configure processor..");
              // Set the track controls for processor
              TrackControl []tracks=processor.getTrackControls();
              if(tracks==null || tracks.length<1){
                   System.err.println(" --X No track is found..");
                   //infoField.setText(" --X No track is found..");               
              }else{
                   System.err.println(" -Track is found..");
              // Set the content description of processor to RAW_RTP format
              // This will limit the supported formats to reported from
              // Track.getSupportedFormats() to valid RTP format
              ContentDescriptor cdes=new ContentDescriptor(ContentDescriptor.RAW_RTP);
              processor.setContentDescriptor(cdes);
              Format []supported;
              Format chosen=null;
              boolean atLeastOneTrack=false;
              for(int i=0;i<tracks.length;i++){
                   Format format=tracks.getFormat();
                   if(tracks[i].isEnabled()){
                        supported=tracks[i].getSupportedFormats();
                        // WE've set the output content to RAW_RTP.
                        // So, all the supporte formats should work with RAW_RTP.
                        // We will pick the first one.
                        if(supported.length>0){
                             if(supported[0] instanceof VideoFormat){                              
                                  chosen=checkVideoSize(tracks[i].getFormat(),supported[0]);
                             }else
                                  chosen=supported[0];
                             tracks[i].setFormat(chosen);
                             System.out.println(" Track "+i+" is transmitted in "+chosen+" format.. ");
                             //infoField.setText(" Track "+i+" is transmitted in "+chosen+" format.. ");
                             atLeastOneTrack=true;
                        }else{
                             // If no format is suitable, track is disabled
                             tracks[i].setEnabled(false);
                   }else
                        tracks[i].setEnabled(false);          
              if(!atLeastOneTrack)
                   System.out.println("atLeastOneTrack: "+atLeastOneTrack);
                   System.out.println(" --X Could Not find track to RTP format..");
                   //infoField.setText("atLeastOneTrack: "+atLeastOneTrack);
                   //infoField.setText(" --X Could Not find track to RTP format..");
              result=waitForState(processor,Controller.Realized);
              if(result==false){
                   System.out.println(" --X Could NOT realize processor...");
                   //infoField.setText(" --X Could NOT realize processor...");
              // Set the JPEG Quality to value 0.5
              //setJPEGQuality(processor,0.5f);
              // Set the output Data Source
              firstClone=processor.getDataOutput();
              //Start the processor
              processor.start();     
              System.out.println(" -processor started...");     
         public boolean waitForState(Processor p,Integer status)
              p.addControllerListener(new StateListener());
              failure=false;
              if(status==Processor.Configured){
                   p.configure();               
              }else if(status==Processor.Realized){
                   p.realize();
              //Wait until an event that confirms the success of the method, or failure of an event
              while(p.getState()<status && !failure){
                   synchronized(getStateLock()){
                        try{
                             System.out.println(" - Processor status : "+p.getState());
                             // Wait
                             getStateLock().wait();
                        }catch(InterruptedException ie){
                             return false;
    //--- DeaD HERE ---------------- :(
              System.out.println(" -Failure :"+failure);
              if(failure)
                   return false;
              else
                   return true;
         public Format checkVideoSize(Format originalFormat,Format supported)
              int width,height;
              Dimension size=((VideoFormat)originalFormat).getSize();     
              Format jpegFormat=new Format(VideoFormat.JPEG_RTP);
              Format h263fmt=new Format(VideoFormat.H263_RTP);
              if(supported.matches(jpegFormat)){
                   width=(size.width%8 == 0 ? size.width:(int)(size.width%8)*8);
                   height=(size.height%8 == 0 ? size.height:(int)(size.height%8)*8);
              }else if(supported.matches(h263fmt)){
                   if(size.width<128){
                        width=128;
                        height=96;
                   }else if(size.width<176){
                        width=176;
                        height=144;
                   }else{
                        width=352;
                        height=288;
              }else{
                   // Unknown format, just return it.
                   return supported;
              return (new VideoFormat(null,new Dimension(width,height),Format.NOT_SPECIFIED,null,Format.NOT_SPECIFIED)).intersects(supported);
         public Integer getStateLock(){
              System.out.println("StateLock : "+stateLock);
              return stateLock;
         public void setFailure(){
              failure=true;
         public void addNewClient(String dip,String portno){
              if(dip!=null && portno!=null){
                   Target currentTarget=new Target(dip,portno);
                   if(connectedClient==null){
                        //connectedClient=new Vector();
                        System.out.println(" No client is to be added, vector is null");
                   for(int i=0;i<listedMgr.length;i++){
                        int dport=new Integer(portno).intValue();
                        addNewClient(listedMgr[i],dip,dport);
                   connectedClient.addElement(currentTarget);
         public void addNewClient(RTPManager mgr,String dip,int port){
              try{
                   SessionAddress addr=new SessionAddress(InetAddress.getByName(dip),new Integer(port).intValue());
                   mgr.addTarget(addr);
              }catch(Exception ex){
                   System.out.println(" --X Unable to add New Client to the list.."+ex.getMessage());
         public void removeTarget(String ipz,String ports)
              try{
                   SessionAddress addrs=new SessionAddress(InetAddress.getByName(ipz),new Integer(ports).intValue());
                   for(int i=0;i<listedMgr.length;i++){
                        listedMgr[i].removeTarget(addrs,"Target REMOVED from Trasmitter..");
              }catch(Exception ex){
                   System.out.println(" -Unable to remove the target..");
         public void stop() {
         synchronized (this) {
         for (int i= 0; i < listedMgr.length; i++) {
         listedMgr[ i].removeTargets( "Session ended.");
              listedMgr[ i].dispose();
              System.out.println(" -Retransmission TERMINATED..");
    * ControllerListener for the Players.
    public synchronized void controllerUpdate(ControllerEvent ce) {
         Player p = (Player)ce.getSourceController();
         if (p == null)
         return;
         // Get this when the internal players are realized.
         if (ce instanceof RealizeCompleteEvent) {
         if (pw == null) {
              // Some strange happened.
              System.err.println("Internal error!");
              System.exit(-1);
         pw.initialize();
         pw.setVisible(true);
         player.start();
         if (ce instanceof ControllerErrorEvent) {
         player.removeControllerListener(this);
         pw.close();     
         System.err.println("server-ReTransmitter001 internal error: " + ce);
    * GUI classes for the Player.
    class PlayerWindow extends Frame{
         Player player;
         ReceiveStream stream;
         PlayerWindow(Player p, ReceiveStream strm) {
         player = p;
         stream = strm;
         public void initialize() {
         add(new PlayerPanel(player));
         public void close() {
         player.close();
         setVisible(false);
         dispose();
         public void addNotify() {
         super.addNotify();
         pack();
    * GUI classes for the Player.
    class PlayerPanel extends Panel {
         Component vc, cc;
         PlayerPanel(Player p) {
         setLayout(new BorderLayout());
         if ((vc = p.getVisualComponent()) != null)
              add("Center", vc);
         if ((cc = p.getControlPanelComponent()) != null)
              add("South", cc);
         public Dimension getPreferredSize() {
         int w = 0, h = 0;
         if (vc != null) {
              Dimension size = vc.getPreferredSize();
              w = size.width;
              h = size.height;
         if (cc != null) {
              Dimension size = cc.getPreferredSize();
              if (w == 0)
              w = size.width;
              h += size.height;
         if (w < 160)
              w = 160;
         return new Dimension(w, h);
    public static void main(String argv[]) {
         //serverReTransmitter001 vReceive = new serverReTransmitter001("192.168.0.9","80");
         ServerBroadcaster005 vReceive = new ServerBroadcaster005();
         if (!vReceive.initialize()) {
         System.err.println("Failed to initialize the sessions.");
         System.exit(-1);
         System.err.println("Exiting ServerBroadcaster005..");
         * StateListener class to handle Controller events
         class StateListener implements ControllerListener{
              public void controllerUpdate(ControllerEvent ce){
                   if(ce instanceof ControllerClosedEvent){
                        processor.close();
                   /* Handle all controller events and notify all
                   waiting thread in waitForState method */
                   if(ce instanceof ControllerEvent){
                        synchronized(getStateLock()){
                             getStateLock().notifyAll();
    }// end of AVReceive2

  • Realizing a Player/Processor does not happen with cloned DataSource

    It seems that a lot of developers have this problem with JMF, but a suitable solution seems not to be around.
    Playing a (audio) file and recording/saving it at the same time to a file seems not to work.
    Either it really doesnot_work_ or the docs are leading me to wrong assumptions and my implementation is wrong. When I do the following, the VM stops in a wait state while realizing a processor and never returns.
    I can listen to the stream or I can save the stream. But doing both things together does not work. Does somebody have any idea what's wrong and how to get it running?
    (Some code was snipped, this shows basically the setup..)
    // 1. player to listen to the stream, this works!
    DataSource ds = stream.getDataSource();
    player = Manager.createPlayer(ds);
    player.addControllerListener...
    player.realize();
    waitForPlayerState(player, Player.Realized); // from RTPExport.java demo
    player.start();
    // 2. processor to save the stream
    DataSource ds = stream.getDataSource();
    ds = Manager.createCloneableDataSource(ds);
    DataSource clone = ((SourceCloneable)ds).createClone();
    processor = Manager.createProcessor(clone);
    processor.addControllerListener...
    processor.configure();
    waitForProcessorState(processor, Processor.Realized);
    -> this does never return :-((
    -> the file will not be created.
    set content type...
    set track format...
    processor.realize();
    MediaLocator f = new MediaLocator("file:///tmp/foo.wav");
    DataSource source = processor.getDataOutput();
    DataSink sink = Manager.createDataSink(source, f);
    sink.open();
    sink.addDataSinkListener...
    processor.start();
    sink.start();
    I can do either step 1. or step 2., but not both of them. Why?
    Thanks for your cooperation.

    The cloneable DataSource is casted to a CloneablePushBufferDataSource.
    I don't get any exception. It just blocks / deadlocks? while configuring the processor.
    I've tried several different methods to setup the processor. Nothing worked so far and I have no idea why?
    Listening or saving seems to work when I use the 'original' DataSource (ds) only. As soon as I try to do it with a clone, it cannot be done.
    Any help or experice on this topic would be of great help. Btw, I'm on Solaris8.

Maybe you are looking for

  • Fixed summary value in fixed place

    Hi ~~~ I have fixed problem. In my RTF ,I have Header .lines.summary. I want summary always output in line 10, this is fixed place. But when I preview PDF , summary will move up automatic. What can I do to make summary in fixed place? Please someone

  • Illustrator CC  Allowing Direct Tool and Selection Tool to Only Select Some Objects at Random

    Whenever I try to select any object I've created,  some will show that they can be selected while others are not available to be selected for no apparent reason except at random. This happens regardless if all my layers are unlocked.

  • Indesign cs5 Crashes everytime i try to create a new document

    i'm on a mac, running OSX10.7.  No new software has been added since i loaded the CS Suite on my machine. in the last two weeks, Indesign has begun crashing everytime i try to make a new document. it will open older documents created in cs5 and earli

  • HT4009 In-app Purchase Help

    I tried to purchase a replenishable in app purchase, and it's saying "please contact iTunes support to complete this transaction". Do I have to wait a certain amount of time to try to purchase it again, or does it have something to do with my credit/

  • Application Crashing - OS Problem?

    I have a problem with an application (that has worked for... a long time... without problem). Photoshop (CS2) crashes repeatedly at exactly the same spot. Reinstalled from CD, erased preference file (adobe plist) - with same problem. After erasing al