Screencast Service

The Screencast Service enables you to record the screen of an Android device and broadcasts the encoded video frames to Kanzi Connect applications. This way the Screencast Service enables you to view remotely the contents of an Android device screen. For example, you can use the Screencast Service to show the contents of an Android device screen in a Kanzi Connect application running on a QNX device. You can find the Screencast Service in <KanziConnectInstallation>/SDK/examples/services/java.

../_images/screencast-service.png

The Screencast Service uses the Android Media Projection API to record the screen and encodes the produced video frames from Android-provided encoder. The service sends the encoded frames to subscribed Kanzi Connect applications using the Kanzi Connect communication channels. Kanzi Connect provides a software H.264 decoder on the client side to decode the frames that it shows.

When the Screencast Service starts, it asks the user for required permissions. When the first Kanzi Connect client connects to the Screencast Service, the service asks before it starts recording the screen.

After Screencast Service connects to a Kanzi Connect Server, it uses the Configuration Service from that server to receive its configuration values. These configuration values can include information, such as the output resolution and encoder parameters. You can set the configuration values that you want to pass to the Screencast Service in the Kanzi Connect Server connect_server_config.xml file that the Configuration Service publishes.

...
<published_configurations>
   <screencast>
      ...
   </screencast>
</published_configurations>
...

Internally the Screencast Service uses the Stream Service to send the frames to Kanzi Connect clients. Kanzi Connect comes with a Kanzi Studio Viewport plugins which contain the necessary decoder to receive the H.264 video stream from the Screencast Service.

You can access the available Screencast Service configurations from the Screencast Service and Stream Service runtime data at

Service configuration

Parameter

Type

Description

auxiliary_data

String

Kanzi Connect forwards this generic string to the Stream Service runtime data. Use this parameter to pass additional information to the decoder clients through the Stream Service runtime data.

bitrate_mode

String

Sets the bitrate mode for the service:

  • To set variable bitrate, use BITRATE_MODE_VBR.

  • To set constant quality bitrate, use BITRATE_MODE_CQ.

  • To set constant bitrate, use BITRATE_MODE_CBR.

If the encoder does not support the specified mode then default are used.

capture_framerate

Integer

Sets the number of frames that the Screencast Service encodes each second. If the screen content is static, the framerate can be low.

capture_height

Integer

Sets the height in pixels to record the video. To use the device native screen height, set to 0.

capture_width

Integer

Sets the width in pixels to record the video. To use the device native screen width, set to 0.

intra_refresh_period

Integer

Sets the refresh rate of the entire frame content in a stream. Not all encoders support this setting.

keyframe_interval_s

Integer

Sets the interval in seconds to send a key frame in a stream.

mime_type

String

Defines the type of video stream to create. Use this parameter to set the encoder that produces the stream. For example, for the H.264 example in Kanzi Connect uses video/avc.

output_width

Integer

Sets the width in pixels of the video stream. When you use a value that is lower than that set in the capture_width parameter, the service crops the video from the top-left corner. To avoid cropping and match the capture width, set to 0.

output_height

Integer

Sets the height in pixels of the video stream. When you use a value that is lower than that set in the capture_height parameter, the service crops the video from the top-left corner. To avoid cropping and match the capture height, set to 0.

priority

Integer

Sets the priority

  • To set priority to real time, use 0.

  • To set priority to best effort, use 1.

This parameter provides a hint for codec configuration and does not guarantee performance.

quality

Integer

Calculates the bitrate for the video stream. Higher values produce better quality and higher bitrate.

screen_density

Integer

Pixel density, use 0 for native density.

stream_identifier

String

Identifies the name of the stream that the Screencast Service creates. The Screencast Service passes this parameter to the internal Stream Service. When a client wants to subscribe to a stream and play that stream, that client must use the same stream identifier.

Interface definition

The interface definition XML file for the Screencast Service is <KanziConnectInstallation>/SDK/interfaces/definitions/screencast_interface.xml.

Fully qualified name for the Screencast Service is Connect.Service.Screencast.

Supported platforms

This service is supported on Android 8.0 (minimum API level 26) and newer.