cyndilib.sender

Sender

class cyndilib.sender.Sender

Bases: object

Sends video and audio streams

ndi_name

The NDI® source name to use

Type:

str

source

A source object representing the sender

Type:

Source

video_frame
Type:

VideoSendFrame

audio_frame
Type:

AudioSendFrame

metadata_frame
Type:

MetadataSendFrame

clock_video

True if the video frames should clock themselves. If False, no rate limiting will be applied to keep within the desired frame rate

Type:

bool

clock_audio

True if the audio frames should clock themselves. If False, no rate limiting will be applied to keep within the desired frame rate

Type:

bool

close(self)

Close the sender and free all resources

get_num_connections(self, timeout: float)

Get the current number of receivers connected to this source

This can be used to avoid even rendering when nothing is connected.

If you specify a timeout that is not 0, this method will block for the given amount of time (in seconds) until there are connections (or the timeout was reached).

name

The current name of the source

This may be different than what was supplied during initialization

open(self)

Open the sender

preview_tally

The current preview tally state of the sender

program_tally

The current program tally state of the sender

send_audio(self)

Send audio data (if available) that was previously written to the audio_frame using its write_data() method.

Note

This method is available for flexibility, but using the write_audio() or write_audio_async() methods may be more desirable as the audio data will be buffered and sent with a single method call.

send_metadata(self, tag: str, attrs: dict)
send_metadata_frame(self, mf: MetadataSendFrame)
send_video(self)

Send a frame of video data (if available) that was previously written to the video_frame using its write_data() method.

Note

This method is available for flexibility, but using the write_video() or write_video_async() methods may be more desirable as the video data will be buffered and sent with a single method call.

send_video_async(self)

Send a frame of video data as described in send_video() asynchronously

This call will return immediately and the required operations on the data will be handled separately by the NDI® library.

Note

This method is available for flexibility, but using the write_video() or write_video_async() methods may be more desirable as the video data will be buffered and sent with a single method call.

Note

This is not an async def function. In this context, “async” only describes how the NDI® library handles processing and syncronization.

set_audio_frame(self, af: AudioSendFrame)

Set the audio_frame

set_video_frame(self, vf: VideoSendFrame)

Set the video_frame

update_tally(self, timeout: float)

Request an update on the current tally state

The tally state will then be reflected on the program_tally and preview_tally attributes of the source.

If timeout is non-zero, this method will block for the given amount of time (in seconds) until a change in tally state (or the timeout was reached).

write_audio(self, data: float32_t[:, _:])

Write the given audio data and send it

Parameters:

data – A 2-d array or memoryview of 32-bit floats with shape (num_channels, num_samples)

write_video(self, data: uint8_t[:])

Write the given video data and send it

Parameters:

data – A 1-d array or memoryview of unsigned 8-bit integers formatted as described in wrapper.ndi_structs.FourCC

write_video_and_audio(self, video_data: uint8_t[:], audio_data: float32_t[:, _:])

Write and send the given video and audio data

The video data will be sent asynchronously (as described in write_video_async()).

Parameters:
  • video_data – A 1-d array or memoryview of unsigned 8-bit integers formatted as described in wrapper.ndi_structs.FourCC

  • audio_data – A 2-d array or memoryview of 32-bit floats with shape (num_channels, num_samples)

write_video_async(self, data: uint8_t[:])

Write the given video data and send it asynchronously

This call will return immediately and the required operations on the data will be handled separately by the NDI® library.

Note

This is not an async def function. In this context, “async” only describes how the NDI® library handles processing and syncronization.

Parameters:

data – A 1-d array or memoryview of unsigned 8-bit integers formatted as described in wrapper.ndi_structs.FourCC