Suggestions

close search

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal

OpenTok.Publisher

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  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  VideoNetworkStats
 Defines a video statistics object for the Stats property of a VideoNetworkStatsEventArgs object. More...
class  VideoNetworkStatsEventArgs
 Defines arguments for VideoStatsUpdated events. More...

Public Types

enum  VideoReason : int { VideoReason.PublishVideo = 1, VideoReason.Quality = 3 }
 Defines values for the VideoEventArgs.Reason and VideoEventArgs.Reason properties. More...

Public Member Functions

 Publisher (Context context, IVideoCapturer capturer=null, string name=null, IVideoRenderer renderer=null, bool hasAudioTrack=true, bool hasVideoTrack=true, bool stereo=false, bool opusDtx=false, bool subscriberAudioFallback=true, bool publisherAudioFallback=false)
 Creates a new Publisher instance. More...
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

virtual void Dispose (bool disposing)

Properties

List< VideoTransformerVideoTransformers [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. More...
List< AudioTransformerAudioTransformers [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. More...
IVideoRenderer VideoRenderer [get]
 The video renderer for the publisher. More...
IVideoCapturer VideoCapturer [get]
 The video capturer for the publisher. More...
StreamStream [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. More...
bool PublishCaptions [get, set]
 Whether the publisher is publishing captions. More...
bool PublishAudio [get, set]
 Whether the publisher is publishing audio. More...
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. More...

Events

EventHandler MuteForced
 Defines arguments for the MuteForced event. More...
EventHandler< StreamEventArgsStreamCreated
 Sent when the publisher's stream is created. More...
EventHandler< StreamEventArgsStreamDestroyed
 Sent when the publisher's stream is destroyed. More...
EventHandler< ErrorEventArgsError
 Sent when the publisher fails. More...
EventHandler< AudioNetworkStatsEventArgsAudioStatsUpdated
 Invoked when the publisher has audio stats to share. More...
EventHandler< VideoNetworkStatsEventArgsVideoStatsUpdated
 Invoked when the publisher has video stats to share. More...
EventHandler< AudioLevelArgsAudioLevel
 Sent periodically to report the audio level of the publisher. More...
EventHandler< RtcStatsReportArgsRtcStatsReport
 Sent in response to a call to GetRtcStatsReport(). More...
EventHandler< VideoEventArgsVideoDisabled
 Called when the publisher stops sending video. More...
EventHandler< VideoEventArgsVideoEnabled
 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
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.

Constructor & Destructor Documentation

◆ Publisher()

OpenTok.Publisher.Publisher ( Context  context,
IVideoCapturer  capturer = null,
string  name = null,
IVideoRenderer  renderer = null,
bool  hasAudioTrack = true,
bool  hasVideoTrack = true,
bool  stereo = false,
bool  opusDtx = false,
bool  subscriberAudioFallback = true,
bool  publisherAudioFallback = false 
)

Creates a new Publisher instance.

Use the Session.Publish(Publisher) method to start streaming from this publisher into a session.

Parameters
contextThe Context to use for this Publisher object.
capturerThe video capturer to use for this publisher. If you do not specify a capturer, the Publisher uses the default video capturer, defined by the VideoCapturer class. This video capturer uses the first video device in the list of devices available on the system.
nameThe 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).
rendererThe video renderer to use for this publisher. If you do not specify a renderer, the video isn't rendered locally.
hasAudioTrackWhether to include an audio track in the published stream.
hasVideoTrackWhether to include an video track in the published stream.
stereoWhether to enable stereo audio in the published stream.
opusDtxWhether to enable Opus DTX in the published stream.
subscriberAudioFallbackWhether to enable subscriber audio fallback.
publisherAudioFallbackWhether to enable publisher audio fallback.

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

◆ AudioTransformers

List<AudioTransformer> OpenTok.Publisher.AudioTransformers

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.

◆ PublishAudio

bool OpenTok.Publisher.PublishAudio

Whether the publisher is publishing audio.

◆ PublishCaptions

bool OpenTok.Publisher.PublishCaptions

Whether the publisher is publishing captions.

◆ PublishVideo

bool OpenTok.Publisher.PublishVideo

◆ Stream

Stream? OpenTok.Publisher.Stream

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.

◆ VideoCapturer

IVideoCapturer OpenTok.Publisher.VideoCapturer

The video capturer for the publisher.

◆ VideoRenderer

IVideoRenderer OpenTok.Publisher.VideoRenderer

The video renderer for the publisher.

◆ VideoSourceType

VideoSourceType OpenTok.Publisher.VideoSourceType

The type of the stream (either camera or screen sharing), as defined by the OpenTok.VideoSourceType enum.

◆ VideoTransformers

List<VideoTransformer> OpenTok.Publisher.VideoTransformers

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.

Event Documentation

◆ AudioLevel

EventHandler<AudioLevelArgs> OpenTok.Publisher.AudioLevel

Sent periodically to report the audio level of the publisher.

◆ AudioStatsUpdated

EventHandler<AudioNetworkStatsEventArgs> OpenTok.Publisher.AudioStatsUpdated

Invoked when the publisher has audio stats to share.

◆ Error

EventHandler<ErrorEventArgs> OpenTok.Publisher.Error

Sent when the publisher fails.

◆ MuteForced

EventHandler OpenTok.Publisher.MuteForced

Defines arguments for the MuteForced event.

◆ RtcStatsReport

EventHandler<RtcStatsReportArgs> OpenTok.Publisher.RtcStatsReport

Sent in response to a call to GetRtcStatsReport().

◆ StreamCreated

EventHandler<StreamEventArgs> OpenTok.Publisher.StreamCreated

Sent when the publisher's stream is created.

◆ StreamDestroyed

EventHandler<StreamEventArgs> OpenTok.Publisher.StreamDestroyed

Sent when the publisher's stream is destroyed.

◆ 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.

◆ VideoStatsUpdated

EventHandler<VideoNetworkStatsEventArgs> OpenTok.Publisher.VideoStatsUpdated

Invoked when the publisher has video stats to share.