jfxrt

ics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, int paramInt7, int paramInt8)
  {
    Object localObject;
    if ((texture == null) && (compoundTexture == null))
    {
      localObject = paramGraphics.getResourceFactory();
      int i = ((ResourceFactory)localObject).getMaximumTextureSize();
      if ((img.getWidth() <= i) && (img.getHeight() <= i))
      {
        texture = ((ResourceFactory)localObject).createTexture(img);
        if ((!$assertionsDisabled) && (texture == null)) {
          throw new AssertionError();
        }
      }
      else
      {
        compoundTexture = new CompoundTexture(img, i);
      }
    }
    if (texture != null)
    {
      assert (compoundTexture == null);
      paramGraphics.drawTexture(texture, paramInt1, paramInt2, paramInt3, paramInt4, paramInt5, paramInt6, paramInt7, paramInt8);
    }
    else
    {
      assert (compoundTexture != null);
      localObject = new ViewPort(paramInt5, paramInt6, paramInt7 - paramInt5, paramInt8 - paramInt6);
      Coords localCoords = new Coords(paramInt3 - paramInt1, paramInt4 - paramInt2, (ViewPort)localObject);
      CompoundCoords localCompoundCoords = new CompoundCoords(compoundTexture, localCoords);
      localCompoundCoords.draw(paramGraphics, compoundTexture, paramInt1, paramInt2);
    }
  }
  
  public void dispose()
  {
    if (texture != null)
    {
      texture.dispose();
      texture = null;
    }
    if (compoundTexture != null)
    {
      compoundTexture.dispose();
      compoundTexture = null;
    }
  }
  
  public int getWidth()
  {
    return img.getWidth();
  }
  
  public int getHeight()
  {
    return img.getHeight();
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCImageImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.javafx.iio.ImageFrame;
import javafx.concurrent.Task;

class WCImgDecoderImpl$1$1
  extends Task<ImageFrame[]>
{
  WCImgDecoderImpl$1$1(WCImgDecoderImpl.1 param1) {}
  
  protected ImageFrame[] call()
    throws Exception
  {
    return WCImgDecoderImpl.access$000(this$1.this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCImgDecoderImpl.1.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.javafx.iio.ImageFrame;
import javafx.concurrent.Service;
import javafx.concurrent.Task;

class WCImgDecoderImpl$1
  extends Service<ImageFrame[]>
{
  WCImgDecoderImpl$1(WCImgDecoderImpl paramWCImgDecoderImpl) {}
  
  protected Task<ImageFrame[]> createTask()
  {
    new Task()
    {
      protected ImageFrame[] call()
        throws Exception
      {
        return WCImgDecoderImpl.access$000(this$0);
      }
    };
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCImgDecoderImpl.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.javafx.iio.ImageFrame;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;

class WCImgDecoderImpl$2
  implements ChangeListener<ImageFrame[]>
{
  WCImgDecoderImpl$2(WCImgDecoderImpl paramWCImgDecoderImpl) {}
  
  public void changed(ObservableValue<? extends ImageFrame[]> paramObservableValue, ImageFrame[] paramArrayOfImageFrame1, ImageFrame[] paramArrayOfImageFrame2)
  {
    if ((paramArrayOfImageFrame2 != null) && (WCImgDecoderImpl.access$100(this$0) != null)) {
      WCImgDecoderImpl.access$200(this$0, paramArrayOfImageFrame2);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCImgDecoderImpl.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.javafx.iio.ImageLoadListener;
import com.sun.javafx.iio.ImageLoader;
import com.sun.javafx.iio.ImageMetadata;
import java.util.logging.Level;
import java.util.logging.Logger;

class WCImgDecoderImpl$3
  implements ImageLoadListener
{
  WCImgDecoderImpl$3(WCImgDecoderImpl paramWCImgDecoderImpl) {}
  
  public void imageLoadProgress(ImageLoader paramImageLoader, float paramFloat) {}
  
  public void imageLoadWarning(ImageLoader paramImageLoader, String paramString) {}
  
  public void imageLoadMetaData(ImageLoader paramImageLoader, ImageMetadata paramImageMetadata)
  {
    if (WCImgDecoderImpl.access$300().isLoggable(Level.FINE)) {
      WCImgDecoderImpl.access$300().fine(String.format("%s Image size %dx%d", new Object[] { this, imageWidth, imageHeight }));
    }
    if (WCImgDecoderImpl.access$400(this$0) < imageWidth.intValue()) {
      WCImgDecoderImpl.access$402(this$0, imageWidth.intValue());
    }
    if (WCImgDecoderImpl.access$500(this$0) < imageHeight.intValue()) {
      WCImgDecoderImpl.access$502(this$0, imageHeight.intValue());
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCImgDecoderImpl.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.webpane.platform.graphics.WCImage;
import com.sun.webpane.platform.graphics.WCImageFrame;

class WCImgDecoderImpl$Frame
  extends WCImageFrame
{
  WCImage image;
  
  public WCImgDecoderImpl$Frame(WCImage paramWCImage)
  {
    image = paramWCImage;
  }
  
  public WCImage getFrame()
  {
    return image;
  }
  
  public void destroyDecodedData()
  {
    image = null;
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCImgDecoderImpl.Frame
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.javafx.iio.ImageFrame;
import com.sun.javafx.iio.ImageLoadListener;
import com.sun.javafx.iio.ImageLoader;
import com.sun.javafx.iio.ImageMetadata;
import com.sun.javafx.iio.ImageStorage;
import com.sun.javafx.iio.ImageStorageException;
import com.sun.webpane.platform.graphics.WCGraphicsManager;
import com.sun.webpane.platform.graphics.WCImage;
import com.sun.webpane.platform.graphics.WCImageFrame;
import com.sun.webpane.platform.graphics.WCImgDecoder;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Service;
import javafx.concurrent.Task;

public class WCImgDecoderImpl
  extends WCImgDecoder
{
  private static final Logger log = Logger.getLogger(WCImgDecoderImpl.class.getName());
  private Service<ImageFrame[]> loader;
  private int imageWidth = 0;
  private int imageHeight = 0;
  private ImageFrame[] frames;
  private PrismImage[] images;
  private volatile byte[] data;
  private volatile int dataSize;
  ImageLoadListener readerListener = new ImageLoadListener()
  {
    public void imageLoadProgress(ImageLoader paramAnonymousImageLoader, float paramAnonymousFloat) {}
    
    public void imageLoadWarning(ImageLoader paramAnonymousImageLoader, String paramAnonymousString) {}
    
    public void imageLoadMetaData(ImageLoader paramAnonymousImageLoader, ImageMetadata paramAnonymousImageMetadata)
    {
      if (WCImgDecoderImpl.log.isLoggable(Level.FINE)) {
        WCImgDecoderImpl.log.fine(String.format("%s Image size %dx%d", new Object[] { this, imageWidth, imageHeight }));
      }
      if (imageWidth < imageWidth.intValue()) {
        imageWidth = imageWidth.intValue();
      }
      if (imageHeight < imageHeight.intValue()) {
        imageHeight = imageHeight.intValue();
      }
    }
  };
  
  public void destroy()
  {
    if (log.isLoggable(Level.FINE)) {
      log.fine(String.format("%s Destroy image decoder", new Object[] { this }));
    }
    super.destroy();
    if (loader != null)
    {
      loader.cancel();
      loader = null;
    }
  }
  
  public String getFilenameExtension()
  {
    return ".img";
  }
  
  public void addImageData(byte[] paramArrayOfByte)
  {
    if (paramArrayOfByte != null) {
      if (data == null)
      {
        data = paramArrayOfByte;
        dataSize = paramArrayOfByte.length;
      }
      else
      {
        int i = dataSize + paramArrayOfByte.length;
        if (i > data.length)
        {
          byte[] arrayOfByte = new byte[Math.max(i, data.length * 2)];
          System.arraycopy(data, 0, arrayOfByte, 0, dataSize);
          data = arrayOfByte;
        }
        System.arraycopy(paramArrayOfByte, 0, data, dataSize, paramArrayOfByte.length);
        dataSize = i;
      }
    }
    if (loader == null)
    {
      loader = new Service()
      {
        protected Task<ImageFrame[]> createTask()
        {
          new Task()
          {
            protected ImageFrame[] call()
              throws Exception
            {
              return WCImgDecoderImpl.this.loadFrames();
            }
          };
        }
      };
      loader.valueProperty().addListener(new ChangeListener()
      {
        public void changed(ObservableValue<? extends ImageFrame[]> paramAnonymousObservableValue, ImageFrame[] paramAnonymousArrayOfImageFrame1, ImageFrame[] paramAnonymousArrayOfImageFrame2)
        {
          if ((paramAnonymousArrayOfImageFrame2 != null) && (loader != null)) {
            WCImgDecoderImpl.this.setFrames(paramAnonymousArrayOfImageFrame2);
          }
        }
      });
    }
    if (paramArrayOfByte == null)
    {
      loader.cancel();
      loader = null;
      setFrames(loadFrames());
    }
    else if (!loader.isRunning())
    {
      loader.restart();
    }
  }
  
  public void loadFromResource(String paramString)
  {
    if (log.isLoggable(Level.FINE)) {
      log.fine(String.format("%s Load image from resource '%s'", new Object[] { this, paramString }));
    }
    String str = WCGraphicsManager.getResourceName(paramString);
    InputStream localInputStream = getClass().getResourceAsStream(str);
    if (localInputStream == null)
    {
      if (log.isLoggable(Level.FINE)) {
        log.fine(String.format("%s Unable to open resource '%s'", new Object[] { this, str }));
      }
      return;
    }
    setFrames(loadFrames(localInputStream));
  }
  
  private ImageFrame[] loadFrames(InputStream paramInputStream)
  {
    if (log.isLoggable(Level.FINE)) {
      log.fine(String.format("%s Decoding frames", new Object[] { this }));
    }
    try
    {
      ImageFrame[] arrayOfImageFrame1 = ImageStorage.loadAll(paramInputStream, readerListener, 0, 0, true, 1.0F, false);
      return arrayOfImageFrame1;
    }
    catch (ImageStorageException localImageStorageException)
    {
      ImageFrame[] arrayOfImageFrame2 = null;
      return arrayOfImageFrame2;
    }
    finally
    {
      try
      {
        paramInputStream.close();
      }
      catch (IOException localIOException3) {}
    }
  }
  
  private ImageFrame[] loadFrames()
  {
    return loadFrames(new ByteArrayInputStream(data, 0, dataSize));
  }
  
  public void getImageSize(int[] paramArrayOfInt)
  {
    paramArrayOfInt[0] = imageWidth;
    paramArrayOfInt[1] = imageHeight;
    if (log.isLoggable(Level.FINE)) {
      log.fine(String.format("%s image size = %dx%d", new Object[] { this, Integer.valueOf(paramArrayOfInt[0]), Integer.valueOf(paramArrayOfInt[1]) }));
    }
  }
  
  private void setFrames(ImageFrame[] paramArrayOfImageFrame)
  {
    frames = paramArrayOfImageFrame;
    images = null;
    if (paramArrayOfImageFrame != null) {
      notifyObserver();
    }
  }
  
  public int getFrameCount()
  {
    return frames != null ? frames.length : 0;
  }
  
  public WCImageFrame getFrame(int paramInt, int[] paramArrayOfInt)
  {
    ImageFrame localImageFrame = getImageFrame(paramInt);
    if (localImageFrame != null)
    {
      if (log.isLoggable(Level.FINE))
      {
        localObject = localImageFrame.getImageType();
        log.fine(String.format("%s getFrame(%d): image type = %s", new Object[] { this, Integer.valueOf(paramInt), localObject }));
      }
      Object localObject = getPrismImage(paramInt, localImageFrame);
      if (paramArrayOfInt != null)
      {
        ImageMetadata localImageMetadata = localImageFrame.getMetadata();
        int i = (localImageMetadata == null) || (delayTime == null) ? 0 : delayTime.intValue();
        if (i < 11) {
          i = 100;
        }
        paramArrayOfInt[0] = (paramInt < frames.length - 1 ? 1 : 0);
        paramArrayOfInt[1] = ((PrismImage)localObject).getWidth();
        paramArrayOfInt[2] = ((PrismImage)localObject).getHeight();
        paramArrayOfInt[3] = i;
        paramArrayOfInt[4] = 1;
        if (log.isLoggable(Level.FINE)) {
          log.fine(String.format("%s getFrame(%d): complete=%d, size=%dx%d, duration=%d, hasAlpha=%d", new Object[] { this, Integer.valueOf(paramInt), Integer.valueOf(paramArrayOfInt[0]), Integer.valueOf(paramArrayOfInt[1]), Integer.valueOf(paramArrayOfInt[2]), Integer.valueOf(paramArrayOfInt[3]), Integer.valueOf(paramArrayOfInt[4]) }));
        }
      }
      return new Frame((WCImage)localObject);
    }
    if (log.isLoggable(Level.FINE)) {
      log.fine(String.format("%s FAILED getFrame(%d)", new Object[] { this, Integer.valueOf(paramInt) }));
    }
    return null;
  }
  
  private ImageFrame getImageFrame(int paramInt)
  {
    return (paramInt >= 0) && (frames != null) && (frames.length > paramInt) ? frames[paramInt] : null;
  }
  
  private PrismImage getPrismImage(int paramInt, ImageFrame paramImageFrame)
  {
    if (images == null) {
      images = new PrismImage[frames.length];
    }
    if (images[paramInt] == null) {
      images[paramInt] = new WCImageImpl(paramImageFrame);
    }
    return images[paramInt];
  }
  
  static class Frame
    extends WCImageFrame
  {
    WCImage image;
    
    public Frame(WCImage paramWCImage)
    {
      image = paramWCImage;
    }
    
    public WCImage getFrame()
    {
      return image;
    }
    
    public void destroyDecodedData()
    {
      image = null;
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCImgDecoderImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.javafx.geom.transform.BaseTransform;
import com.sun.prism.paint.LinearGradient;
import com.sun.prism.paint.Stop;
import com.sun.webpane.platform.graphics.WCGradient;
import com.sun.webpane.platform.graphics.WCPoint;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

final class WCLinearGradient
  extends WCGradient<LinearGradient>
{
  private final WCPoint p1;
  private final WCPoint p2;
  private final List<Stop> stops = new ArrayList();
  
  WCLinearGradient(WCPoint paramWCPoint1, WCPoint paramWCPoint2)
  {
    p1 = paramWCPoint1;
    p2 = paramWCPoint2;
  }
  
  public void addStop(int paramInt, float paramFloat)
  {
    stops.add(new Stop(WCGraphicsPrismContext.createColor(paramInt), paramFloat));
  }
  
  public LinearGradient getPlatformGradient()
  {
    Collections.sort(stops, WCRadialGradient.COMPARATOR);
    return new LinearGradient(p1.getX(), p1.getY(), p2.getX(), p2.getY(), BaseTransform.IDENTITY_TRANSFORM, isProportional(), getSpreadMethod() - 1, stops);
  }
  
  public String toString()
  {
    return WCRadialGradient.toString(this, p1, p2, null, stops);
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCLinearGradient
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.media.jfxmedia.MediaPlayer;

class WCMediaPlayerImpl$1
  implements Runnable
{
  WCMediaPlayerImpl$1(WCMediaPlayerImpl paramWCMediaPlayerImpl, float paramFloat) {}
  
  public void run()
  {
    while (WCMediaPlayerImpl.access$1700(this$0))
    {
      MediaPlayer localMediaPlayer = WCMediaPlayerImpl.access$1800(this$0);
      if (localMediaPlayer == null) {
        break;
      }
      double d = localMediaPlayer.getPresentationTime();
      if ((val$seekTime < 0.01D) || (Math.abs(d) >= 0.01D))
      {
        WCMediaPlayerImpl.access$1900(this$0, false, 4);
        break;
      }
      try
      {
        Thread.sleep(10L);
      }
      catch (InterruptedException localInterruptedException) {}
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCMediaPlayerImpl.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.media.jfxmedia.MediaManager;
import com.sun.media.jfxmedia.MediaPlayer;
import com.sun.media.jfxmedia.locator.Locator;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.Logger;

class WCMediaPlayerImpl$CreateThread
  extends Thread
{
  private boolean cancelled = false;
  private String url;
  private String userAgent;
  
  public WCMediaPlayerImpl$CreateThread(WCMediaPlayerImpl paramWCMediaPlayerImpl, String paramString1, String paramString2)
  {
    url = paramString1;
    userAgent = paramString2;
    WCMediaPlayerImpl.access$102(paramWCMediaPlayerImpl, false);
  }
  
  public void run()
  {
    if (WCMediaPlayerImpl.access$200()) {
      WCMediaPlayerImpl.access$300().log(Level.FINE, "CreateThread: started, url={0}", url);
    }
    WCMediaPlayerImpl.access$400(this$0, 2);
    WCMediaPlayerImpl.access$500(this$0, 0);
    MediaPlayer localMediaPlayer = null;
    try
    {
      Locator localLocator = new Locator(new URI(url));
      if (userAgent != null) {
        localLocator.setConnectionProperty("User-Agent", userAgent);
      }
      localLocator.init();
      if (WCMediaPlayerImpl.access$600()) {
        WCMediaPlayerImpl.access$700().fine("CreateThread: locator created");
      }
      localMediaPlayer = MediaManager.getPlayer(localLocator);
    }
    catch (Exception localException)
    {
      if (WCMediaPlayerImpl.access$800())
      {
        WCMediaPlayerImpl.access$900().log(Level.WARNING, "CreateThread ERROR: {0}", localException.toString());
        localException.printStackTrace(System.out);
      }
      this$0.onError(this, 0, localException.getMessage());
      return;
    }
    synchronized (WCMediaPlayerImpl.access$1000(this$0))
    {
      if (cancelled)
      {
        if (WCMediaPlayerImpl.access$1100()) {
          WCMediaPlayerImpl.access$1200().log(Level.FINE, "CreateThread: cancelled");
        }
        localMediaPlayer.dispose();
        return;
      }
      WCMediaPlayerImpl.access$1302(this$0, null);
      WCMediaPlayerImpl.access$1400(this$0, localMediaPlayer);
    }
    if (WCMediaPlayerImpl.access$1500()) {
      WCMediaPlayerImpl.access$1600().log(Level.FINE, "CreateThread: completed");
    }
  }
  
  public void cancel()
  {
    synchronized (WCMediaPlayerImpl.access$1000(this$0))
    {
      cancelled = true;
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCMediaPlayerImpl.CreateThread
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.media.jfxmedia.control.VideoDataBuffer;
import com.sun.media.jfxmedia.events.NewFrameEvent;
import com.sun.media.jfxmedia.events.VideoRendererListener;

class WCMediaPlayerImpl$MediaFrameListener
  implements VideoRendererListener
{
  private final Object frameLock = new Object();
  private VideoDataBuffer currentFrame;
  private VideoDataBuffer nextFrame;
  
  private WCMediaPlayerImpl$MediaFrameListener(WCMediaPlayerImpl paramWCMediaPlayerImpl) {}
  
  public void videoFrameUpdated(NewFrameEvent paramNewFrameEvent)
  {
    synchronized (frameLock)
    {
      if (null != nextFrame) {
        nextFrame.releaseFrame();
      }
      nextFrame = paramNewFrameEvent.getFrameData();
      if (null != nextFrame) {
        nextFrame.holdFrame();
      }
    }
    WCMediaPlayerImpl.access$2000(this$0);
  }
  
  public void releaseVideoFrames()
  {
    synchronized (frameLock)
    {
      if (null != nextFrame)
      {
        nextFrame.releaseFrame();
        nextFrame = null;
      }
      if (null != currentFrame)
      {
        currentFrame.releaseFrame();
        currentFrame = null;
      }
    }
  }
  
  public VideoDataBuffer getLatestFrame()
  {
    synchronized (frameLock)
    {
      if (null != nextFrame)
      {
        if (null != currentFrame) {
          currentFrame.releaseFrame();
        }
        currentFrame = nextFrame;
        nextFrame = null;
      }
      if (null != currentFrame) {
        currentFrame.holdFrame();
      }
      return currentFrame;
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCMediaPlayerImpl.MediaFrameListener
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.javafx.sg.prism.PrismMediaFrameHandler;
import com.sun.media.jfxmedia.Media;
import com.sun.media.jfxmedia.MediaManager;
import com.sun.media.jfxmedia.MediaPlayer;
import com.sun.media.jfxmedia.control.VideoDataBuffer;
import com.sun.media.jfxmedia.control.VideoRenderControl;
import com.sun.media.jfxmedia.events.BufferListener;
import com.sun.media.jfxmedia.events.BufferProgressEvent;
import com.sun.media.jfxmedia.events.MediaErrorListener;
import com.sun.media.jfxmedia.events.NewFrameEvent;
import com.sun.media.jfxmedia.events.PlayerStateEvent;
import com.sun.media.jfxmedia.events.PlayerStateListener;
import com.sun.media.jfxmedia.events.PlayerTimeListener;
import com.sun.media.jfxmedia.events.VideoRendererListener;
import com.sun.media.jfxmedia.events.VideoTrackSizeListener;
import com.sun.media.jfxmedia.locator.Locator;
import com.sun.media.jfxmedia.track.AudioTrack;
import com.sun.media.jfxmedia.track.Track;
import com.sun.media.jfxmedia.track.VideoTrack;
import com.sun.prism.Graphics;
import com.sun.prism.Texture;
import com.sun.webpane.platform.graphics.WCGraphicsContext;
import com.sun.webpane.platform.graphics.WCMediaPlayer;
import java.net.URI;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class WCMediaPlayerImpl
  extends WCMediaPlayer
  implements PlayerStateListener, MediaErrorListener, VideoTrackSizeListener, BufferListener, PlayerTimeListener
{
  private final Object lock = new Object();
  private volatile MediaPlayer player;
  private volatile CreateThread createThread;
  private volatile PrismMediaFrameHandler frameHandler;
  private final MediaFrameListener frameListener = new MediaFrameListener(null);
  private boolean gotFirstFrame = false;
  private int finished = 0;
  float bufferedStart = 0.0F;
  float bufferedEnd = 0.0F;
  boolean buffering = false;
  
  private MediaPlayer getPlayer()
  {
    synchronized (lock)
    {
      if (createThread != null) {
        return null;
      }
      return player;
    }
  }
  
  private void setPlayer(MediaPlayer paramMediaPlayer)
  {
    synchronized (lock)
    {
      player = paramMediaPlayer;
      installListeners();
      frameHandler = PrismMediaFrameHandler.getHandler(player);
    }
    finished = 0;
  }
  
  protected void load(String paramString1, String paramString2)
  {
    synchronized (lock)
    {
      if (createThread != null) {
        createThread.cancel();
      }
      disposePlayer();
      createThread = new CreateThread(paramString1, paramString2);
    }
    if (getPreload() != 0) {
      createThread.start();
    }
  }
  
  protected void cancelLoad()
  {
    synchronized (lock)
    {
      if (createThread != null) {
        createThread.cancel();
      }
    }
    ??? = getPlayer();
    if (??? != null) {
      ((MediaPlayer)???).stop();
    }
    notifyNetworkStateChanged(0);
    notifyReadyStateChanged(0);
  }
  
  protected void disposePlayer()
  {
    MediaPlayer localMediaPlayer;
    synchronized (lock)
    {
      removeListeners();
      localMediaPlayer = player;
      player = null;
      if (frameHandler != null)
      {
        frameHandler.releaseTextures();
        frameHandler = null;
      }
    }
    if (localMediaPlayer != null)
    {
      localMediaPlayer.stop();
      localMediaPlayer.dispose();
      localMediaPlayer = null;
      if (frameListener != null) {
        frameListener.releaseVideoFrames();
      }
    }
  }
  
  private void installListeners()
  {
    if (null != player)
    {
      player.addMediaPlayerListener(this);
      player.addMediaErrorListener(this);
      player.addVideoTrackSizeListener(this);
      player.addBufferListener(this);
      player.getVideoRenderControl().addVideoRendererListener(frameListener);
    }
  }
  
  private void removeListeners()
  {
    if (null != player)
    {
      player.removeMediaPlayerListener(this);
      player.removeMediaErrorListener(this);
      player.removeVideoTrackSizeListener(this);
      player.removeBufferListener(this);
      player.getVideoRenderControl().removeVideoRendererListener(frameListener);
    }
  }
  
  protected void prepareToPlay()
  {
    synchronized (lock)
    {
      if ((player == null) && (createThread != null) && (!createThread.isAlive())) {
        createThread.start();
      }
    }
  }
  
  protected void play()
  {
    MediaPlayer localMediaPlayer = getPlayer();
    if (localMediaPlayer != null)
    {
      localMediaPlayer.play();
      notifyPaused(false);
    }
  }
  
  protected void pause()
  {
    MediaPlayer localMediaPlayer = getPlayer();
    if (localMediaPlayer != null)
    {
      localMediaPlayer.pause();
      notifyPaused(true);
    }
  }
  
  protected float getCurrentTime()
  {
    MediaPlayer localMediaPlayer = getPlayer();
    if (localMediaPlayer == null) {
      return 0.0F;
    }
    return finished > 0 ? (float)localMediaPlayer.getDuration() : finished == 0 ? (float)localMediaPlayer.getPresentationTime() : 0.0F;
  }
  
  protected void seek(float paramFloat)
  {
    MediaPlayer localMediaPlayer = getPlayer();
    if (localMediaPlayer != null)
    {
      finished = 0;
      if (getReadyState() >= 1) {
        notifySeeking(true, 1);
      } else {
        notifySeeking(true, 0);
      }
      localMediaPlayer.seek(paramFloat);
      final float f = paramFloat;
      Thread localThread = new Thread(new Runnable()
      {
        public void run()
        {
          while (isSeeking())
          {
            MediaPlayer localMediaPlayer = WCMediaPlayerImpl.this.getPlayer();
            if (localMediaPlayer == null) {
              break;
            }
            double d = localMediaPlayer.getPresentationTime();
            if ((f < 0.01D) || (Math.abs(d) >= 0.01D))
            {
              notifySeeking(false, 4);
              break;
            }
            try
            {
              Thread.sleep(10L);
            }
            catch (InterruptedException localInterruptedException) {}
          }
        }
      });
      localThread.setDaemon(true);
      localThread.start();
    }
  }
  
  protected void setRate(float paramFloat)
  {
    MediaPlayer localMediaPlayer = getPlayer();
    if (localMediaPlayer != null) {
      localMediaPlayer.setRate(paramFloat);
    }
  }
  
  protected void setVolume(float paramFloat)
  {
    MediaPlayer localMediaPlayer = getPlayer();
    if (localMediaPlayer != null) {
      localMediaPlayer.setVolume(paramFloat);
    }
  }
  
  protected void setMute(boolean paramBoolean)
  {
    MediaPlayer localMediaPlayer = getPlayer();
    if (localMediaPlayer != null) {
      localMediaPlayer.setMute(paramBoolean);
    }
  }
  
  protected void setSize(int paramInt1, int paramInt2) {}
  
  protected void setPreservesPitch(boolean paramBoolean) {}
  
  protected void renderCurrentFrame(WCGraphicsContext paramWCGraphicsContext, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    synchronized (lock)
    {
      renderImpl(paramWCGraphicsContext, paramInt1, paramInt2, paramInt3, paramInt4);
    }
  }
  
  protected void renderImpl(WCGraphicsContext paramWCGraphicsContext, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    if (verbose) {
      log.log(Level.FINER, ">>(Prism)renderImpl");
    }
    Graphics localGraphics = (Graphics)paramWCGraphicsContext.getPlatformGraphics();
    Texture localTexture = null;
    VideoDataBuffer localVideoDataBuffer = frameListener.getLatestFrame();
    if (null != localVideoDataBuffer)
    {
      if (null != frameHandler) {
        localTexture = frameHandler.getTexture(localGraphics, localVideoDataBuffer);
      }
      localVideoDataBuffer.releaseFrame();
    }
    if (localTexture != null)
    {
      localGraphics.drawTexture(localTexture, paramInt1, paramInt2, paramInt1 + paramInt3, paramInt2 + paramInt4, 0.0F, 0.0F, localTexture.getContentWidth(), localTexture.getContentHeight());
    }
    else
    {
      if (verbose) {
        log.log(Level.FINEST, "  (Prism)renderImpl, texture is null, draw black rect");
      }
      paramWCGraphicsContext.fillRect(paramInt1, paramInt2, paramInt3, paramInt4, Integer.valueOf(-16777216));
    }
    if (verbose) {
      log.log(Level.FINER, "<<(Prism)renderImpl");
    }
  }
  
  public void onReady(PlayerStateEvent paramPlayerStateEvent)
  {
    MediaPlayer localMediaPlayer = getPlayer();
    if (verbose) {
      log.log(Level.FINE, "onReady");
    }
    Media localMedia = localMediaPlayer.getMedia();
    boolean bool1 = false;
    boolean bool2 = false;
    if (localMedia != null)
    {
      List localList = localMedia.getTracks();
      if (localList != null)
      {
        if (verbose) {
          log.log(Level.INFO, "{0} track(s) detected:", Integer.valueOf(localList.size()));
        }
        Iterator localIterator = localList.iterator();
        while (localIterator.hasNext())
        {
          Track localTrack = (Track)localIterator.next();
          if ((localTrack instanceof VideoTrack)) {
            bool1 = true;
          } else if ((localTrack instanceof AudioTrack)) {
            bool2 = true;
          }
          if (verbose) {
            log.log(Level.INFO, "track: {0}", localTrack);
          }
        }
      }
      else if (verbose)
      {
        log.log(Level.WARNING, "onReady, tracks IS NULL");
      }
    }
    else if (verbose)
    {
      log.log(Level.WARNING, "onReady, media IS NULL");
    }
    if (verbose) {
      log.log(Level.FINE, "onReady, hasVideo:{0}, hasAudio: {1}", new Object[] { Boolean.valueOf(bool1), Boolean.valueOf(bool2) });
    }
    notifyReady(bool1, bool2, (float)localMediaPlayer.getDuration());
    if (!bool1) {
      notifyReadyStateChanged(4);
    } else if (getReadyState() < 1) {
      if (gotFirstFrame) {
        notifyReadyStateChanged(4);
      } else {
        notifyReadyStateChanged(1);
      }
    }
  }
  
  public void onPlaying(PlayerStateEvent paramPlayerStateEvent)
  {
    if (verbose) {
      log.log(Level.FINE, "onPlaying");
    }
    notifyPaused(false);
  }
  
  public void onPause(PlayerStateEvent paramPlayerStateEvent)
  {
    if (verbose) {
      log.log(Level.FINE, "onPause, time: {0}", Double.valueOf(paramPlayerStateEvent.getTime()));
    }
    notifyPaused(true);
  }
  
  public void onStop(PlayerStateEvent paramPlayerStateEvent)
  {
    if (verbose) {
      log.log(Level.FINE, "onStop");
    }
    notifyPaused(true);
  }
  
  public void onStall(PlayerStateEvent paramPlayerStateEvent)
  {
    if (verbose) {
      log.log(Level.FINE, "onStall");
    }
  }
  
  public void onFinish(PlayerStateEvent paramPlayerStateEvent)
  {
    MediaPlayer localMediaPlayer = getPlayer();
    if (localMediaPlayer != null)
    {
      finished = (localMediaPlayer.getRate() > 0.0F ? 1 : -1);
      if (verbose) {
        log.log(Level.FINE, "onFinish, time: {0}", Double.valueOf(paramPlayerStateEvent.getTime()));
      }
      notifyFinished();
    }
  }
  
  public void onHalt(PlayerStateEvent paramPlayerStateEvent)
  {
    if (verbose) {
      log.log(Level.FINE, "onHalt");
    }
  }
  
  public void onError(Object paramObject, int paramInt, String paramString)
  {
    if (verbose) {
      log.log(Level.WARNING, "onError, errCode={0}, msg={1}", new Object[] { Integer.valueOf(paramInt), paramString });
    }
    notifyNetworkStateChanged(5);
    notifyReadyStateChanged(0);
  }
  
  public void onStopTimeReached(double paramDouble) {}
  
  public void onDurationChanged(double paramDouble)
  {
    if (verbose) {
      log.log(Level.FINE, "onDurationChanged, duration={0}", Double.valueOf(paramDouble));
    }
    notifyDurationChanged((float)paramDouble);
  }
  
  public void onSizeChanged(int paramInt1, int paramInt2)
  {
    if (verbose) {
      log.log(Level.FINE, "onSizeChanged, new size = {0} x {1}", new Object[] { Integer.valueOf(paramInt1), Integer.valueOf(paramInt2) });
    }
    notifySizeChanged(paramInt1, paramInt2);
  }
  
  private void notifyFrameArrived()
  {
    if (!gotFirstFrame)
    {
      if (getReadyState() >= 1) {
        notifyReadyStateChanged(4);
      }
      gotFirstFrame = true;
    }
    if ((verbose) && (finished != 0)) {
      log.log(Level.FINE, "notifyFrameArrived (after finished) time: {0}", Double.valueOf(getPlayer().getPresentationTime()));
    }
    notifyNewFrame();
  }
  
  void updateBufferingStatus()
  {
    int i = bufferedStart > 0.0F ? 1 : buffering ? 2 : 3;
    if (verbose) {
      log.log(Level.FINE, "updateBufferingStatus, buffered: [{0} - {1}], buffering = {2}", new Object[] { Float.valueOf(bufferedStart), Float.valueOf(bufferedEnd), Boolean.valueOf(buffering) });
    }
    notifyNetworkStateChanged(i);
  }
  
  public void onBufferProgress(BufferProgressEvent paramBufferProgressEvent)
  {
    if (paramBufferProgressEvent.getDuration() < 0.0D) {
      return;
    }
    double d = paramBufferProgressEvent.getDuration() / paramBufferProgressEvent.getBufferStop();
    bufferedStart = ((float)(d * paramBufferProgressEvent.getBufferStart()));
    bufferedEnd = ((float)(d * paramBufferProgressEvent.getBufferPosition()));
    buffering = (paramBufferProgressEvent.getBufferPosition() < paramBufferProgressEvent.getBufferStop());
    float[] arrayOfFloat = new float[2];
    arrayOfFloat[0] = bufferedStart;
    arrayOfFloat[1] = bufferedEnd;
    int i = (int)(paramBufferProgressEvent.getBufferPosition() - paramBufferProgressEvent.getBufferStart());
    if (verbose) {
      log.log(Level.FINER, "onBufferProgress, bufferStart={0}, bufferStop={1}, bufferPos={2}, duration={3}; notify range [{4},[5]], bytesLoaded: {6}", new Object[] { Long.valueOf(paramBufferProgressEvent.getBufferStart()), Long.valueOf(paramBufferProgressEvent.getBufferStop()), Long.valueOf(paramBufferProgressEvent.getBufferPosition()), Double.valueOf(paramBufferProgressEvent.getDuration()), Float.valueOf(arrayOfFloat[0]), Float.valueOf(arrayOfFloat[1]), Integer.valueOf(i) });
    }
    notifyBufferChanged(arrayOfFloat, i);
    updateBufferingStatus();
  }
  
  private class CreateThread
    extends Thread
  {
    private boolean cancelled = false;
    private String url;
    private String userAgent;
    
    public CreateThread(String paramString1, String paramString2)
    {
      url = paramString1;
      userAgent = paramString2;
      gotFirstFrame = false;
    }
    
    public void run()
    {
      if (WCMediaPlayerImpl.verbose) {
        WCMediaPlayerImpl.log.log(Level.FINE, "CreateThread: started, url={0}", url);
      }
      notifyNetworkStateChanged(2);
      notifyReadyStateChanged(0);
      MediaPlayer localMediaPlayer = null;
      try
      {
        Locator localLocator = new Locator(new URI(url));
        if (userAgent != null) {
          localLocator.setConnectionProperty("User-Agent", userAgent);
        }
        localLocator.init();
        if (WCMediaPlayerImpl.verbose) {
          WCMediaPlayerImpl.log.fine("CreateThread: locator created");
        }
        localMediaPlayer = MediaManager.getPlayer(localLocator);
      }
      catch (Exception localException)
      {
        if (WCMediaPlayerImpl.verbose)
        {
          WCMediaPlayerImpl.log.log(Level.WARNING, "CreateThread ERROR: {0}", localException.toString());
          localException.printStackTrace(System.out);
        }
        onError(this, 0, localException.getMessage());
        return;
      }
      synchronized (lock)
      {
        if (cancelled)
        {
          if (WCMediaPlayerImpl.verbose) {
            WCMediaPlayerImpl.log.log(Level.FINE, "CreateThread: cancelled");
          }
          localMediaPlayer.dispose();
          return;
        }
        createThread = null;
        WCMediaPlayerImpl.this.setPlayer(localMediaPlayer);
      }
      if (WCMediaPlayerImpl.verbose) {
        WCMediaPlayerImpl.log.log(Level.FINE, "CreateThread: completed");
      }
    }
    
    public void cancel()
    {
      synchronized (lock)
      {
        cancelled = true;
      }
    }
  }
  
  private class MediaFrameListener
    implements VideoRendererListener
  {
    private final Object frameLock = new Object();
    private VideoDataBuffer currentFrame;
    private VideoDataBuffer nextFrame;
    
    private MediaFrameListener() {}
    
    public void videoFrameUpdated(NewFrameEvent paramNewFrameEvent)
    {
      synchronized (frameLock)
      {
        if (null != nextFrame) {
          nextFrame.releaseFrame();
        }
        nextFrame = paramNewFrameEvent.getFrameData();
        if (null != nextFrame) {
          nextFrame.holdFrame();
        }
      }
      WCMediaPlayerImpl.this.notifyFrameArrived();
    }
    
    public void releaseVideoFrames()
    {
      synchronized (frameLock)
      {
        if (null != nextFrame)
        {
          nextFrame.releaseFrame();
          nextFrame = null;
        }
        if (null != currentFrame)
        {
          currentFrame.releaseFrame();
          currentFrame = null;
        }
      }
    }
    
    public VideoDataBuffer getLatestFrame()
    {
      synchronized (frameLock)
      {
        if (null != nextFrame)
        {
          if (null != currentFrame) {
            currentFrame.releaseFrame();
          }
          currentFrame = nextFrame;
          nextFrame = null;
        }
        if (null != currentFrame) {
          currentFrame.holdFrame();
        }
        return currentFrame;
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCMediaPlayerImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.prism.Graphics;
import com.sun.prism.Image;
import com.sun.webpane.platform.graphics.WCGraphicsContext;

class WCPageBackBufferImpl$1
  extends PrismImage
{
  WCPageBackBufferImpl$1(WCPageBackBufferImpl paramWCPageBackBufferImpl, int paramInt1, int paramInt2, WCGraphicsContext paramWCGraphicsContext) {}
  
  public int getWidth()
  {
    return val$w;
  }
  
  public int getHeight()
  {
    return val$h;
  }
  
  public Graphics getGraphics()
  {
    return (Graphics)val$gc.getPlatformGraphics();
  }
  
  public Image getImage()
  {
    throw new UnsupportedOperationException();
  }
  
  public void draw(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, int paramInt7, int paramInt8)
  {
    paramGraphics.drawTexture(WCPageBackBufferImpl.access$000(this$0), paramInt1, paramInt2, paramInt3, paramInt4, paramInt5, paramInt6, paramInt7, paramInt8);
  }
  
  public void dispose()
  {
    throw new UnsupportedOperationException();
  }
}

/* Location:
 * Qualified Name:     com.sun.webpane.sg.prism.WCPageBackBufferImpl.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.webpane.sg.prism;

import com.sun.prism.Graphics;
import com.sun.prism.GraphicsPipeline;
import com.sun.prism.Image;
import com.sun.prism.RTTexture;
import com.sun.prism.ResourceFactory;
import com.sun.prism.ResourceFactoryListener;
import com.sun.prism.paint.Color;
import com.sun.webpane.platform.graphics.WCGraphicsContext;
import com.sun.webpane.platform.graphics.WCGraphicsManager;
import com.sun.webpane.platform.graphics.WCPageBackBuffer;

public class WCPageBackBufferImpl
  extends WCPageBackBuffer
  implements ResourceFactoryListener
{
  private RTTexture texture;
  private boo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd