Class Publisher.Builder
- java.lang.Object
-
- com.opentok.android.PublisherKit.Builder
-
- com.opentok.android.Publisher.Builder
-
- Enclosing class:
- Publisher
public static class Publisher.Builder extends PublisherKit.Builder
Used to build aPublisher
object. Instantiate a Builder object using thePublisher.Builder(Context context)
constructor. Then call methods of theBuilder
instance to add settings for the publisher. (Note that thePublisher.Builder
class inherits methods from thePublisherKit.Builder
class.) Then call thebuild()
method, which returns aPublisher
object.Use the
Session.publish(PublisherKit publisher)
method to start streaming from the publisher into a session.
-
-
Constructor Summary
Constructors Constructor Description Builder(android.content.Context context)
Instantiates aPublisher.Builder
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Publisher.Builder
audioBitrate(int bitsPerSecond)
Sets the desired bitrate for the published audio, in bits per second.Publisher.Builder
audioTrack(boolean enabled)
Sets whether to include an audio track in the published stream (true
, the default) or not (false
).Publisher
build()
Returns a newPublisher
instance based on thePublisher.Builder
settings.Publisher.Builder
capturer(BaseVideoCapturer capturer)
Sets the video capturer to use for the publisher.Publisher.Builder
enableOpusDtx(boolean enable)
Publisher.Builder
frameRate(Publisher.CameraCaptureFrameRate frameRate)
Sets the desired frame rate of the published video.Publisher.Builder
name(java.lang.String name)
Sets the name of the published video.Publisher.Builder
publisherAudioFallbackEnabled(boolean enabled)
Whether the stream will use the publisher audio-fallback feature (true
) or not (false
).Publisher.Builder
renderer(BaseVideoRenderer renderer)
Sets the video renderer to use for the publisher.Publisher.Builder
resolution(Publisher.CameraCaptureResolution resolution)
Sets the video resolution of the published video.Publisher.Builder
scalableScreenshare(boolean enable)
Whether to allow use of scalable video for a publisher that has the videoType set to PublisherKitVideoTypeScreen (true) or not (false, the default).Publisher.Builder
subscriberAudioFallbackEnabled(boolean enabled)
Whether the stream will use the subscriber audio-fallback feature (true
) or not (false
), for subscribers to the published stream.Publisher.Builder
videoTrack(boolean enabled)
Sets whether to include an video track in the published stream (true
, the default) or not (false
).
-
-
-
Method Detail
-
resolution
public Publisher.Builder resolution(Publisher.CameraCaptureResolution resolution)
Sets the video resolution of the published video. Set this to a value defined in thePublisher.CameraCaptureResolution
enum
-
frameRate
public Publisher.Builder frameRate(Publisher.CameraCaptureFrameRate frameRate)
Sets the desired frame rate of the published video. Set this to a value defined in thePublisher.CameraCaptureFrameRate
enum. If the device does not support the specified frame rate, it will use the closest supported frame rate. 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.)
-
name
public Publisher.Builder name(java.lang.String name)
Description copied from class:PublisherKit.Builder
Sets the name of the published video. Thename
property for a stream published by this publisher will be set to this value (on all clients).- Overrides:
name
in classPublisherKit.Builder
-
audioTrack
public Publisher.Builder audioTrack(boolean enabled)
Description copied from class: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 thePublisherKit.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 thePublisherKit.setPublishAudio(boolean publishAudio)
method, which only temporarily disables the audio track.- Overrides:
audioTrack
in classPublisherKit.Builder
-
videoTrack
public Publisher.Builder videoTrack(boolean enabled)
Description copied from class: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 thePublisherKit.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 thePublisherKit.setPublishVideo(boolean publishVideo)
method, which only temporarily disables the video track.- Overrides:
videoTrack
in classPublisherKit.Builder
-
capturer
public Publisher.Builder capturer(BaseVideoCapturer capturer)
Sets the video capturer to use for the publisher. If you do not call this method, the publisher will use the default Publisher capturer.- Overrides:
capturer
in classPublisherKit.Builder
-
renderer
public Publisher.Builder renderer(BaseVideoRenderer renderer)
Sets the video renderer to use for the publisher. If you do not call this method, the publisher will use the default Publisher renderer.- Overrides:
renderer
in classPublisherKit.Builder
-
audioBitrate
public Publisher.Builder audioBitrate(int bitsPerSecond)
Description copied from class: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.- Overrides:
audioBitrate
in classPublisherKit.Builder
- Parameters:
bitsPerSecond
- The desired bitrate of the audio, in bits per second.- Returns:
- This Builder object.
-
scalableScreenshare
public Publisher.Builder scalableScreenshare(boolean enable)
Description copied from class: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).- Overrides:
scalableScreenshare
in classPublisherKit.Builder
-
enableOpusDtx
public Publisher.Builder enableOpusDtx(boolean enable)
Description copied from class: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.- Overrides:
enableOpusDtx
in classPublisherKit.Builder
-
subscriberAudioFallbackEnabled
public Publisher.Builder subscriberAudioFallbackEnabled(boolean enabled)
Description copied from class: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 tofalse
by default, so that the video does not drop out in subscribers.
-
publisherAudioFallbackEnabled
public Publisher.Builder publisherAudioFallbackEnabled(boolean enabled)
Description copied from class: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).
-
build
public Publisher build()
Returns a newPublisher
instance based on thePublisher.Builder
settings.- Overrides:
build
in classPublisherKit.Builder
- Returns:
- Returns a new
PublisherKit
instance based on thePublisherKit.Builder
settings.
-
-