From ace0e8cf49ee84c2dc909a5e2823848586099061 Mon Sep 17 00:00:00 2001 From: Matias Russitto Date: Mon, 5 Jun 2017 19:29:55 +0200 Subject: [PATCH] add video and audio stream IDs for getStats().switchHistory (#846) Closes #785, #823 --- CONTRIBUTORS | 1 + externs/shaka/player.js | 8 +++++++- lib/util/stream_utils.js | 4 +++- test/offline/storage_unit.js | 4 +++- test/player_unit.js | 20 +++++++++++++++----- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index aa15ac0c4c..49424f9316 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -40,6 +40,7 @@ Jonas Birmé Jono Ward Jozef Chúťka Lucas Gabriel Sánchez +Matias Russitto Mattias Wadman Natalie Harris Nick Desaulniers diff --git a/externs/shaka/player.js b/externs/shaka/player.js index 316ee0c942..f999eb1a11 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -140,7 +140,9 @@ shakaExtern.Stats; * audioCodec: ?string, * videoCodec: ?string, * primary: boolean, - * roles: !Array. + * roles: !Array., + * videoId: ?number, + * audioId: ?number * }} * * @description @@ -190,6 +192,10 @@ shakaExtern.Stats; * cannot be satisfied. * @property {!Array.} roles * The roles of the track, e.g. 'main', 'caption', or 'commentary'. + * @property {?number} videoId + * (only for variant tracks) The video stream id. + * @property {?number} audioId + * (only for variant tracks) The audio stream id. * @exportDoc */ shakaExtern.Track; diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index cfc439aff7..650496c941 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -268,7 +268,9 @@ shaka.util.StreamUtils.getVariantTracks = audioCodec: audioCodec, videoCodec: videoCodec, primary: variant.primary, - roles: roles + roles: roles, + videoId: variant.video ? variant.video.id : null, + audioId: variant.audio ? variant.audio.id : null }; }); diff --git a/test/offline/storage_unit.js b/test/offline/storage_unit.js index 4c93f9f806..a3fb4e19e4 100644 --- a/test/offline/storage_unit.js +++ b/test/offline/storage_unit.js @@ -145,7 +145,9 @@ describe('Storage', function() { codecs: 'avc1.4d401f, vorbis', audioCodec: 'vorbis', videoCodec: 'avc1.4d401f', - roles: [] + roles: [], + videoId: 0, + audioId: 1 } ]; Promise diff --git a/test/player_unit.js b/test/player_unit.js index dec0e91345..7ce1fcd986 100644 --- a/test/player_unit.js +++ b/test/player_unit.js @@ -897,7 +897,9 @@ describe('Player', function() { audioCodec: 'mp4a.40.2', videoCodec: 'avc1.4d401f', primary: false, - roles: [] + roles: [], + videoId: 4, + audioId: 1 }, { id: 2, @@ -915,7 +917,9 @@ describe('Player', function() { audioCodec: 'mp4a.40.2', videoCodec: 'avc1.4d401f', primary: false, - roles: [] + roles: [], + videoId: 5, + audioId: 1 }, { id: 3, @@ -933,7 +937,9 @@ describe('Player', function() { audioCodec: 'mp4a.40.2', videoCodec: 'avc1.4d401f', primary: false, - roles: [] + roles: [], + videoId: 4, + audioId: 2 }, { id: 4, @@ -951,7 +957,9 @@ describe('Player', function() { audioCodec: 'mp4a.40.2', videoCodec: 'avc1.4d401f', primary: false, - roles: [] + roles: [], + videoId: 5, + audioId: 2 }, { id: 5, @@ -969,7 +977,9 @@ describe('Player', function() { audioCodec: 'mp4a.40.2', videoCodec: 'avc1.4d401f', primary: false, - roles: [] + roles: [], + videoId: 5, + audioId: 8 } ];