Package javax.media

Examples of javax.media.Renderer


    if (mode == PLAYER && audioTrackIndex >= 0// if it has a audio track
    {
      final RendererNode rendererNode = filterGraph.getRendererNode(audioTrackIndex);
      if (rendererNode != null) {
       
        final Renderer renderer = rendererNode.getRenderer();
        if (renderer instanceof Clock)
        {
          final Clock rendererAsClock = (Clock) renderer;
          try
          {
            TimeBase timeBase = rendererAsClock.getTimeBase();
           
            // With JMF, this ends up as a com.sun.media.renderer.audio.AudioRenderer$AudioTimeBase@49bdc9d8
            // TODO: what do we do in between getting and setting?
            // probably what we need to do is somehow use this clock as our clock.
            // TODO: this is starting to make sense to me.  An audio renderer differs from a video renderer in that
            // the audio renderer has to determine time, therefore it is the master clock.  The video has to be synched with
            // the audio, not the other way around.
           
            rendererAsClock.setTimeBase(timeBase)// this seems unnecessary, but it does cause the audio renderer to set its master clock.
          } catch (IncompatibleTimeBaseException e)
          {
            logger.log(Level.WARNING, "" + e, e);
            postControllerErrorEvent("" + e);
            return false;
          }
        }
      } 
    }
   
    try
    {
      // root was already opened in setDataSource.
      // TODO: JMF calls open on the parser during realize
      filterGraph.openExcludeDemux();
    }
    catch (ResourceUnavailableException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      postControllerErrorEvent("" + e);
      return false;
    }
   
    // now that nodes are open, add controls:
   
    // mgodehardt: query processor output datasource for controls
    // kenlars99: JMF does not include DataSource controls in its own list of controls.
    /*{
      final Object[] controls = getSource().getControls();
      if (controls != null)
      {
        for (Object o : controls)
          addControl((Control) o);
      }
    }*/
   
    // add controls from demux
    {
      final Object[] controls = filterGraph.getRoot().getDemux().getControls();
      if (controls != null)
      {
        for (Object o : controls)
        {
          addControl((Control) o);
        }
      }
    }
   
    // add all controls from the codec chain ( inclusive mux )
    addCodecChainControls(filterGraph.getRoot());
   
    // add all controls from renderers
    if ( mode == PLAYER )
    {
      for (int trackIndex = 0; trackIndex < filterGraph.getNumTracks(); ++trackIndex)
      {
        final RendererNode rendererNode = filterGraph.getRendererNode(trackIndex);
        if (rendererNode != null) {
          final Renderer renderer = rendererNode.getRenderer();
          // add any controls from renderer
          final Object[] controls = renderer.getControls();
          if (controls != null)
          {
            for (Object o : controls)
            {  addControl((Control) o);
           
View Full Code Here


   
      }
      else if (o instanceof Renderer)
      {
        if (TRACE) logger.fine("PlugInUtility: Registering renderer: " + className);
        final Renderer oCast = (Renderer) o;
        final Format[] inputFormats = oCast.getSupportedInputFormats();
        return new PlugInInfo(className, inputFormats, new Format[] {}, PlugInManager.RENDERER);
      }
      else if (o instanceof Multiplexer)
      { 
        if (TRACE) logger.fine("PlugInUtility: Registering Multiplexer: " + className);
        final Multiplexer oCast = (Multiplexer) o;
        // JMF Multiplexers always have nothing for the input formats.
        return new PlugInInfo(className, new Format[] {}, oCast.getSupportedOutputContentDescriptors(null), PlugInManager.MULTIPLEXER);
      }
      else
      {
        logger.warning("PlugInUtility: Unknown or unsupported plug-in: " + o.getClass());
        return null;
View Full Code Here

      Multiplexer mux = (Multiplexer) pluginObject;
      in = mux.getSupportedInputFormats();
      out = mux.getSupportedOutputContentDescriptors(null);
    }
    else if (pluginObject instanceof Renderer) {
      Renderer renderer = (Renderer) pluginObject;
      in = renderer.getSupportedInputFormats();
      out = null;   
    }
    else if (pluginObject instanceof Effect) {
      Effect effect = (Effect) pluginObject;
      in = effect.getSupportedInputFormats();
View Full Code Here

        return null;

     
    if (destPlugInType == PlugInManager.RENDERER)
    {
      final Renderer renderer = findRenderer(f);
      if (renderer != null)
      { 
        final RendererNode rendererNode = new RendererNode(renderer, null); // format will be set in negotiation
        if (PRE_LINK)
          link(from, rendererNode.getInputPin(0));

        final Format fAccepted;
        if (FIND_NONSPECIFIC_GRAPH_FIRST)
        {
          fAccepted = f;
          if (fAccepted != null)
            rendererNode.getInputPin(0).setFormat(fAccepted);
        }
        else
        {
          fAccepted = negotiate(f, rendererNode.getInputPin(0), null, from);
        }
        if (fAccepted != null)
        { 
          if (SET_RENDERER_BUFFER_LENGTH)
          {
            BufferControl bufferControl = (BufferControl) renderer.getControl("javax.media.control.BufferControl");
            if (bufferControl != null)
            {
              bufferControl.setBufferLength(2000)// TODO: hard-coded for testing
            }
          }
View Full Code Here

        if (TRACE) logger.fine("Trying renderer for " + f + ": " + rendererClassName);
       
        // TODO: instantiate renderer, take first successful one for each track.
        // Or, how do we pick the "best" one?  // how do we pick the "best" format?
       
        final Renderer renderer = (Renderer) instantiate(rendererClassName);
        if (renderer == null)
          continue;
       
      return renderer;
       
View Full Code Here

  }

  @Override
  public int process(final Buffer input, final int sourceTrackNumber, final int destTrackNumber, final int flags)
  {
    final Renderer renderer = getRenderer();
    if (input.getFormat() == null)
      input.setFormat(getInputFormat())// TODO: is this right?
   
    if (renderer instanceof Prefetchable)
    {
      // TODO: where should this be done?  In the Handler's prefetch()?
      final Prefetchable rendererAsPrefetchable = (Prefetchable) renderer;
      if (!isPrefetched() && rendererAsPrefetchable.isPrefetched())
      {
        if (renderer instanceof Clock)
        {
          final Clock rendererAsClock = (Clock) renderer;
          // TODO: what do we set the time to be?
          rendererAsClock.syncStart(new Time(rendererAsClock.getMediaNanoseconds()));
        }
        setPrefetched(true);
      }
    }
   
    {
      int processResult;
     
      // TODO: the caller should take care of this loop.
      do
      {
        int oldOffset = input.getOffset();

                // mgodehardt: sleeping causes audio streams to get hipcups
        // calculate and sleep any sleep needed:
              /*try
              {  sleepHelper.sleep(input.getTimeStamp());
        }
              catch (InterruptedException e)
        {
          logger.log(Level.WARNING, "" + e, e);
          return Renderer.BUFFER_PROCESSED_FAILED;
        }*/
            
       
        //long start = System.currentTimeMillis();
        processResult = renderer.process(input)// TODO: check return code
        //long stop = System.currentTimeMillis();
        //System.out.println("Renderer process took " + (stop - start) + " ms");
       
        if (processResult == Renderer.INPUT_BUFFER_NOT_CONSUMED)
        {
View Full Code Here

            // since NT doesn't have capture
            cls = Class.forName("com.sun.media.protocol.dsound.DSound");
            // Find the renderer class and instantiate it.
            cls = Class.forName(dar);

            Renderer rend = (Renderer) cls.newInstance();
            try {
                // Set the format and open the device
                AudioFormat af = new AudioFormat(AudioFormat.LINEAR, 44100, 16,
                        2);
                rend.setInputFormat(af);
                rend.open();
                Format[] inputFormats = rend.getSupportedInputFormats();
                // Register the device
                PlugInManager.addPlugIn(dar, inputFormats, new Format[0],
                        plType);
                // Move it to the top of the list
                Vector rendList = PlugInManager.getPlugInList(null, null,
                        plType);
                int listSize = rendList.size();
                if (rendList.elementAt(listSize - 1).equals(dar)) {
                    rendList.removeElementAt(listSize - 1);
                    rendList.insertElementAt(dar, 0);
                    PlugInManager.setPlugInList(rendList, plType);
                    PlugInManager.commit();
                    // Log.debug("registered");
                }
                rend.close();
            }
            catch (Throwable t) {
                // Log.debug("Error " + t);
            }
        }
View Full Code Here

            cls = Class.forName("SunVideoAuto");

            // Find the renderer class and instantiate it.
            cls = Class.forName(dar);

            Renderer rend = (Renderer) cls.newInstance();

            if (rend instanceof ExclusiveUse
                    && !((ExclusiveUse) rend).isExclusive()) {
                // sol8+, DAR supports mixing
                Vector rendList = PlugInManager.getPlugInList(null, null,
View Full Code Here

            // since NT doesn't have capture
            cls = Class.forName("com.sun.media.protocol.dsound.DSound");
            // Find the renderer class and instantiate it.
            cls = Class.forName(dar);

            Renderer rend = (Renderer) cls.newInstance();
            try {
                // Set the format and open the device
                AudioFormat af = new AudioFormat(AudioFormat.LINEAR, 44100, 16,
                        2);
                rend.setInputFormat(af);
                rend.open();
                Format[] inputFormats = rend.getSupportedInputFormats();
                // Register the device
                PlugInManager.addPlugIn(dar, inputFormats, new Format[0],
                        plType);
                // Move it to the top of the list
                Vector rendList = PlugInManager.getPlugInList(null, null,
                        plType);
                int listSize = rendList.size();
                if (rendList.elementAt(listSize - 1).equals(dar)) {
                    rendList.removeElementAt(listSize - 1);
                    rendList.insertElementAt(dar, 0);
                    PlugInManager.setPlugInList(rendList, plType);
                    PlugInManager.commit();
                    // Log.debug("registered");
                }
                rend.close();
            }
            catch (Throwable t) {
                // Log.debug("Error " + t);
            }
        }
View Full Code Here

            cls = Class.forName("SunVideoAuto");

            // Find the renderer class and instantiate it.
            cls = Class.forName(dar);

            Renderer rend = (Renderer) cls.newInstance();

            if (rend instanceof ExclusiveUse
                    && !((ExclusiveUse) rend).isExclusive()) {
                // sol8+, DAR supports mixing
                Vector rendList = PlugInManager.getPlugInList(null, null,
View Full Code Here

TOP

Related Classes of javax.media.Renderer

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.