Package javax.media

Examples of javax.media.Format


    Link link = rootDemuxOutputPin.getOwnerNode().getDestLink(rootDemuxOutputPin);
   
    while (link != null)
    {
     
      final Format formatMustMatch;
      if (link.getDestNode() instanceof MuxNode)
        formatMustMatch = link.getDestPin().getFormat();
      else
        formatMustMatch = null;
      if (negotiate(link.getDestPin().getFormat(), link.getDestPin(), formatMustMatch, link.getSourcePin()) == null)
View Full Code Here


 
  /** @param formatMustMatch if not null, the format must match this.  Used for mux input pins only.
   * returns null if negotiation failed.  Sets format on muxInputPin if successful. */
  private static Format negotiate(final Format initialFormat, InputPin inputPin, Format formatMustMatch, OutputPin outputPin)
  {
    Format f = initialFormat; // f will be the curent format we are attempting to use
   
    if (formatMustMatch != null)
    {  if (!formatMustMatch.matches(f))
      {  return null// TODO: do this in the loop as well?
      }
    }
   
    int iterations = 0;
    while (true)
    {
      if (f == null)
        return null;
      if (iterations >= MAX_FORMAT_NEGOTIATION_ITERATIONS)
      {  // just a sanity check, not sure it can or will ever happen.
        logger.warning("negotiate iterated " + MAX_FORMAT_NEGOTIATION_ITERATIONS + " times, probably stuck in infinite loop - abandoning format negotiation");
        logger.warning("src=" + outputPin.getOwnerNode().getPlugIn());
        logger.warning("dest=" + inputPin.getOwnerNode().getPlugIn());
        logger.warning("f=" + f);
        return null;
      }
      ++iterations;
     
      final Format f2 = inputPin.setPlugInInputFormat(f);
      if (f2 == null
      {  logger.warning("Input format rejected by " + inputPin.getOwnerNode().getPlugIn() + ": " + f)// this shouldn't happen, since we chose which nodes to try based on the input formats they offered.
        return null;
      }
      final Format f3;
      if (outputPin.getOwnerNode().getPlugIn() instanceof Codec)
      {
        f3 = outputPin.setPlugInOutputFormat(f2);
      }
      else
View Full Code Here

       
        if (TRACE && logger.isLoggable(Level.FINEST))
        {
          for (int codecOutputFormatIndex = 0; codecOutputFormatIndex < codecOutputFormats.length; ++codecOutputFormatIndex)
          {
            final Format codecOutputFormat = codecOutputFormats[codecOutputFormatIndex];
            logger.finest(indent(depth) + "Found Codec output format: " + codecOutputFormat);
          }
        }
       
        for (int codecOutputFormatIndex = 0; codecOutputFormatIndex < codecOutputFormats.length; ++codecOutputFormatIndex)
        {
          final Format codecOutputFormat = codecOutputFormats[codecOutputFormatIndex];
          if (codecOutputFormat == null)
          {  logger.finer(indent(depth) + "Skipping null Codec (" + codec.getClass() + ") output format, input format: " + f);
            continue;
          }
          if (codecOutputFormat.equals(f))
          {  if (TRACE) logger.finest(indent(depth) + (SKIP_NON_FORMAT_CHANGING_CODECS ? "YES " : "NOT ") + "Skipping Codec output format, same as input format: " + codecOutputFormat);
            if (!FIND_NONSPECIFIC_GRAPH_FIRST && SKIP_NON_FORMAT_CHANGING_CODECS)
              continue// no need to have a codec that does not change formats.  this can happen in the case of
                    // something like com.sun.media.codec.audio.rc.RateCvrt, which will offer an output format
                    // the same as an input format.
          }
         
          // instantiate a new copy of the codec for each pair.
          codecFormatPairs.add(new CodecFormatPair((Codec) instantiate(codecClassName), codecOutputFormat));
        }
       
      }
     
      // now that we have all of the codec/format pairs, sort them (if we know what format we are trying to reach)
      if (muxInputFormat != null)
      {  Collections.sort(codecFormatPairs, new CodecFormatPairProximityComparator(muxInputFormat));
     
//        for (int j = 0; j < codecFormatPairs.size(); ++j)
//        {
//          final CodecFormatPair codecFormatPair = (CodecFormatPair) codecFormatPairs.get(j);
//          final Codec codec =codecFormatPair.getCodec();
//          final Format codecOutputFormat = codecFormatPair.getFormat();
//         
//          if (TRACE) logger.fine(indent(depth) + j + ". Will try " + codec.getClass().getName() + " with output format: " + codecOutputFormat);
// 
//        }
       
        // best-first enabled.
        if (maxBestCodecs > 1)
        {  while (codecFormatPairs.size() > maxBestCodecs)
            codecFormatPairs.remove(maxBestCodecs);
        }
       
        if (TRACE && logger.isLoggable(Level.FINER))
        {
          for (int j = 0; j < codecFormatPairs.size(); ++j)
          {
            final CodecFormatPair codecFormatPair = codecFormatPairs.get(j);
            final Codec codec = codecFormatPair.getCodec();
            final Format codecOutputFormat = codecFormatPair.getFormat();
           
            logger.finer(indent(depth) + j + ". Will try " + codec.getClass().getName() + " with output format: " + codecOutputFormat);
   
          }
        }
View Full Code Here

    // only works once setSupportedInputFormats is called
    c.getSupportedOutputFormats(new VideoFormat("xyz", new Dimension(1, 2), 1000, byte[].class, 2.f));

 
    {
      Format f = new Format("xyz");
      VideoFormat result = (VideoFormat) c.setInputFormat(f)// this calls matches
      assertTrue(null == result);
     
    }
   
View Full Code Here

      streams = new SendStream[numStreams];
      int numStreamsInUse = 0;
      for (int streamIndex = 0; streamIndex < numStreams; ++streamIndex)
      {
        // find the type:
        final Format format = source.getStreams()[streamIndex].getFormat();
        final String elementType;
        if (format instanceof AudioFormat)
          elementType = ParsedRTPUrlElement.AUDIO;
        else if (format instanceof VideoFormat)
          elementType = ParsedRTPUrlElement.VIDEO;
View Full Code Here

   
    final Format[] formats = r.getSupportedInputFormats();
    assertEquals(formats.length, supportedInputFormats.length);
       
    for (int i = 0; i < formats.length; ++i)
    {  Format format = formats[i];
//      System.out.println("\t" + format);
//      if (!format.equals(supportedInputFormats[i]))
//        System.err.println("Not equal: " + format + " " + supportedInputFormats[i]);
      assertEquals(format, supportedInputFormats[i]);
     
View Full Code Here

{

  public void testFormats() throws Exception
  {
   
    assertFalse(new Format(null).isSameEncoding(new Format(null)));
    assertFalse(new Format(null).isSameEncoding((String) null));
    assertFalse(new Format(null).isSameEncoding((Format) null));
   
   
    int count = 0;
    for (int i = 0; i < SerializableTest.formats.length; ++i)
    {
      Format f1 = SerializableTest.formats[i];
//      {
//        checkEncodingCode(f1);
//       
//      }
      assertEquals(f1, f1);
      assertTrue(f1.matches(f1));

      if (f1.getEncoding() != null)
      {
//        if (!f1.isSameEncoding(f1))
//          System.out.println(f1);
        assertTrue(f1.isSameEncoding(f1));
        assertTrue(f1.isSameEncoding(f1.getEncoding()));
      }
      else
      {
        if (f1.isSameEncoding(f1))
          System.out.println(f1);
        assertFalse(f1.isSameEncoding(f1));
        assertFalse(f1.isSameEncoding(f1.getEncoding()));
      }
      assertEquals(f1, f1.clone());
      assertFalse(f1.clone() == f1);
     
      if (f1 instanceof VideoFormat)
      {  final VideoFormat vf1 = (VideoFormat) f1;
        if (vf1.getSize() != null)
          assertFalse(vf1.getSize() == ((VideoFormat) vf1.clone()).getSize());
       
        final VideoFormat fRelax = (VideoFormat) f1.relax();
        assertEquals(fRelax.getEncoding(), vf1.getEncoding());
        assertEquals(fRelax.getDataType(), vf1.getDataType());
        assertEquals(fRelax.getFrameRate(), -1.f);
        assertEquals(fRelax.getMaxDataLength(), -1);
        assertEquals(fRelax.getSize(), null);
                         
      }
     
      if (f1 instanceof RGBFormat)
      {  final RGBFormat vf1 = (RGBFormat) f1;
        if (vf1.getSize() != null)
          assertFalse(vf1.getSize() == ((RGBFormat) vf1.clone()).getSize());
       
        final RGBFormat fRelax = (RGBFormat) f1.relax();
        assertEquals(fRelax.getEncoding(), vf1.getEncoding());
        assertEquals(fRelax.getDataType(), vf1.getDataType());
        assertEquals(fRelax.getFrameRate(), -1.f);
        assertEquals(fRelax.getMaxDataLength(), -1);
        assertEquals(fRelax.getSize(), null);
        assertEquals(fRelax.getLineStride(), -1);
        assertEquals(fRelax.getPixelStride(), -1);
                         
      }
     
      if (f1.getClass() == Format.class)
      {
        final Format fRelax = f1.relax();
        assertEquals(f1, fRelax);
       
       
      }
     
 
     
      for (int j = 0; j < SerializableTest.formats.length; ++j)
      {
        final Format f2 = SerializableTest.formats[j];
           
        final Format f3 = f1.intersects(f2);
     
       
        assertFalse(f3 == f1);
        assertFalse(f3 == f2);
       
View Full Code Here

      else if (localName.equals("Track"))
      {
        // TODO: catch exceptions
        final int index = getIntAttr(atts, "index");
        final String formatStr = getStringAttr(atts, "format");
        Format format = FormatArgUtils.parse(formatStr);
        formatsMap.put(index, format);
        qBuffers.put(index, new ProducerConsumerQueue());
      }
     
      else if (localName.equals("Buffer"))
      {
        currentTrack = getIntAttr(atts, "track");
        final long sequenceNumber = getLongAttr(atts, "sequenceNumber", Buffer.SEQUENCE_UNKNOWN);
        final long timeStamp = getLongAttr(atts, "timeStamp");
        final long duration = getLongAttr(atts, "duration", -1L);
        final int flags = getIntAttr(atts, "flags", 0);
       
        final String formatStr = getStringAttr(atts, "format", null);
       
        final Format format = formatStr == null ? formatsMap.get(currentTrack) : FormatArgUtils.parse(formatStr);

        Buffer buffer = new Buffer();
        buffer.setSequenceNumber(sequenceNumber);
        buffer.setTimeStamp(timeStamp);
        buffer.setDuration(duration);
View Full Code Here

      try
      {
        final Format[] formatsArray = new Format[formatsMap.size()];
        for (int i = 0; i < formatsArray.length; ++i)
        { 
          final Format format = formatsMap.get(i);
          if (format == null)
            throw new SAXException("Expected format for track " + i);
          formatsArray[i] = format;
       
        }
View Full Code Here

  public void test1() throws Exception
  {
    String className = "com.ibm.media.codec.audio.ulaw.JavaEncoder";
    String className2 = "net.sf.fmj.media.codec.audio.ulaw.Encoder";
   
    Format f = new AudioFormat(AudioFormat.LINEAR, -1.0, 16, 1, AudioFormat.BIG_ENDIAN, AudioFormat.SIGNED, 16, -1.0, Format.byteArray);
   
    Codec encoder = open(className, f);
    Codec encoder2 = open(className2, f);
   
    // signed, big: all values with both bytes negative are wrong.  Half of the values are wrong.
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.