diff --git a/externs/shaka/manifest.js b/externs/shaka/manifest.js index 6cb0990c22..58f22c7124 100644 --- a/externs/shaka/manifest.js +++ b/externs/shaka/manifest.js @@ -255,6 +255,7 @@ shaka.extern.CreateSegmentIndexFunction; * mimeType: string, * codecs: string, * frameRate: (number|undefined), + * pixelAspectRatio: ?string, * bandwidth: (number|undefined), * width: (number|undefined), * height: (number|undefined), @@ -301,6 +302,9 @@ shaka.extern.CreateSegmentIndexFunction; * @property {(number|undefined)} frameRate * Video streams only.
* The Stream's framerate in frames per second + * @property {?string} pixelAspectRatio + * Video streams only.
+ * The Stream's pixel aspect ratio * @property {(number|undefined)} bandwidth * Audio and video streams only.
* The stream's required bandwidth in bits per second. diff --git a/externs/shaka/offline.js b/externs/shaka/offline.js index f9c0762b84..541824ff4e 100644 --- a/externs/shaka/offline.js +++ b/externs/shaka/offline.js @@ -114,6 +114,7 @@ shaka.extern.PeriodDB; * mimeType: string, * codecs: string, * frameRate: (number|undefined), + * pixelAspectRatio: ?string, * kind: (string|undefined), * language: string, * label: ?string, @@ -144,6 +145,8 @@ shaka.extern.PeriodDB; * The codecs of the stream. * @property {(number|undefined)} frameRate * The Stream's framerate in frames per second. + * @property {?string} pixelAspectRatio + * The Stream's pixel aspect ratio * @property {(string|undefined)} kind * The kind of text stream; undefined for audio/video. * @property {string} language diff --git a/externs/shaka/player.js b/externs/shaka/player.js index 6f537571d7..fb4dd93e9c 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -176,6 +176,7 @@ shaka.extern.BufferedInfo; * width: ?number, * height: ?number, * frameRate: ?number, + * pixelAspectRatio: ?string, * mimeType: ?string, * codecs: ?string, * audioCodec: ?string, @@ -225,6 +226,8 @@ shaka.extern.BufferedInfo; * The video height provided in the manifest, if present. * @property {?number} frameRate * The video framerate provided in the manifest, if present. + * @property {?string} pixelAspectRatio + * The video pixel aspect ratio provided in the manifest, if present. * @property {?string} mimeType * The MIME type of the content provided in the manifest. * @property {?string} codecs diff --git a/lib/dash/dash_parser.js b/lib/dash/dash_parser.js index a37286fb0c..46626b5ad1 100644 --- a/lib/dash/dash_parser.js +++ b/lib/dash/dash_parser.js @@ -1084,6 +1084,7 @@ shaka.dash.DashParser = class { mimeType: context.representation.mimeType, codecs: context.representation.codecs, frameRate: context.representation.frameRate, + pixelAspectRatio: context.representation.pixelAspectRatio, bandwidth: context.bandwidth, width: context.representation.width, height: context.representation.height, @@ -1190,6 +1191,7 @@ shaka.dash.DashParser = class { codecs: '', emsgSchemeIdUris: [], frameRate: undefined, + pixelAspectRatio: null, numChannels: null, audioSamplingRate: null, }); @@ -1205,6 +1207,8 @@ shaka.dash.DashParser = class { const codecs = elem.getAttribute('codecs') || parent.codecs; const frameRate = XmlUtils.parseAttr(elem, 'frameRate', evalDivision) || parent.frameRate; + const pixelAspectRatio = + elem.getAttribute('par') || parent.pixelAspectRatio; const emsgSchemeIdUris = this.emsgSchemeIdUris_( XmlUtils.findChildren(elem, 'InbandEventStream'), parent.emsgSchemeIdUris); @@ -1234,6 +1238,7 @@ shaka.dash.DashParser = class { mimeType: mimeType, codecs: codecs, frameRate: frameRate, + pixelAspectRatio: pixelAspectRatio, emsgSchemeIdUris: emsgSchemeIdUris, id: elem.getAttribute('id'), numChannels: numChannels, @@ -1621,6 +1626,7 @@ shaka.dash.DashParser.RequestInitSegmentCallback; * mimeType: string, * codecs: string, * frameRate: (number|undefined), + * pixelAspectRatio: ?string, * emsgSchemeIdUris: !Array., * id: ?string, * numChannels: ?number, @@ -1651,6 +1657,8 @@ shaka.dash.DashParser.RequestInitSegmentCallback; * The inherited codecs value. * @property {(number|undefined)} frameRate * The inherited framerate value. + * @property {(number|undefined)} pixelAspectRatio + * The inherited pixel aspect ratio value. * @property {!Array.} emsgSchemeIdUris * emsg registered schemeIdUris. * @property {?string} id diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 0705ea6288..834d054041 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -1194,6 +1194,7 @@ shaka.hls.HlsParser = class { trickModeVideo: null, emsgSchemeIdUris: null, frameRate: undefined, + pixelAspectRatio: null, 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 d6bdb622e5..16debbf7a2 100644 --- a/lib/offline/indexeddb/v1_storage_cell.js +++ b/lib/offline/indexeddb/v1_storage_cell.js @@ -166,6 +166,7 @@ shaka.offline.indexeddb.V1StorageCell = class // mimeType: string, // codecs: string, // frameRate: (number|undefined), + // pixelAspectRatio: ?string, // kind: (string|undefined), // language: string, // label: ?string, @@ -218,6 +219,7 @@ shaka.offline.indexeddb.V1StorageCell = class mimeType: old.mimeType, codecs: old.codecs, frameRate: old.frameRate, + pixelAspectRatio: null, kind: old.kind, language: old.language, label: old.label, diff --git a/lib/offline/manifest_converter.js b/lib/offline/manifest_converter.js index c57a0dc085..b61419758e 100644 --- a/lib/offline/manifest_converter.js +++ b/lib/offline/manifest_converter.js @@ -211,6 +211,7 @@ shaka.offline.ManifestConverter = class { width: streamDB.width || undefined, height: streamDB.height || undefined, frameRate: streamDB.frameRate || undefined, + pixelAspectRatio: streamDB.pixelAspectRatio || null, kind: streamDB.kind, encrypted: streamDB.encrypted, keyId: streamDB.keyId, diff --git a/lib/offline/storage.js b/lib/offline/storage.js index 08c067bcad..2271d2e349 100644 --- a/lib/offline/storage.js +++ b/lib/offline/storage.js @@ -1015,6 +1015,7 @@ shaka.offline.Storage = class { mimeType: stream.mimeType, codecs: stream.codecs, frameRate: stream.frameRate, + pixelAspectRatio: stream.pixelAspectRatio, kind: stream.kind, language: stream.language, label: stream.label, diff --git a/lib/player.js b/lib/player.js index abaaba25c4..c7e6db6fb7 100644 --- a/lib/player.js +++ b/lib/player.js @@ -1825,6 +1825,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget { label: null, type: ContentType.VIDEO, primary: false, + pixelAspectRatio: null, trickModeVideo: null, emsgSchemeIdUris: null, roles: [], @@ -3530,6 +3531,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget { label: label || null, type: ContentType.TEXT, primary: false, + pixelAspectRatio: null, trickModeVideo: null, emsgSchemeIdUris: null, roles: [], @@ -3720,6 +3722,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget { label: null, type: ContentType.TEXT, primary: false, + pixelAspectRatio: null, trickModeVideo: null, emsgSchemeIdUris: null, roles: video.roles, diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index 264fa02a32..2fa87805fc 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -275,6 +275,7 @@ shaka.util.StreamUtils = class { width: null, height: null, frameRate: null, + pixelAspectRatio: null, mimeType: mimeType, codecs: codecs.join(', '), audioCodec: audioCodec, @@ -299,6 +300,7 @@ shaka.util.StreamUtils = class { track.width = video.width || null; track.height = video.height || null; track.frameRate = video.frameRate || null; + track.pixelAspectRatio = video.pixelAspectRatio || null; track.videoBandwidth = video.bandwidth || null; } @@ -335,6 +337,7 @@ shaka.util.StreamUtils = class { width: null, height: null, frameRate: null, + pixelAspectRatio: null, mimeType: stream.mimeType, codecs: stream.codecs || null, audioCodec: null, @@ -440,6 +443,7 @@ shaka.util.StreamUtils = class { width: null, height: null, frameRate: null, + pixelAspectRatio: null, mimeType: null, codecs: null, audioCodec: null, @@ -723,6 +727,7 @@ shaka.util.StreamUtils = class { ' codecs=' + stream.codecs + ' bandwidth=' + stream.bandwidth + ' frameRate=' + stream.frameRate + + ' pixelAspectRatio= ' + stream.pixelAspectRatio + ' width=' + stream.width + ' height=' + stream.height; } diff --git a/test/media/adaptation_set_unit.js b/test/media/adaptation_set_unit.js index c0aa0e1fc4..c911a601c0 100644 --- a/test/media/adaptation_set_unit.js +++ b/test/media/adaptation_set_unit.js @@ -160,6 +160,7 @@ describe('AdaptationSet', () => { 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 49ad169d81..f79bfff7d4 100644 --- a/test/offline/manifest_convert_unit.js +++ b/test/offline/manifest_convert_unit.js @@ -241,6 +241,7 @@ describe('ManifestConverter', () => { label: null, width: null, height: null, + pixelAspectRatio: null, initSegmentKey: null, encrypted: false, keyId: null, @@ -285,6 +286,7 @@ describe('ManifestConverter', () => { mimeType: 'video/mp4', codecs: 'avc1.42c01e', frameRate: 22, + pixelAspectRatio: '59:54', kind: undefined, language: '', label: null, @@ -328,6 +330,7 @@ describe('ManifestConverter', () => { mimeType: 'audio/mp4', codecs: 'mp4a.40.2', frameRate: undefined, + pixelAspectRatio: null, kind: undefined, language: 'en', label: null, @@ -370,6 +373,7 @@ describe('ManifestConverter', () => { mimeType: 'text/vtt', codecs: '', frameRate: undefined, + pixelAspectRatio: null, kind: undefined, language: 'en', label: null, @@ -415,6 +419,7 @@ describe('ManifestConverter', () => { mimeType: streamDb.mimeType, codecs: streamDb.codecs, frameRate: streamDb.frameRate, + pixelAspectRatio: streamDb.pixelAspectRatio || null, width: streamDb.width || undefined, height: streamDb.height || undefined, kind: streamDb.kind, diff --git a/test/offline/storage_integration.js b/test/offline/storage_integration.js index eb9e5269a3..b4a0beb10f 100644 --- a/test/offline/storage_integration.js +++ b/test/offline/storage_integration.js @@ -1173,6 +1173,7 @@ filterDescribe('Storage', storageSupport, () => { width: height * (16 / 9), height: height, frameRate: 30, + pixelAspectRatio: '59:54', mimeType: 'video/mp4,audio/mp4', codecs: 'mp4,mp4', audioCodec: 'mp4', @@ -1209,6 +1210,7 @@ filterDescribe('Storage', storageSupport, () => { width: null, height: null, frameRate: null, + pixelAspectRatio: null, mimeType: 'text/vtt', codecs: 'vtt', audioCodec: null, diff --git a/test/player_unit.js b/test/player_unit.js index 9c0ce970eb..bc94b61889 100644 --- a/test/player_unit.js +++ b/test/player_unit.js @@ -909,6 +909,7 @@ describe('Player', () => { stream.width = 100; stream.height = 200; stream.frameRate = 1000000 / 42000; + stream.pixelAspectRatio = '59:54'; }); variant.addAudio(3, (stream) => { stream.originalId = 'audio-en-6c'; @@ -925,6 +926,7 @@ describe('Player', () => { stream.originalId = 'video-2kbps'; stream.bandwidth = 2000; stream.frameRate = 24; + stream.pixelAspectRatio = '59:54'; stream.size(200, 400); }); variant.addExistingStream(3); // audio @@ -1050,6 +1052,7 @@ describe('Player', () => { width: 100, height: 200, frameRate: 1000000 / 42000, + pixelAspectRatio: '59:54', mimeType: 'video/mp4', codecs: 'avc1.4d401f, mp4a.40.2', audioCodec: 'mp4a.40.2', @@ -1078,6 +1081,7 @@ describe('Player', () => { width: 200, height: 400, frameRate: 24, + pixelAspectRatio: '59:54', mimeType: 'video/mp4', codecs: 'avc1.4d401f, mp4a.40.2', audioCodec: 'mp4a.40.2', @@ -1106,6 +1110,7 @@ describe('Player', () => { width: 100, height: 200, frameRate: 1000000 / 42000, + pixelAspectRatio: '59:54', mimeType: 'video/mp4', codecs: 'avc1.4d401f, mp4a.40.2', audioCodec: 'mp4a.40.2', @@ -1134,6 +1139,7 @@ describe('Player', () => { width: 200, height: 400, frameRate: 24, + pixelAspectRatio: '59:54', mimeType: 'video/mp4', codecs: 'avc1.4d401f, mp4a.40.2', audioCodec: 'mp4a.40.2', @@ -1162,6 +1168,7 @@ describe('Player', () => { width: 100, height: 200, frameRate: 1000000 / 42000, + pixelAspectRatio: '59:54', mimeType: 'video/mp4', codecs: 'avc1.4d401f, mp4a.40.2', audioCodec: 'mp4a.40.2', @@ -1190,6 +1197,7 @@ describe('Player', () => { width: 200, height: 400, frameRate: 24, + pixelAspectRatio: '59:54', mimeType: 'video/mp4', codecs: 'avc1.4d401f, mp4a.40.2', audioCodec: 'mp4a.40.2', @@ -1218,6 +1226,7 @@ describe('Player', () => { width: 100, height: 200, frameRate: 1000000 / 42000, + pixelAspectRatio: '59:54', mimeType: 'video/mp4', codecs: 'avc1.4d401f, mp4a.40.2', audioCodec: 'mp4a.40.2', @@ -1246,6 +1255,7 @@ describe('Player', () => { width: 200, height: 400, frameRate: 24, + pixelAspectRatio: '59:54', mimeType: 'video/mp4', codecs: 'avc1.4d401f, mp4a.40.2', audioCodec: 'mp4a.40.2', @@ -1288,6 +1298,7 @@ describe('Player', () => { width: null, height: null, frameRate: null, + pixelAspectRatio: null, videoId: null, audioId: null, originalAudioId: null, @@ -1316,6 +1327,7 @@ describe('Player', () => { width: null, height: null, frameRate: null, + pixelAspectRatio: null, videoId: null, audioId: null, originalAudioId: null, @@ -1344,6 +1356,7 @@ describe('Player', () => { width: null, height: null, frameRate: null, + pixelAspectRatio: null, videoId: null, audioId: null, originalAudioId: null, diff --git a/test/test/util/manifest_generator.js b/test/test/util/manifest_generator.js index 470af9b62c..95f298c882 100644 --- a/test/test/util/manifest_generator.js +++ b/test/test/util/manifest_generator.js @@ -551,6 +551,8 @@ shaka.test.ManifestGenerator.Stream = class { this.codecs = defaultCodecs; /** @type {(number|undefined)} */ this.frameRate = undefined; + /** @type {?string} */ + this.pixelAspectRatio = null; /** @type {(number|undefined)} */ this.bandwidth = undefined; /** @type {(number|undefined)} */ diff --git a/test/test/util/offline_utils.js b/test/test/util/offline_utils.js index 9b3591237a..255ca38459 100644 --- a/test/test/util/offline_utils.js +++ b/test/test/util/offline_utils.js @@ -39,6 +39,7 @@ shaka.test.OfflineUtils = class { mimeType: '', codecs: '', frameRate: undefined, + pixelAspectRatio: null, kind: undefined, language: '', label: null,