Skip to content

Commit

Permalink
Fix strange compiler problem in HLS parser.
Browse files Browse the repository at this point in the history
Previously, the Closure compiler was causing a strange problem in
non-debug compiled builds in the HLS parser: when we make an alias for
shaka.net.NetworkingEngine.RequestType, if we access RequestType.SEGMENT
the value is undefined. However, if we store
shaka.net.NetworkingEngine.RequestType.SEGMENT in a variable, it works.
Looking at the compiled code, when shaka.net.NetworkingEngine.RequestType
is defined, SEGMENT seems to be treated as some special case, which might
explain this odd behavior.

Fixes #2156

Change-Id: I272dbc8b8db08ef8f9067c535c25890adae32440
  • Loading branch information
theodab committed Sep 25, 2019
1 parent c014d44 commit 8173085
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ shaka.hls.HlsParser = class {
* @private
*/
async fetchPartialSegment_(reference, fullOnly) {
const RequestType = shaka.net.NetworkingEngine.RequestType;
const requestType = shaka.net.NetworkingEngine.RequestType.SEGMENT;

// Create two requests:
// 1. A partial request meant to fetch the smallest part of the segment
Expand All @@ -1519,7 +1519,7 @@ shaka.hls.HlsParser = class {
this.config_.retryParameters);

if (fullOnly) {
return this.makeNetworkRequest_(fullRequest, RequestType.SEGMENT);
return this.makeNetworkRequest_(fullRequest, requestType);
}

// TODO(vaage): The need to do fall back requests is not likely to be unique
Expand All @@ -1531,7 +1531,7 @@ shaka.hls.HlsParser = class {

try {
const response = await this.makeNetworkRequest_(
partialRequest, RequestType.SEGMENT);
partialRequest, requestType);

return response;
} catch (e) {
Expand All @@ -1552,8 +1552,7 @@ shaka.hls.HlsParser = class {
'support Range requests and CORS preflights.',
partialRequest.uris[0]);

const response = await this.makeNetworkRequest_(
fullRequest, RequestType.SEGMENT);
const response = await this.makeNetworkRequest_(fullRequest, requestType);

return response;
}
Expand Down Expand Up @@ -1939,7 +1938,7 @@ shaka.hls.HlsParser = class {
async guessMimeType_(contentType, codecs, playlist) {
const HlsParser = shaka.hls.HlsParser;
const ContentType = shaka.util.ManifestParserUtils.ContentType;
const RequestType = shaka.net.NetworkingEngine.RequestType;
const requestType = shaka.net.NetworkingEngine.RequestType.SEGMENT;

goog.asserts.assert(playlist.segments.length,
'Playlist should have segments!');
Expand Down Expand Up @@ -1974,7 +1973,7 @@ shaka.hls.HlsParser = class {
headRequest.method = 'HEAD';

const response = await this.makeNetworkRequest_(
headRequest, RequestType.SEGMENT);
headRequest, requestType);

const contentMimeType = response.headers['content-type'];

Expand Down Expand Up @@ -2035,12 +2034,12 @@ shaka.hls.HlsParser = class {
* @private
*/
requestManifest_(absoluteUri) {
const RequestType = shaka.net.NetworkingEngine.RequestType;
const requestType = shaka.net.NetworkingEngine.RequestType.MANIFEST;

const request = shaka.net.NetworkingEngine.makeRequest(
[absoluteUri], this.config_.retryParameters);

return this.makeNetworkRequest_(request, RequestType.MANIFEST);
return this.makeNetworkRequest_(request, requestType);
}

/**
Expand Down

0 comments on commit 8173085

Please sign in to comment.