Package javax.media

Examples of javax.media.Format


    assertEquals(b2.getStringBuffer().toString(), "");
   
    assertFalse(c.doIsEOM(b2));
    assertEquals(b2.getStringBuffer().toString(), "isEOM\n");
   
    c.setOutputFormat(new Format("zzz"));
    c.doPropagateEOM(b2);
    assertEquals(b2.getStringBuffer().toString(), "isEOM\nsetFormat(zzz)\nsetLength(0)\nsetOffset(0)\nsetEOM\n");
   
    //System.out.println(b2.getStringBuffer().toString());
    assertTrue(c.doIsEOM(b2));
View Full Code Here


  public void testUpdateOutput()
  {
    {
      final MyBasicCodec c = new MyBasicCodec();
      final TracingBuffer b = new TracingBuffer();
      final Format f = new Format("abc");
      c.doUpdateOutput(b, f, 10, 20);
      assertEquals(b.getLength(), 10);
      assertEquals(b.getOffset(), 20);
      assertTrue(b.getFormat() == f);
      //System.out.println(b.getStringBuffer().toString());
      assertEquals(b.getStringBuffer().toString(),
          "setFormat(abc)\n" +
          "setLength(10)\n" +
          "setOffset(20)\n" +
          "getLength\n" +
          "getOffset\n" +
          "getFormat\n");
    }
   
    {
      final MyBasicCodec c = new MyBasicCodec();
      final TracingBuffer b = new TracingBuffer()
      {

        //@Override
        public int getLength()
        {
          super.getLength();
          return 1;
        }
       
      };
      final TracingFormat f = new TracingFormat("abc");
      assertEquals(f.getStringBuffer().toString(), "");
      c.doUpdateOutput(b, f, 10, 20);
      assertEquals(f.getStringBuffer().toString(), "getEncoding\n");
     
      assertEquals(b.getLength(), 1);
      assertEquals(b.getOffset(), 20);
      assertTrue(b.getFormat() == f);
      //System.out.println(b.getStringBuffer().toString());
      assertEquals(b.getStringBuffer().toString(),
          "setFormat(abc)\n" +
          "setLength(10)\n" +
          "setOffset(20)\n" +
          "getLength\n" +
          "getOffset\n" +
          "getFormat\n");
     
    }
   
    {
      final MyBasicCodec c = new MyBasicCodec();
      final TracingBuffer b = new TracingBuffer();
      final TracingFormat f = new TracingFormat(null);
      c.doUpdateOutput(b, f, 10, 20);
      assertEquals(f.getStringBuffer().toString(), "getEncoding\n");
      assertEquals(b.getLength(), 10);
      assertEquals(b.getOffset(), 20);
      assertTrue(b.getFormat() == f);
      //System.out.println(b.getStringBuffer().toString());
      assertEquals(b.getStringBuffer().toString(),
          "setFormat(null)\n" +
          "setLength(10)\n" +
          "setOffset(20)\n" +
          "getLength\n" +
          "getOffset\n" +
          "getFormat\n");
      assertEquals(f.getStringBuffer().toString(), "getEncoding\n");
      f.toString();
      assertEquals(f.getStringBuffer().toString(), "getEncoding\ngetEncoding\n");
    }

    {
      final MyBasicCodec c = new MyBasicCodec();
      final TracingBuffer b = new TracingBuffer();
      final Format f = null;
      c.doUpdateOutput(b, f, 0, 0);
      assertEquals(b.getLength(), 0);
      assertEquals(b.getOffset(), 0);
      assertTrue(b.getFormat() == f);
      //System.out.println(b.getStringBuffer().toString());
View Full Code Here

         
        }
       
      };
      final Buffer b = new Buffer();
      final Format f = new Format("abc");
      b.setFormat(f);
     
      assertEquals(c.doCheckInputBuffer(b), true);
      assertEquals(sb.toString(), "checkFormat")// checkInputBuffer calls checkFormat
     
      assertEquals(c.doCheckFormat(null), true);
      assertEquals(c.doCheckInputBuffer(new Buffer()), false);
     
    }
   
    {
      final MyBasicCodec c = new MyBasicCodec();
      final Buffer b = new Buffer();
      final Format f = new YUVFormat();
      b.setFormat(f);
      c.setInputFormat(new RGBFormat());
     
      assertEquals(c.doCheckInputBuffer(b), true);
    }
   
    {
      final MyBasicCodec c = new MyBasicCodec();
      final Buffer b = new Buffer();
      final Format f = new Format(null);
      b.setFormat(f);
      b.setLength(-1);
      b.setOffset(-1);
      b.setEOM(true);
      b.setDuration(-1L);
     
      c.setInputFormat(new RGBFormat());
     
      assertEquals(c.doCheckInputBuffer(b), true);
    }
 
    {
      final MyBasicCodec c = new MyBasicCodec();
      final TracingBuffer b = new TracingBuffer();
      final Format f = new Format(null);
      b.setFormat(f);
      b.setEOM(true);
     
      assertEquals(c.doCheckFormat(f), true);
      //System.out.println(b.getStringBuffer().toString());
      assertEquals(b.getStringBuffer().toString(), "setFormat(null)\nsetEOM\n");
     
    }
   
    {
      final MyBasicCodec c = new MyBasicCodec();
      final TracingBuffer b = new TracingBuffer();
      final Format f = new Format(null);
      b.setFormat(f);
      b.setEOM(true);
     
      assertEquals(c.doCheckInputBuffer(b), true);
      assertEquals(b.getStringBuffer().toString(), "setFormat(null)\nsetEOM\nisEOM\n");
     
    }
   
    {
      final MyBasicCodec c = new MyBasicCodec();
      final TracingBuffer b = new TracingBuffer();
      final Format f = null;
      b.setFormat(f);
      b.setEOM(true);
     
      assertEquals(c.doCheckInputBuffer(b), true);
      //System.out.println(b.getStringBuffer().toString());
      assertEquals(b.getStringBuffer().toString(), "setFormat(null)\nsetEOM\nisEOM\n");
     
    }
   
    {
      final MyBasicCodec c = new MyBasicCodec();
      final TracingBuffer b = new TracingBuffer();
      final Format f = new Format(null);
      b.setFormat(f);
     
      assertEquals(b.getStringBuffer().toString(), "setFormat(null)\n");
      assertEquals(c.doCheckInputBuffer(b), true);
      assertEquals(b.getStringBuffer().toString(), "setFormat(null)\nisEOM\ngetFormat\ngetFormat\n");
     
    }
   
    {
      final MyBasicCodec c = new MyBasicCodec();
      final TracingBuffer b = new TracingBuffer();
      final TracingFormat f = new TracingFormat(null);
      b.setFormat(f);
     
      assertEquals(c.doCheckInputBuffer(b), true);
      assertEquals(b.getStringBuffer().toString(), "setFormat(null)\nisEOM\ngetFormat\ngetFormat\n");
     
     
    }

   
    {
      final MyBasicCodec c = new MyBasicCodec();
      final TracingBuffer b = new TracingBuffer();
      final Format f = new Format("xyz");
      b.setFormat(f);
     
      assertEquals(c.doCheckInputBuffer(b), true);
      assertEquals(b.getStringBuffer().toString(), "setFormat(xyz)\nisEOM\ngetFormat\ngetFormat\n");
    }
   
    {
      final MyBasicCodec c = new MyBasicCodec();
      final TracingBuffer b = new TracingBuffer();
      b.setEOM(true);
      final Format f = new Format("xyz");
      b.setFormat(f);
     
      assertEquals(c.doCheckInputBuffer(b), true);
      //System.out.println(b.getStringBuffer().toString());
      assertEquals(b.getStringBuffer().toString(), "setEOM\nsetFormat(xyz)\nisEOM\n");
View Full Code Here

      if (muxInputTrackNumbers[trackNum] < 0)
      {  logger.fine("Rejecting MUX input format " + format + " for track " + trackNum + " because there is no corresponding mux input track");
        return null;
      }
     
      final Format result = mux.setInputFormat(format, muxInputTrackNumbers[trackNum]);
      if (result == null)
      {  logger.fine("Multiplexer rejected input format for track " + trackNum + ": " + format);
        return null;
      }
      muxInputFormats[muxInputTrackNumbers[trackNum]] = result;
View Full Code Here

 

  @Override
  public Format setInputFormat(Format format, int trackID)
  {
    final Format result = super.setInputFormat(format, trackID);
    if (result != null)
    {  if (streams != null// TODO: if null, make sure we set later!
      streams[trackID].setFormat(result);
      }
    }
View Full Code Here

     
    }
    else if (c == Format.class)
    {
 
      final Format o = (Format) f;
      return "new Format(" +
      CGUtils.toLiteral(o.getEncoding()) +
      ", " + dataTypeToStr(o.getDataType())
      + ")";

     
    }
    else if (c == FileTypeDescriptor.class)
    {
      final FileTypeDescriptor o = (FileTypeDescriptor) f;
      return "new FileTypeDescriptor(" +
      CGUtils.toLiteral(o.getEncoding())
      + ")";
    }
    else if (c == ContentDescriptor.class)
    {
      final ContentDescriptor o = (ContentDescriptor) f;
      return "new ContentDescriptor(" +
      CGUtils.toLiteral(o.getEncoding())
      + ")";
    }
    else if (c == com.sun.media.format.WavAudioFormat.class)
    {
      // TODO: are the parameters correct?
      final com.sun.media.format.WavAudioFormat o = (com.sun.media.format.WavAudioFormat) f;
      return "new com.sun.media.format.WavAudioFormat(" +
      CGUtils.toLiteral(o.getEncoding()) +
      ", " + CGUtils.toLiteral(o.getSampleRate()) +
      //", -1" + // int arg TODO - what is this?
      ", " + CGUtils.toLiteral(o.getSampleSizeInBits()) +
      ", " + CGUtils.toLiteral(o.getChannels()) +
      ", " + CGUtils.toLiteral(o.getFrameSizeInBits()) +
      ", " + CGUtils.toLiteral(o.getAverageBytesPerSecond()) +
      ", " + CGUtils.toLiteral(o.getEndian()) +
      ", " + CGUtils.toLiteral(o.getSigned()) +
      ", " + CGUtils.toLiteral((float) o.getFrameRate()) +
      ", " + dataTypeToStr(o.getDataType()) +
      ", " + CGUtils.toLiteral(o.getCodecSpecificHeader())
      + ")";
    }
    else
    throw new IllegalArgumentException("" + f.getClass());
      //System.err.println(f.getClass());
View Full Code Here

   
    {
      final Buffer b1 = new Buffer();
      b1.setData(new byte[10]);
      b1.setFlags(1);
      Format f = new VideoFormat(VideoFormat.JPEG);
      b1.setFormat(f);
      assertTrue(f == b1.getFormat());
      b1.setHeader(new byte[4]);
     
      testBuffer(b1);
View Full Code Here

  {
   

    final MyBasicPlugIn p = new MyBasicPlugIn();
    {
      final Format in = new VideoFormat(null, null, -1, null, -1.0f);
      final Format[] outs = new Format[]{
          new AudioFormat("ULAW", 8000.0, 8, 1, -1, -1, -1, -1.0, Format.byteArray),
          new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff0000, 0xff00, 0xff, 1, -1, 0, -1)
         
      };
      assertTrue(BasicPlugIn.matches(in, outs) == outs[1]);
     
      // Sun's BasicPlugIn throws an NPE in this situation.  So for now, so will FMJ's.
      try
      {
        BasicPlugIn.matches(null, outs);
        assertTrue(false);
      }
      catch (NullPointerException e)
      {
      }
    }

    {
      final Format in = new VideoFormat(null, null, -1, null, -1.0f);
      final Format[] outs = new Format[]{
          new AudioFormat("ULAW", 8000.0, 8, 1, -1, -1, -1, -1.0, Format.byteArray),
          new AudioFormat("ULAW", 8000.0, 8, 1, -1, -1, -1, -1.0, Format.intArray)
         
      };
      assertTrue(BasicPlugIn.matches(in, outs) == null);
    }
   
    {
      final Format in = new VideoFormat(null, null, -1, null, -1.0f);
      final Format[] outs = new Format[]{
         
         
      };
      assertTrue(BasicPlugIn.matches(in, outs) == null);
View Full Code Here

   
    // buf of len 5 with length set to 5, null format datatype:
    {
      final Buffer b = new Buffer();
      final byte[] bBuf = new byte[5];
      b.setFormat(new Format("abc", null));
      b.setData(bBuf);
      b.setLength(bBuf.length);

 
      final byte[] ba = (byte[]) p.doValidateData(b, 0, allowNative);
      assertEquals(ba, null)
      assertEquals(b.getData(), bBuf);

       
     
    }
   
    // buf of len 5 with length set to 5, byte array format
    final String[] encodings = new String[] {null, "abc"};
    for (int k = 0; k < encodings.length; ++k)
    {
      final String encoding = encodings[k];
   
      final Buffer b = new Buffer();
      final byte[] bBuf = new byte[] {1, 2, 3, 4, 5};
      b.setFormat(new Format(encoding, Format.byteArray));
      b.setData(bBuf);
      b.setLength(bBuf.length);

     
      for (int i = 0; i < 10; ++i)
      {
        final byte[] ba = (byte[]) p.doValidateData(b, i, allowNative);
        final int max = i > bBuf.length ? i : bBuf.length;
        assertEquals(ba.length, max)
        for (int j = 0; j < i; ++j)
        { 
          if (j < bBuf.length)
            assertEquals(ba[j], bBuf[j]);
          else
            assertEquals(ba[j], 0);
        }
      }
    }
   
   
   
    // non-byte-array format: - reallocates as type in format.
    {
      final Buffer b = new Buffer();
      final byte[] bBuf = new byte[] {1, 2, 3, 4, 5};
      b.setFormat(new Format(null, Format.intArray));
      b.setData(bBuf);
      b.setLength(bBuf.length);

     
      for (int i = 0; i < 10; ++i)
      {
        final int[] ba = (int[]) p.doValidateData(b, i, allowNative);
        final int max = i > bBuf.length ? i : bBuf.length;
        assertEquals(ba.length, i)
        for (int j = 0; j < i; ++j)
        {  assertEquals(ba[j], 0);
        }
      }
    }
   
//     don't set length
    {
      final Buffer b = new Buffer();
      final byte[] bBuf = new byte[] {1, 2, 3, 4, 5};
      b.setFormat(new Format(null, Format.byteArray));
      b.setData(bBuf);
      //b.setLength(bBuf.length);

     
      for (int i = 0; i < 10; ++i)
View Full Code Here

      b.setData(bBuf);
      b.setLength(100);
      b.setOffset(20);
      b.setDuration(100000);
      b.setDiscard(false);
      b.setFormat(new Format("abc", Format.byteArray));
      b.setSequenceNumber(1234);
      b.setTimeStamp(9999L);
      assertEquals(p.doGetNativeData(b.getData()), 0L);
     
    }
   
    {
      final Buffer b = new Buffer();
      final int[] bBuf = new int[] {1, 2, 3, 4, 5};
      b.setData(bBuf);
      b.setLength(100);
      b.setOffset(20);
      b.setDuration(100000);
      b.setDiscard(false);
      b.setFormat(new Format("abc", Format.intArray));
      b.setSequenceNumber(1234);
      b.setTimeStamp(9999L);
      assertEquals(p.doGetNativeData(b.getData()), 0L);
     
    }
View Full Code Here

TOP

Related Classes of javax.media.Format

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.