Skip to content

Commit

Permalink
Add tests on parameters (#3135)
Browse files Browse the repository at this point in the history
* remove space

* in StreamProcessor, do not create BufferController if type is not defined

Co-authored-by: Bertrand Berthelot <[email protected]>
  • Loading branch information
nicosang and bbert authored May 5, 2020
1 parent c01b681 commit d9009d6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion samples/dash-if-reference-player/app/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@
"moreInfo": "https://github.com/Axinom/dash-test-vectors"
},
{
"name": "2160p with PlayReady and Widevine DRM, multiple keys",
"name": "2160p with PlayReady and Widevine DRM, multiple keys",
"url": "https://media.axprod.net/TestVectors/v7-MultiDRM-MultiKey/Manifest.mpd",
"protData": {
"com.widevine.alpha": {
Expand Down
2 changes: 1 addition & 1 deletion src/dash/DashAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function DashAdapter() {
id = mediaInfo ? mediaInfo.id : null;

if (voPeriods.length > 0 && selectedVoPeriod) {
realAdaptation = id ? dashManifestModel.getAdaptationForId(id, voPeriods[0].mpd.manifest, selectedVoPeriod.index) : dashManifestModel.getAdaptationForIndex(mediaInfo.index, voPeriods[0].mpd.manifest, selectedVoPeriod.index);
realAdaptation = id ? dashManifestModel.getAdaptationForId(id, voPeriods[0].mpd.manifest, selectedVoPeriod.index) : dashManifestModel.getAdaptationForIndex(mediaInfo ? mediaInfo.index : null, voPeriods[0].mpd.manifest, selectedVoPeriod.index);
}

return realAdaptation;
Expand Down
14 changes: 11 additions & 3 deletions src/streaming/StreamProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import EventBus from '../core/EventBus';
import Events from '../core/events/Events';
import DashHandler from '../dash/DashHandler';
import Errors from '../core/errors/Errors';
import DashJSError from './vo/DashJSError';
import Debug from '../core/Debug';
import RequestModifier from './utils/RequestModifier';
import URLUtils from '../streaming/utils/URLUtils';
Expand Down Expand Up @@ -140,7 +141,9 @@ function StreamProcessor(config) {
eventBus: eventBus,
errors: Errors
});
bufferController.initialize(mediaSource);
if (bufferController) {
bufferController.initialize(mediaSource);
}
scheduleController.initialize();
}

Expand Down Expand Up @@ -240,7 +243,7 @@ function StreamProcessor(config) {
}

function getBuffer() {
return bufferController.getBuffer();
return bufferController ? bufferController.getBuffer() : null;
}

function setBuffer(buffer) {
Expand Down Expand Up @@ -370,7 +373,7 @@ function StreamProcessor(config) {
}

function createBuffer(previousBuffers) {
return (bufferController.getBuffer() || bufferController.createBuffer(mediaInfo, previousBuffers));
return (getBuffer() || bufferController ? bufferController.createBuffer(mediaInfo, previousBuffers) : null);
}

function switchTrackAsked() {
Expand All @@ -380,6 +383,11 @@ function StreamProcessor(config) {
function createBufferControllerForType(type) {
let controller = null;

if (!type) {
errHandler.error(new DashJSError(Errors.MEDIASOURCE_TYPE_UNSUPPORTED_CODE, Errors.MEDIASOURCE_TYPE_UNSUPPORTED_MESSAGE + 'not properly defined'));
return null;
}

if (type === Constants.VIDEO || type === Constants.AUDIO) {
controller = BufferController(context).create({
type: type,
Expand Down
12 changes: 7 additions & 5 deletions src/streaming/controllers/AbrController.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,15 @@ function AbrController() {
}

function updateTopQualityIndex(mediaInfo) {
const type = mediaInfo.type;
const streamId = mediaInfo.streamInfo.id;
const max = mediaInfo.representationCount - 1;
if (mediaInfo) {
const type = mediaInfo.type;
const streamId = mediaInfo.streamInfo.id;
const max = mediaInfo.representationCount - 1;

setTopQualityIndex(type, streamId, max);
setTopQualityIndex(type, streamId, max);

return max;
return max;
}
}

function isPlayingAtTopQuality(streamInfo) {
Expand Down
5 changes: 4 additions & 1 deletion src/streaming/controllers/ScheduleController.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ function ScheduleController(config) {
setLiveEdgeSeekTarget();
} else {
setSeekTarget(playbackController.getStreamStartTime(false));
streamProcessor.getBufferController().setSeekStartTime(seekTarget);
const bufferController = streamProcessor.getBufferController();
if (bufferController) {
bufferController.setSeekStartTime(seekTarget);
}
}
}

Expand Down

0 comments on commit d9009d6

Please sign in to comment.