Examples of IPacket


Examples of com.xuggle.xuggler.IPacket

     */
    for (i = 0; i < numStreams; i++)
    {
      if (mOCoders[i] != null)
      {
        IPacket oPacket = IPacket.make();
        do {
          if (mOCoders[i].getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO)
            mOCoders[i].encodeAudio(oPacket, null, 0);
          else
            mOCoders[i].encodeVideo(oPacket, null, 0);
          if (oPacket.isComplete())
            mOContainer.writePacket(oPacket, mForceInterleave);
        } while (oPacket.isComplete());
      }
    }
    /**
     * Some container formats require a trailer to be written to avoid a corrupt
     * files.
 
View Full Code Here

Examples of com.xuggle.xuggler.IPacket

    /**
     * Create packet buffers for reading data from and writing data to the
     * conatiners.
     */
    IPacket iPacket = IPacket.make();
    IPacket oPacket = IPacket.make();

    /**
     * Keep some "pointers' we'll use for the audio we're working with.
     */
    IAudioSamples inSamples = null;
View Full Code Here

Examples of com.xuggle.xuggler.IPacket

          "could not create color space resampler for: " + filename);
    }

    // Now, we start walking through the container looking at each packet.

    IPacket packet = IPacket.make();
    while(container.readNextPacket(packet) >= 0)
    {
     
      // Now we have a packet, let's see if it belongs to our video strea

      if (packet.getStreamIndex() == videoStreamId)
      {
        // We allocate a new picture to get the data out of Xuggle

        IVideoPicture picture = IVideoPicture.make(videoCoder.getPixelType(),
            videoCoder.getWidth(), videoCoder.getHeight());

        int offset = 0;
        while(offset < packet.getSize())
        {
          // Now, we decode the video, checking for any errors.

          int bytesDecoded = videoCoder.decodeVideo(picture, packet, offset);
          if (bytesDecoded < 0)
View Full Code Here

Examples of com.xuggle.xuggler.IPacket

    openJavaWindow();

    /*
     * Now, we start walking through the container looking at each packet.
     */
    IPacket packet = IPacket.make();
    while(container.readNextPacket(packet) >= 0)
    {
      /*
       * Now we have a packet, let's see if it belongs to our video stream
       */
      if (packet.getStreamIndex() == videoStreamId)
      {
        /*
         * We allocate a new picture to get the data out of Xuggler
         */
        IVideoPicture picture = IVideoPicture.make(videoCoder.getPixelType(),
            videoCoder.getWidth(), videoCoder.getHeight());

        int offset = 0;
        while(offset < packet.getSize())
        {
          /*
           * Now, we decode the video, checking for any errors.
           *
           */
 
View Full Code Here

Examples of com.xuggle.xuggler.IPacket

   
   
    /*
     * Now, we start walking through the container looking at each packet.
     */
    IPacket packet = IPacket.make();
    mFirstVideoTimestampInStream = Global.NO_PTS;
    mSystemVideoClockStartTime = 0;
    while(container.readNextPacket(packet) >= 0)
    {
      /*
       * Now we have a packet, let's see if it belongs to our video stream
       */
      if (packet.getStreamIndex() == videoStreamId)
      {
        /*
         * We allocate a new picture to get the data out of Xuggler
         */
        IVideoPicture picture = IVideoPicture.make(videoCoder.getPixelType(),
            videoCoder.getWidth(), videoCoder.getHeight());
       
        /*
         * Now, we decode the video, checking for any errors.
         *
         */
        int bytesDecoded = videoCoder.decodeVideo(picture, packet, 0);
        if (bytesDecoded < 0)
          throw new RuntimeException("got error decoding audio in: " + filename);

        /*
         * Some decoders will consume data in a packet, but will not be able to construct
         * a full video picture yet.  Therefore you should always check if you
         * got a complete picture from the decoder
         */
        if (picture.isComplete())
        {
          IVideoPicture newPic = picture;
          /*
           * If the resampler is not null, that means we didn't get the video in BGR24 format and
           * need to convert it into BGR24 format.
           */
          if (resampler != null)
          {
            // we must resample
            newPic = IVideoPicture.make(resampler.getOutputPixelFormat(), picture.getWidth(), picture.getHeight());
            if (resampler.resample(newPic, picture) < 0)
              throw new RuntimeException("could not resample video from: " + filename);
          }
          if (newPic.getPixelType() != IPixelFormat.Type.BGR24)
            throw new RuntimeException("could not decode video as BGR 24 bit data in: " + filename);

          long delay = millisecondsUntilTimeToDisplay(newPic);
          // if there is no audio stream; go ahead and hold up the main thread.  We'll end
          // up caching fewer video pictures in memory that way.
          try
          {
            if (delay > 0)
              Thread.sleep(delay);
          }
          catch (InterruptedException e)
          {
            return;
          }

          // And finally, convert the picture to an image and display it

          mScreen.setImage(Utils.videoPictureToImage(newPic));
        }
      }
      else if (packet.getStreamIndex() == audioStreamId)
      {
        /*
         * We allocate a set of samples with the same number of channels as the
         * 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;
View Full Code Here

Examples of com.xuggle.xuggler.IPacket

      open();

    // if there is an off-nominal result from read packet, return the
    // correct error

    IPacket packet = IPacket.make();
    try
    {
      int rv = getContainer().readNextPacket(packet);
      if (rv < 0)
      {
        IError error = IError.make(rv);

        // if this is an end of file, or unknow, call close

        if (!mCloseOnEofOnly || IError.Type.ERROR_EOF == error.getType())
          close();

        return error;
      }

      // inform listeners that a packet was read

      super.onReadPacket(new ReadPacketEvent(this,packet));

      // get the coder for this packet

      IStreamCoder coder = getStreamCoder(packet.getStreamIndex());
      // decode based on type

      switch (coder.getCodecType())
      {
        // decode audio

        case CODEC_TYPE_AUDIO:
          decodeAudio(coder, packet);
          break;

          // decode video

        case CODEC_TYPE_VIDEO:
          decodeVideo(coder, packet);
          break;

          // all other stream types are currently ignored

        default:
      }

     
    }
    finally
    {
      if (packet != null)
        packet.delete();
    }

    // return true more packets to be read

    return null;
View Full Code Here

Examples of com.xuggle.xuggler.IPacket

    }
    // encode video picture

    // encode the video packet
   
    IPacket packet = IPacket.make();
    try {
      if (stream.getStreamCoder().encodeVideo(packet, picture, 0) < 0)
        throw new RuntimeException("failed to encode video");
 
      if (packet.isComplete())
        writePacket(packet);
    } finally {
      if (packet != null)
        packet.delete();
    }
 
    // inform listeners

    super.onVideoPicture(new VideoPictureEvent(this, picture, image,
View Full Code Here

Examples of com.xuggle.xuggler.IPacket

      for (int consumed = 0; consumed < samples.getNumSamples(); /* in loop */)
      {
        // encode audio

        IPacket packet = IPacket.make();
        try {
          int result = coder.encodeAudio(packet, samples, consumed);
          if (result < 0)
            throw new RuntimeException("failed to encode audio");

          // update total consumed

          consumed += result;

          // if a complete packed was produced write it out

          if (packet.isComplete())
            writePacket(packet);
        } finally {
          if (packet != null)
            packet.delete();
        }
      }      // inform listeners

      super.onAudioSamples(new AudioSamplesEvent(this, samples,
          streamIndex));
View Full Code Here

Examples of com.xuggle.xuggler.IPacket

      // if it's audio coder flush that

      if (CODEC_TYPE_AUDIO == coder.getCodecType())
      {
        IPacket packet = IPacket.make();
        while (coder.encodeAudio(packet, null, 0) >= 0 && packet.isComplete())
        {
          writePacket(packet);
          packet.delete();
          packet = IPacket.make();
        }
        packet.delete();
      }
     
      // else flush video coder

      else if (CODEC_TYPE_VIDEO == coder.getCodecType())
      {
        IPacket packet = IPacket.make();
        while (coder.encodeVideo(packet, null, 0) >= 0 && packet.isComplete())
        {
          writePacket(packet);
          packet.delete();
          packet = IPacket.make();
        }
        packet.delete();
      }
    }

    // flush the container
View Full Code Here

Examples of com.xuggle.xuggler.IPacket

    openJavaWindow();

    /*
     * Now, we start walking through the container looking at each packet.
     */
    IPacket packet = IPacket.make();
    long firstTimestampInStream = Global.NO_PTS;
    long systemClockStartTime = 0;
    while(container.readNextPacket(packet) >= 0)
    {
      /*
       * Now we have a packet, let's see if it belongs to our video stream
       */
      if (packet.getStreamIndex() == videoStreamId)
      {
        /*
         * We allocate a new picture to get the data out of Xuggler
         */
        IVideoPicture picture = IVideoPicture.make(videoCoder.getPixelType(),
            videoCoder.getWidth(), videoCoder.getHeight());

        int offset = 0;
        while(offset < packet.getSize())
        {
          /*
           * Now, we decode the video, checking for any errors.
           *
           */
 
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.