Search code examples
androidchromecastgoogle-cast

Chromecast EIA-608 Closed Captions with HLS


I'm using the CastCompanionLibrary for chromecast sender support in my android application. The receiver application is the default Styled Media Receiver.

My streams are HLS and contain an EIA-608 closed captions track. From the documentation it seems the styled media receiver and CastCompanionLibrary both support EIA-608 closed captions, but I can't seem to get it working.

I am enabling VideoCastManager.FEATURE_CAPTIONS_PREFERENCE when initialising the CastCompanionLibrary, and building the tracks as follows:

    MediaTrack videoTrack = new MediaTrack.Builder(0, MediaTrack.TYPE_VIDEO)
            .setContentType(PlayerActivity.HLS_MIME_TYPE)
            .setContentId(playlistUrl)
            .build();

    MediaTrack captionsTrack = new MediaTrack.Builder(1, MediaTrack.TYPE_TEXT)
            .setContentType(MediaFormat.MIMETYPE_TEXT_CEA_608)
            .setSubtype(MediaTrack.SUBTYPE_CAPTIONS)
            .setLanguage(Locale.getDefault())
            .setContentId("eia608/1")
            .setName("Closed Captions")
            .build();

My guess is that I'm specifying an incorrect contentId, but there doesn't appear to be anything in the docs about contentId for in-band tracks (maybe it's not required)?

I'd appreciate if someone who's gotten this working could chime in ;)


Solution

  • CEA-608 is supported for HLS (transport stream) by our Media Player Library (MPL) but in order to use that, you need to write a custom receiver and call enableCaptions(true) on the player (on the receiver side). I suggest you copy our reference receiver and then make the changes there; that reference receiver is very close to the Styled Receiver. Once you could get the captions working, then you can add a custom message (supported in CCL) to control that from the sender.