Package javax.media.format

Examples of javax.media.format.AudioFormat


      if (!(input instanceof AudioFormat))
      { 
        logger.warning(this.getClass().getSimpleName() + ".getSupportedOutputFormats: input format does not match, returning format array of {null} for " + input); // this can cause an NPE in JMF if it ever happens.
        return new Format[] {null};
      }
      final AudioFormat inputCast = (AudioFormat) input;
      if (!inputCast.getEncoding().equals(AudioFormat.ALAW) ||
        (inputCast.getSampleSizeInBits() != 8 && inputCast.getSampleSizeInBits() != Format.NOT_SPECIFIED) ||
        (inputCast.getChannels() != 1 && inputCast.getChannels() != Format.NOT_SPECIFIED) ||
        (inputCast.getFrameSizeInBits() != 8 && inputCast.getFrameSizeInBits() != Format.NOT_SPECIFIED)
        )
      {
        logger.warning(this.getClass().getSimpleName() + ".getSupportedOutputFormats: input format does not match, returning format array of {null} for " + input); // this can cause an NPE in JMF if it ever happens.
        return new Format[] {null};
      }
      final AudioFormat result = new AudioFormat(BonusAudioFormatEncodings.ALAW_RTP, inputCast.getSampleRate(), 8,
          1, inputCast.getEndian(), inputCast.getSigned(), 8,
          inputCast.getFrameRate(), inputCast.getDataType());

      return new Format[] {result};
    }
View Full Code Here


    assertEquals(new IndexedColorFormat(new Dimension(1, 1), 2000, Format.byteArray, -1.f, 1, 2, new byte[] {0, 0}, new byte[] {0, 0}, new byte[] {0, 0}).toString(), "IRGB, 1x1, Length=2000");
    assertEquals(new IndexedColorFormat(new Dimension(1, 1), -1, Format.byteArray, -1.f, 1, 2, new byte[] {0, 0}, new byte[] {0, 0}, new byte[] {0, 0}).toString(), "IRGB, 1x1");
    assertEquals(new IndexedColorFormat(null, -1, Format.byteArray, -1.f, 1, 2, new byte[] {0, 0}, new byte[] {0, 0}, new byte[] {0, 0}).toString(), "IRGB");
 
 
    assertEquals(new AudioFormat(AudioFormat.DOLBYAC3).toString(), "dolbyac3, Unknown Sample Rate");
    assertEquals(new AudioFormat(AudioFormat.DOLBYAC3, 2.0, 1, 2, 3, 4, 5, 6.0, Format.byteArray).toString(), "dolbyac3, 2.0 Hz, 1-bit, Stereo, Unsigned, 6.0 frame rate, FrameSize=5 bits");
    assertEquals(new AudioFormat(AudioFormat.DOLBYAC3, 2.0, 1, 1, 3, 4, 5, 6.0, Format.byteArray).toString(), "dolbyac3, 2.0 Hz, 1-bit, Mono, Unsigned, 6.0 frame rate, FrameSize=5 bits");
    assertEquals(new AudioFormat(AudioFormat.DOLBYAC3, 2.0, 1, 0, 3, 4, 5, 6.0, Format.byteArray).toString(), "dolbyac3, 2.0 Hz, 1-bit, 0-channel, Unsigned, 6.0 frame rate, FrameSize=5 bits");
    assertEquals(new AudioFormat(AudioFormat.DOLBYAC3, 2.0, 1, 3, 3, 4, 5, 6.0, Format.byteArray).toString(), "dolbyac3, 2.0 Hz, 1-bit, 3-channel, Unsigned, 6.0 frame rate, FrameSize=5 bits");
    assertEquals(new AudioFormat(AudioFormat.DOLBYAC3, 2.0, 1, 3, 3, 0, 5, 6.0, Format.byteArray).toString(), "dolbyac3, 2.0 Hz, 1-bit, 3-channel, Unsigned, 6.0 frame rate, FrameSize=5 bits");
    assertEquals(new AudioFormat(AudioFormat.DOLBYAC3, 2.0, 1, 3, 3, 1, 5, 6.0, Format.byteArray).toString(), "dolbyac3, 2.0 Hz, 1-bit, 3-channel, Signed, 6.0 frame rate, FrameSize=5 bits");
    assertEquals(new AudioFormat(AudioFormat.DOLBYAC3, 2.0, 32, 3, 1, 1, 5, 6.0, Format.byteArray).toString(), "dolbyac3, 2.0 Hz, 32-bit, 3-channel, BigEndian, Signed, 6.0 frame rate, FrameSize=5 bits");
    assertEquals(new AudioFormat(AudioFormat.DOLBYAC3, 2.0, 32, 3, 0, 1, 5, 6.0, Format.byteArray).toString(), "dolbyac3, 2.0 Hz, 32-bit, 3-channel, LittleEndian, Signed, 6.0 frame rate, FrameSize=5 bits");
    assertEquals(new AudioFormat(AudioFormat.LINEAR, 2.0, 16, 3, 1, 1, 5, 6.0, Format.byteArray).toString(), "LINEAR, 2.0 Hz, 16-bit, 3-channel, BigEndian, Signed, 6.0 frame rate, FrameSize=5 bits");
    assertEquals(new AudioFormat(AudioFormat.LINEAR, 2.0, 8, 3, 1, 1, 5, 6.0, Format.byteArray).toString(), "LINEAR, 2.0 Hz, 8-bit, 3-channel, Signed, 6.0 frame rate, FrameSize=5 bits");
    assertEquals(new AudioFormat(AudioFormat.LINEAR, 2.0, 9, 3, 1, 1, 5, 6.0, Format.byteArray).toString(), "LINEAR, 2.0 Hz, 9-bit, 3-channel, BigEndian, Signed, 6.0 frame rate, FrameSize=5 bits");
    assertEquals(new AudioFormat(AudioFormat.LINEAR, 2.0, -1, 3, 1, 1, 5, 6.0, Format.byteArray).toString(), "LINEAR, 2.0 Hz, 3-channel, Signed, 6.0 frame rate, FrameSize=5 bits");
    assertEquals(new AudioFormat(null).toString(), "null, Unknown Sample Rate");
  }
View Full Code Here

      assertEquals(f2.getSize(), null);
     
    }

    {
      final AudioFormat f1 = new AudioFormat(AudioFormat.DOLBYAC3, 2.0, 1, 2, 3, 4, 5, 6.0, Format.byteArray);
      final AudioFormat f2 = (AudioFormat) f1.relax();
      assertTrue(f1.equals(f2));
      assertEquals(f2.getSampleRate(), f1.getSampleRate());
      assertEquals(f2.getChannels(), f1.getChannels());
      assertEquals(f2.getEndian(), f1.getEndian());
      assertEquals(f2.getEncoding(), f1.getEncoding());
      assertEquals(f2.getDataType(), f1.getDataType());
      assertEquals(f2.getFrameRate(), f1.getFrameRate());
      assertEquals(f2.getFrameSizeInBits(), f1.getFrameSizeInBits());
      assertEquals(f2.getSampleSizeInBits(), f1.getSampleSizeInBits());
      assertEquals(f2.getSigned(), f1.getSigned());
     
    }

    {
      final RGBFormat f1 = new RGBFormat(new Dimension(1, 1), 2000, Format.byteArray, 2.f, 1, 2, 3, 4, 5, 6, 7, 8);
      final RGBFormat f2 = (RGBFormat) f1.relax();
      assertFalse(f1.equals(f2));
      assertEquals(f2.getRedMask(), f1.getRedMask());
      assertEquals(f2.getGreenMask(), f1.getGreenMask());
      assertEquals(f2.getBlueMask(), f1.getBlueMask());
      assertEquals(f2.getEncoding(), f1.getEncoding());
      assertEquals(f2.getDataType(), f1.getDataType());
      assertEquals(f2.getFrameRate(), -1.f);
      assertEquals(f2.getLineStride(), -1);
      assertEquals(f2.getEndian(), f1.getEndian());
      assertEquals(f2.getBitsPerPixel(), f1.getBitsPerPixel());
      assertEquals(f2.getFlipped(), f1.getFlipped());
      assertEquals(f2.getMaxDataLength(), -1);
      assertEquals(f2.getSize(), null);
     
    }

    {
      final YUVFormat f1 = new YUVFormat(new Dimension(1, 1), 2000, Format.byteArray, 2.f, 1, 2, 3, 4, 5, 6);
      final YUVFormat f2 = (YUVFormat) f1.relax();
      assertFalse(f1.equals(f2));
      assertEquals(f2.getEncoding(), f1.getEncoding());
      assertEquals(f2.getDataType(), f1.getDataType());
      assertEquals(f2.getFrameRate(), -1.f);
      assertEquals(f2.getMaxDataLength(), -1);
      assertEquals(f2.getSize(), null);
      assertEquals(f2.getOffsetU(), -1);
      assertEquals(f2.getOffsetV(), -1);
      assertEquals(f2.getOffsetY(), -1);
      assertEquals(f2.getStrideUV(), -1);
      assertEquals(f2.getStrideY(), -1);
      assertEquals(f2.getYuvType(), f1.getYuvType());
     
    }
   
    {
      final JPEGFormat f1 = new JPEGFormat(new Dimension(1, 1), 2000, Format.byteArray, 2.f, 1, 2);
      final JPEGFormat f2 = (JPEGFormat) f1.relax();
      assertFalse(f1.equals(f2));
      assertEquals(f2.getEncoding(), f1.getEncoding());
      assertEquals(f2.getDataType(), f1.getDataType());
      assertEquals(f2.getFrameRate(), -1.f);
      assertEquals(f2.getMaxDataLength(), -1);
      assertEquals(f2.getSize(), null);
      assertEquals(f2.getQFactor(), f1.getQFactor());
      assertEquals(f2.getDecimation(), f1.getDecimation());
     
    }
   
    {
      final H261Format f1 = new H261Format(new Dimension(1, 1), 2000, Format.byteArray, 2.f, 1);
      final H261Format f2 = (H261Format) f1.relax();
      assertFalse(f1.equals(f2));
      assertEquals(f2.getEncoding(), f1.getEncoding());
      assertEquals(f2.getDataType(), f1.getDataType());
      assertEquals(f2.getFrameRate(), -1.f);
      assertEquals(f2.getMaxDataLength(), -1);
      assertEquals(f2.getSize(), null);
      assertEquals(f2.getStillImageTransmission(), f1.getStillImageTransmission());
     
    }

    {
      final H263Format f1 = new H263Format(new Dimension(1, 1), 2000, Format.byteArray, 2.f, 1, 2, 3, 4, 5, 6);
      final H263Format f2 = (H263Format) f1.relax();
      assertFalse(f1.equals(f2));
      assertEquals(f2.getEncoding(), f1.getEncoding());
      assertEquals(f2.getDataType(), f1.getDataType());
      assertEquals(f2.getFrameRate(), -1.f);
      assertEquals(f2.getMaxDataLength(), -1);
      assertEquals(f2.getSize(), null);
      assertEquals(f2.getAdvancedPrediction(), f1.getAdvancedPrediction());
      assertEquals(f2.getArithmeticCoding(), f1.getArithmeticCoding());
      assertEquals(f2.getErrorCompensation(), f1.getErrorCompensation());
      assertEquals(f2.getHrDB(), f1.getHrDB());
      assertEquals(f2.getPBFrames(), f1.getPBFrames());
      assertEquals(f2.getUnrestrictedVector(), f1.getUnrestrictedVector());
     
    }

  }
View Full Code Here

  }
 
  public DePacketizer()
  {
    super();
    this.inputFormats = new Format[] {new AudioFormat(BonusAudioFormatEncodings.ALAW_RTP, -1.0, -1, -1, -1, -1, -1, -1.0, Format.byteArray)};
  }
View Full Code Here

   
      if (!(input instanceof AudioFormat))
      {  logger.warning(this.getClass().getSimpleName() + ".getSupportedOutputFormats: input format does not match, returning format array of {null} for " + input); // this can cause an NPE in JMF if it ever happens.
        return new Format[] {null};
      }
      final AudioFormat inputCast = (AudioFormat) input;
      if (!inputCast.getEncoding().equals(BonusAudioFormatEncodings.ALAW_RTP))
      { 
        logger.warning(this.getClass().getSimpleName() + ".getSupportedOutputFormats: input format does not match, returning format array of {null} for " + input); // this can cause an NPE in JMF if it ever happens.
        return new Format[] {null};
      }
      final AudioFormat result = new AudioFormat(AudioFormat.ALAW, inputCast.getSampleRate(), inputCast.getSampleSizeInBits(),
          inputCast.getChannels(), inputCast.getEndian(), inputCast.getSigned(), inputCast.getFrameSizeInBits(),
          inputCast.getFrameRate(), inputCast.getDataType());

      return new Format[] {result};
    }
View Full Code Here

 
  public Decoder()
  {
    super();
    this.inputFormats = new Format[] {
        new AudioFormat(AudioFormat.ALAW, -1.0, 8, 1, -1, AudioFormat.SIGNED, 8, -1.0, Format.byteArray)
        };
   
  }
View Full Code Here

  @Override
  public Format setOutputFormat(Format format)
  {
    if (!(format instanceof AudioFormat))
      return null;
    final AudioFormat audioFormat = (AudioFormat) format;
    return super.setOutputFormat(AudioFormatCompleter.complete(audioFormat));
  }
View Full Code Here

   
      if (!(input instanceof AudioFormat))
      {  logger.warning(this.getClass().getSimpleName() + ".getSupportedOutputFormats: input format does not match, returning format array of {null} for " + input); // this can cause an NPE in JMF if it ever happens.
        return new Format[] {null};
      }
      final AudioFormat inputCast = (AudioFormat) input;
      if (!inputCast.getEncoding().equals(AudioFormat.ALAW) ||
        (inputCast.getSampleSizeInBits() != 8 && inputCast.getSampleSizeInBits() != Format.NOT_SPECIFIED) ||
        (inputCast.getChannels() != 1 && inputCast.getChannels() != Format.NOT_SPECIFIED) ||
        (inputCast.getSigned() != AudioFormat.SIGNED && inputCast.getSigned() != Format.NOT_SPECIFIED) ||
        (inputCast.getFrameSizeInBits() != 8 && inputCast.getFrameSizeInBits() != Format.NOT_SPECIFIED) ||
        (inputCast.getDataType() != null && inputCast.getDataType() != Format.byteArray)
        )
      { 
        logger.warning(this.getClass().getSimpleName() + ".getSupportedOutputFormats: input format does not match, returning format array of {null} for " + input); // this can cause an NPE in JMF if it ever happens.
        return new Format[] {null};
      }
      final AudioFormat result = new AudioFormat(AudioFormat.LINEAR, inputCast.getSampleRate(), 16,
          1, inputCast.getEndian(), AudioFormat.SIGNED, 16,
          inputCast.getFrameRate(), Format.byteArray);

      return new Format[] {result};
    }
View Full Code Here

    assertEquals(new YUVFormat().getEncoding(), "yuv");
    assertEquals(new YUVFormat().getOffsetV(), -1);
    assertTrue(new YUVFormat().getSize() == null);
    assertEquals(new YUVFormat().getDataType(), Format.byteArray);
   
    assertEquals(new AudioFormat(AudioFormat.DOLBYAC3).getDataType(), Format.byteArray);

  }
View Full Code Here

  public void testMatches()
  {
    // strangely, WavAudioFormat and AudioFormat match.
    {
      final WavAudioFormat f = new WavAudioFormat("abc");
      final AudioFormat f2 = new AudioFormat("abc");
      assertEquals(f.matches(f2), true);
      assertEquals(f2.matches(f), true);
    }
   
    {
     
      final WavAudioFormat f = new WavAudioFormat("abc", 1.0, 2, 3, 7, 4, 5, 6, 7, byte[].class, new byte[0]);
      final AudioFormat f2 = new AudioFormat("abc", 1.0, 2, 3, 4, 5, 6, 7, byte[].class);
      assertEquals(f.matches(f2), false);
      assertEquals(f2.matches(f), false);
    }
   
  }
View Full Code Here

TOP

Related Classes of javax.media.format.AudioFormat

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.