neuray API Programmer's Manual

mi::bridge::IServer_video_context Class Reference

[Bridge server]

Description

Server-side video context that generates and encodes video frames for the corresponding client-side video context. An application using the video transmission facilities of the Bridge API must implement the abstract interface mi::bridge::IVideo_source and set it by calling set_video_source() to generate video frames.

Note that even though the focus is on video, it is equally valid to transmit any kind of data suitable for streaming, and the application can deliver pure data buffers in addition to, or instead of, video frames.

See also:

mi::bridge::IServer_session::get_video_context(), mi::bridge::IClient_video_context

Public Member Functions

virtual void close() =0
Closes the video stream associated with this context and frees all resources. More...
virtual void frame_ready() =0
Notifies the Bridge that the application produced the next video frame. More...
virtual Uint32 get_bit_rate() const =0
Returns the currently used bit rate. More...
virtual Uint32 get_id() const =0
Returns the ID of the video context.
virtual Uint32 get_max_bitrate() const =0
Returns the currently set maximum bitrate. More...
virtual Uint32 get_max_frame_rate() const =0
Returns the maximum frame rate. More...
virtual Uint32 get_min_bitrate() const =0
Returns the currently set minimum bitrate. More...
virtual const IStringget_video_format() const =0
Returns the current video format for encoding. More...
virtual IVideo_sourceget_video_source() const =0
Returns the currently set video source, or NULL if none is set.
virtual void report_error( Sint32 error_code, const char* error_message) =0
Communicates an error message to the client side. More...
virtual void report_progress( Float64 value, const char* area, const char* message) =0
Communicates a progress message to the client side. More...
virtual void reset() =0
Resets the video stream and any stateful video encoders like h264.
virtual Sint32 set_bit_rate( Uint32 bit_rate) =0
Sets the bit rate. More...
virtual Sint32 set_max_bitrate( Uint32 bit_rate) =0
Sets the maximum bitrate used by the video stream. More...
virtual Sint32 set_max_frame_rate( Uint32 frame_rate) =0
Sets the maximum frame rate. More...
virtual Sint32 set_min_bitrate( Uint32 bit_rate) =0
Sets the minimum bitrate used by the video stream. More...
virtual Sint32 set_render_frame_rate( Float64 frame_rate) =0
Sets the current frame rate. More...
virtual Sint32 set_video_format( const char* format) =0
Sets the video format for encoding. More...
virtual void set_video_source( IVideo_source* video_source) =0
Sets the video source that will produce video frames generated by the server. More...

Member Functions

virtual void mi::​bridge::​IServer_video_context::close() [pure virtual]

Closes the video stream associated with this context and frees all resources. This will also close the associated video context on the client.

set_video_source(), mi::bridge::IClient_video_context

virtual void mi::​bridge::​IServer_video_context::frame_ready() [pure virtual]

Notifies the Bridge that the application produced the next video frame. When the process is ready to process the next frame it calls as response the callback mi::bridge::IVideo_source::video_get_next_frame() of the video source associated with this video context (see also set_video_source()).

This method can be called any number of times between callbacks, but multiple calls after the last video_get_next_frame() callback will only result in a single callback of video_get_next_frame().

virtual Uint32 mi::​bridge::​IServer_video_context::get_bit_rate() const [pure virtual]

Returns the currently used bit rate.

See also:

set_bit_rate()

virtual Uint32 mi::​bridge::​IServer_video_context::get_id() const [pure virtual]

Returns the ID of the video context.

virtual Uint32 mi::​bridge::​IServer_video_context::get_max_bitrate() const [pure virtual]

Returns the currently set maximum bitrate.

See also:

set_max_bitrate()

virtual Uint32 mi::​bridge::​IServer_video_context::get_max_frame_rate() const [pure virtual]

Returns the maximum frame rate.

See also:

set_max_frame_rate()

virtual Uint32 mi::​bridge::​IServer_video_context::get_min_bitrate() const [pure virtual]

Returns the currently set minimum bitrate.

See also:

set_min_bitrate()

virtual const IString* mi::​bridge::​IServer_video_context::get_video_format() const [pure virtual]

Returns the current video format for encoding.

See also:

set_video_format()

virtual IVideo_source* mi::​bridge::​IServer_video_context::get_video_source() const [pure virtual]

Returns the currently set video source, or NULL if none is set.

virtual void mi::​bridge::​IServer_video_context::report_error( Sint32 error_code, const char* error_message) [pure virtual]

Communicates an error message to the client side. The Bridge video protocol invokes IVideo_sink::video_error() on the video sink associated with the corresponding video context on the client side and passes the arguments provided here.

Parameters

error_code
Error code specified by the application.
error_message
A short description of the error.
virtual void mi::​bridge::​IServer_video_context::report_progress( Float64 value, const char* area, const char* message) [pure virtual]

Communicates a progress message to the client side. The Bridge video protocol invokes IVideo_sink::video_progress() on the video sink associated with the corresponding video context on the client side and passes the arguments provided here.

Parameters

value
The progress value.
area
The progress area.
message
The progress message.
virtual void mi::​bridge::​IServer_video_context::reset() [pure virtual]

Resets the video stream and any stateful video encoders like h264.

virtual Sint32 mi::​bridge::​IServer_video_context::set_bit_rate( Uint32 bit_rate) [pure virtual]

Sets the bit rate. This method is deprecated and is equivalent to calling set_max_bitrate() and set_min_bitrate() with the same value.

The "h264" format will use the frame rate and the current bit rate when calculating the budget for each frame. The quality of the "lossless" format and image formats is not affected by this setting.

Note:

It is recommended to change settings like video format, frame rate, and bit rate only from the mi::bridge::IVideo_source::video_get_next_frame() callback (or before the first call to frame_ready()). Otherwise, it is not guaranteed that multiple changes will be applied atomically to the next frame (because encoding of the next frame might start at any time).

See also:

get_bit_rate(), set_video_format(), set_max_frame_rate()

Parameters

bit_rate
The bit rate to use

Returns

0 in case of success, < 0 in case of failure.

virtual Sint32 mi::​bridge::​IServer_video_context::set_max_bitrate( Uint32 bit_rate) [pure virtual]

Sets the maximum bitrate used by the video stream. To adapt to the available bandwidth, the bridge video will automatically adjust the bitrate. However, the bitrate will not be set below the minimum bitrate. If the available bandwidth is smaller then frame rate will go down to compensate. Likewise, the bitrate won't go above the set maximum bitrate. Set min and max bitrate to the same value to override the automatic adjustment. The max bitrate setting takes precedence if max bitrate is set lower than min bitrate.

The "h264" format will use the frame rate and the current bit rate when calculating the budget for each frame. The quality of the "lossless" format and image formats is not affected by this setting.

Note:

It is recommended to change settings like video format, frame rate, and bit rate only from the mi::bridge::IVideo_source::video_get_next_frame() callback (or before the first call to frame_ready()). Otherwise, it is not guaranteed that multiple changes will be applied atomically to the next frame (because encoding of the next frame might start at any time).

See also:

get_max_bitrate(), set_min_bitrate(), get_bit_rate(), set_video_format(), set_max_frame_rate()

Parameters

bit_rate
The bit rate to use

Returns

0 in case of success, < 0 in case of failure.

virtual Sint32 mi::​bridge::​IServer_video_context::set_max_frame_rate( Uint32 frame_rate) [pure virtual]

Sets the maximum frame rate. This setting limits the rate at with which frames are sent from the server to this rate, but the frame rate is allowed to drop below this if frames are not produced or encoded quickly enough.

The "h264" format will use the frame rate and the current bit rate when calculating the budget for each frame. The quality of the "lossless" format and image formats is not affected by this setting.

Note:

It is recommended to change settings like video format, frame rate, and bit rate only from the mi::bridge::IVideo_source::video_get_next_frame() callback (or before the first call to frame_ready()). Otherwise, it is not guaranteed that multiple changes will be applied atomically to the next frame (because encoding of the next frame might start at any time).

See also:

get_max_frame_rate(), set_video_format(), set_bit_rate()

Parameters

frame_rate
The maximum frame rate to use.

Returns

0 in case of success, < 0 in case of failure.

virtual Sint32 mi::​bridge::​IServer_video_context::set_min_bitrate( Uint32 bit_rate) [pure virtual]

Sets the minimum bitrate used by the video stream. To adapt to the available bandwidth, the bridge video will automatically adjust the bitrate. is smaller then frame rate will go down to compensate. Likewise, the bitrate won't go above the set maximum bitrate. Set min and max bitrate to the same value to override the automatic adjustment. The max bitrate setting takes precedence if max bitrate is set lower than min bitrate.

The "h264" format will use the frame rate and the current bit rate when calculating the budget for each frame. The quality of the "lossless" format and image formats is not affected by this setting.

Note:

It is recommended to change settings like video format, frame rate, and bit rate only from the mi::bridge::IVideo_source::video_get_next_frame() callback (or before the first call to frame_ready()). Otherwise, it is not guaranteed that multiple changes will be applied atomically to the next frame (because encoding of the next frame might start at any time).

See also:

get_max_bitrate(), set_min_bitrate(), get_bit_rate(), set_video_format(), set_max_frame_rate()

Parameters

bit_rate
The bit rate to use

Returns

0 in case of success, < 0 in case of failure.

virtual Sint32 mi::​bridge::​IServer_video_context::set_render_frame_rate( Float64 frame_rate) [pure virtual]

Sets the current frame rate. This is an optional hint that can be set to inform the video context about the actual current frame rate. It is recommended to call this every time the actual frame rate changes substantially, or simply call in each mi::bridge::IVideo_source::video_get_next_frame() callback with the current value.

Note:

It is recommended to change settings like video format, frame rate, and bit rate only from the mi::bridge::IVideo_source::video_get_next_frame() callback (or before the first call to frame_ready()). Otherwise, it is not guaranteed that multiple changes will be applied atomically to the next frame (because encoding of the next frame might start at any time).

See also:

get_max_frame_rate(), set_video_format(), set_bit_rate()

Parameters

frame_rate
The maximum frame rate to use.

Returns

0 in case of success, < 0 in case of failure.

virtual Sint32 mi::​bridge::​IServer_video_context::set_video_format( const char* format) [pure virtual]

Sets the video format for encoding.

Note:

It is recommended to change settings like video format, frame rate, and bit rate only from the mi::bridge::IVideo_source::video_get_next_frame() callback (or before the first call to frame_ready()). Otherwise, it is not guaranteed that multiple changes will be applied atomically to the next frame (because encoding of the next frame might start at any time).

See also:

get_video_format(), set_max_frame_rate(), set_bit_rate()

Parameters

format
The video format to use when encoding canvases. Supported formats:
  • "h264": h264 encoding, requires an h264 encoder plugin.
  • "lossless": lossless encoding, supports all pixel formats, built-in.
  • any valid image format: any supported image format, requires the corresponding image plugin.

Returns

  • 0: Success.
  • -1: Unsupported format.
  • <= -2: Unspecified error.

virtual void mi::​bridge::​IServer_video_context::set_video_source( IVideo_source* video_source) [pure virtual]

Sets the video source that will produce video frames generated by the server.

Parameters

video_source
The video source to set. Replaces any previously set video source (if any). Pass NULL to disconnect the currently set video source.