From cc38168eb1a8647204883df8dff004730aea6fd3 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Wed, 15 Jan 2020 10:16:25 -0800 Subject: [PATCH] Fix pixelAspectRatio types for backward compatibility For backward compatibility, the new pixelAspectRatio field in Stream should be string|undefined rather than being nullable. This ensures that manifest parser plugins that do not output that field will still compile against the externs. PR #2294 Backported to v2.5.x Change-Id: I1aae03994a213c8ce52dc64e8a34bf179045f4fb --- externs/shaka/manifest.js | 4 ++-- externs/shaka/offline.js | 4 ++-- lib/dash/dash_parser.js | 4 ++-- lib/hls/hls_parser.js | 2 +- lib/offline/indexeddb/v1_storage_cell.js | 3 +-- lib/offline/manifest_converter.js | 2 +- lib/player.js | 6 +++--- test/media/adaptation_set_unit.js | 1 - test/offline/manifest_convert_unit.js | 7 +++---- test/test/util/manifest_generator.js | 2 +- test/test/util/offline_utils.js | 2 +- 11 files changed, 17 insertions(+), 20 deletions(-) diff --git a/externs/shaka/manifest.js b/externs/shaka/manifest.js index f6d5b30fa7..16db09b749 100644 --- a/externs/shaka/manifest.js +++ b/externs/shaka/manifest.js @@ -293,7 +293,7 @@ shaka.extern.GetSegmentReferenceFunction; * mimeType: string, * codecs: string, * frameRate: (number|undefined), - * pixelAspectRatio: ?string, + * pixelAspectRatio: (string|undefined), * bandwidth: (number|undefined), * width: (number|undefined), * height: (number|undefined), @@ -360,7 +360,7 @@ shaka.extern.GetSegmentReferenceFunction; * @property {(number|undefined)} frameRate * Video streams only.
* The Stream's framerate in frames per second - * @property {?string} pixelAspectRatio + * @property {(string|undefined)} pixelAspectRatio * Video streams only.
* The Stream's pixel aspect ratio * @property {(number|undefined)} bandwidth diff --git a/externs/shaka/offline.js b/externs/shaka/offline.js index 74d3b83454..06c08313cb 100644 --- a/externs/shaka/offline.js +++ b/externs/shaka/offline.js @@ -126,7 +126,7 @@ shaka.extern.PeriodDB; * mimeType: string, * codecs: string, * frameRate: (number|undefined), - * pixelAspectRatio: ?string, + * pixelAspectRatio: (string|undefined), * kind: (string|undefined), * language: string, * label: ?string, @@ -156,7 +156,7 @@ shaka.extern.PeriodDB; * The codecs of the stream. * @property {(number|undefined)} frameRate * The Stream's framerate in frames per second. - * @property {?string} pixelAspectRatio + * @property {(string|undefined)} pixelAspectRatio * The Stream's pixel aspect ratio * @property {(string|undefined)} kind * The kind of text stream; undefined for audio/video. diff --git a/lib/dash/dash_parser.js b/lib/dash/dash_parser.js index 9279ff7bb8..9acb24e20e 100644 --- a/lib/dash/dash_parser.js +++ b/lib/dash/dash_parser.js @@ -130,7 +130,7 @@ shaka.dash.DashParser.RequestInitSegmentCallback; * mimeType: string, * codecs: string, * frameRate: (number|undefined), - * pixelAspectRatio: ?string, + * pixelAspectRatio: (string|undefined), * emsgSchemeIdUris: !Array., * id: ?string, * numChannels: ?number, @@ -161,7 +161,7 @@ shaka.dash.DashParser.RequestInitSegmentCallback; * The inherited codecs value. * @property {(number|undefined)} frameRate * The inherited framerate value. - * @property {(number|undefined)} pixelAspectRatio + * @property {(string|undefined)} pixelAspectRatio * The inherited pixel aspect ratio value. * @property {!Array.} emsgSchemeIdUris * emsg registered schemeIdUris. diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 4957b279cd..c719ec5b8d 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -1258,7 +1258,7 @@ shaka.hls.HlsParser.prototype.createStreamInfo_ = async function( trickModeVideo: null, emsgSchemeIdUris: null, frameRate: undefined, - pixelAspectRatio: null, + pixelAspectRatio: undefined, width: undefined, height: undefined, bandwidth: undefined, diff --git a/lib/offline/indexeddb/v1_storage_cell.js b/lib/offline/indexeddb/v1_storage_cell.js index 2644fd005f..e7825923b2 100644 --- a/lib/offline/indexeddb/v1_storage_cell.js +++ b/lib/offline/indexeddb/v1_storage_cell.js @@ -352,7 +352,6 @@ shaka.offline.indexeddb.V1StorageCell = class { // mimeType: string, // codecs: string, // frameRate: (number|undefined), - // pixelAspectRatio: ?string, // kind: (string|undefined), // language: string, // label: ?string, @@ -405,7 +404,7 @@ shaka.offline.indexeddb.V1StorageCell = class { mimeType: old.mimeType, codecs: old.codecs, frameRate: old.frameRate, - pixelAspectRatio: null, + pixelAspectRatio: undefined, kind: old.kind, language: old.language, label: old.label, diff --git a/lib/offline/manifest_converter.js b/lib/offline/manifest_converter.js index 59b0dbfb26..572105a2e0 100644 --- a/lib/offline/manifest_converter.js +++ b/lib/offline/manifest_converter.js @@ -199,7 +199,7 @@ shaka.offline.ManifestConverter = class { width: streamDB.width || undefined, height: streamDB.height || undefined, frameRate: streamDB.frameRate || undefined, - pixelAspectRatio: streamDB.pixelAspectRatio || null, + pixelAspectRatio: streamDB.pixelAspectRatio || undefined, kind: streamDB.kind, encrypted: streamDB.encrypted, keyId: streamDB.keyId, diff --git a/lib/player.js b/lib/player.js index 335df05dfc..63abef4753 100644 --- a/lib/player.js +++ b/lib/player.js @@ -1834,7 +1834,7 @@ shaka.Player.prototype.onInitializeSrcEqualsDrm_ = async function(has, wants) { type: ContentType.VIDEO, primary: false, frameRate: undefined, - pixelAspectRatio: null, + pixelAspectRatio: undefined, trickModeVideo: null, emsgSchemeIdUris: null, roles: [], @@ -3550,7 +3550,7 @@ shaka.Player.prototype.addTextTrack = async function( type: ContentType.TEXT, primary: false, frameRate: undefined, - pixelAspectRatio: null, + pixelAspectRatio: undefined, trickModeVideo: null, emsgSchemeIdUris: null, roles: [], @@ -3752,7 +3752,7 @@ shaka.Player.prototype.createTextStreamsForClosedCaptions_ = function(periods) { type: ContentType.TEXT, primary: false, frameRate: undefined, - pixelAspectRatio: null, + pixelAspectRatio: undefined, trickModeVideo: null, emsgSchemeIdUris: null, roles: video.roles, diff --git a/test/media/adaptation_set_unit.js b/test/media/adaptation_set_unit.js index 4304a650e8..8b37c44a2d 100644 --- a/test/media/adaptation_set_unit.js +++ b/test/media/adaptation_set_unit.js @@ -172,7 +172,6 @@ describe('AdaptationSet', function() { function makeStream(id, mimeType, codecs, roles) { return { audioSamplingRate: null, - pixelAspectRatio: null, channelsCount: null, closedCaptions: null, codecs: codecs.join(','), diff --git a/test/offline/manifest_convert_unit.js b/test/offline/manifest_convert_unit.js index 46b7f78847..caa178c89b 100644 --- a/test/offline/manifest_convert_unit.js +++ b/test/offline/manifest_convert_unit.js @@ -225,7 +225,6 @@ describe('ManifestConverter', function() { label: null, width: null, height: null, - pixelAspectRatio: null, initSegmentKey: null, encrypted: false, keyId: null, @@ -312,7 +311,7 @@ describe('ManifestConverter', function() { mimeType: 'audio/mp4', codecs: 'mp4a.40.2', frameRate: undefined, - pixelAspectRatio: null, + pixelAspectRatio: undefined, kind: undefined, language: 'en', label: null, @@ -354,7 +353,7 @@ describe('ManifestConverter', function() { mimeType: 'text/vtt', codecs: '', frameRate: undefined, - pixelAspectRatio: null, + pixelAspectRatio: undefined, kind: undefined, language: 'en', label: null, @@ -404,7 +403,7 @@ describe('ManifestConverter', function() { mimeType: streamDb.mimeType, codecs: streamDb.codecs, frameRate: streamDb.frameRate, - pixelAspectRatio: streamDb.pixelAspectRatio || null, + pixelAspectRatio: streamDb.pixelAspectRatio || undefined, width: streamDb.width || undefined, height: streamDb.height || undefined, kind: streamDb.kind, diff --git a/test/test/util/manifest_generator.js b/test/test/util/manifest_generator.js index 895b91f89e..6adaf290cc 100644 --- a/test/test/util/manifest_generator.js +++ b/test/test/util/manifest_generator.js @@ -545,7 +545,7 @@ shaka.test.ManifestGenerator.prototype.createStream_ = mimeType: defaultMimeType, codecs: defaultCodecs, frameRate: undefined, - pixelAspectRatio: null, + pixelAspectRatio: undefined, bandwidth: undefined, width: undefined, height: undefined, diff --git a/test/test/util/offline_utils.js b/test/test/util/offline_utils.js index 003a95fea9..a51b5d8a7f 100644 --- a/test/test/util/offline_utils.js +++ b/test/test/util/offline_utils.js @@ -51,7 +51,7 @@ shaka.test.OfflineUtils.createStream = function(id, type) { mimeType: '', codecs: '', frameRate: undefined, - pixelAspectRatio: null, + pixelAspectRatio: undefined, kind: undefined, language: '', label: null,