A publisher captures an audio-video stream from the sources you specify. More...

Inherits IDisposable.

Classes
class AudioLevelArgs
Defines arguments for AudioLevel events. More...
class AudioNetworkStats
Defines an audio statistics object for the Stats property of a AudioNetworkStatsEventArgs object. More...
class AudioNetworkStatsEventArgs
Defines arguments for AudioStatsUpdated events. More...
class Builder
Used to create a Publisher instance. More...
class ErrorEventArgs
Defines arguments for the Error event. More...
class NetworkConditionChangedEventArgs
Defines arguments for NetworkConditionChanged events raised by the publisher. More...
class PublisherMediaLinkStats
Provides publisher media link statistics including local transport metrics. More...
class PublisherMediaLinkStatsEventArgs
Defines arguments for MediaLinkStatsUpdated events. More...
class PublisherRtcStats
Represents RTC statistics for a media stream published by the publisher. More...
class RtcStatsReportArgs
Defines arguments for RtcStatsReport events. More...
class StreamEventArgs
Defines arguments for the StreamCreated and StreamDestroyed events. More...
class VideoEventArgs
Defines arguments for the VideoEnabled and VideoDisabled events. More...
class VideoLayerStats
Represents the statistics for a single published video layer. More...
class VideoNetworkStats
Defines a video statistics object for the Stats property of a VideoNetworkStatsEventArgs object. More...
class VideoNetworkStatsEventArgs
Defines arguments for VideoStatsUpdated events. More...
class VideoQualityChangedEventArgs
Defines arguments for VideoQualityChanged events. More...
Public Types
enum VideoReason : int {   None = 0 , PublishVideo = 1 , Quality = 3 , QualityDegradationBandwidth = 5 ,   QualityDegradationCPU = 6 , QualityDegradationOther = 7 , CodecChange = 8 , ResolutionChange = 9 }
Defines values for the VideoEventArgs.Reason and VideoEventArgs.Reason properties. More...
Public Member Functions
void GetRtcStatsReport ()
Gets the RTC stats report for the publisher. This is an asynchronous operation. When the stats are available, the RtcStatsReport message is sent. More...
void Dispose ()
Disposes of the Publisher object's resources. More...
Protected Member Functions
Publisher (Builder builder)
virtual void Dispose (bool disposing)
Properties
List< VideoTransformer > VideoTransformers [get, set]
List of VideoTransformer in the order to be applied to the stream. See the documentation on Using the Vonage Media Processor library and applying media tranformations. Getter returns a copy of the list. Adding or removing transformers from this copy will not affect the internal layers.
List< AudioTransformer > AudioTransformers [get, set]
List of AudioTransformer in the order to be applied to the stream. See the documentation on Using the Vonage Media Processor library and applying media tranformations. Getter returns a copy of the list. Adding or removing transformers from this copy will not affect the internal layers.
IVideoRenderer VideoRenderer [get]
The video renderer for the publisher.
IVideoCapturer VideoCapturer [get]
The video capturer for the publisher.
Stream Stream [get]
The stream for this publisher. The properties of the Stream object are a snapshot of the stream state at the time this property is accessed, and will not be updated as the state of the stream changes.
bool PublishCaptions [get, set]
Whether the publisher is publishing captions.
bool PublishAudio [get, set]
Whether the publisher is publishing audio.
bool PublishVideo [get, set]
VideoSourceType VideoSourceType [get, set]
The type of the stream (either camera or screen sharing), as defined by the OpenTok.VideoSourceType enum.
int MaxVideoBitrate [get, set]
The maximum video bitrate for the publisher's video stream (in bits per second). More...
VideoBitratePreset VideoBitratePreset [get, set]
The video bitrate preset strategy applied to the publisher's video stream. More...
DegradationPreference DegradationPreference [get, set]
The preferred policy that the video engine will follow when adjusting frame rate and resolution to limited bandwidth and CPU conditions. See DegradationPreference enum for a description of the possible values.
Events
EventHandler MuteForced
Defines arguments for the MuteForced event.
EventHandler< StreamEventArgs > StreamCreated
Sent when the publisher's stream is created.
EventHandler< StreamEventArgs > StreamDestroyed
Sent when the publisher's stream is destroyed.
EventHandler< ErrorEventArgs > Error
Sent when the publisher fails.
EventHandler< VideoQualityChangedEventArgs > VideoQualityChanged
Occurs when there is a change in the quality state of the publisher's video stream. More...
EventHandler< NetworkConditionChangedEventArgs > NetworkConditionChanged
Occurs when network condition changes are detected on the publisher side. More...
EventHandler< PublisherMediaLinkStatsEventArgs > MediaLinkStatsUpdated
Occurs periodically to report media link statistics for the publisher.
EventHandler< AudioLevelArgs > AudioLevel
Sent periodically to report the audio level of the publisher.
EventHandler< AudioNetworkStatsEventArgs > AudioStatsUpdated
Invoked when the publisher has audio stats to share.
EventHandler< VideoNetworkStatsEventArgs > VideoStatsUpdated
Invoked when the publisher has video stats to share.
EventHandler< RtcStatsReportArgs > RtcStatsReport
Sent in response to a call to GetRtcStatsReport().
EventHandler< VideoEventArgs > VideoDisabled
Called when the publisher stops sending video. More...
EventHandler< VideoEventArgs > VideoEnabled
Called when the publisher's video stream resumes (after video was disabled). More...
EventHandler VideoDisableWarning
Called when the publisher determines that the network congestion level has degraded and the video will be disabled if the congestion degrades further. More...
EventHandler VideoDisableWarningLifted
Called when the publisher determines that the network congestion level has improved to the point at which the video being disabled is not an immediate risk. More...

Detailed Description

A publisher captures an audio-video stream from the sources you specify.

Use the Publisher.Builder class to create a Publisher instance. You can then publish the audio-video stream to an Vonage Video API session by calling the Session.Publish(Publisher) method.

The Publisher class implements the System.IDisposable interface. Be sure to call the Dispose() method of the Publisher object to release its resources when you no longer need the object (for example, when the Publisher is removed or when the app or window is closing).

Member Enumeration Documentation

VideoReason

Defines values for the VideoEventArgs.Reason and VideoEventArgs.Reason properties.

Enumerator
None No notable video event or quality degradation. Default or unknown reason.
PublishVideo The event occured because the publisher of the stream started or stopped publishing video.
Quality The event was caused by a change in the network congestion level. When the video stream quality degrades due to network conditions, the Publisher sends the VideoDisabled event. When conditions improve, the video stream resumes, and the Publisher sends the VideoEnabled event. When the video stream is dropped, the Publisher continues to send the audio stream, if there is one. Moreover, the capturer corresponding to this publisher will not be disabled, and the captured frames will still be seen on the publisher side.
QualityDegradationBandwidth Quality degradation due to insufficient network bandwidth.
QualityDegradationCPU Quality degradation caused by CPU limitations on the client device.
QualityDegradationOther Quality degradation caused by other reasons not categorized as bandwidth or CPU constraints.
CodecChange The video codec for the stream has changed.
ResolutionChange Change in video resolution or number of layers. This can occur due to bitrate constraints, encoder adaptation, camera source changes (such as switching cameras or changing input resolution), or configuration changes. Does not necessarily imply quality degradation.

Member Function Documentation

Dispose()

void OpenTok.Publisher.Dispose ( )

Disposes of the Publisher object's resources.

Note that the Publisher's resources are not disposed of when you call the Session.Publish(Publisher) method. When you call Session.Publish(Publisher), the resources of the Publisher object are retained so that you can reuse it (to Publish again to the session).

GetRtcStatsReport()

void OpenTok.Publisher.GetRtcStatsReport ( )

Gets the RTC stats report for the publisher. This is an asynchronous operation. When the stats are available, the RtcStatsReport message is sent.

Also see AudioStatsUpdated, VideoStatsUpdated, and Subscriber.GetRtcStatsReport().

Property Documentation

MaxVideoBitrate

The maximum video bitrate for the publisher's video stream (in bits per second).

This property sets an explicit upper limit on the publisher’s video bitrate. Setting this property to 0 clears any manual cap and reverts to the default preset-based adaptive bitrate behavior with no explicit limit.

Reading this property returns the currently configured maximum bitrate in bps. If no manual bitrate has been set, or if a bitrate preset is active, the value is 0.

A value of 0 indicates that no explicit bitrate limit is applied and the stream operates under adaptive preset rules to optimize quality.

PublishVideo

VideoBitratePreset

The video bitrate preset strategy applied to the publisher's video stream.

This property configures a predefined bitrate strategy to balance video quality and bandwidth usage. Preset configurations and manual bitrate settings are mutually exclusive. Setting the MaxVideoBitrate property overrides any preset and automatically changes this property to VideoBitratePreset.Custom.

Reading this property returns the currently active preset. If a custom bitrate has been manually set, the value will be VideoBitratePreset.Custom.

The default value is VideoBitratePreset.Default.

Note: The VideoBitratePreset.Custom value cannot be set directly.

For details, see Publisher Max Bitrate.

Event Documentation

NetworkConditionChanged

EventHandler<NetworkConditionChangedEventArgs> OpenTok.Publisher.NetworkConditionChanged

Occurs when network condition changes are detected on the publisher side.

This event is triggered when significant network condition changes occur, providing media link statistics along with the reason for the change.

VideoDisabled

EventHandler<VideoEventArgs> OpenTok.Publisher.VideoDisabled

Called when the publisher stops sending video.

Check the reason property of the event arguments for the reason why the video stopped.

VideoDisableWarning

EventHandler OpenTok.Publisher.VideoDisableWarning

Called when the publisher determines that the network congestion level has degraded and the video will be disabled if the congestion degrades further.

If the network degrades further, the Publisher disables the video and sends the AudioFallback message. If the stream quality improves, the Publisher sends the VideoDisableWarningLifted event.

This method is mainly called when the connection quality degrades.

VideoDisableWarningLifted

EventHandler OpenTok.Publisher.VideoDisableWarningLifted

Called when the publisher determines that the network congestion level has improved to the point at which the video being disabled is not an immediate risk.

This method is mainly called when the connection quality improves.

VideoEnabled

EventHandler<VideoEventArgs> OpenTok.Publisher.VideoEnabled

Called when the publisher's video stream resumes (after video was disabled).

Check the reason property of the event arguments for the reason why the video was enabled.

VideoQualityChanged

EventHandler<VideoQualityChangedEventArgs> OpenTok.Publisher.VideoQualityChanged

Occurs when there is a change in the quality state of the publisher's video stream.

This event provides updated video statistics and a reason code indicating why the quality change occurred.

The VideoReason value specifies the cause of the event and follows this priority order: bandwidth degradation, CPU degradation, other quality degradation reasons, codec changes, and resolution or layer changes.

This event differs from the VideoDisabled and VideoEnabled events in that it reports quality-related changes rather than simple on/off state changes. The VideoDisabled and VideoEnabled events indicate when the publisher’s video track is turned off or on (for example, due to audio fallback or stream property updates). In contrast, VideoQualityChanged provides diagnostic insights into quality degradation causes—such as CPU or bandwidth limitations—and may be raised even when the video remains enabled.

Applications can use this event to monitor video quality and respond accordingly, such as updating UI indicators or notifying users of performance issues.