Package com.xuggle.xuggler

Examples of com.xuggle.xuggler.IContainer


  }

  @Test
  public void testSeekKeyFrameWithInvalidStream()
  {
    IContainer container = IContainer.make();
   
    int retval = -1;
    retval = container.open(mSampleFile, IContainer.Type.READ, null);
    assertTrue("could not open file", retval >= 0);

    retval = container.seekKeyFrame(2, 20*1000, IURLProtocolHandler.SEEK_CUR);
    assertTrue("should fail as only 2 strems in this file", retval <0);
  }
View Full Code Here


  }

  @Test
  public void testGetAndSetProperty()
  {
    IContainer container = IContainer.make();

    int numProperties = container.getNumProperties();
    assertTrue("should be able to set properties before opening",
        numProperties>0);

    int retval = -1;
    retval = container.open(mSampleFile, IContainer.Type.READ, null);
    assertTrue("could not open file", retval >= 0);

    assertEquals("should have same properties",
        numProperties, container.getNumProperties());
    long probeSize = container.getPropertyAsLong("probesize");
    log.debug("probesize: {}", probeSize);
    assertTrue("should have a non-zero probesize",
        probeSize > 0);
    assertTrue("should succeed",
        container.setProperty("probesize", 53535353)>=0);
    assertEquals("should be equal",
        53535353,
        container.getPropertyAsLong("probesize"));
    assertTrue("should fail",
        container.setProperty("notapropertyatall", 15) <0);
   
  }
View Full Code Here

  }
 
  @Test
  public void testGetFlags()
  {
    IContainer container = IContainer.make();
   
    int retval = -1;
    retval = container.open(mSampleFile, IContainer.Type.READ, null);
    assertTrue("could not open file", retval >= 0);

    int flags = container.getFlags();
    assertEquals("container should have no flags: " + flags, flags, 0);
   
    container.close();
  }
View Full Code Here

  }

  @Test
  public void testSetFlags()
  {
    IContainer container = IContainer.make();
   
    int retval = -1;
    retval = container.open(mSampleFile, IContainer.Type.READ, null);
    assertTrue("could not open file", retval >= 0);

    int flags = container.getFlags();
    assertEquals("container should have no flags: " + flags, flags, 0);
   
    boolean genPts = container.getFlag(IContainer.Flags.FLAG_GENPTS);
    assertTrue("should be false", !genPts);
   
    container.setFlag(IContainer.Flags.FLAG_GENPTS, true);
    genPts = container.getFlag(IContainer.Flags.FLAG_GENPTS);
    assertTrue("should be true", genPts);
   
    container.close();
  }
View Full Code Here

  }
 
  @Test
  public void testWriteTrailerAfterCodecClosingFails()
  {
    IContainer container = IContainer.make();
   
    // now, try opening a container.
    int retval = container.open("file:"+this.getClass().getName()+"_"+this.getName()+".flv",
        IContainer.Type.WRITE, null);
    assertTrue("could not open file for writing", retval >= 0);

    // add a stream
    IStream stream = container.addNewStream(0);
    IStreamCoder coder = stream.getStreamCoder();
    coder.setCodec(ICodec.ID.CODEC_ID_MP3);
    coder.setChannels(1);
    coder.setSampleRate(22050);
    retval = coder.open();
    assertTrue("could not open audio codec", retval >= 0);
    retval = container.writeHeader();
    assertTrue("could not write header", retval >= 0);
   
    // now close the codec
    retval = coder.close();
    assertTrue("could not close audio codec", retval >= 0);
   
    // Now, this should fail; in previous versions it would work but could crash the JVM
    retval = container.writeTrailer();
    assertTrue("this should fail", retval <0);
   
    retval = container.close();
    assertTrue("could not close file", retval >= 0);
   
  }
View Full Code Here

  }

  @Test
  public void testGetURL()
  {
    IContainer container = IContainer.make();
   
    int retval = -1;
    retval = container.open(mSampleFile, IContainer.Type.READ, null);
    assertTrue("could not open file", retval >= 0);

    assertEquals("should be the same", mSampleFile, container.getURL());
  }
View Full Code Here

  }
 
  @Test
  public void testGetURLEmptyContainer()
  {
    IContainer container = IContainer.make();
    assertNull("should be null", container.getURL());

    int retval = container.open("", IContainer.Type.READ, null);
    assertTrue("should fail", retval < 0);

    assertNull("should be null", container.getURL());

  }
View Full Code Here

  }
 
  @Test
  public void testFlushPacket()
  {
    IContainer container = IContainer.make();
   
    // now, try opening a container.
    int retval = container.open("file:"+this.getClass().getName()+"_"+this.getName()+".flv",
        IContainer.Type.WRITE, null);
    assertTrue("could not open file for writing", retval >= 0);

    // add a stream
    IStream stream = container.addNewStream(0);
    IStreamCoder coder = stream.getStreamCoder();
    coder.setCodec(ICodec.ID.CODEC_ID_MP3);
    coder.setChannels(1);
    coder.setSampleRate(22050);
    retval = coder.open();
    assertTrue("could not open audio codec", retval >= 0);
    retval = container.writeHeader();
    assertTrue("could not write header", retval >= 0);
   
    // Try a flush
    retval = container.flushPackets();
    assertTrue("could not flush packets", retval >= 0);
   
    // Now, this should fail; in previous versions it would work but could crash the JVM
    retval = container.writeTrailer();
    assertTrue("this should fail", retval >=0);

    // now close the codec
    retval = coder.close();
    assertTrue("could not close audio codec", retval >= 0);
   

    retval = container.close();
    assertTrue("could not close file", retval >= 0);
   
  }
View Full Code Here

  }

  @Test
  public void testWriteFailsOnReadOnlyContainers()
  {
    IContainer container = IContainer.make();
   
    int retval = -1;
    retval = container.open(mSampleFile, IContainer.Type.READ, null);
    assertTrue("could not open file", retval >= 0);
   
    retval = container.writeHeader();
    assertTrue("should fail on read only file", retval < 0);
   
    IPacket pkt = IPacket.make();
    retval = container.writePacket(pkt);
    assertTrue("should fail on read only file", retval < 0);

    retval = container.writeTrailer();
    assertTrue("should fail on read only file", retval < 0);
   
   
  }
View Full Code Here

   * http://code.google.com/p/xuggle/issues/detail?id=97
   */
  @Test
  public void testIssue97Regression()
  {
    IContainer container = IContainer.make();
   
    int retval = -1;
    retval = container.open(
        this.getClass().getName()+"_"+TestUtils.getNameOfCallingMethod()
        + ".mp3", IContainer.Type.WRITE, null);
    assertTrue("could not open file", retval >= 0);
   
    retval = container.writeHeader();
    assertTrue("should fail instead of core dumping", retval < 0);
  }
View Full Code Here

TOP

Related Classes of com.xuggle.xuggler.IContainer

Copyright © 2018 www.massapicom. 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.