Package com.amazonaws.ivs.broadcast
Class SurfaceSource
java.lang.Object
com.amazonaws.ivs.broadcast.Device
com.amazonaws.ivs.broadcast.ImageDevice
com.amazonaws.ivs.broadcast.SurfaceSource
- Direct Known Subclasses:
CameraSource
,CustomImageSource
An image source backed by an Android Surface. This may be used with inputs such as a Camera2 producer,
OpenGL ES or Vulkan, or a MediaProjection. See also
Session.createImageInputSource()
-
Nested Class Summary
Nested classes/interfaces inherited from class com.amazonaws.ivs.broadcast.ImageDevice
ImageDevice.FrameCallback, ImageDevice.Rotation
Nested classes/interfaces inherited from class com.amazonaws.ivs.broadcast.Device
Device.Descriptor
-
Field Summary
Modifier and TypeFieldDescriptionprotected android.content.Context
protected long
protected boolean
-
Constructor Summary
ModifierConstructorDescriptionprotected
SurfaceSource
(android.content.Context context, android.view.Surface inputSurface, android.graphics.SurfaceTexture inputSurfaceTexture, android.os.Handler handler, String tag, long handle) -
Method Summary
Modifier and TypeMethodDescriptionprotected long
android.view.Surface
Retrieving this Surface can be done from any thread, but API calls on the Surface may not be thread safe.getTag()
boolean
isValid()
void
rotateOnConfigurationChanges
(boolean enable) Enables/disables rotations of this ImageDevice when the physical device is rotated.protected void
setInputSurface
(android.view.Surface inputSurface, android.graphics.SurfaceTexture inputSurfaceTexture) void
setOnFrameCallback
(ImageDevice.FrameCallback callback) Set a callback to receive information about image frames as they move through this device.void
setRotation
(float rotation) Sets the rotation of the ImageDevice.void
setSize
(int width, int height) Set the size of the surfaceboolean
Methods inherited from class com.amazonaws.ivs.broadcast.ImageDevice
getPreviewSurfaceTarget, getPreviewSurfaceView, getPreviewTextureView, getPreviewView, getPreviewView, setRotation
-
Field Details
-
handle
protected long handle -
context
protected android.content.Context context -
shouldRotateOnConfigurationChanges
protected boolean shouldRotateOnConfigurationChanges
-
-
Constructor Details
-
SurfaceSource
protected SurfaceSource(@NonNull android.content.Context context, @Nullable android.view.Surface inputSurface, @Nullable android.graphics.SurfaceTexture inputSurfaceTexture, @NonNull android.os.Handler handler, String tag, long handle)
-
-
Method Details
-
getInputSurface
@Nullable public android.view.Surface getInputSurface()Retrieving this Surface can be done from any thread, but API calls on the Surface may not be thread safe.- Returns:
- The input surface to be attached to some image producer such as a camera or opengl context
-
setSize
public void setSize(int width, int height) Set the size of the surface- Parameters:
width
- width in pixelsheight
- height in pixels
-
getDescriptor
- Specified by:
getDescriptor
in classDevice
-
getPreviewTextureView
- Specified by:
getPreviewTextureView
in classImageDevice
-
getPreviewSurfaceView
- Specified by:
getPreviewSurfaceView
in classImageDevice
-
getPreviewSurfaceTarget
public ImagePreviewSurfaceTarget getPreviewSurfaceTarget(BroadcastConfiguration.AspectMode aspectMode) - Specified by:
getPreviewSurfaceTarget
in classImageDevice
-
setOnFrameCallback
Description copied from class:ImageDevice
Set a callback to receive information about image frames as they move through this device. This will be called on the main thread.- Specified by:
setOnFrameCallback
in classImageDevice
- Parameters:
callback
- A callback lambda that takes aImageDeviceFrame
.
-
isValid
public boolean isValid() -
getTag
-
setRotation
public void setRotation(float rotation) Description copied from class:ImageDevice
Sets the rotation of the ImageDevice.- Specified by:
setRotation
in classImageDevice
- Parameters:
rotation
- Rotation in radians
-
rotateOnConfigurationChanges
public void rotateOnConfigurationChanges(boolean enable) Description copied from class:ImageDevice
Enables/disables rotations of this ImageDevice when the physical device is rotated. When this is enabled, the image source will be rotated to match configuration changes. This is often useful with camera devices, for example. When this is disabled, the image source will not be rotated to match configuration changes. This is often useful for custom image sources or if the camera ought to be locked to a particular orientation to match the application.- Specified by:
rotateOnConfigurationChanges
in classImageDevice
- Parameters:
enable
- Whether this device should rotate on configuration changes (e.g. when the physical device is rotated).
-
willRotateOnConfigurationChanges
public boolean willRotateOnConfigurationChanges()- Specified by:
willRotateOnConfigurationChanges
in classImageDevice
- Returns:
- Whether this ImageDevice will rotate on configuration changes.
-
getHandle
protected long getHandle() -
setInputSurface
protected void setInputSurface(@Nullable android.view.Surface inputSurface, @Nullable android.graphics.SurfaceTexture inputSurfaceTexture)
-