public class WOWZCameraView extends SurfaceView implements WOWZBroadcastAPI.VideoBroadcaster, WOWZBroadcastAPI.AdaptiveBroadcaster
Modifier and Type | Class and Description |
---|---|
static interface |
WOWZCameraView.PreviewStatusListener
Callback interface to use with
setPreviewStatusListener(PreviewStatusListener) . |
Modifier and Type | Field and Description |
---|---|
static int |
EXTENSION_BLACK_AND_WHITE |
static int |
EXTENSION_DEFAULT |
static int |
EXTENSION_MIRROR |
Constructor and Description |
---|
WOWZCameraView(Context context)
Simple constructor to use when creating a view from code.
|
WOWZCameraView(Context context,
AttributeSet attrs)
Called when inflating a view from XML.
|
Modifier and Type | Method and Description |
---|---|
void |
changeAdaptiveBitrate(int bitrate) |
void |
changeAdaptiveFramerate(int framerate) |
void |
clearView()
Clears the currently rendered frame from the view.
|
void |
doConfigChange() |
WOWZSize |
getActiveFrameSize()
Gets the active video frame size, which may differ from the requested frame size if the current scale mode is FILL_VIEW.
|
int |
getAdaptiveBitrate() |
int |
getAdaptiveFramerate() |
static WOWZCamera[] |
getAvailableDeviceCameras()
Deprecated.
Use
WOWZCamera.getAvailableDeviceCameras() instead. |
WOWZBroadcastConfig |
getBroadcastConfig()
Gets the configuration settings for an active broadcast session.
|
WOWZBroadcastAPI.VideoBroadcaster |
getBroadcaster()
Deprecated.
The WOWZCameraView class now implements the
WOWZBroadcastAPI.VideoBroadcaster interface
so you can use a WOWZCameraView instance directly in
WOWZBroadcastConfig.setVideoBroadcaster(WOWZBroadcastAPI.VideoBroadcaster) ,
for example, broadcastConfig.setVideoBroadcaster(cameraView); . |
WOWZStatus |
getBroadcasterStatus()
Gets the status for a broadcast component.
|
WOWZCamera |
getCamera()
Gets the active camera.
|
WOWZCamera |
getCameraByDirection(int direction)
Gets a camera instance based on its ID specifier
|
WOWZCamera |
getCameraById(int cameraId)
Gets a camera instance based on its ID specifier.
|
static java.lang.String |
getCameraInfo()
Deprecated.
Use
WOWZCamera.getCameraInfo() instead. |
WOWZCamera[] |
getCameras()
Gets an array of
WOWZCamera instances for each camera device present. |
static WOWZCamera[] |
getDeviceCameras()
Deprecated.
Use
WOWZCamera.getDeviceCameras() instead. |
int |
getDeviceOrientation()
Deprecated.
Use
WOWZDeviceUtils.getDeviceOrientation(Context) instead. |
int |
getFramerate()
Gets the currently configured video frame rate.
|
WOWZSize |
getFrameSize()
Gets the currently configured video frame size.
|
static int |
getNumberOfDeviceCameras()
Deprecated.
Use
WOWZCamera.getNumberOfDeviceCameras() instead. |
WOWZCamera |
getOtherCamera()
Gets the camera that isn't currently active, if present.
|
int |
getOtherCameraId()
Gets the ID of the camera that isn't currently active, if present.
|
WOWZStatus |
getPreviewStatus()
Gets this view's preview status.
|
int |
getScaleMode() |
WOWZSize |
getScreenSize()
Gets the size of camera preview display.
|
WOWZStatus |
getStatus()
Deprecated.
Use
getPreviewStatus() instead. |
WOWZColor |
getVideoBackgroundColor() |
WOWZMediaConfig |
getVideoSourceConfig()
Gets configuration information for the video source.
|
boolean |
isPaused()
Deprecated.
Use
isPreviewPaused() instead. |
boolean |
isPreviewing()
Checks whether the camera preview display is active.
|
boolean |
isPreviewPaused()
Checks whether the camera preview display was paused due to the onPause method begin called.
|
boolean |
isPreviewReady()
Checks whether the camera preview has been fully initialized.
|
boolean |
isSwitchCameraAvailable()
Checks whether the current camera can be switched based on the state of any live streaming broadcast currently active and device presence.
|
boolean |
isSwitchCameraAvailable(WOWZMediaConfig mediaConfig)
Checks whether the current camera can be switched based on the state of any live streaming broadcast currently active and device presence.
|
boolean |
isSwitchCameraAvailable(WOWZSize withFrameSize)
Checks whether the current camera can be switched based on the state of any live streaming broadcast currently active and device presence.
|
boolean |
isVideoEnabled()
Checks whether a video broadcast component is enabled.
|
boolean |
isVideoPaused()
Checks whether a video broadcast component is paused.
|
void |
onConfigurationChanged(Configuration newConfig)
Called when the device configuration changes, typically to detect device orientation changes.
|
void |
onLowMemory()
Called when the overall system is running low on memory
and actively running processes should trim their memory usage.
|
void |
onPause()
Called from the activity's
onPause() method to store the state of the
camera preview display before the application is sent to the background. |
void |
onResume()
|
WOWZStatus |
prepareForBroadcast(WOWZBroadcastConfig broadcastConfig)
Initializes each component of a broadcast.
|
void |
registerFrameListener(WOWZRenderAPI.VideoFrameListener frameListener)
Registers an object instance implementing the
WOWZRenderAPI.VideoFrameListener interface
that can be used to capture content from the camera preview display. |
void |
registerFrameRenderer(WOWZRenderAPI.VideoFrameRenderer frameRenderer)
Registers an object instance implementing the
WOWZRenderAPI.VideoFrameRenderer interface
that can be used to render additional content, such as a logo, to the camera preview display. |
WOWZCamera |
setCamera(int cameraId)
Sets the active camera.
|
WOWZCamera |
setCamera(WOWZCamera camera)
Sets the active camera.
|
WOWZCamera |
setCameraByDirection(int direction)
Sets the active camera based on the specified direction (front or back).
|
void |
setCameraConfig(WOWZMediaConfig previewConfig)
Updates the frame size and frame rate for the active camera with the corresponding values from the specified configuration.
|
int |
setFramerate(int framerate)
Updates the frame rate for the active camera with the specified value.
|
WOWZSize |
setFrameSize(int width,
int height)
Updates the frame size for the active camera with the specified values.
|
WOWZSize |
setFrameSize(WOWZSize frameSize)
Updates the frame size for the active camera with the specified size.
|
void |
setPreviewReadyListener(WOWZCameraView.PreviewStatusListener previewReadyListener)
Deprecated.
Use
setPreviewStatusListener(PreviewStatusListener) instead. |
void |
setPreviewStatusListener(WOWZCameraView.PreviewStatusListener previewStatusListener)
Sets the callback instance to receive callback notifications when the camera preview is fully started
or stopped or an error occurred in the process.
|
void |
setScaleMode(int scaleMode) |
void |
setSurfaceExtension(int extensionType) |
void |
setVideoBackgroundColor(WOWZColor videoBackgroundColor) |
void |
setVideoEnabled(boolean enabled)
Sets the flag indicating that a video broadcast component is enabled.
|
void |
setVideoPaused(boolean videoPaused)
Sets the flag indicating that a video broadcast component is paused.
|
WOWZStatus |
startBroadcasting()
Called on each broadcast component to begin a live streaming broadcast.
|
WOWZCamera |
startPreview()
Starts the camera preview display.
|
WOWZCamera |
startPreview(WOWZCameraView.PreviewStatusListener previewStatusListener) |
WOWZCamera |
startPreview(WOWZMediaConfig cameraConfig)
Starts the camera preview display using the values from the specified configuration for the camera frame size and frame rate.
|
WOWZCamera |
startPreview(WOWZMediaConfig cameraConfig,
WOWZCameraView.PreviewStatusListener previewStatusListener)
Starts the camera preview display.
|
WOWZStatus |
stopBroadcasting()
Called on each broadcast component to end a live streaming broadcast.
|
WOWZCamera |
stopPreview()
Stops the camera preview display.
|
WOWZCamera |
stopPreview(WOWZCameraView.PreviewStatusListener previewStatusListener)
Stops the camera preview display.
|
void |
surfaceChanged(SurfaceHolder holder,
int format,
int width,
int height)
Called immediately after any structural changes (format or size) have been made to the surface.
|
void |
surfaceCreated(SurfaceHolder surfaceHolder)
Called immediately after the surface is first created.
|
void |
surfaceDestroyed(SurfaceHolder holder)
Called immediately before a surface is being destroyed.
|
WOWZCamera |
switchCamera()
Changes the active camera being previewed to the alternate device camera, if available.
|
void |
unregisterFrameListener(WOWZRenderAPI.VideoFrameListener frameListener)
Unregisters a frame listener.
|
void |
unregisterFrameRenderer(WOWZRenderAPI.VideoFrameRenderer frameRenderer)
Unregisters a frame listener.
|
public static final int EXTENSION_DEFAULT
public static final int EXTENSION_MIRROR
public static final int EXTENSION_BLACK_AND_WHITE
public WOWZCameraView(Context context, AttributeSet attrs)
context
- The Context the view is running in, through which it can access the current theme, resources, etc.attrs
- The attributes of the XML tag that is inflating the view.public WOWZCameraView(Context context)
context
- The Context the view is running in, through which it can access the current theme, resources, etc.public static int getNumberOfDeviceCameras()
WOWZCamera.getNumberOfDeviceCameras()
instead.WOWZCamera.getNumberOfDeviceCameras()
public static WOWZCamera[] getDeviceCameras()
WOWZCamera.getDeviceCameras()
instead.public static WOWZCamera[] getAvailableDeviceCameras()
WOWZCamera.getAvailableDeviceCameras()
instead.public static java.lang.String getCameraInfo()
WOWZCamera.getCameraInfo()
instead.public int getDeviceOrientation()
WOWZDeviceUtils.getDeviceOrientation(Context)
instead.public void setPreviewStatusListener(WOWZCameraView.PreviewStatusListener previewStatusListener)
previewStatusListener
- An object that has implemented the PreviewStatusListener interface.public void setPreviewReadyListener(WOWZCameraView.PreviewStatusListener previewReadyListener)
setPreviewStatusListener(PreviewStatusListener)
instead.public WOWZStatus getPreviewStatus()
WOWZState.RUNNING
or WOWZState.IDLE
.public WOWZStatus getStatus()
getPreviewStatus()
instead.getStatus
in interface WOWZBroadcastAPI.Broadcaster
public boolean isPreviewing()
public boolean isPreviewReady()
public boolean isPreviewPaused()
public boolean isPaused()
isPreviewPaused()
instead.public WOWZBroadcastAPI.VideoBroadcaster getBroadcaster()
WOWZBroadcastAPI.VideoBroadcaster
interface
so you can use a WOWZCameraView instance directly in
WOWZBroadcastConfig.setVideoBroadcaster(WOWZBroadcastAPI.VideoBroadcaster)
,
for example, broadcastConfig.setVideoBroadcaster(cameraView);
.public WOWZColor getVideoBackgroundColor()
public void setVideoBackgroundColor(WOWZColor videoBackgroundColor)
public WOWZMediaConfig getVideoSourceConfig()
WOWZBroadcastAPI.VideoBroadcaster
getVideoSourceConfig
in interface WOWZBroadcastAPI.VideoBroadcaster
public void setVideoEnabled(boolean enabled)
WOWZBroadcastAPI.VideoBroadcaster
setVideoEnabled
in interface WOWZBroadcastAPI.VideoBroadcaster
enabled
- True if the component should be enabled; false otherwise.public boolean isVideoEnabled()
WOWZBroadcastAPI.VideoBroadcaster
isVideoEnabled
in interface WOWZBroadcastAPI.VideoBroadcaster
public void setVideoPaused(boolean videoPaused)
WOWZBroadcastAPI.VideoBroadcaster
setVideoPaused
in interface WOWZBroadcastAPI.VideoBroadcaster
videoPaused
- True if the component should be paused; false otherwise.public boolean isVideoPaused()
WOWZBroadcastAPI.VideoBroadcaster
isVideoPaused
in interface WOWZBroadcastAPI.VideoBroadcaster
public WOWZBroadcastConfig getBroadcastConfig()
WOWZBroadcastAPI.Broadcaster
getBroadcastConfig
in interface WOWZBroadcastAPI.Broadcaster
public WOWZStatus getBroadcasterStatus()
WOWZBroadcastAPI.Broadcaster
getBroadcasterStatus
in interface WOWZBroadcastAPI.Broadcaster
public WOWZStatus prepareForBroadcast(WOWZBroadcastConfig broadcastConfig)
WOWZBroadcastAPI.Broadcaster
WOWZState.READY
or WOWZState.IDLE
and also indicate the error in the status.prepareForBroadcast
in interface WOWZBroadcastAPI.Broadcaster
broadcastConfig
- The broadcast configuration.WOWZState.READY
.public WOWZStatus startBroadcasting()
WOWZBroadcastAPI.Broadcaster
WOWZState.RUNNING
or WOWZState.IDLE
and also indicate the error in the status.startBroadcasting
in interface WOWZBroadcastAPI.Broadcaster
WOWZState.RUNNING
.public WOWZStatus stopBroadcasting()
WOWZBroadcastAPI.Broadcaster
WOWZState.IDLE
.stopBroadcasting
in interface WOWZBroadcastAPI.Broadcaster
WOWZState.IDLE
.public void changeAdaptiveBitrate(int bitrate)
changeAdaptiveBitrate
in interface WOWZBroadcastAPI.AdaptiveBroadcaster
public int getAdaptiveBitrate()
getAdaptiveBitrate
in interface WOWZBroadcastAPI.AdaptiveBroadcaster
public void changeAdaptiveFramerate(int framerate)
changeAdaptiveFramerate
in interface WOWZBroadcastAPI.AdaptiveBroadcaster
public int getAdaptiveFramerate()
getAdaptiveFramerate
in interface WOWZBroadcastAPI.AdaptiveBroadcaster
public WOWZCamera startPreview(WOWZMediaConfig cameraConfig, WOWZCameraView.PreviewStatusListener previewStatusListener)
public WOWZCamera startPreview(WOWZCameraView.PreviewStatusListener previewStatusListener)
public WOWZCamera startPreview(WOWZMediaConfig cameraConfig)
cameraConfig
- A configuration with the frame size and frame rate to use.public WOWZCamera startPreview()
public WOWZCamera stopPreview(WOWZCameraView.PreviewStatusListener previewStatusListener)
public WOWZCamera stopPreview()
public void clearView()
public void setSurfaceExtension(int extensionType)
public void setCameraConfig(WOWZMediaConfig previewConfig)
previewConfig
- A configuration with the frame size and frame rate values to use.public int getScaleMode()
public void setScaleMode(int scaleMode)
public WOWZSize getFrameSize()
public WOWZSize getActiveFrameSize()
public WOWZSize setFrameSize(int width, int height)
width
- The width of the video frame size, in pixels.height
- The height of the video frame size, in pixels.public WOWZSize setFrameSize(WOWZSize frameSize)
frameSize
- The frame size specification.public int getFramerate()
public int setFramerate(int framerate)
framerate
- The requested frame rate, in fps.public WOWZCamera[] getCameras()
WOWZCamera
instances for each camera device present.public WOWZCamera getCamera()
public WOWZCamera getCameraById(int cameraId)
cameraId
- The camera's unique ID available via WOWZCamera.getCameraId()
.public WOWZCamera getCameraByDirection(int direction)
direction
- WOWZCamera.DIRECTION_FRONT
or WOWZCamera##DIRECTION_FRONT
.public WOWZCamera getOtherCamera()
public int getOtherCameraId()
public WOWZCamera setCamera(int cameraId)
cameraId
- The ID of the camera to display.public WOWZCamera setCamera(WOWZCamera camera)
camera
- The camera to display.public WOWZCamera setCameraByDirection(int direction)
direction
- WOWZCamera.DIRECTION_FRONT
or WOWZCamera##DIRECTION_FRONT
.public WOWZCamera switchCamera()
public boolean isSwitchCameraAvailable(WOWZSize withFrameSize)
withFrameSize
- If supplied, the result will only be true if the other camera supports the specified frame size.public boolean isSwitchCameraAvailable(WOWZMediaConfig mediaConfig)
mediaConfig
- If supplied, the result will only be true if the other camera supports the video frame size indicated by the specified configration.public boolean isSwitchCameraAvailable()
public void doConfigChange()
public void onConfigurationChanged(Configuration newConfig)
newConfig
- The new device configuration.
https://developer.android.com/reference/android/app/Activity.html#ConfigurationChanges
public void onLowMemory()
https://developer.android.com/reference/android/app/Activity.html#onLowMemory()
public void surfaceCreated(SurfaceHolder surfaceHolder)
surfaceHolder
- The SurfaceHolder whose surface is being created.public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
holder
- The SurfaceHolder whose surface has changed.public void surfaceDestroyed(SurfaceHolder holder)
holder
- The SurfaceHolder whose surface is being destroyed.public void onPause()
onPause()
method to store the state of the
camera preview display before the application is sent to the background.
The stored state can then be restored with a corresponding call to onResume()
made from the activity's onResume()
method.public void onResume()
public WOWZSize getScreenSize()
public void registerFrameRenderer(WOWZRenderAPI.VideoFrameRenderer frameRenderer)
WOWZRenderAPI.VideoFrameRenderer
interface
that can be used to render additional content, such as a logo, to the camera preview display.frameRenderer
- An instance of a WOWZRenderAPI.VideoFrameRenderer
implementation.public void unregisterFrameRenderer(WOWZRenderAPI.VideoFrameRenderer frameRenderer)
frameRenderer
- A previously registered instance of a WOWZRenderAPI.VideoFrameRenderer
implementation.public void registerFrameListener(WOWZRenderAPI.VideoFrameListener frameListener)
WOWZRenderAPI.VideoFrameListener
interface
that can be used to capture content from the camera preview display.frameListener
- An instance of a WOWZRenderAPI.VideoFrameListener
implementation.public void unregisterFrameListener(WOWZRenderAPI.VideoFrameListener frameListener)
frameListener
- A previously registered instance of a WOWZRenderAPI.VideoFrameListener
implementation.© 2016 - 2018 Wowza Media Systems, LLC. All rights reserved. Terms | Privacy | Trademarks | Legal