Examples of IAudioSamples


Examples of com.xuggle.xuggler.IAudioSamples

  public void testGetBufferType()
  {
    int sampleRate = 440;
    int channels=1;
   
    IAudioSamples samples = IAudioSamples.make(sampleRate, 1);
    assertNotNull(samples);

    samples.setComplete(true, sampleRate, sampleRate,
        channels, IAudioSamples.Format.FMT_S16, 0);
    assertTrue(samples.isComplete());
   
    IBuffer buffer;
    buffer = samples.getData();
    assertEquals(IBuffer.Type.IBUFFER_SINT16, buffer.getType());

    samples.setComplete(true, sampleRate, sampleRate,
        channels, IAudioSamples.Format.FMT_S32, 0);
    assertTrue(samples.isComplete());
    buffer = samples.getData();
    assertEquals(IBuffer.Type.IBUFFER_SINT32, buffer.getType());
}
View Full Code Here

Examples of com.xuggle.xuggler.IAudioSamples

      mContainer = ((IMediaCoder)event.getSource()).getContainer();
    }

    // establish the audio samples

    final IAudioSamples samples = event.getAudioSamples();

    // if in realtime mode, add samples to queue audio

    if (getMode().isRealTime())
    {
View Full Code Here

Examples of com.xuggle.xuggler.IAudioSamples

         * coder tells us is in this buffer.
         *
         * We also pass in a buffer size (1024 in our example), although Xuggler
         * will probably allocate more space than just the 1024 (it's not important why).
         */
        IAudioSamples samples = IAudioSamples.make(1024, audioCoder.getChannels());
       
        /*
         * A packet can actually contain multiple sets of samples (or frames of samples
         * in audio-decoding speak).  So, we may need to call decode audio multiple
         * times at different offsets in the packet's data.  We capture that here.
         */
        int offset = 0;
       
        /*
         * Keep going until we've processed all data
         */
        while(offset < packet.getSize())
        {
          int bytesDecoded = audioCoder.decodeAudio(samples, packet, offset);
          if (bytesDecoded < 0)
            throw new RuntimeException("got error decoding audio in: " + filename);
          offset += bytesDecoded;
          /*
           * Some decoder will consume data in a packet, but will not be able to construct
           * a full set of samples yet.  Therefore you should always check if you
           * got a complete set of samples from the decoder
           */
          if (samples.isComplete())
          {
            playJavaSound(samples);
          }
        }
      }
View Full Code Here

Examples of com.xuggle.xuggler.IAudioSamples

    IPacket oPacket = IPacket.make();

    /**
     * Keep some "pointers' we'll use for the audio we're working with.
     */
    IAudioSamples inSamples = null;
    IAudioSamples outSamples = null;
    IAudioSamples reSamples = null;

    int retval = 0;

    /**
     * And keep some convenience pointers for the specific stream we're working
View Full Code Here

Examples of com.xuggle.xuggler.IAudioSamples

            }

            packetOffset += bytesDecoded;

            if (samples.isComplete()) {
                IAudioSamples outSamples;
                if (resampler != null && samples.getNumSamples() > 0) {
                    logger.trace("Re-sampling completed samples");
                    resampler.resample(reSamples, samples,
                            samples.getNumSamples());
                    outSamples = reSamples;
                } else {
                    outSamples = samples;
                }

                logger.trace("Samples complete, turning into next element");
                nextStream = new ByteArrayInputStream(outSamples.getData()
                        .getByteArray(0, outSamples.getSize()));
                anyMore = true;
                return;
            } else {
                logger.trace("Samples not complete yet, shoving more data in");
                grabNextStream();
View Full Code Here

Examples of com.xuggle.xuggler.IAudioSamples

         * coder tells us is in this buffer.
         *
         * We also pass in a buffer size (1024 in our example), although Xuggler
         * will probably allocate more space than just the 1024 (it's not important why).
         */
        IAudioSamples samples = IAudioSamples.make(1024, audioCoder.getChannels());
       
        /*
         * A packet can actually contain multiple sets of samples (or frames of samples
         * in audio-decoding speak).  So, we may need to call decode audio multiple
         * times at different offsets in the packet's data.  We capture that here.
         */
        int offset = 0;
       
        /*
         * Keep going until we've processed all data
         */
        while(offset < packet.getSize())
        {
          int bytesDecoded = audioCoder.decodeAudio(samples, packet, offset);
          if (bytesDecoded < 0)
            throw new RuntimeException("got error decoding audio in: " + filename);
          offset += bytesDecoded;
          /*
           * Some decoder will consume data in a packet, but will not be able to construct
           * a full set of samples yet.  Therefore you should always check if you
           * got a complete set of samples from the decoder
           */
          if (samples.isComplete())
          {
            playJavaSound(samples);
          }
        }
      }
View Full Code Here

Examples of com.xuggle.xuggler.IAudioSamples

                while(stoper == false)
                {
                        container.readNextPacket(packet);
                    if (packet.getStreamIndex() == audioStreamId)
                    {
                        IAudioSamples samples = IAudioSamples.make(512, audioCoder.getChannels(),IAudioSamples.Format.FMT_S16 );
                        int offset = 0;
                        while(offset < packet.getSize())
                        {
                                int bytesDecoded = audioCoder.decodeAudio(samples, packet, offset);
                            if (bytesDecoded < 0)
                            {
                                  throw new RuntimeException("got error decoding audio in");
                            }
                            offset += bytesDecoded;
                                    
                            if (samples.isComplete())
                            {
                                if(timer < total)
                                {
                                        orangeMovie.encodeAudio(streamIndex, samples);
                                }
View Full Code Here

Examples of com.xuggle.xuggler.IAudioSamples

    IPacket oPacket = IPacket.make();

    /**
     * Keep some "pointers' we'll use for the audio we're working with.
     */
    IAudioSamples inSamples = null;
    IAudioSamples outSamples = null;
    IAudioSamples reSamples = null;

    int retval = 0;

    /**
     * And keep some convenience pointers for the specific stream we're working
View Full Code Here

Examples of com.xuggle.xuggler.IAudioSamples

      long sampleCount = samples.length / coder.getChannels();

      // create the audio samples object and extract the internal buffer
      // as an array

      IAudioSamples audioFrame = IAudioSamples.make(sampleCount, coder
          .getChannels());

      /**
       * We allow people to pass in a null timeUnit for audio as
       * a signal that time stamps are unknown.  This is a common
       * case for audio data, and Xuggler should handle it if
       * we set a invalid time stamp on the audio.
       */
      final long timeStampMicro;
      if (timeUnit == null)
        timeStampMicro = Global.NO_PTS;
      else
        timeStampMicro = MICROSECONDS.convert(timeStamp, timeUnit);

      audioFrame.setComplete(true, sampleCount, coder.getSampleRate(), coder
          .getChannels(), coder.getSampleFormat(), timeStampMicro);

      audioFrame.put(samples, 0, 0, samples.length);
      encodeAudio(streamIndex, audioFrame);
    }
    finally
    {
      if (coder != null)
View Full Code Here

Examples of com.xuggle.xuggler.IAudioSamples

         * coder tells us is in this buffer.
         *
         * We also pass in a buffer size (1024 in our example), although Xuggler
         * will probably allocate more space than just the 1024 (it's not important why).
         */
        IAudioSamples samples = IAudioSamples.make(1024, audioCoder.getChannels());
       
        /*
         * A packet can actually contain multiple sets of samples (or frames of samples
         * in audio-decoding speak).  So, we may need to call decode audio multiple
         * times at different offsets in the packet's data.  We capture that here.
         */
        int offset = 0;
       
        /*
         * Keep going until we've processed all data
         */
        while(offset < packet.getSize())
        {
          int bytesDecoded = audioCoder.decodeAudio(samples, packet, offset);
          if (bytesDecoded < 0)
            throw new RuntimeException("got error decoding audio in: " + filename);
          offset += bytesDecoded;
          /*
           * Some decoder will consume data in a packet, but will not be able to construct
           * a full set of samples yet.  Therefore you should always check if you
           * got a complete set of samples from the decoder
           */
          if (samples.isComplete())
          {
            // note: this call will block if Java's sound buffers fill up, and we're
            // okay with that.  That's why we have the video "sleeping" occur
            // on another thread.
            playJavaSound(samples);
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.