Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions types/chromecast-caf-receiver/cast.framework.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,12 @@ export class PlayerManager {
/**
* Sends a media status message to all senders (broadcast). Applications use this to send a custom state change.
*/
broadcastStatus(includeMedia?: boolean, requestId?: number, customData?: any, includeQueueItems?: boolean): void;
broadcastStatus(
includeMedia?: boolean,
requestId?: number,
customData?: messages.MediaStatusCustomData | null,
includeQueueItems?: boolean,
): void;

/**
* Convert media time to absolute time.
Expand Down Expand Up @@ -736,7 +741,7 @@ export class PlayerManager {
requestId: number,
type: messages.ErrorType,
reason?: messages.ErrorReason,
customData?: any,
customData?: unknown,
): void;

/**
Expand All @@ -751,7 +756,7 @@ export class PlayerManager {
senderId: string,
requestId: number,
includeMedia?: boolean,
customData?: any,
customData?: messages.MediaStatusCustomData | null,
includeQueueItems?: boolean,
): void;

Expand Down
92 changes: 85 additions & 7 deletions types/chromecast-caf-receiver/cast.framework.messages.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,18 @@ export class AudioTrackInfo {
*/
spatialAudio?: boolean | undefined;
}

/**
* Custom data set by the receiver application.
*
* @remarks
*
* Augment this interface in custom receivers.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface TrackCustomData {
}

/**
* Describes track metadata information.
* @see https://developers.google.com/cast/docs/reference/caf_receiver/cast.framework.messages.Track
Expand All @@ -625,7 +637,7 @@ export class Track {
/**
* Custom data set by the receiver application.
*/
customData?: any;
customData?: TrackCustomData;

/**
* Indicate track is in-band and not side-loaded track. Relevant only for text tracks.
Expand Down Expand Up @@ -683,6 +695,17 @@ export class Track {
roles?: string[] | undefined;
}

/**
* Custom data set by the receiver application.
*
* @remarks
*
* Augment this interface in custom receivers.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface TextTrackStyleCustomData {
}

/**
* Describes style information for a text track.
* @see https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.TextTrackStyle
Expand All @@ -696,7 +719,7 @@ export class TextTrackStyle {
/**
* Custom data set by the receiver application.
*/
customData?: any;
customData?: TextTrackStyleCustomData;

/**
* RGBA color for the edge; this value will be ignored if edgeType is NONE.
Expand Down Expand Up @@ -818,6 +841,17 @@ export class SetCredentialsRequestData extends RequestData {
source?: string | undefined;
}

/**
* Customizable object for storing session state.
*
* @remarks
*
* Augment this interface in custom receivers.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface SessionStateCustomData {
}

/**
* A state object containing all data to be stored in StoreSession and to be
* recovered in ResumeSession.
Expand All @@ -829,7 +863,7 @@ export class SessionState {
/**
* Customizable object for storing the state.
*/
customData?: any;
customData?: SessionStateCustomData;

loadRequestData?: LoadRequestData | undefined;
}
Expand Down Expand Up @@ -1103,6 +1137,17 @@ export class QueueLoadRequestData extends RequestData {
startIndex?: number | undefined;
}

/**
* The application can define any extra queue item information needed.
*
* @remarks
*
* Augment this interface in custom receivers.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface QueueItemCustomData {
}

/**
* Queue item information. Application developers may need to create a QueueItem to
* insert a queue element using InsertQueueItems. In this case they should not
Expand All @@ -1128,7 +1173,7 @@ export class QueueItem {
/**
* The application can define any extra queue item information needed.
*/
customData?: any;
customData?: QueueItemCustomData;

/**
* Unique identifier of the item in the queue.
Expand Down Expand Up @@ -1637,6 +1682,17 @@ export class MovieMediaMetadata {
title?: string | undefined;
}

/**
* Applicaiton-specific media status.
*
* @remarks
*
* Augment this interface in custom receivers.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface MediaStatusCustomData {
}

/**
* Represents the status of a media session.
* [Documentation]{@link https://developers.google.com/cast/docs/reference/caf_receiver/cast.framework.messages.MediaStatus}
Expand Down Expand Up @@ -1668,7 +1724,7 @@ export class MediaStatus {
/**
* Application-specific media status.
*/
customData?: any;
customData?: MediaStatusCustomData;

/**
* Extended media status information.
Expand Down Expand Up @@ -1804,6 +1860,17 @@ export class MediaMetadata {
sectionStartTimeInMedia?: number | undefined;
}

/**
* Application-specific media information.
*
* @remarks
*
* Augment this interface in custom receivers.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface MediaInformationCustomData {
}

/**
* Represents the media information.
* @see https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.MediaInformation
Expand Down Expand Up @@ -1841,7 +1908,7 @@ export class MediaInformation {
/**
* Application-specific media information.
*/
customData?: any;
customData?: MediaInformationCustomData;

/**
* The media duration.
Expand Down Expand Up @@ -2383,6 +2450,17 @@ export class BreakStatus {
whenSkippable?: number | undefined;
}

/**
* Application-specific break clip data.
*
* @remarks
*
* Augment this interface in custom receivers.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface BreakClipCustomData {
}

/**
* Represents break clip (e.g. a clip of ad during ad break)
* @see https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.BreakClip
Expand Down Expand Up @@ -2411,7 +2489,7 @@ export class BreakClip {
/**
* Application-specific break clip data.
*/
customData?: any;
customData?: BreakClipCustomData;
/**
* Duration of break clip in sec.
*/
Expand Down
44 changes: 44 additions & 0 deletions types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,47 @@ tracksInfo.activeTrackIds = [1, 2];
tracksInfo.language = "en";
tracksInfo.textTrackStyle = new cast.framework.messages.TextTrackStyle();
tracksInfo.tracks = [new cast.framework.messages.Track(1, cast.framework.messages.TrackType.AUDIO)];

// You can extend the types of some customData fields via declaration merging, so that
// custom data passed between your custom receiver and CAF remains statically typed.

declare module "./cast.framework.messages" {
interface TrackCustomData {
dialect?: string;
}

interface TextTrackStyleCustomData {
lineHeight?: number;
}

interface SessionStateCustomData {
userId?: string;
}

interface QueueItemCustomData {
priority?: number;
}

interface MediaStatusCustomData {
description?: string;
}

interface MediaInformationCustomData {
environment: "production" | "staging";
}

interface BreakClipCustomData {
advertiser?: string;
}
}

const sessionState = new cast.framework.messages.SessionState();
const mediaStatus = new cast.framework.messages.MediaStatus();

track.customData = { dialect: "关中话" };
tracksInfo.textTrackStyle!.customData = { lineHeight: 1.5 };
sessionState.customData = { userId: "1234" };
mediaStatus.customData = { description: "Lorem ipsum" };
queueItem.customData = { priority: 1 };
queueItem.media.customData = { environment: "production" };
breakClip.customData = { advertiser: "Umbrella Corporation" };