project.android.imageprocessing.input
Class VideoResourceInput

java.lang.Object
  extended by project.android.imageprocessing.GLRenderer
      extended by project.android.imageprocessing.input.GLTextureOutputRenderer
          extended by project.android.imageprocessing.input.VideoResourceInput
All Implemented Interfaces:
android.graphics.SurfaceTexture.OnFrameAvailableListener

public class VideoResourceInput
extends GLTextureOutputRenderer
implements android.graphics.SurfaceTexture.OnFrameAvailableListener

A video input extension of GLTextureOutputRenderer. This class takes advantage of the android MediaPlayer and SurfaceTexture to produce new textures for processing.

Note: This class requires an API level of at least 14.

Author:
Chris Batt

Field Summary
 
Fields inherited from class project.android.imageprocessing.GLRenderer
ATTRIBUTE_POSITION, ATTRIBUTE_TEXCOORD, UNIFORM_TEXTURE0, VARYING_TEXCOORD
 
Constructor Summary
VideoResourceInput(android.opengl.GLSurfaceView view, android.content.Context context, int id)
          Creates a VideoResourceInput which captures the camera preview with all the default camera parameters and settings.
 
Method Summary
 void destroy()
          Cleans up the opengl objects for this renderer.
 boolean isPlaying()
          Returns whether or not the video is currently playing.
 void onFrameAvailable(android.graphics.SurfaceTexture arg0)
           
 void setVideoSource(int id)
          Sets the video to a new video source.
 void startWhenReady()
          Starts the video player if the opengl context has initialized the video already.
 void stop()
          Stops the video
 
Methods inherited from class project.android.imageprocessing.input.GLTextureOutputRenderer
addTarget, getLockObject, getTargets, removeTarget
 
Methods inherited from class project.android.imageprocessing.GLRenderer
getBackgroundAlpha, getBackgroundBlue, getBackgroundGreen, getBackgroundRed, getHeight, getWidth, onDrawFrame, reInitialize, rotateClockwise90Degrees, rotateCounterClockwise90Degrees, setBackgroundAlpha, setBackgroundBlue, setBackgroundColour, setBackgroundGreen, setBackgroundRed, setRenderSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VideoResourceInput

public VideoResourceInput(android.opengl.GLSurfaceView view,
                          android.content.Context context,
                          int id)
Creates a VideoResourceInput which captures the camera preview with all the default camera parameters and settings.

Parameters:
context - The context which contains the given resource id.
id - The resource id that points to the video that should be displayed
Method Detail

onFrameAvailable

public void onFrameAvailable(android.graphics.SurfaceTexture arg0)
Specified by:
onFrameAvailable in interface android.graphics.SurfaceTexture.OnFrameAvailableListener

setVideoSource

public void setVideoSource(int id)
Sets the video to a new video source. The id must be from the same context as the previous id.

Parameters:
id - The id that points to the video resource

isPlaying

public boolean isPlaying()
Returns whether or not the video is currently playing.

Returns:
playing Whether or not the video is currently playing.

startWhenReady

public void startWhenReady()
Starts the video player if the opengl context has initialized the video already. Otherwise, starts the video once the opengl context has been initialized.


stop

public void stop()
Stops the video


destroy

public void destroy()
Description copied from class: GLRenderer
Cleans up the opengl objects for this renderer. Must be called with opengl context. Normally called by FastImageProcessingPipeline.

Overrides:
destroy in class GLTextureOutputRenderer