Examples of URLDataSource


Examples of javax.media.protocol.URLDataSource

   
    try
    {
      // test to verify that URLDataSource does not use MimeManager
      final File file = File.createTempFile("test", ".html");
      final URLDataSource d = new URLDataSource(new URL("file://" + file.getAbsolutePath()));
      d.connect();
      assertEquals(d.getContentType(), "text.html");
     
     
      com.sun.media.protocol.file.DataSource d2 = new com.sun.media.protocol.file.DataSource();
      d2.setLocator(new MediaLocator("file://" + file.getAbsolutePath()));
      d2.connect();
      assertEquals(d2.getContentType(), "text.html");
     
     
     
    } catch (MalformedURLException e)
    {
      e.printStackTrace();
      assertTrue(false);
    } catch (IOException e)
    {
      e.printStackTrace();
      assertTrue(false);
    }
   
    try
    {
      // test to verify that URLDataSource does not use MimeManager
      File file = new File("samplemedia/safexmas.mov");
      URLDataSource d = new URLDataSource(new URL("file://" + file.getAbsolutePath()));
      d.connect();
      assertEquals(d.getContentType(), "video.quicktime");
     
    } catch (MalformedURLException e)
    {
      e.printStackTrace();
      assertTrue(false);
    } catch (IOException e)
    {
      e.printStackTrace();
      assertTrue(false);
    }

   
   
   
    assertEquals(MimeManager.addMimeType("foo", "foo/bar"), true);

   
    try
    {
      File file = File.createTempFile("test", "foo");
      // test to verify that URLDataSource does not use MimeManager
      //File file = new File("test.foo");
      URLDataSource d = new URLDataSource(new URL("file://" + file.getAbsolutePath()));
      d.connect();
      assertEquals(d.getContentType(), "content.unknown");
     
    } catch (MalformedURLException e)
    {
      e.printStackTrace();
      assertTrue(false);
View Full Code Here

Examples of javax.media.protocol.URLDataSource

   
    // TODO: test http
   
    String test = "file://" + new File("samplemedia/safexmas.mov").getAbsolutePath();
   
    URLDataSource s = new URLDataSource(new URL(test));
    assertTrue(s.getLocator() != null);
    assertTrue(s.getLocator().getURL().getProtocol().equals("file"));
    assertEquals(s.getLocator().getClass().getName(), "javax.media.MediaLocator");
 
    assertEquals(s.getControls().length, 0);
    try
    {
      s.getContentType();
    }
    catch (Error e)
    {  assertTrue(e.getClass() == Error.class);
      assertEquals(e.getMessage(), "Source is unconnected.");
    }
   
    try
    {
      s.getStreams();
    }
    catch (Error e)
    {  assertTrue(e.getClass() == Error.class);
      assertEquals(e.getMessage(), "Unconnected source.");
    }
    s.connect();
    assertEquals(s.getContentType(), "video.quicktime");
    PullSourceStream sts[] = s.getStreams();
    assertEquals(sts.length, 1);
   
    PullSourceStream st = sts[0];
    assertEquals(st.getControls().length, 0);
    ContentDescriptor cd = st.getContentDescriptor();
    assertEquals(cd.getContentType(), "video.quicktime");
    assertEquals(cd.getEncoding(), "video.quicktime");
    assertTrue(cd.getDataType() == byte[].class);
   
   
    assertFalse(st.endOfStream());
    assertEquals(st.getContentLength(), 3547908L);
    assertEquals(s.getDuration().getNanoseconds(), 9223372036854775806L);
    assertEquals(s.getDuration().getNanoseconds(), Time.TIME_UNKNOWN.getNanoseconds());
    assertFalse(st.willReadBlock());
    assertFalse(st.endOfStream());
   
    {
      final byte[] buf = new byte[1];
      final int res = st.read(buf, 0, buf.length);
      assertEquals(res, 1);
    }
   
    s.start();
    s.stop();
    s.connect()// new connection - new streams?
   
    assertEquals(s.getStreams().length, 1);
    assertTrue(s.getStreams() != sts);
    assertTrue(s.getStreams()[0] != st);
   
    s.disconnect();
   
    // disconnect does not affect read.
    {
      final byte[] buf = new byte[1];
      final int res = st.read(buf, 0, buf.length);
View Full Code Here

Examples of javax.media.protocol.URLDataSource

        }
        catch (Exception e)
        {   logger.log(Level.WARNING, ""  + e, e);
            throw new NoPlayerException();
        }
        final URLDataSource dataSource = new URLDataSource(url);
        dataSource.connect();   // TODO: there is a problem because we connect to the datasource here, but
                                // the following call may try twice or more to use the datasource with a player, once
                                // for the right content type, and multiple times for unknown.  The first attempt (for example) may actually
                                // read data, in which case the second one will be missing data when it reads.
                                // really, the datasource needs to be recreated.
                                // The workaround for now is that URLDataSource (and others) allows repeated connect() calls.
View Full Code Here

Examples of javax.media.protocol.URLDataSource

        }
        catch (Exception e)
        {   logger.log(Level.WARNING, ""  + e, e);
            throw new NoDataSourceException();
        }
        final URLDataSource dataSource = new URLDataSource(url);
        dataSource.connect();
        return dataSource;
    }
View Full Code Here

Examples of uk.ac.starlink.util.URLDataSource

            // read the URL to get the query arguments
            try {
                URL url =_makeURL(_url, "FORMAT=METADATA");
                LOG.info("Reading SLAP server configuration from " + _url);
                VOElement topEl = new VOElementFactory(StoragePolicy.getDefaultPolicy())
                        .makeVOElement(new URLDataSource(url));
                _checkStatus(topEl);

                NodeList params = topEl.getElementsByTagName("PARAM");
                _fieldDesc = new FieldDescAdapter[params.getLength()];
                for (int i = 0; i < _fieldDesc.length; i++) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.