Skip to content

Commit

Permalink
Fix a bug that causes SegmentBase playback to crash
Browse files Browse the repository at this point in the history
  • Loading branch information
dsilhavy committed Oct 31, 2024
1 parent 9d96353 commit 6bceddb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 29 deletions.
6 changes: 4 additions & 2 deletions src/dash/SegmentBaseLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ function SegmentBaseLoader() {
searching: false,
bytesLoaded: 0,
bytesToLoad: 1500,
mediaType: mediaType
mediaType: mediaType,
representation
};

logger.debug('Start searching for initialization.');
Expand Down Expand Up @@ -183,7 +184,8 @@ function SegmentBaseLoader() {
searching: !hasRange,
bytesLoaded: loadingInfo ? loadingInfo.bytesLoaded : 0,
bytesToLoad: 1500,
mediaType: mediaType
mediaType: mediaType,
representation
};

const request = getFragmentRequest(info);
Expand Down
65 changes: 39 additions & 26 deletions src/streaming/controllers/ExtUrlQueryInfoController.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ import Utils from '../../core/Utils.js';
import DashConstants from '../../dash/constants/DashConstants.js';
import Constants from '../constants/Constants.js';
import {HTTPRequest} from '../vo/metrics/HTTPRequest.js';
import Debug from '../../core/Debug.js';

function ExtUrlQueryInfoController() {
let instance,
logger,
mpdQueryStringInformation;
const context = this.context;

function setup() {
logger = Debug(context).getInstance().getLogger(instance);
}

function _generateQueryParams(resultObject, manifestObject, mpdUrlQuery, parentLevelInfo, mpdElement) {
const property = _getDescriptorTypeFromManifestObject(manifestObject, mpdElement);
Expand Down Expand Up @@ -117,7 +123,7 @@ function ExtUrlQueryInfoController() {
};

const mpdUrlQuery = manifest.url.split('?')[1];
const initialMpdObject = {initialQueryString: '', includeInRequests: []};
const initialMpdObject = { initialQueryString: '', includeInRequests: [] };

_generateQueryParams(mpdQueryStringInformation, manifest, mpdUrlQuery, initialMpdObject, DashConstants.MPD);

Expand Down Expand Up @@ -146,36 +152,43 @@ function ExtUrlQueryInfoController() {
}

function getFinalQueryString(request) {
if (!mpdQueryStringInformation) {
return
}
if (request.type === HTTPRequest.MEDIA_SEGMENT_TYPE || request.type === HTTPRequest.INIT_SEGMENT_TYPE) {
const representation = request.representation;
const adaptation = representation.adaptation;
const period = adaptation.period;
const queryInfo = mpdQueryStringInformation
.period[period.index]
.adaptation[adaptation.index]
.representation[representation.index];
const requestUrl = new URL(request.url);
const canSendToOrigin = !queryInfo.sameOriginOnly || mpdQueryStringInformation.origin === requestUrl.origin;
const inRequest = queryInfo.includeInRequests.includes(DashConstants.SEGMENT_TYPE);
if (inRequest && canSendToOrigin) {
return queryInfo.queryParams;
try {
if (!mpdQueryStringInformation) {
return
}
} else if (request.type === HTTPRequest.MPD_TYPE) {
const inRequest = [DashConstants.MPD_TYPE, DashConstants.MPD_PATCH_TYPE].some(r => mpdQueryStringInformation.includeInRequests.includes(r));
if (inRequest) {
return mpdQueryStringInformation.queryParams;
}
} else if (request.type === HTTPRequest.CONTENT_STEERING_TYPE) {
const inRequest = mpdQueryStringInformation.includeInRequests.includes(DashConstants.STEERING_TYPE);
if (inRequest) {
return mpdQueryStringInformation.queryParams;
if (request.type === HTTPRequest.MEDIA_SEGMENT_TYPE || request.type === HTTPRequest.INIT_SEGMENT_TYPE) {
const representation = request.representation;
const adaptation = representation.adaptation;
const period = adaptation.period;
const queryInfo = mpdQueryStringInformation
.period[period.index]
.adaptation[adaptation.index]
.representation[representation.index];
const requestUrl = new URL(request.url);
const canSendToOrigin = !queryInfo.sameOriginOnly || mpdQueryStringInformation.origin === requestUrl.origin;
const inRequest = queryInfo.includeInRequests.includes(DashConstants.SEGMENT_TYPE);
if (inRequest && canSendToOrigin) {
return queryInfo.queryParams;
}
} else if (request.type === HTTPRequest.MPD_TYPE) {
const inRequest = [DashConstants.MPD_TYPE, DashConstants.MPD_PATCH_TYPE].some(r => mpdQueryStringInformation.includeInRequests.includes(r));
if (inRequest) {
return mpdQueryStringInformation.queryParams;
}
} else if (request.type === HTTPRequest.CONTENT_STEERING_TYPE) {
const inRequest = mpdQueryStringInformation.includeInRequests.includes(DashConstants.STEERING_TYPE);
if (inRequest) {
return mpdQueryStringInformation.queryParams;
}
}
} catch (e) {
logger.error(e);
return null
}
}

setup();

instance = {
getFinalQueryString,
createFinalQueryStrings
Expand Down
3 changes: 2 additions & 1 deletion src/streaming/vo/FragmentRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

import { HTTPRequest } from './metrics/HTTPRequest.js';
import {HTTPRequest} from './metrics/HTTPRequest.js';

/**
* @class
Expand Down Expand Up @@ -72,6 +72,7 @@ class FragmentRequest {
this.url = info && info.url ? info.url : null;
this.range = info && info.range ? info.range.start + '-' + info.range.end : null;
this.mediaType = info && info.mediaType ? info.mediaType : null;
this.representation = info && info.representation ? info.representation : null;
}
}

Expand Down

0 comments on commit 6bceddb

Please sign in to comment.