Examples of ResourceUnavailableException


Examples of javax.media.ResourceUnavailableException

     
          // Find the decoder for the video stream
          this.codec = AVCODEC.avcodec_find_decoder(codecCtx.codec_id);
          if (codec == null)
              throw new ResourceUnavailableException("Codec not found for codec_id " + codecCtx.codec_id + " (0x" + Integer.toHexString(codecCtx.codec_id) + ")"); // Codec not found - see AVCodecLibrary.CODEC_ID constants
         
          // Open codec
          if (AVCODEC.avcodec_open(codecCtx, codec) < 0)
             throw new ResourceUnavailableException("Could not open codec"); // Could not open codec
       
          // actually appears to be used as a short array.
          bufferSize = AVCodecLibrary.AVCODEC_MAX_AUDIO_FRAME_SIZE;
          buffer = AVUTIL.av_malloc(bufferSize);
        
View Full Code Here

Examples of javax.media.ResourceUnavailableException

          /* look for further theora headers */
          while (theora_p != 0 && (theora_p < 3) && ((ret = to.packetout(op))) != 0)
          {
            if (ret < 0)
            {
              throw new ResourceUnavailableException("Error parsing Theora stream headers; corrupt stream?");
            }
            if (ti.decodeHeader(tc, op) != 0)
            {
              throw new ResourceUnavailableException("Error parsing Theora stream headers; corrupt stream?");
            }
            theora_p++;
            if (theora_p == 3)
              break;
          }

          /* look for more vorbis header packets */
          while (vorbis_p != 0 && (vorbis_p < 3) && ((ret = vo.packetout(op))) != 0)
          {
            if (ret < 0)
            {
              throw new ResourceUnavailableException("Error parsing Vorbis stream headers; corrupt stream?");
            }

            if (vi.synthesis_headerin(vc, op) != 0)
            {
              throw new ResourceUnavailableException("Error parsing Vorbis stream headers; corrupt stream?");
            }
            vorbis_p++;
            if (vorbis_p == 3)
              break;
          }

          /* The header pages/packets will arrive before anything else we
             care about, or the stream is not obeying spec */

          if (oy.pageout(og) > 0)
          {
            queue_page(og); /* demux into the appropriate stream */
          } else
          {
            final int ret2 = buffer_data(oy); /* someone needs more data */
            if (ret2 <= 0)
            {
              throw new ResourceUnavailableException("End of file while searching for codec headers.");
            }
          }
        }

        //System.out.println("Initializing decoders...");

        /* and now we have it all.  initialize decoders */
        if (theora_p != 0)
        {
          td.decodeInit(ti);
          final double fps = (double) ti.fps_numerator / (double) ti.fps_denominator;
          logger.info("Ogg logical stream " + Integer.toHexString(getSerialNo(to)) + " is Theora " + ti.width + "x" + ti.height + " " + fps + " fps");
          // TODO: jheora doesn't have pixelformat as a field of ti:
          //      switch(ti.pixelformat){
          //        case TheoraLibrary.OC_PF_420: System.out.printf(" 4:2:0 video\n"); break;
          //        case TheoraLibrary.OC_PF_422: System.out.printf(" 4:2:2 video\n"); break;
          //        case TheoraLibrary.OC_PF_444: System.out.printf(" 4:4:4 video\n"); break;
          //        case TheoraLibrary.OC_PF_RSVD:
          //        default:
          //          System.out.printf(" video\n  (UNKNOWN Chroma sampling!)\n");
          //    break;
          //      }
          if (ti.width != ti.frame_width || ti.height != ti.frame_height)
          {  logger.warning("  Frame content is " + ti.frame_width + "x" + ti.frame_height + " with offset (" +  ti.offset_x + "," + ti.offset_y + ").");
            // TODO: we need to handle cropping properly.
          }
          report_colorspace(ti);
          dump_comments(tc);
        } else
        {
          /* tear down the partial theora setup */
          ti.clear();
          // tc.clear();
        }
        if (vorbis_p != 0)
        {
          vd.synthesis_init(vi);
          vb.init(vd);
          logger.info("Ogg logical stream " + Integer.toHexString(getSerialNo(vo)) + " is Vorbis " + vi.channels + " channel " + vi.rate + " Hz audio.");

        } else
        {
          /* tear down the partial vorbis setup */
          vi.clear();
          // vc.clear();
        }
       
        stateflag = 0; /* playback has not begun */

        VideoTrack videoTrack = null;
        AudioTrack audioTrack = null;

        if (theora_p != 0)
        {
          videoTrack = new VideoTrack();
        }
        if (vorbis_p != 0)
        {
          audioTrack = new AudioTrack();
        }

        if (audioTrack == null && videoTrack == null)
          throw new ResourceUnavailableException("No audio or video track found");
        else if (audioTrack != null && videoTrack != null)
          tracks = new PullSourceStreamTrack[] { videoTrack, audioTrack };
        else if (audioTrack != null)
          tracks = new PullSourceStreamTrack[] { audioTrack };
        else
          tracks = new PullSourceStreamTrack[] { videoTrack };

      } catch (IOException e)
      {
        logger.log(Level.WARNING, "" + e, e);
        throw new ResourceUnavailableException("" + e);
      }
    }

   
    super.open();
View Full Code Here

Examples of javax.media.ResourceUnavailableException

          /* look for further theora headers */
          while (theora_p != 0 && (theora_p < 3) && ((ret = OGG.ogg_stream_packetout(to, op))) != 0)
          {
            if (ret < 0)
            {
              throw new ResourceUnavailableException("Error parsing Theora stream headers; corrupt stream?");
            }
            if (THEORA.theora_decode_header(ti, tc, op) != 0)
            {
              throw new ResourceUnavailableException("Error parsing Theora stream headers; corrupt stream?");
            }
            theora_p++;
            if (theora_p == 3)
              break;
          }

          /* look for more vorbis header packets */
          while (vorbis_p != 0 && (vorbis_p < 3) && ((ret = OGG.ogg_stream_packetout(vo, op))) != 0)
          {
            if (ret < 0)
            {
              throw new ResourceUnavailableException("Error parsing Vorbis stream headers; corrupt stream?");
            }

            if (VORBIS.vorbis_synthesis_headerin(vi, vc, op) != 0)
            {
              throw new ResourceUnavailableException("Error parsing Vorbis stream headers; corrupt stream?");
            }
            vorbis_p++;
            if (vorbis_p == 3)
              break;
          }

          /*
           * The header pages/packets will arrive before anything else
           * we care about, or the stream is not obeying spec
           */

          if (OGG.ogg_sync_pageout(oy, og) > 0)
          {
            queue_page(og); /* demux into the appropriate stream */
          } else
          {
            final int ret2 = buffer_data(oy); /* someone needs more data  */
            if (ret2 <= 0)
            {
              throw new ResourceUnavailableException("End of file while searching for codec headers.");
            }
          }
        }

        /* and now we have it all. initialize decoders */
        if (theora_p != 0)
        {
          THEORA.theora_decode_init(td, ti);
          final double fps = (double) ti.fps_numerator / (double) ti.fps_denominator;
          logger.info("Ogg logical stream " + Integer.toHexString( to.serialno.intValue()) + " is Theora " + ti.width + "x" + ti.height + " " + fps + " fps");
          switch (ti.pixelformat)
          {
          case TheoraLibrary.OC_PF_420:
            logger.info(" 4:2:0 video");
            break;
          case TheoraLibrary.OC_PF_422:
            logger.info(" 4:2:2 video");
            break;
          case TheoraLibrary.OC_PF_444:
            logger.info(" 4:4:4 video");
            break;
          case TheoraLibrary.OC_PF_RSVD:
          default:
            logger.info(" video\n  (UNKNOWN Chroma sampling!)");
            break;
          }
          if (ti.width != ti.frame_width || ti.height != ti.frame_height)
          {  logger.warning("  Frame content is " + ti.frame_width + "x" + ti.frame_height + " with offset (" +  ti.offset_x + "," + ti.offset_y + ").");
            // TODO: we need to handle cropping properly.
          }
          report_colorspace(ti);
          dump_comments(tc);
        } else
        {
          /* tear down the partial theora setup */
          THEORA.theora_info_clear(ti);
          THEORA.theora_comment_clear(tc);
        }
        if (vorbis_p != 0)
        {
          VORBIS.vorbis_synthesis_init(vd, vi);
          VORBIS.vorbis_block_init(vd, vb);
          logger.info("Ogg logical stream " + Integer.toHexString(vo.serialno.intValue()) + " is Vorbis " + vi.channels + " channel " + vi.rate.intValue() + " Hz audio.");
        } else
        {
          /* tear down the partial vorbis setup */
          VORBIS.vorbis_info_clear(vi);
          VORBIS.vorbis_comment_clear(vc);
        }

        stateflag = 0; /* playback has not begun */

        VideoTrack videoTrack = null;
        AudioTrack audioTrack = null;

        if (theora_p != 0)
        {
          videoTrack = new VideoTrack();
        }
        if (vorbis_p != 0)
        {
          audioTrack = new AudioTrack();
        }

        if (audioTrack == null && videoTrack == null)
          throw new ResourceUnavailableException("No audio or video track found");
        else if (audioTrack != null && videoTrack != null)
          tracks = new PullSourceStreamTrack[] { videoTrack, audioTrack };
        else if (audioTrack != null)
          tracks = new PullSourceStreamTrack[] { audioTrack };
        else
          tracks = new PullSourceStreamTrack[] { videoTrack };

      } catch (IOException e)
      {
        logger.log(Level.WARNING, "" + e, e);
        throw new ResourceUnavailableException("" + e);
      }
    }

    super.open();

View Full Code Here

Examples of javax.media.ResourceUnavailableException

      {
        outputHeader(getOutputStream());
      } catch (IOException e)
      {
        logger.log(Level.WARNING, "" + e, e);
        throw new ResourceUnavailableException("" + e);
      }
      headerWritten = true;
    }
  }
View Full Code Here

Examples of javax.media.ResourceUnavailableException

      {
        outputHeader(getOutputStream());
      } catch (IOException e)
      {
        logger.log(Level.WARNING, "" + e, e);
        throw new ResourceUnavailableException("" + e);
      }
      headerWritten = true;
    }
  }
View Full Code Here

Examples of javax.media.ResourceUnavailableException

      {
        outputHeader(getOutputStream());
      } catch (IOException e)
      {
        logger.log(Level.WARNING, "" + e, e);
        throw new ResourceUnavailableException("" + e);
      }
      headerWritten = true;
    }
  }
View Full Code Here

Examples of javax.media.ResourceUnavailableException

      }
   
    } catch (IOException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      throw new ResourceUnavailableException("" + e);
    }

    super.open();

  }
View Full Code Here

Examples of javax.media.ResourceUnavailableException

     
      // read first frame to determine format
      final Buffer buffer = new Buffer();
      readFrame(buffer);
      if (buffer.isDiscard() || buffer.isEOM())
        throw new ResourceUnavailableException("Unable to read first frame");
      // TODO: catch runtime exception too?
     
      // parse jpeg
      final java.awt.Image image;
      try
      {
        image = ImageIO.read(new ByteArrayInputStream((byte []) buffer.getData(), buffer.getOffset(), buffer.getLength()));
      } catch (IOException e)
      {
        logger.log(Level.WARNING, "" + e, e);
        throw new ResourceUnavailableException("Error reading image: " + e);
      }
     
      if (image == null)
      {
        logger.log(Level.WARNING, "Failed to read image (ImageIO.read returned null).");
        throw new ResourceUnavailableException();
      }
     
      if (frameContentType.equals("image/jpeg"))
        format = new JPEGFormat(new Dimension(image.getWidth(null), image.getHeight(null)), Format.NOT_SPECIFIED, Format.byteArray, -1.f, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED);
      else if(frameContentType.equals("image/gif"))
        format = new GIFFormat(new Dimension(image.getWidth(null), image.getHeight(null)), Format.NOT_SPECIFIED, Format.byteArray, -1.f);
      else if(frameContentType.equals("image/png"))
        format = new PNGFormat(new Dimension(image.getWidth(null), image.getHeight(null)), Format.NOT_SPECIFIED, Format.byteArray, -1.f);
      else
        throw new ResourceUnavailableException("Unsupported frame content type: " + frameContentType);
      // TODO: this discards first image.  save and return first time readFrame is called.
       
    }
View Full Code Here

Examples of javax.media.ResourceUnavailableException

      }
   
    } catch (IOException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      throw new ResourceUnavailableException("" + e);
    } catch (SAXException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      throw new ResourceUnavailableException("" + e);
    } catch (InterruptedException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      throw new ResourceUnavailableException("" + e);
    }

    super.open();

  }
View Full Code Here

Examples of javax.media.ResourceUnavailableException

      {
        doOpen();
      } catch (UnsupportedAudioFileException e)
      {
        logger.log(Level.WARNING, "" + e, e);
        throw new ResourceUnavailableException("" + e);
      } catch (IOException e)
      {
        logger.log(Level.WARNING, "" + e, e);
        throw new ResourceUnavailableException("" + e);
      }

    }
  }
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.