Skip to content

Commit

Permalink
Expose Storage Aspect Ratio (SAR)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro Velad committed Jun 3, 2020
1 parent 8c3775c commit bd12de6
Show file tree
Hide file tree
Showing 16 changed files with 52 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 @@ -224,6 +224,7 @@ shaka.extern.CreateSegmentIndexFunction;
* codecs: string,
* frameRate: (number|undefined),
* pixelAspectRatio: (string|undefined),
* storageAspectRatio: (string|undefined),
* bandwidth: (number|undefined),
* width: (number|undefined),
* height: (number|undefined),
Expand Down Expand Up @@ -274,6 +275,9 @@ shaka.extern.CreateSegmentIndexFunction;
* @property {(string|undefined)} pixelAspectRatio
* <i>Video streams only.</i> <br>
* The Stream's pixel aspect ratio
* @property {(string|undefined)} storageAspectRatio
* <i>Video streams only.</i> <br>
* The Stream's storage 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 @@ -104,6 +104,7 @@ shaka.extern.ManifestDB;
* codecs: string,
* frameRate: (number|undefined),
* pixelAspectRatio: (string|undefined),
* storageAspectRatio: (string|undefined),
* kind: (string|undefined),
* language: string,
* label: ?string,
Expand Down Expand Up @@ -136,6 +137,8 @@ shaka.extern.ManifestDB;
* The Stream's framerate in frames per second.
* @property {(string|undefined)} pixelAspectRatio
* The Stream's pixel aspect ratio
* @property {(string|undefined)} storageAspectRatio
* The Stream's storage 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/offline_compat_v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ shaka.extern.PeriodDBV2;
* codecs: string,
* frameRate: (number|undefined),
* pixelAspectRatio: (string|undefined),
* storageAspectRatio: (string|undefined),
* kind: (string|undefined),
* language: string,
* label: ?string,
Expand Down Expand Up @@ -99,6 +100,8 @@ shaka.extern.PeriodDBV2;
* The Stream's framerate in frames per second.
* @property {(string|undefined)} pixelAspectRatio
* The Stream's pixel aspect ratio
* @property {(string|undefined)} storageAspectRatio
* The Stream's storage 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 @@ -195,6 +195,7 @@ shaka.extern.BufferedInfo;
* height: ?number,
* frameRate: ?number,
* pixelAspectRatio: ?string,
* storageAspectRatio: ?string,
* mimeType: ?string,
* codecs: ?string,
* audioCodec: ?string,
Expand Down Expand Up @@ -246,6 +247,8 @@ shaka.extern.BufferedInfo;
* 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} storageAspectRatio
* The video pixel storage 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 @@ -995,6 +995,7 @@ shaka.dash.DashParser = class {
codecs: context.representation.codecs,
frameRate: context.representation.frameRate,
pixelAspectRatio: context.representation.pixelAspectRatio,
storageAspectRatio: context.representation.storageAspectRatio,
bandwidth: context.bandwidth,
width: context.representation.width,
height: context.representation.height,
Expand Down Expand Up @@ -1103,6 +1104,7 @@ shaka.dash.DashParser = class {
emsgSchemeIdUris: [],
frameRate: undefined,
pixelAspectRatio: undefined,
storageAspectRatio: undefined,
numChannels: null,
audioSamplingRate: null,
});
Expand All @@ -1120,6 +1122,8 @@ shaka.dash.DashParser = class {
XmlUtils.parseAttr(elem, 'frameRate', evalDivision) || parent.frameRate;
const pixelAspectRatio =
elem.getAttribute('par') || parent.pixelAspectRatio;
const storageAspectRatio =
elem.getAttribute('sar') || parent.storageAspectRatio;
const emsgSchemeIdUris = this.emsgSchemeIdUris_(
XmlUtils.findChildren(elem, 'InbandEventStream'),
parent.emsgSchemeIdUris);
Expand Down Expand Up @@ -1150,6 +1154,7 @@ shaka.dash.DashParser = class {
codecs: codecs,
frameRate: frameRate,
pixelAspectRatio: pixelAspectRatio,
storageAspectRatio: storageAspectRatio,
emsgSchemeIdUris: emsgSchemeIdUris,
id: elem.getAttribute('id'),
numChannels: numChannels,
Expand Down Expand Up @@ -1538,6 +1543,7 @@ shaka.dash.DashParser.RequestInitSegmentCallback;
* codecs: string,
* frameRate: (number|undefined),
* pixelAspectRatio: (string|undefined),
* storageAspectRatio: (string|undefined),
* emsgSchemeIdUris: !Array.<string>,
* id: ?string,
* numChannels: ?number,
Expand Down Expand Up @@ -1570,6 +1576,8 @@ shaka.dash.DashParser.RequestInitSegmentCallback;
* The inherited framerate value.
* @property {(string|undefined)} pixelAspectRatio
* The inherited pixel aspect ratio value.
* @property {(string|undefined)} storageAspectRatio
* The inherited pixel storage 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 @@ -1275,6 +1275,7 @@ shaka.hls.HlsParser = class {
emsgSchemeIdUris: null,
frameRate: undefined,
pixelAspectRatio: undefined,
storageAspectRatio: undefined,
width: undefined,
height: undefined,
bandwidth: undefined,
Expand Down
1 change: 1 addition & 0 deletions lib/offline/indexeddb/v1_storage_cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ shaka.offline.indexeddb.V1StorageCell = class
codecs: old.codecs,
frameRate: old.frameRate,
pixelAspectRatio: undefined,
storageAspectRatio: undefined,
kind: old.kind,
language: old.language,
label: old.label,
Expand Down
1 change: 1 addition & 0 deletions lib/offline/indexeddb/v2_storage_cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ shaka.offline.indexeddb.V2StorageCell = class
codecs: old.codecs,
frameRate: old.frameRate,
pixelAspectRatio: old.pixelAspectRatio,
storageAspectRatio: undefined,
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 @@ -176,6 +176,7 @@ shaka.offline.ManifestConverter = class {
height: streamDB.height || undefined,
frameRate: streamDB.frameRate,
pixelAspectRatio: streamDB.pixelAspectRatio,
storageAspectRatio: streamDB.storageAspectRatio,
kind: streamDB.kind,
encrypted: streamDB.encrypted,
drmInfos: [],
Expand Down
1 change: 1 addition & 0 deletions lib/offline/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,7 @@ shaka.offline.Storage = class {
codecs: stream.codecs,
frameRate: stream.frameRate,
pixelAspectRatio: stream.pixelAspectRatio,
storageAspectRatio: stream.storageAspectRatio,
kind: stream.kind,
language: stream.language,
label: stream.label,
Expand Down
4 changes: 4 additions & 0 deletions lib/util/stream_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ shaka.util.StreamUtils = class {
height: null,
frameRate: null,
pixelAspectRatio: null,
storageAspectRatio: null,
mimeType: mimeType,
codecs: codecs.join(', '),
audioCodec: audioCodec,
Expand All @@ -379,6 +380,7 @@ shaka.util.StreamUtils = class {
track.height = video.height || null;
track.frameRate = video.frameRate || null;
track.pixelAspectRatio = video.pixelAspectRatio || null;
track.storageAspectRatio = video.storageAspectRatio || null;
track.videoBandwidth = video.bandwidth || null;
}

Expand Down Expand Up @@ -416,6 +418,7 @@ shaka.util.StreamUtils = class {
height: null,
frameRate: null,
pixelAspectRatio: null,
storageAspectRatio: null,
mimeType: stream.mimeType,
codecs: stream.codecs || null,
audioCodec: null,
Expand Down Expand Up @@ -525,6 +528,7 @@ shaka.util.StreamUtils = class {
height: null,
frameRate: null,
pixelAspectRatio: null,
storageAspectRatio: null,
mimeType: null,
codecs: null,
audioCodec: null,
Expand Down
4 changes: 4 additions & 0 deletions test/offline/manifest_convert_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ describe('ManifestConverter', () => {
codecs: 'avc1.42c01e',
frameRate: 22,
pixelAspectRatio: '59:54',
storageAspectRatio: '64:45',
kind: undefined,
language: '',
label: null,
Expand Down Expand Up @@ -370,6 +371,7 @@ describe('ManifestConverter', () => {
codecs: 'mp4a.40.2',
frameRate: undefined,
pixelAspectRatio: undefined,
storageAspectRatio: undefined,
kind: undefined,
language: 'en',
label: null,
Expand Down Expand Up @@ -414,6 +416,7 @@ describe('ManifestConverter', () => {
codecs: '',
frameRate: undefined,
pixelAspectRatio: undefined,
storageAspectRatio: undefined,
kind: undefined,
language: 'en',
label: null,
Expand Down Expand Up @@ -465,6 +468,7 @@ describe('ManifestConverter', () => {
codecs: streamDb.codecs,
frameRate: streamDb.frameRate,
pixelAspectRatio: streamDb.pixelAspectRatio,
storageAspectRatio: streamDb.storageAspectRatio,
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 @@ -1238,6 +1238,7 @@ filterDescribe('Storage', storageSupport, () => {
height: height,
frameRate: 30,
pixelAspectRatio: '59:54',
storageAspectRatio: '64:45',
mimeType: 'video/mp4,audio/mp4',
codecs: 'mp4,mp4',
audioCodec: 'mp4',
Expand Down Expand Up @@ -1275,6 +1276,7 @@ filterDescribe('Storage', storageSupport, () => {
height: null,
frameRate: null,
pixelAspectRatio: null,
storageAspectRatio: 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 @@ -894,6 +894,7 @@ describe('Player', () => {
stream.height = 200;
stream.frameRate = 1000000 / 42000;
stream.pixelAspectRatio = '59:54';
stream.storageAspectRatio = '64:45';
stream.roles = ['main'];
});
variant.addAudio(3, (stream) => {
Expand All @@ -912,6 +913,7 @@ describe('Player', () => {
stream.bandwidth = 2000;
stream.frameRate = 24;
stream.pixelAspectRatio = '59:54';
stream.storageAspectRatio = '64:45';
stream.size(200, 400);
});
variant.addExistingStream(3); // audio
Expand Down Expand Up @@ -1012,6 +1014,7 @@ describe('Player', () => {
height: 200,
frameRate: 1000000 / 42000,
pixelAspectRatio: '59:54',
storageAspectRatio: '64:45',
mimeType: 'video/mp4',
codecs: 'avc1.4d401f, mp4a.40.2',
audioCodec: 'mp4a.40.2',
Expand Down Expand Up @@ -1041,6 +1044,7 @@ describe('Player', () => {
height: 400,
frameRate: 24,
pixelAspectRatio: '59:54',
storageAspectRatio: '64:45',
mimeType: 'video/mp4',
codecs: 'avc1.4d401f, mp4a.40.2',
audioCodec: 'mp4a.40.2',
Expand Down Expand Up @@ -1070,6 +1074,7 @@ describe('Player', () => {
height: 200,
frameRate: 1000000 / 42000,
pixelAspectRatio: '59:54',
storageAspectRatio: '64:45',
mimeType: 'video/mp4',
codecs: 'avc1.4d401f, mp4a.40.2',
audioCodec: 'mp4a.40.2',
Expand Down Expand Up @@ -1099,6 +1104,7 @@ describe('Player', () => {
height: 400,
frameRate: 24,
pixelAspectRatio: '59:54',
storageAspectRatio: '64:45',
mimeType: 'video/mp4',
codecs: 'avc1.4d401f, mp4a.40.2',
audioCodec: 'mp4a.40.2',
Expand Down Expand Up @@ -1128,6 +1134,7 @@ describe('Player', () => {
height: 200,
frameRate: 1000000 / 42000,
pixelAspectRatio: '59:54',
storageAspectRatio: '64:45',
mimeType: 'video/mp4',
codecs: 'avc1.4d401f, mp4a.40.2',
audioCodec: 'mp4a.40.2',
Expand Down Expand Up @@ -1157,6 +1164,7 @@ describe('Player', () => {
height: 400,
frameRate: 24,
pixelAspectRatio: '59:54',
storageAspectRatio: '64:45',
mimeType: 'video/mp4',
codecs: 'avc1.4d401f, mp4a.40.2',
audioCodec: 'mp4a.40.2',
Expand Down Expand Up @@ -1186,6 +1194,7 @@ describe('Player', () => {
height: 200,
frameRate: 1000000 / 42000,
pixelAspectRatio: '59:54',
storageAspectRatio: '64:45',
mimeType: 'video/mp4',
codecs: 'avc1.4d401f, mp4a.40.2',
audioCodec: 'mp4a.40.2',
Expand Down Expand Up @@ -1215,6 +1224,7 @@ describe('Player', () => {
height: 400,
frameRate: 24,
pixelAspectRatio: '59:54',
storageAspectRatio: '64:45',
mimeType: 'video/mp4',
codecs: 'avc1.4d401f, mp4a.40.2',
audioCodec: 'mp4a.40.2',
Expand Down Expand Up @@ -1258,6 +1268,7 @@ describe('Player', () => {
height: null,
frameRate: null,
pixelAspectRatio: null,
storageAspectRatio: null,
videoId: null,
audioId: null,
originalAudioId: null,
Expand Down Expand Up @@ -1287,6 +1298,7 @@ describe('Player', () => {
height: null,
frameRate: null,
pixelAspectRatio: null,
storageAspectRatio: null,
videoId: null,
audioId: null,
originalAudioId: null,
Expand Down Expand Up @@ -1316,6 +1328,7 @@ describe('Player', () => {
height: null,
frameRate: null,
pixelAspectRatio: null,
storageAspectRatio: 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 @@ -476,6 +476,8 @@ shaka.test.ManifestGenerator.Stream = class {
this.frameRate = undefined;
/** @type {(string|undefined)} */
this.pixelAspectRatio = undefined;
/** @type {(string|undefined)} */
this.storageAspectRatio = undefined;
/** @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 @@ -41,6 +41,7 @@ shaka.test.OfflineUtils = class {
codecs: '',
frameRate: undefined,
pixelAspectRatio: undefined,
storageAspectRatio: undefined,
kind: undefined,
language: '',
label: null,
Expand Down

0 comments on commit bd12de6

Please sign in to comment.