Skip to content

Commit

Permalink
Add pixelAspectRatio property from DASH (#2294)
Browse files Browse the repository at this point in the history
  • Loading branch information
Álvaro Velad Galván authored and joeyparrish committed Jan 6, 2020
1 parent 1b6ecf8 commit bdca05f
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 0 deletions.
4 changes: 4 additions & 0 deletions externs/shaka/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -301,6 +302,9 @@ shaka.extern.CreateSegmentIndexFunction;
* @property {(number|undefined)} frameRate
* <i>Video streams only.</i> <br>
* The Stream's framerate in frames per second
* @property {?string} pixelAspectRatio
* <i>Video streams only.</i> <br>
* The Stream's pixel aspect ratio
* @property {(number|undefined)} bandwidth
* <i>Audio and video streams only.</i> <br>
* The stream's required bandwidth in bits per second.
Expand Down
3 changes: 3 additions & 0 deletions externs/shaka/offline.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ shaka.extern.PeriodDB;
* mimeType: string,
* codecs: string,
* frameRate: (number|undefined),
* pixelAspectRatio: ?string,
* kind: (string|undefined),
* language: string,
* label: ?string,
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ shaka.extern.BufferedInfo;
* width: ?number,
* height: ?number,
* frameRate: ?number,
* pixelAspectRatio: ?string,
* mimeType: ?string,
* codecs: ?string,
* audioCodec: ?string,
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1190,6 +1191,7 @@ shaka.dash.DashParser = class {
codecs: '',
emsgSchemeIdUris: [],
frameRate: undefined,
pixelAspectRatio: null,
numChannels: null,
audioSamplingRate: null,
});
Expand All @@ -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);
Expand Down Expand Up @@ -1234,6 +1238,7 @@ shaka.dash.DashParser = class {
mimeType: mimeType,
codecs: codecs,
frameRate: frameRate,
pixelAspectRatio: pixelAspectRatio,
emsgSchemeIdUris: emsgSchemeIdUris,
id: elem.getAttribute('id'),
numChannels: numChannels,
Expand Down Expand Up @@ -1621,6 +1626,7 @@ shaka.dash.DashParser.RequestInitSegmentCallback;
* mimeType: string,
* codecs: string,
* frameRate: (number|undefined),
* pixelAspectRatio: ?string,
* emsgSchemeIdUris: !Array.<string>,
* id: ?string,
* numChannels: ?number,
Expand Down Expand Up @@ -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.<string>} emsgSchemeIdUris
* emsg registered schemeIdUris.
* @property {?string} id
Expand Down
1 change: 1 addition & 0 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ shaka.hls.HlsParser = class {
trickModeVideo: null,
emsgSchemeIdUris: null,
frameRate: undefined,
pixelAspectRatio: null,
width: undefined,
height: undefined,
bandwidth: undefined,
Expand Down
2 changes: 2 additions & 0 deletions lib/offline/indexeddb/v1_storage_cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lib/offline/manifest_converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lib/offline/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down Expand Up @@ -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: [],
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions lib/util/stream_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ shaka.util.StreamUtils = class {
width: null,
height: null,
frameRate: null,
pixelAspectRatio: null,
mimeType: mimeType,
codecs: codecs.join(', '),
audioCodec: audioCodec,
Expand All @@ -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;
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -440,6 +443,7 @@ shaka.util.StreamUtils = class {
width: null,
height: null,
frameRate: null,
pixelAspectRatio: null,
mimeType: null,
codecs: null,
audioCodec: null,
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions test/media/adaptation_set_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ describe('AdaptationSet', () => {
function makeStream(id, mimeType, codecs, roles) {
return {
audioSamplingRate: null,
pixelAspectRatio: null,
channelsCount: null,
closedCaptions: null,
codecs: codecs.join(','),
Expand Down
5 changes: 5 additions & 0 deletions test/offline/manifest_convert_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ describe('ManifestConverter', () => {
label: null,
width: null,
height: null,
pixelAspectRatio: null,
initSegmentKey: null,
encrypted: false,
keyId: null,
Expand Down Expand Up @@ -285,6 +286,7 @@ describe('ManifestConverter', () => {
mimeType: 'video/mp4',
codecs: 'avc1.42c01e',
frameRate: 22,
pixelAspectRatio: '59:54',
kind: undefined,
language: '',
label: null,
Expand Down Expand Up @@ -328,6 +330,7 @@ describe('ManifestConverter', () => {
mimeType: 'audio/mp4',
codecs: 'mp4a.40.2',
frameRate: undefined,
pixelAspectRatio: null,
kind: undefined,
language: 'en',
label: null,
Expand Down Expand Up @@ -370,6 +373,7 @@ describe('ManifestConverter', () => {
mimeType: 'text/vtt',
codecs: '',
frameRate: undefined,
pixelAspectRatio: null,
kind: undefined,
language: 'en',
label: null,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions test/offline/storage_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -1209,6 +1210,7 @@ filterDescribe('Storage', storageSupport, () => {
width: null,
height: null,
frameRate: null,
pixelAspectRatio: null,
mimeType: 'text/vtt',
codecs: 'vtt',
audioCodec: null,
Expand Down
13 changes: 13 additions & 0 deletions test/player_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -1288,6 +1298,7 @@ describe('Player', () => {
width: null,
height: null,
frameRate: null,
pixelAspectRatio: null,
videoId: null,
audioId: null,
originalAudioId: null,
Expand Down Expand Up @@ -1316,6 +1327,7 @@ describe('Player', () => {
width: null,
height: null,
frameRate: null,
pixelAspectRatio: null,
videoId: null,
audioId: null,
originalAudioId: null,
Expand Down Expand Up @@ -1344,6 +1356,7 @@ describe('Player', () => {
width: null,
height: null,
frameRate: null,
pixelAspectRatio: null,
videoId: null,
audioId: null,
originalAudioId: null,
Expand Down
2 changes: 2 additions & 0 deletions test/test/util/manifest_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)} */
Expand Down
1 change: 1 addition & 0 deletions test/test/util/offline_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ shaka.test.OfflineUtils = class {
mimeType: '',
codecs: '',
frameRate: undefined,
pixelAspectRatio: null,
kind: undefined,
language: '',
label: null,
Expand Down

0 comments on commit bdca05f

Please sign in to comment.