Tuner framework

For Android 11 or higher, you can use the Android Tuner framework to deliver A/V content. The framework uses the hardware pipeline from vendors, making it suitable for both low-end and high-end SoC. The framework provides a secure way to deliver A/V content protected by a trusted execution environment (TEE) and secure media path (SMP), allowing it to be used in a highly restricted, content protection environment.

The standardized interface between Tuner and Android CAS results in a faster integration between Tuner vendors and CAS vendors. The Tuner interface works with MediaCodec and AudioTrack to build a one world solution for Android TV. The Tuner interface supports both digital TV and analog TV based on major broadcast standards.

Components

For Android 11, three components are specifically designed for the TV platform.

  • Tuner HAL: An interface between the framework and vendors
  • Tuner SDK API: An interface between the framework and apps
  • Tuner Resource Manager (TRM): Coordinates Tuner HW resources

For Android 11, the following components have been enhanced.

  • CAS V2
  • TvInputService or TV Input Service (TIS)
  • TvInputManagerService or TV Input Manager Service (TIMS)
  • MediaCodec or media codec
  • AudioTrack or audio track
  • MediaResourceManager or media resource manager (MRM)

Flow diagram of Tuner framework components.

Figure 1. Interactions between Android TV components

Features

Frontend supports the DTV standards below.

  • ATSC
  • ATSC3
  • DVB C/S/T
  • ISDB S/S3/T
  • Analog

The frontend in Android 12 with Tuner HAL 1.1 or higher supports the DTV standard below.

  • DTMB

Demux supports the stream protocols below.

  • Transport stream (TS)
  • MPEG media transport protocol (MMTP)
  • Internet protocol (IP)
  • Type length value (TLV)
  • ATSC link-layer protocol (ALP)

Descrambler supports the content protections below.

  • Secure media path
  • Clear media path
  • Secure local record
  • Secure local playback

Tuner APIs support the use cases below.

  • Scan
  • Live
  • Playback
  • Record

Tuner, MediaCodec, and AudioTrack support the data flow modes below.

  • ES payload with clear memory buffer
  • ES payload with secure memory handle
  • Passthrough

Overall design

The Tuner HAL is defined between the Android framework and the vendor's hardware.

  • Describes what the framework expects from the vendor and how the vendor might do it.
  • Exports the functionalities of frontend, demux and descrambler to the framework through IFrontend, IDemux, IDescrambler, IFilter, IDvr, and ILnb interfaces.
  • Includes the functions to integrate the Tuner HAL with other framework components, such as MediaCodec and AudioTrack.

A Tuner Java class and native class are created.

  • The Tuner Java API allows apps to access the Tuner HAL through public APIs.
  • Native class allows permission control and handling of large amounts of recording or playback data with the Tuner HAL.
  • Native Tuner module is a bridge between the Tuner Java class and the Tuner HAL.

A TRM class is created.

  • Manages limited Tuner resources, such as Frontend, LNB, CAS sessions, and a TV input device from the TV input HAL.
  • Applies rules to reclaim insufficient resources from apps. The default rule is the foreground win.

Media CAS and the CAS HAL are enhanced with the features below.

  • Opens CAS sessions for different usages and algorithms.
  • Supports dynamic CAS systems, such as CICAM removal and insertion.
  • Integrates with the Tuner HAL by providing key tokens.

MediaCodec and AudioTrack are enhanced with the features below.

  • Takes secure A/V memory as content input.
  • Configured to do hardware A/V sync in tunneled playback.
  • Configured support for ES_payload and passthrough mode.

Overall design of the Tuner HAL.

Figure 2. Diagram of the components within the Tuner HAL

Overall workflow

The diagrams below illustrate call sequences for live broadcast playback.

Setup

Setup sequence of live broadcast playback diagram.

Figure 3. Setup sequence for live broadcast playback

Handling A/V

Handling A/V for live broadcast playback diagram.

Figure 4. Handling A/V for live broadcast playback

Handling scrambled content

Handling scrambled content for live broadcast playback diagram.

Figure 5. Handling scrambled content for live broadcast playback

Processing A/V data

Process A/V data for live broadcast playback diagram.

Figure 6. Processing A/V for live broadcast playback

Tuner SDK API

The Tuner SDK API handles the interactions with the Tuner JNI, the Tuner HAL, and TunerResourceManager. The TIS app uses the Tuner SDK API to access Tuner resources and subcomponents such as the filter and descrambler. Frontend and demux are internal components.

Flow diagram of the Tuner SDK API.

Figure 7. Interactions with the Tuner SDK API

Versions

From Android 12, the Tuner SDK API supports new feature in Tuner HAL 1.1, which is a backward-compatible version upgrade of Tuner 1.0.

Use the following API to check the running HAL version.

  • android.media.tv.tuner.TunerVersionChecker.getTunerVersion()

The minimum required HAL version can be found in the documentation of the new Android 12 APIs.

Packages