public class Publisher extends PublisherKit
Session.publish(PublisherKit publisher)
Modifier and Type | Class and Description |
---|---|
static class |
Publisher.CameraCaptureFrameRate
Defines values for the
frameRate parameter of the
Publisher(Context context, String name, CameraCaptureResolution resolution,
CameraCaptureFrameRate frameRate) constructor. |
static class |
Publisher.CameraCaptureResolution
Defines values for the
resolution parameter of the
Publisher(Context context, String name, Publisher.CameraCaptureResolution
resolution, Publisher.CameraCaptureFrameRate frameRate) constructor. |
static interface |
Publisher.CameraListener
Monitors when the camera used by the publisher changes.
|
PublisherKit.AudioLevelListener, PublisherKit.PublisherKitVideoType, PublisherKit.PublisherListener
Modifier and Type | Field and Description |
---|---|
protected Publisher.CameraCaptureFrameRate |
cameraFrameRate |
protected Publisher.CameraListener |
cameraListener |
protected Publisher.CameraCaptureResolution |
cameraResolution |
audioLevelListener, capturer, context, publisherListener, renderer, session
Constructor and Description |
---|
Publisher(android.content.Context context)
Creates a new Publisher instance.
|
Publisher(android.content.Context context,
java.lang.String name)
Creates a new Publisher instance.
|
Publisher(android.content.Context context,
java.lang.String name,
BaseVideoCapturer capturer)
Creates a new Publisher instance.
|
Publisher(android.content.Context context,
java.lang.String name,
boolean audioTrack,
boolean videoTrack)
Creates a new Publisher instance.
|
Publisher(android.content.Context context,
java.lang.String name,
Publisher.CameraCaptureResolution resolution,
Publisher.CameraCaptureFrameRate frameRate)
Creates a new Publisher instance.
|
Modifier and Type | Method and Description |
---|---|
void |
cycleCamera()
Cycles between cameras, if there are multiple cameras on the device.
|
void |
destroy()
Releases this object, including all hardware and UI resources bound to
it.
|
protected void |
finalize() |
int |
getCameraId()
Deprecated.
|
protected void |
onCameraChanged(int newCameraId)
Invoked when the publisher changes the active camera.
|
protected void |
onCameraError(OpentokError error) |
void |
setCameraId(int cameraId)
Deprecated.
|
void |
setCameraListener(Publisher.CameraListener listener)
Sets a
Publisher.CameraListener object to monitor when the camera used by
the publisher changes. |
void |
startPreview()
Call to display the camera's video in the Publisher's view before the it starts streaming
video.
|
void |
swapCamera()
Deprecated.
|
attachToSession, detachFromSession, getAudioFallbackEnabled, getCapturer, getName, getPublishAudio, getPublisherVideoType, getPublishVideo, getRenderer, getSession, getStream, getView, initCapturerRendererNative, onError, onPause, onResume, onStreamCreated, onStreamDestroyed, setAudioFallbackEnabled, setAudioLevelListener, setCapturer, setName, setPublishAudio, setPublisherListener, setPublisherVideoType, setPublishVideo, setRenderer, setStyle
protected Publisher.CameraCaptureFrameRate cameraFrameRate
protected Publisher.CameraCaptureResolution cameraResolution
protected Publisher.CameraListener cameraListener
public Publisher(android.content.Context context)
Session.publish(PublisherKit publisher)
method to start streaming
from this Publisher into a session.
The PublisherKit.getView()
method returns the android.view.View object
containing the published video.
You cannot reuse a publisher after you have called the destroy()
method.
context
- The android.content.Context for the Publisher.public Publisher(android.content.Context context, java.lang.String name)
Session.publish(PublisherKit publisher)
method to start streaming
from this Publisher into a session.
This version of the constructor lets you add a name for the publisher's stream.
The PublisherKit.getView()
method returns the android.view.View object
containing the published video.
You cannot reuse a publisher after you have called the destroy()
method.
context
- The android.content.Context for the Publisher.name
- The name of the publisher video. The Stream.name
property for
a stream published by this publisher will be set to this value
(on all clients).public Publisher(android.content.Context context, java.lang.String name, BaseVideoCapturer capturer)
Session.publish(PublisherKit publisher)
method to start streaming
from this Publisher into a session.
This version of the constructor lets you define a custom video capturer for the Publisher.
The PublisherKit.getView()
method returns the android.view.View object
containing the published video.
You cannot reuse a publisher after you have called the destroy()
method.
context
- The android.content.Context for the Publisher.name
- The name of the publisher video. The Stream.name
property for
a stream published by this publisher will be set to this value
(on all clients).capturer
- The video capturer to use for the Publisher.public Publisher(android.content.Context context, java.lang.String name, boolean audioTrack, boolean videoTrack)
Session.publish(PublisherKit publisher)
method to start streaming
from this Publisher into a session.
This version of the constructor adds parameters that let you exclude the audio track or video track from the published stream. Creating a Publisher without an audio track or video track can save CPU resources.
The PublisherKit.getView()
method returns the android.view.View object
containing the published video.
You cannot reuse a publisher after you have called the destroy()
method.
context
- The android.content.Context for the Publisher.name
- The name of the publisher video. The Stream.name
property for
a stream published by this publisher will be set to this value
(on all clients).audioTrack
- Whether to include an audio track in the published stream.videoTrack
- Whether to include a video track in the published stream.public Publisher(android.content.Context context, java.lang.String name, Publisher.CameraCaptureResolution resolution, Publisher.CameraCaptureFrameRate frameRate)
Session.publish(PublisherKit publisher)
method to start streaming
from this Publisher into a session.
This version of the constructor adds parameters for setting the resolution and frame rate of the video.
For sessions that use the OpenTok Media Router (sessions with the media mode set to routed), lowering the frame rate or lowering the resolution reduces the maximum bandwidth the stream can use. However, in sessions with the media mode set to relayed, lowering the frame rate or resolution may not reduce the stream's bandwidth.
The PublisherKit.getView()
method returns the android.view.View object
containing the published video.
Note: The default frame rate and resolution for a Publisher constructed using other
versions of the Publisher constructor are set to
Publisher.CameraCaptureFrameRate.FPS_30
and
Publisher.CameraCaptureResolution.MEDIUM
. However, these can vary over time for
the stream.
You cannot reuse a publisher after you have called the destroy()
method.
context
- The android.content.Context for the Publisher.name
- The name of the publisher video. The Stream.name
property for
a stream published by this publisher will be set to this value
(on all clients).resolution
- The resolution of the video. Set this to a value defined in the
Publisher.CameraCaptureResolution
enum.frameRate
- The frame rate of the video. Set this to a value defined in the
Publisher.CameraCaptureFrameRate
enum. If the device does not support the specified
frame rate, it will use the closest supported frame rate that is lower.
Note that in sessions that use the OpenTok Media Router (sessions with
the media mode set to routed), lowering the frame rate proportionally
reduces the bandwidth the stream uses. However, in sessions that have the
media mode set to relayed, lowering the frame rate does not reduce
the stream's bandwidth. (See The
OpenTok Media Router and media modes.)public void setCameraListener(Publisher.CameraListener listener)
Publisher.CameraListener
object to monitor when the camera used by
the publisher changes.listener
- The Publisher.CameraListener
instance.protected void finalize() throws java.lang.Throwable
finalize
in class PublisherKit
java.lang.Throwable
public void destroy()
PublisherKit
destroy
in class PublisherKit
@Deprecated public void setCameraId(int cameraId)
cameraId
can be a value between 0
and android.hardware.Camera#getNumberOfCameras() - 1.
When the camera used by the Publisher changes, the
Publisher.CameraListener.onCameraChanged(Publisher publisher, int newCameraId)
method is called.
cycleCamera()
method to cycle
between cameras, if there are multiple cameras on the device.cameraId
- the id of the camera you want to use on this publisherpublic void cycleCamera()
Publisher.CameraListener.onCameraChanged(Publisher publisher, int newCameraId)
method is called.@Deprecated public void swapCamera()
cycleCamera()
method to cycle
between cameras, if there are multiple cameras on the device.
If you are using a custom video capturer, implement the
BaseVideoCapturer.CaptureSwitch
interface in the object that extends
BaseVideoCapturer, and implement the
BaseVideoCapturer.CaptureSwitch.swapCamera(int cameraId)
method to define the behavior
of the Publisher.swapCamera()
method.
@Deprecated public int getCameraId()
setCameraId(int)
is never called, the return value is 1 (for the
front-facing camera).
This method is deprecated. You should use the new cycleCamera()
method to cycle
between cameras, if there are multiple cameras on the device.
protected void onCameraChanged(int newCameraId)
onCameraChanged()
method of the Publisher.CameraListener
interface.newCameraId
- The ID of the new active camera.protected void onCameraError(OpentokError error)
public void startPreview()
destroy()
method to remove the
Publisher's view (and the video), when the publisher stops streaming (when the
PublisherKit.PublisherListener.onStreamDestroyed(PublisherKit publisher,
Stream stream)
method is called).