PublisherKit.Builder
public static class Builder
Enclosing class: PublisherKit
Used to build a PublisherKit object. Instantiate a Builder object using the
PublisherKit.Builder(Context context) constructor. Then call methods of
the Builder instance to add settings for the publisher. Then call the
build() method, which returns a PublisherKit object.
Use the Session#publish(PublisherKit publisher) method to start streaming
from the publisher into a session.
Publishers cannot be reused. Instantiate a new PublisherKit object each time you
want to publish a new stream.
Methods
| Name | Description |
|---|---|
Builder(context) |
Instantiates a PublisherKit.Builder object. |
allowAudioCaptureWhileMuted(allow) → {PublisherKit.Builder} |
If set to false, the microphone will be automatically switched off when all publishers have muted their audio. |
audioBitrate(bitsPerSecond) → {PublisherKit.Builder} |
Sets the desired bitrate for the published audio, in bits per second. |
audioTrack(enabled) → {PublisherKit.Builder} |
Sets whether to include an audio track in the published stream (true, the default) or not (false). |
build() → {PublisherKit} |
|
capturer(capturer) → {PublisherKit.Builder} |
Sets the video capturer to use for the publisher. |
enableOpusDtx(enable) → {PublisherKit.Builder} |
Whether to enable Opus DTX (true) or not (false, the default). |
name(name) → {PublisherKit.Builder} |
Sets the name of the published video. |
preferredVideoCodecs(preferredVideoCodecs) → {PublisherKit.Builder} |
|
publisherAudioFallbackEnabled(enabled) → {PublisherKit.Builder} |
Whether the stream will use the publisher audio-fallback feature (true) or not (false). |
renderer(renderer) → {PublisherKit.Builder} |
Sets the video renderer to use for the publisher. |
scalableScreenshare(enabled) → {PublisherKit.Builder} |
Whether to allow use of scalable video for a publisher that has the videoType set to PublisherKitVideoTypeScreen (true) or not (false, the default). |
senderStatsTrack(enabled) → {PublisherKit.Builder} |
If you do not call this and pass in true, the sender statistics subsystem will not be initialized for the publisher. |
subscriberAudioFallbackEnabled(enabled) → {PublisherKit.Builder} |
Whether the stream will use the subscriber audio-fallback feature (true) or not (false), for subscribers to the published stream. |
videoTrack(enabled) → {PublisherKit.Builder} |
Sets whether to include an video track in the published stream (true, the default) or not (false). |
Builder(context)
Instantiates a PublisherKit.Builder object.
Parameters:
| Name | Type | Description |
|---|---|---|
context |
Context | The android.content.Context for the publisher. |
allowAudioCaptureWhileMuted(allow) → {PublisherKit.Builder}
If set to false, the microphone will be automatically switched off when all publishers have muted their audio. Microphone will be automatically switched on again when at least one publisher unmutes their audio. If set to true, mic will always remain switched on even when all publishers have muted their audio. Be aware that when the microphone is switched off, callbacks like AudioLevel or AudioData will no longer be invoked for the publishers. The default value is false.
Parameters:
| Name | Type | Description |
|---|---|---|
allow |
boolean |
Returns:
PublisherKit.Builder
audioBitrate(bitsPerSecond) → {PublisherKit.Builder}
Sets the desired bitrate for the published audio, in bits per second. The supported range of values is 6,000 - 510,000. (Invalid values are ignored.) Set this value to enable high-quality audio (or to reduce bandwidth usage with lower-quality audio).
The following are recommended settings:
- 8,000 - 12,000 for narrowband (NB) speech
- 16,000 - 20,000 for wideband (WB) speech
- 28,000 - 40,000 for full-band (FB) speech
- 48,000 - 64,000 for full-band (FB) mono music
- 64,000 - 128,000 for full-band (FB) stereo music
The default value is 40,000.
To set other audio settings, see the AudioDeviceManager class.
Parameters:
| Name | Type | Description |
|---|---|---|
bitsPerSecond |
int | The desired bitrate of the audio, in bits per second. |
Returns:
This Builder object.
audioTrack(enabled) → {PublisherKit.Builder}
Sets whether to include an audio track in the published stream (true,
the default) or not (false). Creating a publisher without an audio track
can save CPU resources and reduce the bandwidth used by the stream.
If you call this and pass in false, the audio subsystem will not be
initialized for the publisher, and calling the
PublisherKit#setPublishAudio(boolean publishAudio) method will have no effect.
If your application does not require the use of audio, it is recommended to use this
Builder setting rather than use the
PublisherKit#setPublishAudio(boolean publishAudio) method, which only
temporarily disables the audio track.
Parameters:
| Name | Type | Description |
|---|---|---|
enabled |
boolean |
Returns:
PublisherKit.Builder
build() → {PublisherKit}
Returns:
Returns a new PublisherKit instance based on the PublisherKit.Builder
settings.
capturer(capturer) → {PublisherKit.Builder}
Sets the video capturer to use for the publisher.
Parameters:
| Name | Type | Description |
|---|---|---|
capturer |
BaseVideoCapturer |
Returns:
PublisherKit.Builder
enableOpusDtx(enable) → {PublisherKit.Builder}
Whether to enable Opus DTX (true) or not (false, the default). Enabling Opus DTX
can reduce bandwidth usage in streams that have long periods of silence.
By default, Opus DTX is disabled. If this property is set to true,
Opus DTX will be enabled for the publisher.
Parameters:
| Name | Type | Description |
|---|---|---|
enable |
boolean |
Returns:
PublisherKit.Builder
name(name) → {PublisherKit.Builder}
Sets the name of the published video. The name property for a stream
published by this publisher will be set to this value (on all clients).
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String |
Returns:
PublisherKit.Builder
preferredVideoCodecs(preferredVideoCodecs) → {PublisherKit.Builder}
Parameters:
| Name | Type | Description |
|---|---|---|
preferredVideoCodecs |
PublisherKit.PreferredVideoCodecs |
Returns:
PublisherKit.Builder
publisherAudioFallbackEnabled(enabled) → {PublisherKit.Builder}
Whether the stream will use the publisher audio-fallback feature (true) or not
(false). With the publisher audio-fallback feature enabled (the default), when
publisher determines that a stream's quality has degraded significantly, it disables the video
in order to preserve audio quality.
The default setting is false (the audio-fallback feature is disabled).
Parameters:
| Name | Type | Description |
|---|---|---|
enabled |
boolean |
See:
: - PublisherKit.VideoListener#onVideoDisabled(PublisherKit publisher, String reason)
- the OpenTok Media Router and media modes
Returns:
PublisherKit.Builder
renderer(renderer) → {PublisherKit.Builder}
Sets the video renderer to use for the publisher.
Parameters:
| Name | Type | Description |
|---|---|---|
renderer |
BaseVideoRenderer |
Returns:
PublisherKit.Builder
scalableScreenshare(enabled) → {PublisherKit.Builder}
Whether to allow use of scalable video for a publisher that has the videoType set to PublisherKitVideoTypeScreen (true) or not (false, the default).
Parameters:
| Name | Type | Description |
|---|---|---|
enabled |
boolean |
Returns:
PublisherKit.Builder
senderStatsTrack(enabled) → {PublisherKit.Builder}
If you do not call this and pass in true, the sender statistics subsystem will not be
initialized for the publisher.
Parameters:
| Name | Type | Description |
|---|---|---|
enabled |
boolean |
Returns:
PublisherKit.Builder
subscriberAudioFallbackEnabled(enabled) → {PublisherKit.Builder}
Whether the stream will use the subscriber audio-fallback feature (true) or not
(false), for subscribers to the published stream. The subscriber audio-fallback
feature is available in sessions that use the the OpenTok Media Router. With the subscriber
audio-fallback feature enabled (the default), when the OpenTok Media Router determines that a
stream's quality has degraded significantly for a specific subscriber, it disables the video
in that subscriber in order to preserve audio quality.
The default setting is true (the audio-fallback feature is enabled).
When using the screen video type in a session that uses the OpenTok Media Server, the
subscriber audio-fallback setting is set to false by default,
so that the video does not drop out in subscribers.
Parameters:
| Name | Type | Description |
|---|---|---|
enabled |
boolean |
See:
: - SubscriberKit.VideoListener#onVideoDisabled(SubscriberKit subscriber, String reason)
- the OpenTok Media Router and media modes
Returns:
PublisherKit.Builder
videoTrack(enabled) → {PublisherKit.Builder}
Sets whether to include an video track in the published stream (true,
the default) or not (false). Creating a publisher without a video track
can save CPU resources and reduce the bandwidth used by the stream.
If you call this and pass in false, the video subsystem will not be
initialized for the publisher, and calling the
PublisherKit#setPublishVideo(boolean publishVideo) method will have no effect.
If your application does not require the use of video, it is recommended to use this
Builder setting rather than use the
PublisherKit#setPublishVideo(boolean publishVideo) method, which only
temporarily disables the video track.
Parameters:
| Name | Type | Description |
|---|---|---|
enabled |
boolean |
Returns:
PublisherKit.Builder