Control a camera and microphone with GoCoder SDK for Android

Learn how to use the WOWZCamera and WowzaGoCoder classes in the Wowza GoCoder™ SDK for Android to control cameras and microphones on a device.

Contents


Control a camera Control a microphone
More resources

Control a camera


The WOWZCamera class controls the capabilities that vary between the device's two cameras.

Note: Most of the configuration options that don't vary are controlled by the WOWZCameraView class.

Determine camera capabilities

The WOWZCamera class uses the following methods to determine the capabilities supported by a particular camera:

Method Description
getSupportedFrameSizes() Returns an array of the frame sizes that the camera supports.
hasCapability(WOWZCamera.TORCH) Returns true if a camera has a flash (torch).
hasCapability(WOWZCamera.FOCUS_MODE_AUTO) Returns true if the camera can auto-focus to a specified point location.
hasCapability(WOWZCamera.FOCUS_MODE_CONTINUOUS) Returns true if the camera can continuously adjust the focus.

The following example configures the WZCamera.TORCH method:

// Enable the flash if the current camera has a flashlight (torch)
WOWZCamera activeCamera = this.goCoderCameraView.getCamera();
mBtnTorch.setEnabled(activeCamera.hasCapability(WOWZCamera.TORCH));

Control a camera flash

Use the isTorchOn and setTorchOn methods, respectively, to determine the state of the camera's flash and to turn it on and off.

// Turn the flash on if it's off
WOWZCamera activeCamera = this.goCoderCameraView.getCamera();
if (!activeCamera.isTorchOn())
  activeCamera.setTorchOn(mBtnTorch.toggleState());

Control a microphone


Use the muteAudio method of the WowzaGoCoder class to mute or pause audio while streaming.

// Mute the audio stream if it isn't already
if (!this.goCoder.isMuted())
  this.goCoder.muteAudio = newMutedState;

More resources