This discussion is archived
2 Replies Latest reply: May 18, 2011 7:29 PM by 862644 RSS

javax.media.NoDataSinkException

862644 Newbie
Currently Being Moderated
This function is to save the vedio from the PC CAMERA according the procedure of the JMF,but it has some questions!
Thanks for your replay!
-------------------------------------------------------------------------------------------------
Exception in thread "main" javax.media.NoDataSinkException: Cannot find a DataSink for: com.sun.media.multiplexer.RawBufferMux$RawBufferDataSource@1aaa14a
at javax.media.Manager.createDataSink(Manager.java:1894)
at SaveVedio.main(SaveVedio.java:42)
------------------------------------------------------------------------------------------------------

import java.util.Vector;
import java.text.Format;
import java.net.*;
import javax.media.*;
import javax.media.protocol.*;
import javax.media.control.*;
import javax.media.protocol.FileTypeDescriptor;

public class SaveVedio{
     public static void main(String[] args)throws Exception{
          Vector v=CaptureDeviceManager.getDeviceList(null);     
          CaptureDeviceInfo cdi=null;
          MediaLocator inLocator=null;
          MediaLocator outLocator=null;
          Processor processor=null;
          DataSource inDS=null;
          DataSource outDS=null;
          DataSink dSink=null;
          StreamWriterControl swc=null;
          
          for(int i=0;i<v.size();i++){
               cdi=(CaptureDeviceInfo)v.elementAt(i);
               if(cdi.getName().contains("vfw:")){
                    inLocator=cdi.getLocator();

                    inDS=Manager.createDataSource(inLocator);     
                    processor=Manager.createProcessor(inDS);     
               }
          }
          while(processor.getState()<Processor.Configured){
               processor.configure();
          }
          
          processor.setContentDescriptor(new FileTypeDescriptor(FileTypeDescriptor.MPEG));
          
          while(processor.getState()<processor.Realized){
               processor.realize();
          }

          outDS=processor.getDataOutput();
          outLocator=new MediaLocator("file://test.mpeg");

          dSink=Manager.createDataSink(outDS,outLocator); //--throws NoDataSinkException--(why?)
          dSink.open();

          swc=(StreamWriterControl)processor.getControl("javax.media.control.StreamWriterControl");
          swc.setStreamSizeLimit(4096000);
          
          processor.start();
     }
}

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points