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.

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

  • 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

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

  • Attempting to write RTP stream to wave

    I have been working long and hard trying to figure out to save an RTP stream from a Cisco phone to a wave. I need the wave file to be in the format ULAW, 8khz, 8 bit mono.
    Through much research this is the code I come up with but I does not work. I states that I am trying to get a datasink for null when I try to create the filewriter datasink.
    I also have gotten the following error message with other version of the code below:
    newReceiveStreamEvent exception Cannot find a DataSink for: com.sun.media.protocol.rtp.DataSource@3680c1
    When I get the RTP stream I get the following as the format of the input stream:
    - Recevied new RTP stream: ULAW/rtp, 8000.0 Hz, 8-bit, Mono
    else if (evt instanceof NewReceiveStreamEvent) {
         try {
              stream = ((NewReceiveStreamEvent)evt).getReceiveStream();
    Format formats[] = new Format[1];
    formats[0] = new AudioFormat(AudioFormat.LINEAR,8000,8,1);
    FileTypeDescriptor outputType = new FileTypeDescriptor(FileTypeDescriptor.WAVE);
    DataSource ds = stream.getDataSource();
              // 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());
    ProcessorModel processorModel = new ProcessorModel(ds, formats, null);
    Processor processor = Manager.createRealizedProcessor(processorModel);
              processor.setContentDescriptor(new ContentDescriptor(ContentDescriptor.RAW_RTP));
    MediaLocator f = new MediaLocator("file:/C:/output.wav");
    DataSink filewriter = null;
    DataSource tempds = processor.getDataOutput();
    filewriter = Manager.createDataSink(tempds, f);
    filewriter.open();
    Edited by: phodat on Sep 16, 2010 10:17 PM
    Edited by: phodat on Sep 16, 2010 10:20 PM

    The content descriptor is designed to specify the output format, not the input format. The input format is specified by the DataSource automatically, and you set the content descriptor to whatever you want the output format to be. In this case, you'd want to set it to a WAV file.
    You'd then need to go through all of the Track objects on the processor and set their output format to the ULAW specifications as you want there.
    [http://www.cs.odu.edu/~cs778/spring04/lectures/jmfsolutions/examplesindex.html]
    There's actually an example program that exports RTP streams, you can probably use that code without modification to fit your needs.

  • Can I have a custom RTP payload, and still use a MediaLocator?

    Hi,
    I think I am a little confused. Can I have a custom RTP payload, and still use Manager.createPlayer(MediaLocator locator) to create my player?
    This doesn't seem possible because the RTPManger's addPayload(Format format, int payloadType) method isn't static, forcing me to always create my RTPManager first.
    Is this a valid observation, or am I missing something?
    Your comments are highly appreciated.
    Kind regards,
    Erwin

    Thanks for your prompt reply.
    The short answer is yes.
    The MediaLocator is used to identify the source, or destination for a media stream. For example this could be a file (file://c:\mydisk\audio.wav) or a URL (http://mydomain/music/audio.wav)
    Ok, I get that, but the MediaLocator is also used to identify the protocol, rtp in this case, and the protocol in its turn is used by the framework to locate the DataSource. I am not suggesting what you write is incorrect, I am only trying to understand how this works the way it does.
    RTP is used to transport streaming media in real time over a network (usually UDP).And that is exactly what I need it for.
    The receiver of an RTP stream is an RTP receiver. Players take the datasource(created from the MediaLocator) and feed the data to the RTP manager so it can be streamed across the network or vice versa.
    The vice versa part is what I am interested in. I need to handle a proprietary video format, packed as RTP, and shipped over UDP. My initial approach was to simply register my DePacketizer with the PlugInManager, and add my custom payload type to the RTPHandler (addFormat(Format fmt, int type)). That obviously doesn't work.
    So what I'm trying to convey is that the MediaLocator used in creating a Player will be different, and is used for a different purpose, than the Internet address, and Port used to create an RTPManager.I need a good night of sleep to think that over. I.m.h.o. there is no reason to handle "http://host:port/video/whatever.ext" different from "rtp://host:port/video/whatever.ext". The only difference is that in the first case I can build my graph based on the extension of whatever, and in the second case I have to wait for my first packet in order to determine the payload type. In both cases I expect "DataSource ds = Manager.createDataSource(ml) to work (and it probably does for the standard payload types).
    The JMF framework has a .../media/protocol/rtp/DataSource class as well as a .../media/protocol/http/DataSource class.
    Is this making any sense?Not sure yet, but I certainly appreciate your help.
    Note: In general you don't need to create a custom Payload for RTP.
    What if I want to ship a proprietary video format?
    Thanks a lot,
    Erwin

  • Save the rtp streaming

    Hi,
    If my data source type is
    "com.sun.media.protocol.vfw.DataSource@cd5f8b" ,
    I can use the following method to grab the image frome the real-time video that my webcam catpured
    cds = (PushBufferDataSource) ds;
    cds.getStreams()[0].setTransferHandler(this);
    cds.start();
    Buffer buf = new Buffer();
    public void transferData(PushBufferStream pbs) {
            try {
                pbs.read(buf);
            }catch(java.io.IOException ioe) {
                System.err.println(ioe);
            if (bti == null) {
                VideoFormat vf = (VideoFormat) buf.getFormat();
                bti = new BufferToImage(vf);
            Image im = bti.createImage(buf);
            try
                     BufferedImage tag = new BufferedImage(320,240,BufferedImage.TYPE_INT_RGB);
              tag.getGraphics().drawImage(im,0,0,320,240,null);
                     FileOutputStream out=new FileOutputStream("test.jpg");
                     JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);      
                     encoder.encode(tag);
                     out.close();
              catch(Exception e)
    }but if my data source type is "com.sun.media.protocol.rtp.DataSource@14c194d" the previous method does not work.
    Does anyone know how should I modify my method when the data source is rtp for grabing image and saving the video?
    Thanks!

    natdeamer wrote:
    Having some problems streaming over the internet - probably because im doing it wrong.That's correct, you're doing it wrong.
    Im using www.whatismyip.com to get the internet IP of the 2 computers im trying to stream to and from - and using these in the code, but nothing happens.99% of the time, your public IP actually addresses your router, rather than your computer. That means your computer is not publically addressably by it's IP address alone. You'll need to do something called a "NAT holepunch", which you can look up online. Also, I've included two links to discussions I've had with people about the same issue.
    [http://forums.sun.com/thread.jspa?forumID=28&threadID=5355413]
    [http://forums.sun.com/thread.jspa?forumID=28&threadID=5356672]

  • How to solve the problem "cannot create a datasink for **(datasource)"

    There is a forums that can send and receive RTP streams, and it can play on the client. Now I want to save it. I write the code according to the jmf2_0-guide, how ever it always throws the exception "cannot create a datasink for **(datasource)". The datasource is the RTP stream received from the server. Is there anything wrong with the data source or anything else?
    here is the code:
    public synchronized void update( ReceiveStreamEvent evt){
    if(evt instanceof NewReceiveStreamEvent){
    try{
    stream = ((NewReceiveStreamEvent)evt).getReceiveStream();
    DataSource ds = stream.getDataSource();
    MediaLocator f = new MediaLocator("file://foo.au");
    Manager.createDataSink(ds, f);
    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 p = javax.media.Manager.createPlayer(ds);
         if (p == null) {
         return;
         p.addControllerListener(this);
         p.realize();
         PlayerWindow pw = new PlayerWindow(p, stream);
         playerWindows.addElement(pw);
         // 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;
    Does any one know how to solve this problem? How to save or how to create a datasink? Please help! Thank you!!

    The complete error message:
    NewReceiveStreamEvent exception Cannot find a DataSink for: com.sun.media.protocol.rtp.DataSource@4741d6

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

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

  • 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

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

  • Registering custom payload

    First of all i had a media file from which i could generate a perfectly fine output when run from a local file.
    Then i finally managed to to configure the VLC-player as RTSP/RTP Server and tried to request that same media file via those protocols,
    Unfortunatly i soon found this error-message in my logfile:
    XX No format has been registered for RTP Payload type 96
    As far as i understood the JMF, i figured that there already is a working format/codec for my mediafile - otherwise it couldnt be played locally in the first place.
    Therefore i managed to extract the format information via:
    System.out.println("Video format: " + videoTrack.getFormat());
    And i got the following response:"FFMPEG_VIDEO, 640x480, FrameRate=25.0, Length=307200 0 extra bytes"
    I then put that data into a new Format-Class (FfmpegVideoFormat) and registered it with:
    AviVideoFormat format = new FfmpegVideoFormat();
    int customPayloadNumber = 96;
    mgr.addFormat(format, customPayloadNumber);
    Et voila. Error message was gone. Unfortunatly so was the video output. The logfile doesnt show any errors at all but for some reason my processor doesnt generate any output at all:
    The interesting part of the log-file ist :
    ## outgoing msg:
    ## PLAY rtsp://192.168.178.22:5554/Test RTSP/1.0
    CSeq: 3928214
    Session: 15724
    Range: npt=now
    User-Agent: HBT RTSP Client 1.0
    ## incoming msg:
    ## RTSP/1.0 200 OK
    Server: VLC Server
    Content-Length: 0
    CSeq: 3928214
    Cache-Control: no-cache
    Session: 15724;timeout=5
    ## RTP video socket buffer size: 30825 bytes.
    ## RTP video socket buffer size: 41437 bytes.
    ## RTP video buffer size: 11 pkts, 7476 bytes.
    ## RTP video socket buffer size: 49387 bytes.
    ## RTP video buffer size: 21 pkts, 18832 bytes.
    $$ Profile: instantiation: 3 ms
    ## Processor created: com.sun.media.processor.unknown.Handler@148cc8c
    ## using DataSource: com.sun.media.protocol.rtp.DataSource@1786e64
    $$ Profile: parsing: 6 ms
    ## Building flow graph for: null
    ## Building Track: 0
    ## Input: FFMPEG_VIDEO, 640x480, FrameRate=25.0, Length=307200 0 extra bytes
    ## Custom options specified.
    ## A custom renderer is specified: de.hbt.customer.jmf.renderer.RotatingRenderer@ed0338
    ## Here's the completed flow graph:
    com.sun.media.parser.RawBufferParser@199f91c
    connects to: com.omnividea.media.codec.video.NativeDecoder@1b1aa65
    format: FFMPEG_VIDEO, 640x480, FrameRate=25.0, Length=307200 0 extra bytes
    com.omnividea.media.codec.video.NativeDecoder@1b1aa65
    connects to: com.sun.media.codec.video.colorspace.JavaRGBConverter@129f3b5
    format: RGB, 640x480, FrameRate=25.0, Length=307200, 32-bit, Masks=16711680:65280:255, LineStride=640, class [I
    com.sun.media.codec.video.colorspace.JavaRGBConverter@129f3b5
    connects to: de.hbt.customer.jmf.renderer.RotatingRenderer@ed0338
    format: RGB, 640x480, FrameRate=25.0, Length=307200, 32-bit, Masks=255:65280:16711680, LineStride=640, class [I
    $$ Profile: graph building: 582 ms
    $$ Profile: realize, post graph building: 45 ms
    ## Created RTP time base for session: 192.168.178.22
    <End Of File>
    Anyone an idea what went wrong?

    Looks like a bad kludge job to me...
    Telling the manager what format is associated with a given RTP payload type doesn't do anything if the Manager doesn't have a codec associated with that format type.
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/formats.html]
    FFMPEG isn't listed there, which means JMF doesn't have a codec for it... So the system goes "Oh, ok...this is an FFMPEG_Video stream, I'll create a Processor for that because I identified the video" and then it creates a Processor that can't actually do anything with the stream because it can't find a codec for it.
    I'm suprised it isn't throwing an error telling you that it can't do anything with that video format, but, I'm guessing that the way you've registered the format has caused JMF to think it can do something with it and thus prevent that error from being thrown. I'm not 100% sure what's going on, but, I'm sure that what you did won't work unless JMF has a codec for the video format.

  • About Retransmission

    Hello,
    I want to transmit video from say Machine1 to Machine2. Now from Machine2 , I want to retransmit the same to Machine3 for example. For this to happen I plan to do the following at <<Machine2>>:
    1-Create a MediaLocator using rtpurl where Machine1 is sending the RTP data.
    2-Create the input datsource using the MediaLocator at step1.
    3-Create the MediaLocator which is the destination of media , targeting Machine3.
    4-Create the DataSink using input datsource at step2 and output MediaLocator created at step3.
    5-Finally opening and starting the DataSink.     
    Are the above steps correct?

    That looks like it should work...give it a try and let us know if it works.
    Random note:
    Right now, you have the following data flow
    RTP -> DataSource -> DataSink -> DataSource -> RTP
    If it doesn't work like that, you might need to run it through a processor before you send it back out. Certainly try it without a processor first, but you may need the following flow for it to work:
    RTP -> DataSource -> Processor -> DataSource -> DataSink -> RTP
    But I'd imagine that because you received it in an RTP-able format, you can just datasink it out without processing it. Just an "next thing to try" idea ;-)

Maybe you are looking for

  • Unable to install Itunes 10.6.3 on windows 7 (64 bit)

    Hey everyone I recently had itunes version 10...... installed on my laptop and had no issues with it. However a couple of days ago I wanted to sync my iphone 4s to my laptop and nothing was happening. So i tried to start the Apple Mobile Device Suppo

  • Tip: How to link to a non-iWeb page in the main navigation menu.

    I've figured out an easy way to add a link to the main navigation menu which links to a URL of your choosing. For example, I have an older .Mac site using the now archaic HomePage. Instead of rebuilding all of my old pages in iWeb, I thought it would

  • Bitlocker: How to read drive identifier from manage-bde

    Hi there, I'm trying to unlock a hard drive in the command line using the 48 digit recovery password: manage-bde -unlock c: -rp 0123456789...47 I have several encrypted disks and therefore several printouts of recovery keys, so I am unsure which reco

  • Adobe Camera Raw (ACR), Jpeg Files and Metadata

    I have been using Adobe Camera Raw (ACR) with my Canon EOS 30D, an 8 MP camera, for a while now. I would make non-destructive changes to the raw file (.CR2) in ACR where the changes would be stored in an adjoining .xmp file. Jpegs of the unedited and

  • EBS - Discoverer  Vs  BI Publisher

    Hi All, My Client has EBS R12 and has both Discoverer 10g and BI Publisher. Please can someone help me to understand where to use Discoverer Tool and when to use BI Publisher tool. What are the major differences and limitations of these products. I a