TrackSelector
The policy that picks which video and audio stream to play when the caller did not name one.
MediaSource.primaryVideo and MediaSource.primaryAudio apply Default. A player with its own preferences builds a selector and calls selectVideo or selectAudio with MediaSource.streams.
The rules, in order:
Video: the first stream that is not cover art (Disposition.attachedPicture). A file whose only video is its cover art gets that picture, because a picture beats nothing.
Audio: a stream for a special audience never beats an ordinary sibling. Special means audio description (Disposition.descriptions or Disposition.visualImpaired), commentary (Disposition.comment) or a hearing-impaired mix (Disposition.hearingImpaired). Among the streams left, the best-ranked preferredAudioLanguages match wins, then among the streams of that language the closest one, then the stream the container marks Disposition.default, then container order.
Audio beside a picture: in a source with programmes, such as a transport stream carrying several channels, the audio rules choose only among the sound of the picture's own programme, so the picture fixes the channel and a language preference never moves the sound to another one. Pass the picture and MediaSource.programs to the selectAudio that takes them.
Properties
Audio languages, best first, as BCP 47 tags or ISO 639 codes. A preference matches a stream whose language names the same language, however either spells it: en, eng and en-GB are all English, and de, deu and ger all German. Among the streams that match one preference, one whose script and then region agree with it comes first, then one that names none, then one that names another: pt-BR takes a pt-BR stream over a plain por one and that over pt-PT, which it still takes over nothing. A region implies the script of Chinese, so zh-TW is zh-Hant. A related language is not the language (enm, Middle English, is not en), and a code that names none (und, mul, mis, zxx, qaa to qtz) matches nothing. A tag not led by a language code, such as x-klingon, matches its own spelling without regard to case. Empty lets the other rules decide.
Functions
The audio stream to play from streams, or null when there is none. It knows nothing of programmes, so for a source that has them use the selectAudio that takes the picture and the programmes.
The audio stream to play beside video, or null when there is none (#165).
The video stream to play from streams, or null when there is none.